public interface HFileReader extends Closeable
| Modifier and Type | Field and Description |
|---|---|
static int |
SEEK_TO_BEFORE_BLOCK_FIRST_KEY |
static int |
SEEK_TO_BEFORE_FILE_FIRST_KEY |
static int |
SEEK_TO_EOF |
static int |
SEEK_TO_FOUND |
static int |
SEEK_TO_IN_RANGE |
| Modifier and Type | Method and Description |
|---|---|
Option<KeyValue> |
getKeyValue() |
Option<ByteBuffer> |
getMetaBlock(String metaBlockName)
Gets the content of a meta block from HFile.
|
Option<byte[]> |
getMetaInfo(UTF8StringKey key)
Gets info entry from file info block of a HFile.
|
long |
getNumKeyValueEntries() |
void |
initializeMetadata()
Initializes metadata based on a HFile before other read operations.
|
boolean |
isSeeked() |
boolean |
next()
Scans to the next entry in the file.
|
boolean |
seekTo()
Positions this reader at the start of the file.
|
int |
seekTo(Key key)
seekTo or just before the passed
Key. |
static final int SEEK_TO_BEFORE_BLOCK_FIRST_KEY
static final int SEEK_TO_BEFORE_FILE_FIRST_KEY
static final int SEEK_TO_FOUND
static final int SEEK_TO_IN_RANGE
static final int SEEK_TO_EOF
void initializeMetadata()
throws IOException
IOException - upon read errors.Option<byte[]> getMetaInfo(UTF8StringKey key) throws IOException
key - meta key.IOException - upon read errors.Option<ByteBuffer> getMetaBlock(String metaBlockName) throws IOException
metaBlockName - meta block name.IOException - upon read errors.long getNumKeyValueEntries()
int seekTo(Key key) throws IOException
Key. Examine the return code to figure whether we
found the key or not. Consider the key-value pairs in the file,
kv[0] .. kv[n-1], where there are n KV pairs in the file.
The position only moves forward so the caller has to make sure the keys are sorted before making multiple calls of this method.
key - Key to seek to.SEEK_TO_BEFORE_BLOCK_FIRST_KEY), such that
block_fake_first_key <= key < block_actual_first_key if there is no
exact match, and the reader is left in position at block_actual_first_key;
-1 (SEEK_TO_BEFORE_FILE_FIRST_KEY), if key < kv[0], the reader
is left in position 0;
0 (SEEK_TO_FOUND), such that kv[i].key = key and the reader is
left in position i;
1 (SEEK_TO_IN_RANGE), such that kv[i].key < key if there is
no exact match and the key is greater than the actual first of the data block, and
the reader is left in position i;
2 (SEEK_TO_EOF), if there is no KV greater than or equal to the
input key, and the reader positions itself at the end of the file and next() will
return false when it is called.IOException - upon read errors.boolean seekTo()
throws IOException
false if empty file; i.e. a call to next would return false and
the current key and value are undefined.IOException - upon read errors.boolean next()
throws IOException
false if the current position is at the end;
otherwise true if more in file.IOException - upon read errors.Option<KeyValue> getKeyValue() throws IOException
KeyValue instance at current position.IOExceptionboolean isSeeked()
true if the reader has had one of the seek calls invoked; i.e.
seekTo() or seekTo(Key).
Otherwise, false.Copyright © 2025 The Apache Software Foundation. All rights reserved.