public static class SequenceFile.Reader extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
static interface |
SequenceFile.Reader.Option
A tag interface for all of the Reader options
|
| Constructor and Description |
|---|
Reader(Configuration conf,
SequenceFile.Reader.Option... opts) |
Reader(FileSystem fs,
Path file,
Configuration conf)
Deprecated.
Use Reader(Configuration, Option...) instead.
|
Reader(FSDataInputStream in,
int buffersize,
long start,
long length,
Configuration conf)
Deprecated.
Use Reader(Configuration, Reader.Option...) instead.
|
| Modifier and Type | Method and Description |
|---|---|
static SequenceFile.Reader.Option |
bufferSize(int value)
Create an option with the buffer size for reading the given pathname.
|
void |
close()
Close the file.
|
SequenceFile.ValueBytes |
createValueBytes() |
static SequenceFile.Reader.Option |
file(Path value)
Create an option to specify the path name of the sequence file.
|
CompressionCodec |
getCompressionCodec()
Returns the compression codec of data in this file.
|
SequenceFile.CompressionType |
getCompressionType()
Get the compression type for this file.
|
Object |
getCurrentValue(Object val) |
void |
getCurrentValue(Writable val)
Get the 'value' corresponding to the last read 'key'.
|
Class<?> |
getKeyClass() |
String |
getKeyClassName() |
SequenceFile.Metadata |
getMetadata()
Returns the metadata object of the file.
|
long |
getPosition() |
Class<?> |
getValueClass() |
String |
getValueClassName() |
boolean |
isBlockCompressed()
Returns true if records are block-compressed.
|
boolean |
isCompressed()
Returns true if values are compressed.
|
static SequenceFile.Reader.Option |
length(long value)
Create an option to specify the number of bytes to read.
|
Object |
next(Object key)
Read the next key in the file, skipping its
value.
|
boolean |
next(Writable key) |
boolean |
next(Writable key,
Writable val)
Read the next key/value pair in the file into
key and
val. |
int |
nextRaw(org.apache.hadoop.io.DataOutputBuffer key,
SequenceFile.ValueBytes val)
Read 'raw' records.
|
int |
nextRawKey(org.apache.hadoop.io.DataOutputBuffer key)
Read 'raw' keys.
|
int |
nextRawValue(SequenceFile.ValueBytes val)
Read 'raw' values.
|
protected FSDataInputStream |
openFile(FileSystem fs,
Path file,
int bufferSize,
long length)
Override this method to specialize the type of
FSDataInputStream returned. |
void |
seek(long position)
Set the current byte position in the input file.
|
static SequenceFile.Reader.Option |
start(long value)
Create an option to specify the starting byte to read.
|
static SequenceFile.Reader.Option |
stream(FSDataInputStream value)
Create an option to specify the stream with the sequence file.
|
void |
sync(long position)
Seek to the next sync mark past a given position.
|
boolean |
syncSeen() |
String |
toString()
Returns the name of the file.
|
public Reader(Configuration conf, SequenceFile.Reader.Option... opts) throws IOException
IOException@Deprecated public Reader(FileSystem fs, Path file, Configuration conf) throws IOException
fs - The file system used to open the file.file - The file being read.conf - ConfigurationIOException - raised on errors performing I/O.@Deprecated public Reader(FSDataInputStream in, int buffersize, long start, long length, Configuration conf) throws IOException
in - An input stream.buffersize - unusedstart - The starting position.length - The length being read.conf - ConfigurationIOException - raised on errors performing I/O.public static SequenceFile.Reader.Option file(Path value)
value - the path to readpublic static SequenceFile.Reader.Option stream(FSDataInputStream value)
value - the stream to read.public static SequenceFile.Reader.Option start(long value)
value - the number of bytes to skip overpublic static SequenceFile.Reader.Option length(long value)
value - the number of bytes to readpublic static SequenceFile.Reader.Option bufferSize(int value)
value - the number of bytes to bufferprotected FSDataInputStream openFile(FileSystem fs, Path file, int bufferSize, long length) throws IOException
FSDataInputStream returned.fs - The file system used to open the file.file - The file being read.bufferSize - The buffer size used to read the file.length - The length being read if it is >= 0.
Otherwise, the length is not available.IOException - raised on errors performing I/O.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic String getKeyClassName()
public Class<?> getKeyClass()
public String getValueClassName()
public Class<?> getValueClass()
public boolean isCompressed()
public boolean isBlockCompressed()
public CompressionCodec getCompressionCodec()
public SequenceFile.CompressionType getCompressionType()
public SequenceFile.Metadata getMetadata()
public void getCurrentValue(Writable val) throws IOException
val - : The 'value' to be read.IOException - raised on errors performing I/O.public Object getCurrentValue(Object val) throws IOException
val - : The 'value' to be read.IOException - raised on errors performing I/O.public boolean next(Writable key) throws IOException
key - key.key, skipping its
value.True if another entry exists, and false at end of file.IOException - raised on errors performing I/O.public boolean next(Writable key, Writable val) throws IOException
key and
val.key - input key.val - input val.IOException - raised on errors performing I/O.public SequenceFile.ValueBytes createValueBytes()
public int nextRaw(org.apache.hadoop.io.DataOutputBuffer key,
SequenceFile.ValueBytes val)
throws IOException
key - - The buffer into which the key is readval - - The 'raw' valueIOException - raised on errors performing I/O.public int nextRawKey(org.apache.hadoop.io.DataOutputBuffer key)
throws IOException
key - - The buffer into which the key is readIOException - raised on errors performing I/O.public Object next(Object key) throws IOException
key - input Object key.IOException - raised on errors performing I/O.public int nextRawValue(SequenceFile.ValueBytes val) throws IOException
val - - The 'raw' valueIOException - raised on errors performing I/O.public void seek(long position)
throws IOException
The position passed must be a position returned by SequenceFile.Writer.getLength() when writing this file. To seek to an arbitrary
position, use sync(long).
position - input position.IOException - raised on errors performing I/O.public void sync(long position)
throws IOException
position - position.IOException - raised on errors performing I/O.public boolean syncSeen()
public long getPosition()
throws IOException
IOException - raised on errors performing I/O.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.