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(Compression.Algorithm compressionAlgorithm,
HFileDataBlockEncoder dataBlockEncoder,
boolean includesMemstoreTS,
ChecksumType checksumType,
int bytesPerChecksum) |
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()
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(Compression.Algorithm compressionAlgorithm, HFileDataBlockEncoder dataBlockEncoder, boolean includesMemstoreTS, ChecksumType checksumType, int bytesPerChecksum)
compressionAlgorithm
- compression algorithm to usedataBlockEncoder
- data block encoding algorithm to usechecksumType
- type of checksumbytesPerChecksum
- bytes per checksumpublic 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()
Copyright © 2013 The Apache Software Foundation. All rights reserved.