java.io.Closeable, java.lang.AutoCloseable@Evolving
public static class TFile.Reader
extends java.lang.Object
implements java.io.Closeable
createScanner()
) , a portion of TFile based on byte offsets (
createScannerByByteRange(long, long)), or a portion of TFile with keys
fall in a certain key range (for sorted TFile only,
createScannerByKey(byte[], byte[]) or
createScannerByKey(RawComparable, RawComparable)).| Modifier and Type | Class | Description |
|---|---|---|
static class |
TFile.Reader.Scanner |
The TFile Scanner.
|
| Constructor | Description |
|---|---|
Reader(FSDataInputStream fsdis,
long fileLength,
Configuration conf) |
Constructor
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
Close the reader.
|
TFile.Reader.Scanner |
createScanner() |
Get a scanner than can scan the whole TFile.
|
TFile.Reader.Scanner |
createScanner(byte[] beginKey,
byte[] endKey) |
Deprecated.
Use
createScannerByKey(byte[], byte[]) instead. |
TFile.Reader.Scanner |
createScanner(RawComparable beginKey,
RawComparable endKey) |
Deprecated.
Use
createScannerByKey(RawComparable, RawComparable)
instead. |
TFile.Reader.Scanner |
createScannerByByteRange(long offset,
long length) |
Get a scanner that covers a portion of TFile based on byte offsets.
|
TFile.Reader.Scanner |
createScannerByKey(byte[] beginKey,
byte[] endKey) |
Get a scanner that covers a portion of TFile based on keys.
|
TFile.Reader.Scanner |
createScannerByKey(RawComparable beginKey,
RawComparable endKey) |
Get a scanner that covers a specific key range.
|
TFile.Reader.Scanner |
createScannerByRecordNum(long beginRecNum,
long endRecNum) |
Create a scanner that covers a range of records.
|
java.util.Comparator<RawComparable> |
getComparator() |
Get an instance of the RawComparator that is constructed based on the
string comparator representation.
|
java.lang.String |
getComparatorName() |
Get the string representation of the comparator.
|
java.util.Comparator<TFile.Reader.Scanner.Entry> |
getEntryComparator() |
Get a Comparator object to compare Entries.
|
long |
getEntryCount() |
Get the number of key-value pair entries in TFile.
|
RawComparable |
getFirstKey() |
Get the first key in the TFile.
|
RawComparable |
getKeyNear(long offset) |
Get a sample key that is within a block whose starting offset is greater
than or equal to the specified offset.
|
RawComparable |
getLastKey() |
Get the last key in the TFile.
|
java.io.DataInputStream |
getMetaBlock(java.lang.String name) |
Stream access to a meta block.``
|
long |
getRecordNumNear(long offset) |
Get the RecordNum for the first key-value pair in a compressed block
whose byte offset in the TFile is greater than or equal to the specified
offset.
|
boolean |
isSorted() |
Is the TFile sorted?
|
public Reader(FSDataInputStream fsdis, long fileLength, Configuration conf) throws java.io.IOException
fsdis - FS input stream of the TFile.fileLength - The length of TFile. This is required because we have no easy
way of knowing the actual size of the input file through the
File input stream.conf - configuration.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 getComparatorName()
public boolean isSorted()
public long getEntryCount()
public RawComparable getFirstKey() throws java.io.IOException
java.io.IOException - raised on errors performing I/O.public RawComparable getLastKey() throws java.io.IOException
java.io.IOException - raised on errors performing I/O.public java.util.Comparator<TFile.Reader.Scanner.Entry> getEntryComparator()
public java.util.Comparator<RawComparable> getComparator()
public java.io.DataInputStream getMetaBlock(java.lang.String name)
throws java.io.IOException,
MetaBlockDoesNotExist
name - The name of the meta block.java.io.IOException - on I/O error.MetaBlockDoesNotExist - If the meta block with the name does not exist.public long getRecordNumNear(long offset)
throws java.io.IOException
offset - the user supplied offset.java.io.IOException - raised on errors performing I/O.public RawComparable getKeyNear(long offset) throws java.io.IOException
offset - The file offset.java.io.IOException - raised on errors performing I/O.public TFile.Reader.Scanner createScanner() throws java.io.IOException
java.io.IOException - raised on errors performing I/O.public TFile.Reader.Scanner createScannerByByteRange(long offset, long length) throws java.io.IOException
offset - The beginning byte offset in the TFile.length - The length of the region.java.io.IOException - raised on errors performing I/O.@Deprecated public TFile.Reader.Scanner createScanner(byte[] beginKey, byte[] endKey) throws java.io.IOException
createScannerByKey(byte[], byte[]) instead.beginKey - Begin key of the scan (inclusive). If null, scan from the first
key-value entry of the TFile.endKey - End key of the scan (exclusive). If null, scan up to the last
key-value entry of the TFile.java.io.IOException - raised on errors performing I/O.public TFile.Reader.Scanner createScannerByKey(byte[] beginKey, byte[] endKey) throws java.io.IOException
beginKey - Begin key of the scan (inclusive). If null, scan from the first
key-value entry of the TFile.endKey - End key of the scan (exclusive). If null, scan up to the last
key-value entry of the TFile.java.io.IOException - raised on errors performing I/O.@Deprecated public TFile.Reader.Scanner createScanner(RawComparable beginKey, RawComparable endKey) throws java.io.IOException
createScannerByKey(RawComparable, RawComparable)
instead.beginKey - Begin key of the scan (inclusive). If null, scan from the first
key-value entry of the TFile.endKey - End key of the scan (exclusive). If null, scan up to the last
key-value entry of the TFile.java.io.IOException - raised on errors performing I/O.public TFile.Reader.Scanner createScannerByKey(RawComparable beginKey, RawComparable endKey) throws java.io.IOException
beginKey - Begin key of the scan (inclusive). If null, scan from the first
key-value entry of the TFile.endKey - End key of the scan (exclusive). If null, scan up to the last
key-value entry of the TFile.java.io.IOException - raised on errors performing I/O.public TFile.Reader.Scanner createScannerByRecordNum(long beginRecNum, long endRecNum) throws java.io.IOException
beginRecNum - The RecordNum for the first record (inclusive).endRecNum - The RecordNum for the last record (exclusive). To scan the whole
file, either specify endRecNum==-1 or endRecNum==getEntryCount().java.io.IOException - raised on errors performing I/O.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.