/**
* 读取文件位置
*/
public void seekSeq() throws IOException {
Configuration configuration = new Configuration();
FileSystem fileSystem = FileSystem.get(configuration);
SequenceFile.Reader sr = new SequenceFile.Reader(fileSystem,path,configuration);
IntWritable key = new IntWritable();
Text value = new Text();
sr.seek(253);
//
定位到第253字节的位置,告诉指针下一次要定位的位置。
sr.next(key,value);
//
定位到第253字节的位置,并取出相应的值。
System.out.println(key +
" : "
+ value);
sr.close();
}
/**
* 读取seqfile 同步点
*/
public void
sync
() throws IOException {
/**
* -----文件头-------
128byte* --key-value----
sync
153byte* --key-value----
.* --key-value----
.* --key-value----
.* --key-value----
sync
* --key-value----
* --key-value----
* --key-value----
sync
*/
Configuration configuration = new Configuration();
FileSystem fileSystem = FileSystem.get(configuration);
SequenceFile.Reader sr = new SequenceFile.Reader(fileSystem,path,configuration);
IntWritable key = new IntWritable();
Text value = new Text();