하이브 테이블 (Hadoop 2.2.0.2.0.6.0-101)에서 필드 값의 분포를 계산하는 map-reduce 작업을 작성하려고합니다.MapReduce에서 HCatalog를 사용하여 하이브 테이블
입력 하이브 테이블 "ATABLE": 예를 들어
+------+--------+
! name | rating | |
+------+--------+
| Bond | 7 |
| Megre| 2 |
! Holms| 11 |
| Puaro| 7 |
! Holms| 1 |
| Puaro| 7 |
| Megre| 2 |
| Puaro| 7 |
+------+--------+
지도-감소 하이브 또한 다음과 같은 출력 테이블을 생성해야 작업을 :
+--------+-------+--------+
| Field | Value | Count |
+--------+-------+--------+
| name | Bond | 1 |
| name | Puaro | 3 |
| name | Megre | 2 |
| name | Holms | 1 |
| rating | 7 | 4 |
| rating | 11 | 1 |
| rating | 1 | 1 |
| rating | 2 | 2 |
+--------+-------+--------+
는 내가 필요로하는 필드 이름/값을 얻으려면 HCatalog 메타 데이터에 액세스하기 위해 map 메소드 (org.apache.hadoop.mapreduce.Mapper)에서 이것을 사용할 수 있습니다. http://java.dzone.com/articles/mapreduce-hive-tables-using
0을 예제로 사용하려고합니다.protected void map(WritableComparable key, HCatRecord value,
org.apache.hadoop.mapreduce.Mapper.Context context)
throws IOException, InterruptedException {
// Get table schema
HCatSchema schema = HCatBaseInputFormat.getTableSchema(context);
Integer year = new Integer(value.getString("year", schema));
Integer month = new Integer(value.getString("month", schema));
Integer DayofMonth = value.getInteger("dayofmonth", schema);
context.write(new IntWritable(month), new IntWritable(DayofMonth));
}
중단 경고 :이 예에서
코드는하지만 많이 사용 중단 경고 생산 때문에 컴파일에 HCatalog를 사용하는 유사한 예를 찾기 위해
HCatRecord
HCatSchema
HCatBaseInputFormat.getTableSchema
, 최신하지지도 - 감소 사용되지 않는 인터페이스?
감사합니다.