@InterfaceAudience.Private public class HFileInfo extends Object implements SortedMap<byte[],byte[]>
append(byte[], byte[], boolean)
and they'll be persisted and available at read time.
Reader creates the HFileInfo on open by reading the tail of the HFile. The parse of the HFile
trailer also creates a HFileContext
, a read-only data structure that includes bulk of the
HFileInfo and extras that is safe to pass around when working on HFiles.HFileContext
Modifier and Type | Field and Description |
---|---|
(package private) static byte[] |
AVG_KEY_LEN |
(package private) static byte[] |
AVG_VALUE_LEN |
private int |
avgKeyLen
Average key length read from file info
|
private int |
avgValueLen
Average value length read from file info
|
private HFileBlock.BlockIterator |
blockIter
The iterator will track all blocks in load-on-open section, since we use the
ByteBuffAllocator to manage the ByteBuffers in block now, so
we must ensure that deallocate all ByteBuffers in the end. |
(package private) static byte[] |
CREATE_TIME_TS |
private HFileBlockIndex.CellBasedKeyBlockIndexReader |
dataIndexReader |
private boolean |
decodeMemstoreTS |
private HFileContext |
hfileContext |
private boolean |
includesMemstoreTS |
(package private) static byte[] |
LASTKEY |
private Cell |
lastKeyCell
Last key in the file.
|
private List<HFileBlock> |
loadOnOpenBlocks
Blocks read from the load-on-open section, excluding data root index, meta index, and file
info.
|
private static org.slf4j.Logger |
LOG |
private SortedMap<byte[],byte[]> |
map |
(package private) static int |
MAX_MINOR_VERSION
Maximum minor version supported by this HFile format
|
static byte[] |
MAX_TAGS_LEN |
private HFileBlockIndex.ByteArrayKeyBlockIndexReader |
metaIndexReader |
private static int |
MIN_V2_MINOR_VERSION_WITH_PB
We can read files whose major version is v2 IFF their minor version is at least 3.
|
(package private) static String |
RESERVED_PREFIX |
(package private) static byte[] |
RESERVED_PREFIX_BYTES |
(package private) static byte[] |
TAGS_COMPRESSED |
private FixedFileTrailer |
trailer |
Constructor and Description |
---|
HFileInfo() |
HFileInfo(ReaderContext context,
org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
HFileInfo |
append(byte[] k,
byte[] v,
boolean checkPrefix)
Append the given key/value pair to the file info, optionally checking the key prefix.
|
private void |
checkFileVersion(org.apache.hadoop.fs.Path path)
File version check is a little sloppy.
|
void |
clear() |
void |
close() |
Comparator<? super byte[]> |
comparator() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
private HFileContext |
createHFileContext(org.apache.hadoop.fs.Path path,
FixedFileTrailer trailer,
org.apache.hadoop.conf.Configuration conf) |
Set<Map.Entry<byte[],byte[]>> |
entrySet() |
boolean |
equals(Object o) |
byte[] |
firstKey() |
byte[] |
get(Object key) |
int |
getAvgKeyLen() |
int |
getAvgValueLen() |
HFileBlockIndex.CellBasedKeyBlockIndexReader |
getDataBlockIndexReader() |
HFileContext |
getHFileContext() |
Cell |
getLastKeyCell() |
List<HFileBlock> |
getLoadOnOpenBlocks() |
int |
getMajorVersion() |
HFileBlockIndex.ByteArrayKeyBlockIndexReader |
getMetaBlockIndexReader() |
FixedFileTrailer |
getTrailer() |
int |
hashCode() |
SortedMap<byte[],byte[]> |
headMap(byte[] toKey) |
void |
initMetaAndIndex(HFile.Reader reader)
should be called after initTrailerAndContext
|
void |
initTrailerAndContext(ReaderContext context,
org.apache.hadoop.conf.Configuration conf) |
boolean |
isDecodeMemstoreTS() |
boolean |
isEmpty() |
static boolean |
isReservedFileInfoKey(byte[] key)
Return true if the given file info key is reserved for internal use.
|
Set<byte[]> |
keySet() |
byte[] |
lastKey() |
private void |
loadMetaInfo(HFileBlock.BlockIterator blockIter,
HFileContext hfileContext) |
(package private) void |
parsePB(org.apache.hadoop.hbase.shaded.protobuf.generated.HFileProtos.FileInfoProto fip)
Fill our map with content of the pb we read off disk
|
(package private) void |
parseWritable(DataInputStream in)
Now parse the old Writable format.
|
byte[] |
put(byte[] key,
byte[] value) |
void |
putAll(Map<? extends byte[],? extends byte[]> m) |
(package private) void |
read(DataInputStream in)
Populate this instance with what we find on the passed in
in stream. |
byte[] |
remove(Object key) |
void |
setTrailer(FixedFileTrailer trailer) |
boolean |
shouldIncludeMemStoreTS() |
int |
size() |
SortedMap<byte[],byte[]> |
subMap(byte[] fromKey,
byte[] toKey) |
SortedMap<byte[],byte[]> |
tailMap(byte[] fromKey) |
Collection<byte[]> |
values() |
(package private) void |
write(DataOutputStream out)
Write out this instance on the passed in
out stream. |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
private static final org.slf4j.Logger LOG
static final String RESERVED_PREFIX
static final byte[] RESERVED_PREFIX_BYTES
static final byte[] LASTKEY
static final byte[] AVG_KEY_LEN
static final byte[] AVG_VALUE_LEN
static final byte[] CREATE_TIME_TS
static final byte[] TAGS_COMPRESSED
public static final byte[] MAX_TAGS_LEN
private static final int MIN_V2_MINOR_VERSION_WITH_PB
static final int MAX_MINOR_VERSION
private Cell lastKeyCell
private int avgKeyLen
private int avgValueLen
private boolean includesMemstoreTS
private boolean decodeMemstoreTS
private List<HFileBlock> loadOnOpenBlocks
private HFileBlock.BlockIterator blockIter
ByteBuffAllocator
to manage the ByteBuffers in block now, so
we must ensure that deallocate all ByteBuffers in the end.private HFileBlockIndex.CellBasedKeyBlockIndexReader dataIndexReader
private HFileBlockIndex.ByteArrayKeyBlockIndexReader metaIndexReader
private FixedFileTrailer trailer
private HFileContext hfileContext
public HFileInfo()
public HFileInfo(ReaderContext context, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public HFileInfo append(byte[] k, byte[] v, boolean checkPrefix) throws IOException
k
- key to addv
- value to addcheckPrefix
- whether to check that the provided key does not start with the reserved
prefixIOException
- if the key or value is invalidpublic static boolean isReservedFileInfoKey(byte[] key)
public Comparator<? super byte[]> comparator()
comparator
in interface SortedMap<byte[],byte[]>
public boolean containsKey(Object key)
containsKey
in interface Map<byte[],byte[]>
public boolean containsValue(Object value)
containsValue
in interface Map<byte[],byte[]>
public int hashCode()
public Collection<byte[]> values()
void write(DataOutputStream out) throws IOException
out
stream. We write it as a protobuf.IOException
read(DataInputStream)
void read(DataInputStream in) throws IOException
in
stream. Can
deserialize protobuf of old Writables format.IOException
write(DataOutputStream)
void parseWritable(DataInputStream in) throws IOException
IOException
void parsePB(org.apache.hadoop.hbase.shaded.protobuf.generated.HFileProtos.FileInfoProto fip)
fip
- protobuf message to readpublic void initTrailerAndContext(ReaderContext context, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public void initMetaAndIndex(HFile.Reader reader) throws IOException
IOException
private HFileContext createHFileContext(org.apache.hadoop.fs.Path path, FixedFileTrailer trailer, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
private void loadMetaInfo(HFileBlock.BlockIterator blockIter, HFileContext hfileContext) throws IOException
IOException
private void checkFileVersion(org.apache.hadoop.fs.Path path)
public void close()
public int getMajorVersion()
public void setTrailer(FixedFileTrailer trailer)
public FixedFileTrailer getTrailer()
public HFileBlockIndex.CellBasedKeyBlockIndexReader getDataBlockIndexReader()
public HFileBlockIndex.ByteArrayKeyBlockIndexReader getMetaBlockIndexReader()
public HFileContext getHFileContext()
public List<HFileBlock> getLoadOnOpenBlocks()
public Cell getLastKeyCell()
public int getAvgKeyLen()
public int getAvgValueLen()
public boolean shouldIncludeMemStoreTS()
public boolean isDecodeMemstoreTS()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.