@InterfaceAudience.Private public abstract class AbstractHFileWriter extends Object implements HFile.Writer
HFile writers.| Modifier and Type | Field and Description |
|---|---|
protected HFileDataBlockEncoder |
blockEncoder
The data block encoding which will be used.
|
protected CacheConfig |
cacheConf
Cache configuration for caching data on write.
|
protected boolean |
closeOutputStream
True if we opened the
outputStream (and so will close it). |
protected KeyValue.KVComparator |
comparator
Key comparator.
|
protected long |
entryCount
Total # of key/value entries, i.e.
|
protected HFile.FileInfo |
fileInfo
A "file info" block: a key-value map of file-wide metadata.
|
protected byte[] |
firstKeyInBlock
First key in a block.
|
protected HFileContext |
hFileContext |
protected byte[] |
lastKeyBuffer
Key previously appended.
|
protected int |
lastKeyLength |
protected int |
lastKeyOffset |
protected List<org.apache.hadoop.io.Writable> |
metaData
Writables representing meta block data. |
protected List<byte[]> |
metaNames
Meta block names.
|
protected String |
name
Name for this object used when logging or in toString.
|
protected org.apache.hadoop.fs.FSDataOutputStream |
outputStream
FileSystem stream to write into.
|
protected org.apache.hadoop.fs.Path |
path
May be null if we were passed a stream.
|
protected long |
totalKeyLength
Used for calculating the average key length.
|
protected long |
totalUncompressedBytes
Total uncompressed bytes, maybe calculate a compression ratio later.
|
protected long |
totalValueLength
Used for calculating the average value length.
|
| Constructor and Description |
|---|
AbstractHFileWriter(CacheConfig cacheConf,
org.apache.hadoop.fs.FSDataOutputStream outputStream,
org.apache.hadoop.fs.Path path,
KeyValue.KVComparator comparator,
HFileContext fileContext) |
| Modifier and Type | Method and Description |
|---|---|
void |
appendFileInfo(byte[] k,
byte[] v)
Add to the file info.
|
protected boolean |
checkKey(byte[] key,
int offset,
int length)
Checks that the given key does not violate the key order.
|
protected void |
checkValue(byte[] value,
int offset,
int length)
Checks the given value for validity.
|
static Compression.Algorithm |
compressionByName(String algoName) |
protected static org.apache.hadoop.fs.FSDataOutputStream |
createOutputStream(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
InetSocketAddress[] favoredNodes)
A helper method to create HFile output streams in constructors
|
protected void |
finishClose(FixedFileTrailer trailer)
Sets remaining trailer fields, writes the trailer to disk, and optionally
closes the output stream.
|
protected void |
finishFileInfo()
Add last bits of metadata to file info before it is written out.
|
org.apache.hadoop.fs.Path |
getPath() |
String |
toString() |
protected void |
writeFileInfo(FixedFileTrailer trailer,
DataOutputStream out)
Sets the file info offset in the trailer, finishes up populating fields in
the file info, and writes the file info into the given data output.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddDeleteFamilyBloomFilter, addGeneralBloomFilter, addInlineBlockWriter, append, append, append, appendMetaBlock, getFileContextprotected byte[] lastKeyBuffer
protected int lastKeyOffset
protected int lastKeyLength
protected org.apache.hadoop.fs.FSDataOutputStream outputStream
protected final boolean closeOutputStream
outputStream (and so will close it).protected HFile.FileInfo fileInfo
protected long entryCount
protected long totalKeyLength
protected long totalValueLength
protected long totalUncompressedBytes
protected final KeyValue.KVComparator comparator
protected List<byte[]> metaNames
protected List<org.apache.hadoop.io.Writable> metaData
Writables representing meta block data.protected byte[] firstKeyInBlock
protected final org.apache.hadoop.fs.Path path
protected final CacheConfig cacheConf
protected final String name
protected final HFileDataBlockEncoder blockEncoder
NoOpDataBlockEncoder.INSTANCE if there is no encoding.protected final HFileContext hFileContext
public AbstractHFileWriter(CacheConfig cacheConf, org.apache.hadoop.fs.FSDataOutputStream outputStream, org.apache.hadoop.fs.Path path, KeyValue.KVComparator comparator, HFileContext fileContext)
protected void finishFileInfo()
throws IOException
IOExceptionpublic void appendFileInfo(byte[] k,
byte[] v)
throws IOException
HFile.Reader.loadFileInfo().appendFileInfo in interface HFile.Writerk - Keyv - ValueIOException - in case the key or the value are invalidprotected final void writeFileInfo(FixedFileTrailer trailer, DataOutputStream out) throws IOException
outputStream is that we store
file info as a block in version 2.trailer - fixed file trailerout - the data output to write the file info toIOExceptionprotected boolean checkKey(byte[] key,
int offset,
int length)
throws IOException
key - Key to check.IOException - if the key or the key order is wrongprotected void checkValue(byte[] value,
int offset,
int length)
throws IOException
IOExceptionpublic org.apache.hadoop.fs.Path getPath()
getPath in interface HFile.Writerprotected void finishClose(FixedFileTrailer trailer) throws IOException
IOExceptionpublic static Compression.Algorithm compressionByName(String algoName)
protected static org.apache.hadoop.fs.FSDataOutputStream createOutputStream(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path,
InetSocketAddress[] favoredNodes)
throws IOException
IOExceptionCopyright © 2014 The Apache Software Foundation. All rights reserved.