Package ml.shifu.guagua.hadoop.io
Class GuaguaSequenceRecordReader<KEY extends org.apache.hadoop.io.Writable,VALUE extends org.apache.hadoop.io.Writable>
- java.lang.Object
-
- ml.shifu.guagua.hadoop.io.GuaguaSequenceRecordReader<KEY,VALUE>
-
- All Implemented Interfaces:
ml.shifu.guagua.io.GuaguaRecordReader<GuaguaWritableAdapter<KEY>,GuaguaWritableAdapter<VALUE>>
- Direct Known Subclasses:
GuaguaSequenceAsBinaryRecordReader,GuaguaSequenceAsTextRecordReader
public class GuaguaSequenceRecordReader<KEY extends org.apache.hadoop.io.Writable,VALUE extends org.apache.hadoop.io.Writable> extends Object implements ml.shifu.guagua.io.GuaguaRecordReader<GuaguaWritableAdapter<KEY>,GuaguaWritableAdapter<VALUE>>
A reader read HDFS sequence file key by key. The types of sequence key and value are bothBytesWritable.Copy some code from
SequenceFileRecordReaderbut to supportGuaguaRecordReaderinterface.If use default constructor, user should also call
initialize(GuaguaFileSplit)like in below:this.setRecordReader(new SequenceFileRecordReader(Text.class, Text,class)); this.getRecordReader().initialize(fileSplit);
or directly use other constructors:this.setRecordReader(new SequenceFileRecordReader(fileSplit, Text.class, Text,class));
-
-
Constructor Summary
Constructors Constructor Description GuaguaSequenceRecordReader(Class<? extends org.apache.hadoop.io.Writable> keyClass, Class<? extends org.apache.hadoop.io.Writable> valueClass)GuaguaSequenceRecordReader(ml.shifu.guagua.io.GuaguaFileSplit split, Class<? extends org.apache.hadoop.io.Writable> keyClass, Class<? extends org.apache.hadoop.io.Writable> valueClass)GuaguaSequenceRecordReader(org.apache.hadoop.conf.Configuration conf, ml.shifu.guagua.io.GuaguaFileSplit split, Class<? extends org.apache.hadoop.io.Writable> keyClass, Class<? extends org.apache.hadoop.io.Writable> valueClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()GuaguaWritableAdapter<KEY>getCurrentKey()GuaguaWritableAdapter<VALUE>getCurrentValue()floatgetProgress()Return the progress within the input splitvoidinitialize(ml.shifu.guagua.io.GuaguaFileSplit split)booleannextKeyValue()
-
-
-
Constructor Detail
-
GuaguaSequenceRecordReader
public GuaguaSequenceRecordReader(Class<? extends org.apache.hadoop.io.Writable> keyClass, Class<? extends org.apache.hadoop.io.Writable> valueClass) throws IOException
- Throws:
IOException
-
GuaguaSequenceRecordReader
public GuaguaSequenceRecordReader(ml.shifu.guagua.io.GuaguaFileSplit split, Class<? extends org.apache.hadoop.io.Writable> keyClass, Class<? extends org.apache.hadoop.io.Writable> valueClass) throws IOException- Throws:
IOException
-
GuaguaSequenceRecordReader
public GuaguaSequenceRecordReader(org.apache.hadoop.conf.Configuration conf, ml.shifu.guagua.io.GuaguaFileSplit split, Class<? extends org.apache.hadoop.io.Writable> keyClass, Class<? extends org.apache.hadoop.io.Writable> valueClass) throws IOException- Throws:
IOException
-
-
Method Detail
-
getProgress
public float getProgress() throws IOExceptionReturn the progress within the input split- Returns:
- 0.0 to 1.0 of the input byte range
- Throws:
IOException
-
initialize
public void initialize(ml.shifu.guagua.io.GuaguaFileSplit split) throws IOException- Specified by:
initializein interfaceml.shifu.guagua.io.GuaguaRecordReader<KEY extends org.apache.hadoop.io.Writable,VALUE extends org.apache.hadoop.io.Writable>- Throws:
IOException
-
nextKeyValue
public boolean nextKeyValue() throws IOException- Specified by:
nextKeyValuein interfaceml.shifu.guagua.io.GuaguaRecordReader<KEY extends org.apache.hadoop.io.Writable,VALUE extends org.apache.hadoop.io.Writable>- Throws:
IOException
-
getCurrentKey
public GuaguaWritableAdapter<KEY> getCurrentKey()
-
getCurrentValue
public GuaguaWritableAdapter<VALUE> getCurrentValue()
-
close
public void close() throws IOException- Specified by:
closein interfaceml.shifu.guagua.io.GuaguaRecordReader<KEY extends org.apache.hadoop.io.Writable,VALUE extends org.apache.hadoop.io.Writable>- Throws:
IOException
-
-