Hadoop map-reduce ジョブの出力であるシーケンシャル ファイルがあります。このファイルでは、データはキーと値のペアで記述され、値自体はマップです。さらに処理できるように、値を MAP オブジェクトとして読み取りたいと考えています。
Configuration config = new Configuration();
Path path = new Path("D:\\OSP\\sample_data\\data\\part-00000");
SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.get(config), path, config);
WritableComparable key = (WritableComparable) reader.getKeyClass().newInstance();
Writable value = (Writable) reader.getValueClass().newInstance();
long position = reader.getPosition();
while(reader.next(key,value))
{
System.out.println("Key is: "+textKey +" value is: "+val+"\n");
}
プログラムの出力: キーは: [これはキー] 値は: {abc=839177, xyz=548498, lmn=2, pqr=1}
ここでは文字列として値を取得していますが、マップのオブジェクトとして使用したいです。