@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 Cell |
firstCellInBlock
First cell in a block.
|
protected HFileContext |
hFileContext |
protected Cell |
lastCell
The Cell previously appended.
|
protected List<org.apache.hadoop.io.Writable> |
metaData
Writable s 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(Cell cell)
Checks that the given Cell's 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, wait
addDeleteFamilyBloomFilter, addGeneralBloomFilter, addInlineBlockWriter, append, appendMetaBlock, getFileContext
protected Cell lastCell
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
Writable
s representing meta block data.protected Cell firstCellInBlock
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
IOException
public void appendFileInfo(byte[] k, byte[] v) throws IOException
HFile.Reader.loadFileInfo()
.appendFileInfo
in interface HFile.Writer
k
- 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 toIOException
protected boolean checkKey(Cell cell) throws IOException
cell
- Cell whose key to check.IOException
- if the key or the key order is wrongprotected void checkValue(byte[] value, int offset, int length) throws IOException
IOException
public org.apache.hadoop.fs.Path getPath()
getPath
in interface HFile.Writer
protected void finishClose(FixedFileTrailer trailer) throws IOException
IOException
public 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
IOException
Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.