|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.regionserver.metrics.SchemaConfigured
org.apache.hadoop.hbase.io.hfile.HFileBlockIndex.BlockIndexWriter
public static class HFileBlockIndex.BlockIndexWriter
Writes the block index into the output stream. Generate the tree from bottom up. The leaf level is written to disk as a sequence of inline blocks, if it is larger than a certain number of bytes. If the leaf level is not large enough, we write all entries to the root level instead. After all leaf blocks have been written, we end up with an index referencing the resulting leaf index blocks. If that index is larger than the allowed root index size, the writer will break it up into reasonable-size intermediate-level index block chunks write those chunks out, and create another index referencing those chunks. This will be repeated until the remaining index is small enough to become the root index. However, in most practical cases we will only have leaf-level blocks and the root index, or just the root index.
Field Summary |
---|
Fields inherited from class org.apache.hadoop.hbase.regionserver.metrics.SchemaConfigured |
---|
SCHEMA_CONFIGURED_UNALIGNED_HEAP_SIZE |
Constructor Summary | |
---|---|
HFileBlockIndex.BlockIndexWriter()
Creates a single-level block index writer |
|
HFileBlockIndex.BlockIndexWriter(HFileBlock.Writer blockWriter,
BlockCache blockCache,
String nameForCaching)
Creates a multi-level block index writer. |
Method Summary | |
---|---|
void |
addEntry(byte[] firstKey,
long blockOffset,
int blockDataSize)
Add one index entry to the current leaf-level block. |
void |
blockWritten(long offset,
int onDiskSize,
int uncompressedSize)
Called after an inline block has been written so that we can add an entry referring to that block to the parent-level index. |
boolean |
cacheOnWrite()
|
void |
ensureSingleLevel()
|
BlockType |
getInlineBlockType()
The type of blocks this block writer produces. |
int |
getNumLevels()
|
int |
getNumRootEntries()
|
long |
getTotalUncompressedSize()
The total uncompressed size of the root index block, intermediate-level index blocks, and leaf-level index blocks. |
void |
setMaxChunkSize(int maxChunkSize)
|
boolean |
shouldWriteBlock(boolean closing)
Whether there is an inline block ready to be written. |
long |
writeIndexBlocks(org.apache.hadoop.fs.FSDataOutputStream out)
Writes the root level and intermediate levels of the block index into the output stream, generating the tree from bottom up. |
void |
writeInlineBlock(DataOutput out)
Write out the current inline index block. |
void |
writeSingleLevelIndex(DataOutput out,
String description)
Writes the block index data as a single level only. |
Methods inherited from class org.apache.hadoop.hbase.regionserver.metrics.SchemaConfigured |
---|
createUnknown, getColumnFamilyName, getSchemaMetrics, getTableName, heapSize, isSchemaConfigured, passSchemaMetricsTo, resetSchemaMetricsConf, schemaConfAsJSON, schemaConfigurationChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HFileBlockIndex.BlockIndexWriter()
public HFileBlockIndex.BlockIndexWriter(HFileBlock.Writer blockWriter, BlockCache blockCache, String nameForCaching)
blockWriter
- the block writer to use to write index blocksblockCache
- if this is not null, index blocks will be cached
on write into this block cache.Method Detail |
---|
public void setMaxChunkSize(int maxChunkSize)
public long writeIndexBlocks(org.apache.hadoop.fs.FSDataOutputStream out) throws IOException
out
- FSDataOutputStream
IOException
public void writeSingleLevelIndex(DataOutput out, String description) throws IOException
out
- the buffered output stream to write the index to. Typically a
stream writing into an HFile
block.description
- a short description of the index being written. Used
in a log message.
IOException
public final int getNumRootEntries()
public int getNumLevels()
public boolean shouldWriteBlock(boolean closing)
shouldWriteBlock
in interface InlineBlockWriter
closing
- whether the file is being closed, in which case we need to write
out all available data and not wait to accumulate another blockpublic void writeInlineBlock(DataOutput out) throws IOException
writeInlineBlock
in interface InlineBlockWriter
out
-
IOException
public void blockWritten(long offset, int onDiskSize, int uncompressedSize)
blockWritten
in interface InlineBlockWriter
offset
- the offset of the block in the streamonDiskSize
- the on-disk size of the blockuncompressedSize
- the uncompressed size of the blockpublic BlockType getInlineBlockType()
InlineBlockWriter
getInlineBlockType
in interface InlineBlockWriter
public void addEntry(byte[] firstKey, long blockOffset, int blockDataSize)
firstKey
- the first key of the data blockblockOffset
- the offset of the data blockblockDataSize
- the on-disk size of the data block (HFile
format version 2), or the uncompressed size of the data block (
HFile
format version 1).public void ensureSingleLevel() throws IOException
IOException
- if we happened to write a multi-level index.public boolean cacheOnWrite()
cacheOnWrite
in interface InlineBlockWriter
public long getTotalUncompressedSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |