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.
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.
|
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 |
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 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
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 © 2014 The Apache Software Foundation. All rights reserved.