|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.io.hfile.HFileBlock
public class HFileBlock
Reading HFile
version 1 and 2 blocks, and writing version 2 blocks.
HFile
's compression algorithm, with a type-specific
magic record stored in the beginning of the compressed data (i.e. one needs
to uncompress the compressed block to determine the block type). There is
only a single compression algorithm setting for all blocks. Offset and size
information from the block index are required to read a block.
HFile
,
similarly to what was done in version 1.
Nested Class Summary | |
---|---|
static class |
HFileBlock.AbstractFSReader
A common implementation of some methods of HFileBlock.FSReader and some
tools for implementing HFile format version-specific block readers. |
static interface |
HFileBlock.BlockIterator
An interface allowing to iterate HFileBlock s. |
static interface |
HFileBlock.BlockWritable
Something that can be written into a block. |
static interface |
HFileBlock.FSReader
A full-fledged reader with iteration ability. |
static class |
HFileBlock.FSReaderV1
Reads version 1 blocks from the file system. |
static class |
HFileBlock.FSReaderV2
Reads version 2 blocks from the filesystem. |
static class |
HFileBlock.Writer
Unified version 2 HFile block writer. |
Field Summary | |
---|---|
static int |
BYTE_BUFFER_HEAP_SIZE
|
static byte[] |
DUMMY_HEADER
Just an array of bytes of the right size. |
static int |
HEADER_SIZE
The size of a version 2 HFile block header |
Constructor Summary | |
---|---|
HFileBlock(BlockType blockType,
int onDiskSizeWithoutHeader,
int uncompressedSizeWithoutHeader,
long prevBlockOffset,
ByteBuffer buf,
boolean fillHeader,
long offset)
Creates a new HFile block from the given fields. |
Method Summary | |
---|---|
void |
assumeUncompressed()
An additional sanity-check in case no compression is being used. |
boolean |
equals(Object comparison)
|
void |
expectType(BlockType expectedType)
|
BlockType |
getBlockType()
|
ByteBuffer |
getBufferReadOnly()
Returns the buffer this block stores internally. |
ByteBuffer |
getBufferWithHeader()
Returns a byte buffer of this block, including header data, positioned at the beginning of header. |
ByteBuffer |
getBufferWithoutHeader()
Returns a buffer that does not include the header. |
DataInputStream |
getByteStream()
|
CacheableDeserializer<Cacheable> |
getDeserializer()
Returns CacheableDeserializer instance which reconstructs original object from ByteBuffer. |
int |
getNextBlockOnDiskSizeWithHeader()
|
long |
getOffset()
|
int |
getOnDiskSizeWithHeader()
|
int |
getOnDiskSizeWithoutHeader()
Returns the size of the compressed part of the block in case compression is used, or the uncompressed size of the data part otherwise. |
long |
getPrevBlockOffset()
|
int |
getSerializedLength()
Returns the length of the ByteBuffer required to serialized the object. |
int |
getUncompressedSizeWithoutHeader()
|
long |
heapSize()
|
void |
readInto(org.apache.hadoop.io.Writable w)
Deserializes fields of the given writable using the data portion of this block. |
static boolean |
readWithExtra(InputStream in,
byte[] buf,
int bufOffset,
int necessaryLen,
int extraLen)
Read from an input stream. |
void |
serialize(ByteBuffer destination)
Serializes its data into destination. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int HEADER_SIZE
HFile
block header
public static final byte[] DUMMY_HEADER
public static final int BYTE_BUFFER_HEAP_SIZE
Constructor Detail |
---|
public HFileBlock(BlockType blockType, int onDiskSizeWithoutHeader, int uncompressedSizeWithoutHeader, long prevBlockOffset, ByteBuffer buf, boolean fillHeader, long offset)
HFile
block from the given fields. This constructor
is mostly used when the block data has already been read and uncompressed,
and is sitting in a byte buffer.
blockType
- the type of this block, see BlockType
onDiskSizeWithoutHeader
- compressed size of the block if compression
is used, otherwise uncompressed size, header size not includeduncompressedSizeWithoutHeader
- uncompressed size of the block,
header size not included. Equals onDiskSizeWithoutHeader if
compression is disabled.prevBlockOffset
- the offset of the previous block in the
HFile
buf
- block header (HEADER_SIZE
bytes) followed by
uncompressed data. ThisfillHeader
- true to fill in the first HEADER_SIZE
bytes of
the buffer based on the header fields providedoffset
- the file offset the block was read fromMethod Detail |
---|
public BlockType getBlockType()
public int getOnDiskSizeWithHeader()
public int getOnDiskSizeWithoutHeader()
public int getUncompressedSizeWithoutHeader()
public long getPrevBlockOffset()
public ByteBuffer getBufferWithoutHeader()
public ByteBuffer getBufferReadOnly()
CompoundBloomFilter
to avoid object creation on every
Bloom filter lookup, but has to be used with caution.
public ByteBuffer getBufferWithHeader()
public void readInto(org.apache.hadoop.io.Writable w) throws IOException
IOException
public String toString()
toString
in class Object
public void assumeUncompressed() throws IOException
IOException
public void expectType(BlockType expectedType) throws IOException
expectedType
- the expected type of this block
IOException
- if this block's type is different than expectedpublic long getOffset()
public DataInputStream getByteStream()
public long heapSize()
heapSize
in interface HeapSize
public static boolean readWithExtra(InputStream in, byte[] buf, int bufOffset, int necessaryLen, int extraLen) throws IOException
IOUtils.readFully(InputStream, byte[], int, int)
, but specifies a
number of "extra" bytes that would be desirable but not absolutely
necessary to read.
in
- the input stream to read frombuf
- the buffer to read intobufOffset
- the destination offset in the buffernecessaryLen
- the number of bytes that are absolutely necessary to
readextraLen
- the number of extra bytes that would be nice to read
IOException
- if failed to read the necessary bytespublic int getNextBlockOnDiskSizeWithHeader()
public int getSerializedLength()
Cacheable
getSerializedLength
in interface Cacheable
public void serialize(ByteBuffer destination)
Cacheable
serialize
in interface Cacheable
public CacheableDeserializer<Cacheable> getDeserializer()
Cacheable
getDeserializer
in interface Cacheable
public boolean equals(Object comparison)
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |