java.io.Closeable, java.lang.AutoCloseablepublic static class SequenceFile.Reader
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Class | Description |
|---|---|---|
static interface |
SequenceFile.Reader.Option |
A tag interface for all of the Reader options
|
| Constructor | 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 | 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.
|
java.lang.Object |
getCurrentValue(java.lang.Object val) |
|
void |
getCurrentValue(Writable val) |
Get the 'value' corresponding to the last read 'key'.
|
java.lang.Class<?> |
getKeyClass() |
|
java.lang.String |
getKeyClassName() |
|
SequenceFile.Metadata |
getMetadata() |
Returns the metadata object of the file.
|
long |
getPosition() |
|
java.lang.Class<?> |
getValueClass() |
|
java.lang.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.
|
java.lang.Object |
next(java.lang.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(DataOutputBuffer key,
SequenceFile.ValueBytes val) |
Read 'raw' records.
|
int |
nextRawKey(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() |
|
java.lang.String |
toString() |
Returns the name of the file.
|
public Reader(Configuration conf, SequenceFile.Reader.Option... opts) throws java.io.IOException
java.io.IOException@Deprecated public Reader(FileSystem fs, Path file, Configuration conf) throws java.io.IOException
fs - The file system used to open the file.file - The file being read.conf - Configurationjava.io.IOException - raised on errors performing I/O.@Deprecated public Reader(FSDataInputStream in, int buffersize, long start, long length, Configuration conf) throws java.io.IOException
in - An input stream.buffersize - unusedstart - The starting position.length - The length being read.conf - Configurationjava.io.IOException - 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 java.io.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.java.io.IOException - raised on errors performing I/O.public void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionpublic java.lang.String getKeyClassName()
public java.lang.Class<?> getKeyClass()
public java.lang.String getValueClassName()
public java.lang.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 java.io.IOException
val - : The 'value' to be read.java.io.IOException - raised on errors performing I/O.public java.lang.Object getCurrentValue(java.lang.Object val)
throws java.io.IOException
val - : The 'value' to be read.java.io.IOException - raised on errors performing I/O.public boolean next(Writable key) throws java.io.IOException
key - key.key, skipping its
value.True if another entry exists, and false at end of file.java.io.IOException - raised on errors performing I/O.public boolean next(Writable key, Writable val) throws java.io.IOException
key and
val.key - input key.val - input val.java.io.IOException - raised on errors performing I/O.public SequenceFile.ValueBytes createValueBytes()
public int nextRaw(DataOutputBuffer key, SequenceFile.ValueBytes val) throws java.io.IOException
key - - The buffer into which the key is readval - - The 'raw' valuejava.io.IOException - raised on errors performing I/O.public int nextRawKey(DataOutputBuffer key) throws java.io.IOException
key - - The buffer into which the key is readjava.io.IOException - raised on errors performing I/O.public java.lang.Object next(java.lang.Object key)
throws java.io.IOException
key - input Object key.java.io.IOException - raised on errors performing I/O.public int nextRawValue(SequenceFile.ValueBytes val) throws java.io.IOException
val - - The 'raw' valuejava.io.IOException - raised on errors performing I/O.public void seek(long position)
throws java.io.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.java.io.IOException - raised on errors performing I/O.public void sync(long position)
throws java.io.IOException
position - position.java.io.IOException - raised on errors performing I/O.public boolean syncSeen()
public long getPosition()
throws java.io.IOException
java.io.IOException - raised on errors performing I/O.public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2008–2025 Apache Software Foundation. All rights reserved.