public static class HFileBlock.Writer extends Object
HFile
block writer. The intended usage pattern
is as follows:
HFileBlock.Writer
, providing a compression algorithm.
startWriting(org.apache.hadoop.hbase.io.hfile.BlockType)
and get a data stream to write to.
writeHeaderAndData(FSDataOutputStream)
as many times as you need to.
store the serialized block into an external stream.
Modifier and Type | Class and Description |
---|---|
static class |
HFileBlock.Writer.BufferGrabbingByteArrayOutputStream |
Constructor and Description |
---|
HFileBlock.Writer(HFileDataBlockEncoder dataBlockEncoder,
HFileContext fileContext) |
Modifier and Type | Method and Description |
---|---|
int |
blockSizeWritten()
Returns the number of bytes written into the current block so far, or
zero if not writing the block at the moment.
|
protected void |
finishBlockAndWriteHeaderAndData(DataOutputStream out)
Writes the header and the compressed data of this block (or uncompressed
data when not using compression) into the given stream.
|
HFileBlock |
getBlockForCaching(CacheConfig cacheConf)
Creates a new HFileBlock.
|
boolean |
isWriting() |
void |
release()
Releases resources used by this writer.
|
DataOutputStream |
startWriting(BlockType newBlockType)
Starts writing into the block.
|
void |
write(Cell cell)
Writes the Cell to this block
|
void |
writeBlock(HFileBlock.BlockWritable bw,
org.apache.hadoop.fs.FSDataOutputStream out)
Takes the given
HFileBlock.BlockWritable instance, creates a new block of
its appropriate type, writes the writable into this block, and flushes
the block into the output stream. |
void |
writeHeaderAndData(org.apache.hadoop.fs.FSDataOutputStream out)
Similar to
writeHeaderAndData(FSDataOutputStream) , but records
the offset of this block so that it can be referenced in the next block
of the same type. |
public HFileBlock.Writer(HFileDataBlockEncoder dataBlockEncoder, HFileContext fileContext)
dataBlockEncoder
- data block encoding algorithm to usepublic DataOutputStream startWriting(BlockType newBlockType) throws IOException
IOException
public void write(Cell cell) throws IOException
cell
- IOException
public void writeHeaderAndData(org.apache.hadoop.fs.FSDataOutputStream out) throws IOException
writeHeaderAndData(FSDataOutputStream)
, but records
the offset of this block so that it can be referenced in the next block
of the same type.out
- IOException
protected void finishBlockAndWriteHeaderAndData(DataOutputStream out) throws IOException
out
- the output stream to write theIOException
public void release()
public boolean isWriting()
public int blockSizeWritten()
public void writeBlock(HFileBlock.BlockWritable bw, org.apache.hadoop.fs.FSDataOutputStream out) throws IOException
HFileBlock.BlockWritable
instance, creates a new block of
its appropriate type, writes the writable into this block, and flushes
the block into the output stream. The writer is instructed not to buffer
uncompressed bytes for cache-on-write.bw
- the block-writable object to write as a blockout
- the file system output streamIOException
public HFileBlock getBlockForCaching(CacheConfig cacheConf)
Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.