public static class HFileBlockIndex.BlockIndexWriter extends Object implements InlineBlockWriter
Constructor and Description |
---|
HFileBlockIndex.BlockIndexWriter()
Creates a single-level block index writer
|
HFileBlockIndex.BlockIndexWriter(HFileBlock.Writer blockWriter,
CacheConfig cacheConf,
String nameForCaching)
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() |
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) |
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 HFileBlockIndex.BlockIndexWriter()
public HFileBlockIndex.BlockIndexWriter(HFileBlock.Writer blockWriter, CacheConfig cacheConf, String nameForCaching)
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
- FSDataOutputStreamIOException
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)
public void ensureSingleLevel() throws IOException
IOException
- if we happened to write a multi-level index.public boolean getCacheOnWrite()
getCacheOnWrite
in interface InlineBlockWriter
public long getTotalUncompressedSize()
Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.