org.apache.accumulo.core.file.rfile.bcfile
Constructor and Description |
---|
TFile.Writer(org.apache.hadoop.fs.FSDataOutputStream fsdos,
int minBlockSize,
String compressName,
String comparator,
org.apache.hadoop.conf.Configuration conf)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
append(byte[] key,
byte[] value)
Adding a new key-value pair to the TFile.
|
void |
append(byte[] key,
int koff,
int klen,
byte[] value,
int voff,
int vlen)
Adding a new key-value pair to TFile.
|
void |
close()
Close the Writer.
|
DataOutputStream |
prepareAppendKey(int length)
Obtain an output stream for writing a key into TFile.
|
DataOutputStream |
prepareAppendValue(int length)
Obtain an output stream for writing a value into TFile.
|
DataOutputStream |
prepareMetaBlock(String name)
Obtain an output stream for creating a meta block.
|
DataOutputStream |
prepareMetaBlock(String name,
String compressName)
Obtain an output stream for creating a meta block.
|
public TFile.Writer(org.apache.hadoop.fs.FSDataOutputStream fsdos, int minBlockSize, String compressName, String comparator, org.apache.hadoop.conf.Configuration conf) throws IOException
fsdos
- output stream for writing. Must be at position 0.minBlockSize
- Minimum compressed block size in bytes. A compression block will not be closed until it reaches this size except for the last block.compressName
- Name of the compression algorithm. Must be one of the strings returned by TFile.getSupportedCompressionAlgorithms()
.comparator
- Leave comparator as null or empty string if TFile is not sorted. Otherwise, provide the string name for the comparison algorithm for keys. Two
kinds of comparators are supported.
WritableComparator
or JavaSerializationComparator
may not
be directly used. One should write a wrapper class that inherits from such classes and use its default constructor to perform proper
initialization.
conf
- The configuration object.IOException
public void close() throws IOException
close
in interface Closeable
IOException
public void append(byte[] key, byte[] value) throws IOException
key
- Buffer for key.value
- Buffer for value.IOException
public void append(byte[] key, int koff, int klen, byte[] value, int voff, int vlen) throws IOException
key
- buffer for key.koff
- offset in key buffer.klen
- length of key.value
- buffer for value.voff
- offset in value buffer.vlen
- length of value.IOException
- Upon IO errors.
If an exception is thrown, the TFile will be in an inconsistent state. The only legitimate call after that would be close
public DataOutputStream prepareAppendKey(int length) throws IOException
length
- The expected length of the key. If length of the key is not known, set length = -1. Otherwise, the application must write exactly as many bytes
as specified here before calling close on the returned output stream.IOException
public DataOutputStream prepareAppendValue(int length) throws IOException
length
- The expected length of the value. If length of the value is not known, set length = -1. Otherwise, the application must write exactly as many
bytes as specified here before calling close on the returned output stream. Advertising the value size up-front guarantees that the value is
encoded in one chunk, and avoids intermediate chunk buffering.IOException
public DataOutputStream prepareMetaBlock(String name, String compressName) throws IOException, MetaBlockAlreadyExists
name
- Name of the meta block.compressName
- Name of the compression algorithm to be used. Must be one of the strings returned by TFile.getSupportedCompressionAlgorithms()
.MetaBlockAlreadyExists
- the Meta Block with the same name already exists.IOException
public DataOutputStream prepareMetaBlock(String name) throws IOException, MetaBlockAlreadyExists
name
- Name of the meta block.MetaBlockAlreadyExists
- the Meta Block with the same name already exists.IOException
Copyright © 2015 Apache Accumulo Project. All Rights Reserved.