java读取hive导出的数据

通过HQL语句:

insert overwrite directory '/COMP/206/OUT/LDAPD_BUSI_CMNCTN_ACCU/${current_date}'
select  callingnum,custphone,count(*) as callcount
from DAPD_VOICE_LOG_TMP
group by callingnum,custphone;

将统计信息导出到HDFS上,导出了3个字段,HIVE默认字段分隔符为'\001',我将导出到HDFS的数据拷贝到了本地D盘重命名为testdata,尝试解析它,解析代码如下:

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		FileReader reader = new FileReader("d:\\testdata");
		BufferedReader br = new BufferedReader(reader);
		String line = "";
		String[] arrs = null;
		while ((line = br.readLine()) != null) {
			byte[] bytes = new byte[] { 1 };
			String sendString = new String(bytes, "GBK");
			arrs = line.split(sendString);
			System.out.println(arrs[0] + " : " + arrs[1] + " : " + arrs[2]);
		}
		br.close();
		reader.close();
	}

输出为:

13860393195 : 114 : 1
15280154404 : 0591-87677500 : 1
18059386085 : 0593-7668885 : 1

说明可以被正确的解析。

你可能感兴趣的:(java读取hive导出的数据)