|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.io.hfile.AbstractHFileWriter
@InterfaceAudience.Private public abstract class AbstractHFileWriter
Common functionality needed by all versions of HFile
writers.
Field Summary | |
---|---|
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
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 Summary | |
---|---|
AbstractHFileWriter(CacheConfig cacheConf,
org.apache.hadoop.fs.FSDataOutputStream outputStream,
org.apache.hadoop.fs.Path path,
KeyValue.KVComparator comparator,
HFileContext fileContext)
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.hadoop.hbase.io.hfile.HFile.Writer |
---|
addDeleteFamilyBloomFilter, addGeneralBloomFilter, addInlineBlockWriter, append, append, append, appendMetaBlock, getFileContext |
Methods inherited from interface java.io.Closeable |
---|
close |
Field Detail |
---|
protected 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
Writable
s 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
Constructor Detail |
---|
public AbstractHFileWriter(CacheConfig cacheConf, org.apache.hadoop.fs.FSDataOutputStream outputStream, org.apache.hadoop.fs.Path path, KeyValue.KVComparator comparator, HFileContext fileContext)
Method Detail |
---|
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
- Value
IOException
- 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 to
IOException
protected 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
IOException
public org.apache.hadoop.fs.Path getPath()
getPath
in interface HFile.Writer
public String toString()
toString
in class Object
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |