public class ArcRecordReader extends RecordReader<Text,BytesWritable>
ArchRecordReader
class provides a record reader which reads
records from arc files.
Arc files are essentially tars of gzips. Each record in an arc file is a compressed gzip. Multiple records are concatenated together to form a complete arc.
For more information on the arc file format
Arc files are used by the internet archive and grub projects.
, archive.org, grub.orgModifier and Type | Field and Description |
---|---|
protected Configuration |
conf |
protected long |
fileLen |
protected FSDataInputStream |
in |
protected long |
pos |
protected long |
splitEnd |
protected long |
splitLen |
protected long |
splitStart |
Constructor and Description |
---|
ArcRecordReader(Configuration conf,
FileSplit split)
Constructor that sets the configuration and file split.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the record reader resources.
|
Text |
createKey()
Creates a new instance of the
Text object for the key. |
BytesWritable |
createValue()
Creates a new instance of the
BytesWritable object for the key |
Text |
getCurrentKey() |
BytesWritable |
getCurrentValue() |
long |
getPos()
Returns the current position in the file.
|
float |
getProgress()
Returns the percentage of progress in processing the file.
|
void |
initialize(InputSplit split,
TaskAttemptContext context) |
static boolean |
isMagic(byte[] input)
Returns true if the byte array passed matches the gzip header magic number.
|
boolean |
next(Text key,
BytesWritable value)
Returns true if the next record in the split is read into the key and value
pair.
|
boolean |
nextKeyValue() |
protected Configuration conf
protected long splitStart
protected long pos
protected long splitEnd
protected long splitLen
protected long fileLen
protected FSDataInputStream in
public ArcRecordReader(Configuration conf, FileSplit split) throws IOException
conf
- The job configuration.split
- The file split to read from.IOException
- If an IO error occurs while initializing file split.public static boolean isMagic(byte[] input)
Returns true if the byte array passed matches the gzip header magic number.
input
- The byte array to check.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class RecordReader<Text,BytesWritable>
IOException
public Text createKey()
Text
object for the key.public BytesWritable createValue()
BytesWritable
object for the keypublic long getPos() throws IOException
IOException
public float getProgress() throws IOException
getProgress
in class RecordReader<Text,BytesWritable>
IOException
public BytesWritable getCurrentValue()
getCurrentValue
in class RecordReader<Text,BytesWritable>
public Text getCurrentKey()
getCurrentKey
in class RecordReader<Text,BytesWritable>
public boolean nextKeyValue()
nextKeyValue
in class RecordReader<Text,BytesWritable>
public void initialize(InputSplit split, TaskAttemptContext context)
initialize
in class RecordReader<Text,BytesWritable>
public boolean next(Text key, BytesWritable value) throws IOException
Returns true if the next record in the split is read into the key and value pair. The key will be the arc record header and the values will be the raw content bytes of the arc record.
key
- The record keyvalue
- The record valueIOException
- If an error occurs while reading the record value.Copyright © 2021 The Apache Software Foundation