org.apache.hadoop.hbase.io.hfile
Class HFileWriterV1

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.metrics.SchemaConfigured
      extended by org.apache.hadoop.hbase.io.hfile.AbstractHFileWriter
          extended by org.apache.hadoop.hbase.io.hfile.HFileWriterV1
All Implemented Interfaces:
Closeable, HeapSize, HFile.Writer, SchemaMetrics.SchemaAware

public class HFileWriterV1
extends AbstractHFileWriter

Writes version 1 HFiles. Mainly used for testing backwards-compatibility.


Field Summary
static String BLOOM_FILTER_DATA_KEY
          Meta data block name for bloom filter bits.
 
Fields inherited from class org.apache.hadoop.hbase.io.hfile.AbstractHFileWriter
blockEncoder, blockSize, cacheConf, closeOutputStream, comparator, compressAlgo, entryCount, fileInfo, firstKeyInBlock, lastKeyBuffer, lastKeyLength, lastKeyOffset, metaData, metaNames, name, outputStream, path, totalKeyLength, totalUncompressedBytes, totalValueLength
 
Fields inherited from class org.apache.hadoop.hbase.regionserver.metrics.SchemaConfigured
SCHEMA_CONFIGURED_UNALIGNED_HEAP_SIZE
 
Constructor Summary
HFileWriterV1(org.apache.hadoop.conf.Configuration conf, CacheConfig cacheConf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path, org.apache.hadoop.fs.FSDataOutputStream ostream, int blockSize, Compression.Algorithm compress, HFileDataBlockEncoder blockEncoder, KeyValue.KeyComparator comparator)
          Constructor that takes a path, creates and closes the output stream.
 
Method Summary
 void addDeleteFamilyBloomFilter(BloomFilterWriter bfw)
          Store delete family Bloom filter in the file, which is only supported in HFile V2.
 void addGeneralBloomFilter(BloomFilterWriter bfw)
          Version 1 general Bloom filters are stored in two meta blocks with two different keys.
 void addInlineBlockWriter(InlineBlockWriter bloomWriter)
          Adds an inline block writer such as a multi-level block index writer or a compound Bloom filter writer.
 void append(byte[] key, byte[] value)
          Add key/value to file.
 void append(KeyValue kv)
          Add key/value to file.
 void appendMetaBlock(String metaBlockName, org.apache.hadoop.io.Writable content)
          Add a meta block to the end of the file.
 void close()
           
protected  void finishFileInfo()
          Add last bits of metadata to file info before it is written out.
 
Methods inherited from class org.apache.hadoop.hbase.io.hfile.AbstractHFileWriter
appendFileInfo, checkKey, checkValue, compressionByName, createOutputStream, finishClose, getPath, toString, writeFileInfo
 
Methods inherited from class org.apache.hadoop.hbase.regionserver.metrics.SchemaConfigured
createUnknown, getColumnFamilyName, getSchemaMetrics, getTableName, heapSize, isSchemaConfigured, passSchemaMetricsTo, resetSchemaMetricsConf, schemaConfAsJSON, schemaConfigurationChanged
 
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
getColumnFamilyName
 

Field Detail

BLOOM_FILTER_DATA_KEY

public static final String BLOOM_FILTER_DATA_KEY
Meta data block name for bloom filter bits.

See Also:
Constant Field Values
Constructor Detail

HFileWriterV1

public HFileWriterV1(org.apache.hadoop.conf.Configuration conf,
                     CacheConfig cacheConf,
                     org.apache.hadoop.fs.FileSystem fs,
                     org.apache.hadoop.fs.Path path,
                     org.apache.hadoop.fs.FSDataOutputStream ostream,
                     int blockSize,
                     Compression.Algorithm compress,
                     HFileDataBlockEncoder blockEncoder,
                     KeyValue.KeyComparator comparator)
              throws IOException
Constructor that takes a path, creates and closes the output stream.

Throws:
IOException
Method Detail

appendMetaBlock

public void appendMetaBlock(String metaBlockName,
                            org.apache.hadoop.io.Writable content)
Add a meta block to the end of the file. Call before close(). Metadata blocks are expensive. Fill one with a bunch of serialized data rather than do a metadata block per metadata instance. If metadata is small, consider adding to file info using AbstractHFileWriter.appendFileInfo(byte[], byte[])

Parameters:
metaBlockName - name of the block
content - will call readFields to get data later (DO NOT REUSE)

append

public void append(KeyValue kv)
            throws IOException
Add key/value to file. Keys must be added in an order that agrees with the Comparator passed on construction.

Parameters:
kv - KeyValue to add. Cannot be empty nor null.
Throws:
IOException

append

public void append(byte[] key,
                   byte[] value)
            throws IOException
Add key/value to file. Keys must be added in an order that agrees with the Comparator passed on construction.

Parameters:
key - Key to add. Cannot be empty nor null.
value - Value to add. Cannot be empty nor null.
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException

finishFileInfo

protected void finishFileInfo()
                       throws IOException
Description copied from class: AbstractHFileWriter
Add last bits of metadata to file info before it is written out.

Overrides:
finishFileInfo in class AbstractHFileWriter
Throws:
IOException

addInlineBlockWriter

public void addInlineBlockWriter(InlineBlockWriter bloomWriter)
Description copied from interface: HFile.Writer
Adds an inline block writer such as a multi-level block index writer or a compound Bloom filter writer.


addGeneralBloomFilter

public void addGeneralBloomFilter(BloomFilterWriter bfw)
Version 1 general Bloom filters are stored in two meta blocks with two different keys.


addDeleteFamilyBloomFilter

public void addDeleteFamilyBloomFilter(BloomFilterWriter bfw)
                                throws IOException
Description copied from interface: HFile.Writer
Store delete family Bloom filter in the file, which is only supported in HFile V2.

Throws:
IOException


Copyright © 2015 The Apache Software Foundation. All Rights Reserved.