Package org.apache.hadoop.hbase.io.hfile
Class HFileInfo
java.lang.Object
org.apache.hadoop.hbase.io.hfile.HFileInfo
Metadata Map of attributes for HFile written out as HFile Trailer. Created by the Writer and
added to the tail of the file just before close. Metadata includes core attributes such as last
key seen, comparator used writing the file, etc. Clients can add their own attributes via
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.- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescription(package private) static final byte[]
(package private) static final byte[]
private int
Average key length read from file infoprivate int
Average value length read from file infoprivate Cell
Biggest Cell in the file, key only.private HFileBlock.BlockIterator
The iterator will track all blocks in load-on-open section, since we use theByteBuffAllocator
to manage the ByteBuffers in block now, so we must ensure that deallocate all ByteBuffers in the end.(package private) static final byte[]
private boolean
private HFileContext
private boolean
(package private) static final byte[]
(package private) static final byte[]
private Cell
Last key in the file.(package private) static final byte[]
private long
Length of the biggest Cellprivate List<HFileBlock>
Blocks read from the load-on-open section, excluding data root index, meta index, and file info.private static final org.slf4j.Logger
private final SortedMap<byte[],
byte[]> (package private) static final int
Maximum minor version supported by this HFile formatstatic final byte[]
private static final int
We can read files whose major version is v2 IFF their minor version is at least 3.(package private) static final String
(package private) static final byte[]
(package private) static final byte[]
private FixedFileTrailer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionappend
(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[]>
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) entrySet()
boolean
byte[]
firstKey()
byte[]
int
int
long
int
int
hashCode()
SortedMap<byte[],
byte[]> headMap
(byte[] toKey) void
initMetaAndIndex
(HFile.Reader reader) should be called after initTrailerAndContextvoid
initTrailerAndContext
(ReaderContext context, org.apache.hadoop.conf.Configuration conf) boolean
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
Now parse the old Writable format.byte[]
put
(byte[] key, byte[] value) void
(package private) void
read
(DataInputStream in) Populate this instance with what we find on the passed inin
stream.byte[]
void
setTrailer
(FixedFileTrailer trailer) boolean
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 inout
stream.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
LOG
-
RESERVED_PREFIX
- See Also:
-
RESERVED_PREFIX_BYTES
-
LASTKEY
-
AVG_KEY_LEN
-
AVG_VALUE_LEN
-
CREATE_TIME_TS
-
TAGS_COMPRESSED
-
KEY_OF_BIGGEST_CELL
-
LEN_OF_BIGGEST_CELL
-
MAX_TAGS_LEN
-
map
-
MIN_V2_MINOR_VERSION_WITH_PB
We can read files whose major version is v2 IFF their minor version is at least 3.- See Also:
-
MAX_MINOR_VERSION
Maximum minor version supported by this HFile format- See Also:
-
lastKeyCell
Last key in the file. Filled in when we read in the file info -
avgKeyLen
Average key length read from file info -
avgValueLen
Average value length read from file info -
biggestCell
Biggest Cell in the file, key only. Filled in when we read in the file info -
lenOfBiggestCell
Length of the biggest Cell -
includesMemstoreTS
-
decodeMemstoreTS
-
loadOnOpenBlocks
Blocks read from the load-on-open section, excluding data root index, meta index, and file info. -
blockIter
The iterator will track all blocks in load-on-open section, since we use theByteBuffAllocator
to manage the ByteBuffers in block now, so we must ensure that deallocate all ByteBuffers in the end. -
dataIndexReader
-
metaIndexReader
-
trailer
-
hfileContext
-
-
Constructor Details
-
HFileInfo
public HFileInfo() -
HFileInfo
public HFileInfo(ReaderContext context, org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
-
Method Details
-
append
Append the given key/value pair to the file info, optionally checking the key prefix.- Parameters:
k
- key to addv
- value to addcheckPrefix
- whether to check that the provided key does not start with the reserved prefix- Returns:
- this file info object
- Throws:
IOException
- if the key or value is invalid
-
isReservedFileInfoKey
Return true if the given file info key is reserved for internal use. -
clear
-
comparator
- Specified by:
comparator
in interfaceSortedMap<byte[],
byte[]>
-
containsKey
- Specified by:
containsKey
in interfaceMap<byte[],
byte[]>
-
containsValue
- Specified by:
containsValue
in interfaceMap<byte[],
byte[]>
-
entrySet
-
equals
-
firstKey
-
get
-
hashCode
-
headMap
-
isEmpty
-
keySet
-
lastKey
-
put
-
putAll
-
remove
-
size
-
subMap
-
tailMap
-
values
-
write
Write out this instance on the passed inout
stream. We write it as a protobuf.- Throws:
IOException
- See Also:
-
read
Populate this instance with what we find on the passed inin
stream. Can deserialize protobuf of old Writables format.- Throws:
IOException
- See Also:
-
parseWritable
Now parse the old Writable format. It was a list of Map entries. Each map entry was a key and a value of a byte []. The old map format had a byte before each entry that held a code which was short for the key or value type. We know it was a byte [] so in below we just read and dump it.- Throws:
IOException
-
parsePB
Fill our map with content of the pb we read off disk- Parameters:
fip
- protobuf message to read
-
initTrailerAndContext
public void initTrailerAndContext(ReaderContext context, org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
initMetaAndIndex
should be called after initTrailerAndContext- Throws:
IOException
-
createHFileContext
private HFileContext createHFileContext(org.apache.hadoop.fs.Path path, FixedFileTrailer trailer, org.apache.hadoop.conf.Configuration conf) throws IOException - Throws:
IOException
-
loadMetaInfo
private void loadMetaInfo(HFileBlock.BlockIterator blockIter, HFileContext hfileContext) throws IOException - Throws:
IOException
-
checkFileVersion
File version check is a little sloppy. We read v3 files but can also read v2 files if their content has been pb'd; files written with 0.98. -
close
-
getMajorVersion
-
setTrailer
-
getTrailer
-
getDataBlockIndexReader
-
getMetaBlockIndexReader
-
getHFileContext
-
getLoadOnOpenBlocks
-
getLastKeyCell
-
getAvgKeyLen
-
getAvgValueLen
-
getKeyOfBiggestCell
-
getLenOfBiggestCell
-
shouldIncludeMemStoreTS
-
isDecodeMemstoreTS
-