@InterfaceAudience.Private public class FixedFileTrailer extends Object
HFile
has a fixed trailer which contains offsets to other variable parts of the file.
Also includes basic metadata on this file. The trailer size is fixed within a given HFile
format version only, but we always store the version number as the last four-byte integer of the
file. The version number itself is split into two portions, a major version and a minor version.
The last three bytes of a file are the major version and a single preceding byte is the minor
number. The major version determines which readers/writers to use to read/write a hfile while a
minor version determines smaller changes in hfile format that do not need a new reader/writer
type.Modifier and Type | Field and Description |
---|---|
private String |
comparatorClassName
Raw key comparator class name in version 3
|
private Compression.Algorithm |
compressionCodec
The compression codec used for all blocks.
|
private int |
dataIndexCount
The number of entries in the root data index.
|
private byte[] |
encryptionKey
The encryption key
|
private long |
entryCount
The number of key/value pairs in the file.
|
private long |
fileInfoOffset
Offset to the fileinfo data, a small block of vitals.
|
private long |
firstDataBlockOffset
The offset of the first data block.
|
private long |
lastDataBlockOffset
It is guaranteed that no key/value data blocks start after this offset in the file.
|
private long |
loadOnOpenDataOffset
In version 1, the offset to the data block index.
|
private static org.slf4j.Logger |
LOG |
private int |
majorVersion
The
HFile format major version. |
private static int |
MAX_COMPARATOR_NAME_LENGTH
We store the comparator class name as a fixed-length field in the trailer.
|
private static int |
MAX_TRAILER_SIZE |
private int |
metaIndexCount
The number of entries in the meta index
|
private int |
minorVersion
The
HFile format minor version. |
private static int |
NOT_PB_SIZE |
private int |
numDataIndexLevels
The number of levels in the potentially multi-level data index.
|
private long |
totalUncompressedBytes
The total uncompressed size of keys/values stored in the file.
|
private static int[] |
TRAILER_SIZE |
private long |
uncompressedDataIndexSize
Total uncompressed size of all blocks of the data index
|
Constructor and Description |
---|
FixedFileTrailer(int majorVersion,
int minorVersion) |
Modifier and Type | Method and Description |
---|---|
private void |
append(StringBuilder sb,
String s) |
private static int[] |
computeTrailerSizeByVersion() |
(package private) CellComparator |
createComparator() |
(package private) static CellComparator |
createComparator(String comparatorClassName) |
(package private) void |
deserialize(DataInputStream inputStream)
Deserialize the fixed file trailer from the given stream.
|
(package private) void |
deserializeFromPB(DataInputStream inputStream)
Deserialize the file trailer as protobuf
|
(package private) void |
deserializeFromWritable(DataInput input)
Deserialize the file trailer as writable data
|
void |
expectAtLeastMajorVersion(int lowerBound) |
void |
expectMajorVersion(int expected) |
void |
expectMinorVersion(int expected) |
private static int |
extractMajorVersion(int serializedVersion)
Extracts the major version for a 4-byte serialized version data.
|
private static int |
extractMinorVersion(int serializedVersion)
Extracts the minor version for a 4-byte serialized version data.
|
private static Class<? extends CellComparator> |
getComparatorClass(String comparatorClassName) |
String |
getComparatorClassName() |
Compression.Algorithm |
getCompressionCodec() |
int |
getDataIndexCount() |
byte[] |
getEncryptionKey() |
long |
getEntryCount() |
long |
getFileInfoOffset() |
long |
getFirstDataBlockOffset() |
private String |
getHBase1CompatibleName(String comparator)
Deprecated.
Since hbase-2.0.0. Will be removed in hbase-3.0.0.
|
long |
getLastDataBlockOffset() |
long |
getLoadOnOpenDataOffset() |
int |
getMajorVersion()
Returns the major version of this HFile format
|
private static int |
getMaxTrailerSize() |
int |
getMetaIndexCount() |
int |
getMinorVersion()
Returns the minor version of this HFile format
|
int |
getNumDataIndexLevels() |
long |
getTotalUncompressedBytes() |
int |
getTrailerSize() |
(package private) static int |
getTrailerSize(int version) |
long |
getUncompressedDataIndexSize() |
(package private) static int |
materializeVersion(int majorVersion,
int minorVersion)
Create a 4 byte serialized version number by combining the minor and major version numbers.
|
static FixedFileTrailer |
readFromStream(org.apache.hadoop.fs.FSDataInputStream istream,
long fileSize)
Reads a file trailer from the given file.
|
(package private) void |
serialize(DataOutputStream outputStream)
Write the trailer to a data stream.
|
(package private) void |
serializeAsPB(DataOutputStream output)
Write trailer data as protobuf.
|
void |
setComparatorClass(Class<? extends CellComparator> klass) |
void |
setCompressionCodec(Compression.Algorithm compressionCodec) |
void |
setDataIndexCount(int dataIndexCount) |
void |
setEncryptionKey(byte[] keyBytes) |
void |
setEntryCount(long newEntryCount) |
void |
setFileInfoOffset(long fileInfoOffset) |
void |
setFirstDataBlockOffset(long firstDataBlockOffset) |
void |
setLastDataBlockOffset(long lastDataBlockOffset) |
void |
setLoadOnOpenOffset(long loadOnOpenDataOffset) |
void |
setMetaIndexCount(int metaIndexCount) |
void |
setNumDataIndexLevels(int numDataIndexLevels) |
void |
setTotalUncompressedBytes(long totalUncompressedBytes) |
void |
setUncompressedDataIndexSize(long uncompressedDataIndexSize) |
(package private) org.apache.hadoop.hbase.shaded.protobuf.generated.HFileProtos.FileTrailerProto |
toProtobuf() |
String |
toString() |
private static final org.slf4j.Logger LOG
private static final int MAX_COMPARATOR_NAME_LENGTH
private long fileInfoOffset
private long loadOnOpenDataOffset
private int dataIndexCount
private long uncompressedDataIndexSize
private int metaIndexCount
private long totalUncompressedBytes
private long entryCount
private Compression.Algorithm compressionCodec
private int numDataIndexLevels
private long firstDataBlockOffset
private long lastDataBlockOffset
private String comparatorClassName
private byte[] encryptionKey
private final int majorVersion
HFile
format major version.private final int minorVersion
HFile
format minor version.private static final int[] TRAILER_SIZE
private static final int MAX_TRAILER_SIZE
private static final int NOT_PB_SIZE
FixedFileTrailer(int majorVersion, int minorVersion)
private static int[] computeTrailerSizeByVersion()
private static int getMaxTrailerSize()
static int getTrailerSize(int version)
public int getTrailerSize()
void serialize(DataOutputStream outputStream) throws IOException
IOException
org.apache.hadoop.hbase.shaded.protobuf.generated.HFileProtos.FileTrailerProto toProtobuf()
void serializeAsPB(DataOutputStream output) throws IOException
getHBase1CompatibleName(String)
.IOException
void deserialize(DataInputStream inputStream) throws IOException
serialize(DataOutputStream)
.IOException
void deserializeFromPB(DataInputStream inputStream) throws IOException
IOException
void deserializeFromWritable(DataInput input) throws IOException
IOException
private void append(StringBuilder sb, String s)
public static FixedFileTrailer readFromStream(org.apache.hadoop.fs.FSDataInputStream istream, long fileSize) throws IOException
istream
- the input stream with the ability to seek. Does not have to be buffered, as
only one read operation is made.fileSize
- the file size. Can be obtained using
FileSystem.getFileStatus( org.apache.hadoop.fs.Path)
.IOException
- if failed to read from the underlying stream, or the trailer is corrupted,
or the version of the trailer is unsupportedpublic void expectMajorVersion(int expected)
public void expectMinorVersion(int expected)
public void expectAtLeastMajorVersion(int lowerBound)
public long getFileInfoOffset()
public void setFileInfoOffset(long fileInfoOffset)
public long getLoadOnOpenDataOffset()
public void setLoadOnOpenOffset(long loadOnOpenDataOffset)
public int getDataIndexCount()
public void setDataIndexCount(int dataIndexCount)
public int getMetaIndexCount()
public void setMetaIndexCount(int metaIndexCount)
public long getTotalUncompressedBytes()
public void setTotalUncompressedBytes(long totalUncompressedBytes)
public long getEntryCount()
public void setEntryCount(long newEntryCount)
public Compression.Algorithm getCompressionCodec()
public void setCompressionCodec(Compression.Algorithm compressionCodec)
public int getNumDataIndexLevels()
public void setNumDataIndexLevels(int numDataIndexLevels)
public long getLastDataBlockOffset()
public void setLastDataBlockOffset(long lastDataBlockOffset)
public long getFirstDataBlockOffset()
public void setFirstDataBlockOffset(long firstDataBlockOffset)
public String getComparatorClassName()
public int getMajorVersion()
public int getMinorVersion()
public void setComparatorClass(Class<? extends CellComparator> klass)
@Deprecated private String getHBase1CompatibleName(String comparator)
The Comparators in hbase-2.x work the same as they did in hbase-1.x; they compare KeyValues. In
hbase-2.x they were renamed making use of the more generic 'Cell' nomenclature to indicate that
we intend to move away from KeyValues post hbase-2. A naming change is not reason enough to
make it so hbase-1.x cannot read hbase-2.x files given the structure goes unchanged (hfile v3).
So, lets write the old names for Comparators into the hfile tails in hbase-2. Here is where we
do the translation. getComparatorClass(String)
does translation going the other way.
The translation is done on the serialized Protobuf only.
comparator
- String class name of the Comparator used in this hfile.getComparatorClass(String)
private static Class<? extends CellComparator> getComparatorClass(String comparatorClassName) throws IOException
IOException
static CellComparator createComparator(String comparatorClassName) throws IOException
IOException
CellComparator createComparator() throws IOException
IOException
public long getUncompressedDataIndexSize()
public void setUncompressedDataIndexSize(long uncompressedDataIndexSize)
public byte[] getEncryptionKey()
public void setEncryptionKey(byte[] keyBytes)
private static int extractMajorVersion(int serializedVersion)
private static int extractMinorVersion(int serializedVersion)
static int materializeVersion(int majorVersion, int minorVersion)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.