public static class HFileBlockIndex.BlockIndexWriter extends Object implements InlineBlockWriter
| Constructor and Description |
|---|
BlockIndexWriter()
Creates a single-level block index writer
|
BlockIndexWriter(org.apache.hadoop.hbase.io.hfile.HFileBlock.Writer blockWriter,
CacheConfig cacheConf,
String nameForCaching,
HFileIndexBlockEncoder indexBlockEncoder)
Creates a multi-level block index writer.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
void |
ensureSingleLevel() |
boolean |
getCacheOnWrite()
Returns true if inline blocks produced by this writer should be cached
|
BlockType |
getInlineBlockType()
The type of blocks this block writer produces.
|
int |
getNumLevels()
Returns the number of levels in this block index.
|
int |
getNumRootEntries()
Returns how many block index entries there are in the root level
|
long |
getTotalUncompressedSize()
The total uncompressed size of the root index block, intermediate-level index blocks, and
leaf-level index blocks.
|
void |
setMaxChunkSize(int maxChunkSize) |
void |
setMinIndexNumEntries(int minIndexNumEntries) |
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.
|
public BlockIndexWriter()
public BlockIndexWriter(org.apache.hadoop.hbase.io.hfile.HFileBlock.Writer blockWriter, CacheConfig cacheConf, String nameForCaching, HFileIndexBlockEncoder indexBlockEncoder)
blockWriter - the block writer to use to write index blockscacheConf - used to determine when and how a block should be cached-on-write.public void setMaxChunkSize(int maxChunkSize)
public void setMinIndexNumEntries(int minIndexNumEntries)
public long writeIndexBlocks(org.apache.hadoop.fs.FSDataOutputStream out)
throws IOException
out - FSDataOutputStreamIOExceptionpublic 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.IOExceptionpublic final int getNumRootEntries()
public int getNumLevels()
public boolean shouldWriteBlock(boolean closing)
shouldWriteBlock in interface InlineBlockWriterpublic void writeInlineBlock(DataOutput out) throws IOException
writeInlineBlock in interface InlineBlockWriterIOExceptionpublic void blockWritten(long offset,
int onDiskSize,
int uncompressedSize)
blockWritten in interface InlineBlockWriteroffset - the offset of the block in the streamonDiskSize - the on-disk size of the blockuncompressedSize - the uncompressed size of the blockpublic BlockType getInlineBlockType()
InlineBlockWritergetInlineBlockType in interface InlineBlockWriterpublic void addEntry(byte[] firstKey,
long blockOffset,
int blockDataSize)
public void ensureSingleLevel()
throws IOException
IOException - if we happened to write a multi-level index.public boolean getCacheOnWrite()
InlineBlockWritergetCacheOnWrite in interface InlineBlockWriterpublic long getTotalUncompressedSize()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.