Search in sources :

Example 1 with HFileDataBlockEncoder

use of org.apache.hadoop.hbase.io.hfile.HFileDataBlockEncoder in project hbase by apache.

the class TestStoreFile method testDataBlockEncodingMetaData.

/**
   * Check if data block encoding information is saved correctly in HFile's
   * file info.
   */
@Test
public void testDataBlockEncodingMetaData() throws IOException {
    // Make up a directory hierarchy that has a regiondir ("7e0102") and familyname.
    Path dir = new Path(new Path(testDir, "7e0102"), "familyname");
    Path path = new Path(dir, "1234567890");
    DataBlockEncoding dataBlockEncoderAlgo = DataBlockEncoding.FAST_DIFF;
    HFileDataBlockEncoder dataBlockEncoder = new HFileDataBlockEncoderImpl(dataBlockEncoderAlgo);
    cacheConf = new CacheConfig(conf);
    HFileContext meta = new HFileContextBuilder().withBlockSize(BLOCKSIZE_SMALL).withChecksumType(CKTYPE).withBytesPerCheckSum(CKBYTES).withDataBlockEncoding(dataBlockEncoderAlgo).build();
    // Make a store file and write data to it.
    StoreFileWriter writer = new StoreFileWriter.Builder(conf, cacheConf, this.fs).withFilePath(path).withMaxKeyCount(2000).withFileContext(meta).build();
    writer.close();
    StoreFile storeFile = new StoreFile(fs, writer.getPath(), conf, cacheConf, BloomType.NONE);
    StoreFileReader reader = storeFile.createReader();
    Map<byte[], byte[]> fileInfo = reader.loadFileInfo();
    byte[] value = fileInfo.get(HFileDataBlockEncoder.DATA_BLOCK_ENCODING);
    assertEquals(dataBlockEncoderAlgo.getNameInBytes(), value);
}
Also used : Path(org.apache.hadoop.fs.Path) HFileDataBlockEncoder(org.apache.hadoop.hbase.io.hfile.HFileDataBlockEncoder) DataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding) HFileContextBuilder(org.apache.hadoop.hbase.io.hfile.HFileContextBuilder) HFileContextBuilder(org.apache.hadoop.hbase.io.hfile.HFileContextBuilder) HFileContext(org.apache.hadoop.hbase.io.hfile.HFileContext) HFileDataBlockEncoderImpl(org.apache.hadoop.hbase.io.hfile.HFileDataBlockEncoderImpl) CacheConfig(org.apache.hadoop.hbase.io.hfile.CacheConfig) Test(org.junit.Test)

Example 2 with HFileDataBlockEncoder

use of org.apache.hadoop.hbase.io.hfile.HFileDataBlockEncoder in project hbase by apache.

the class TestMajorCompaction method majorCompactionWithDataBlockEncoding.

public void majorCompactionWithDataBlockEncoding(boolean inCacheOnly) throws Exception {
    Map<HStore, HFileDataBlockEncoder> replaceBlockCache = new HashMap<>();
    for (HStore store : r.getStores()) {
        HFileDataBlockEncoder blockEncoder = store.getDataBlockEncoder();
        replaceBlockCache.put(store, blockEncoder);
        final DataBlockEncoding inCache = DataBlockEncoding.PREFIX;
        final DataBlockEncoding onDisk = inCacheOnly ? DataBlockEncoding.NONE : inCache;
        ((HStore) store).setDataBlockEncoderInTest(new HFileDataBlockEncoderImpl(onDisk));
    }
    majorCompaction();
    // restore settings
    for (Entry<HStore, HFileDataBlockEncoder> entry : replaceBlockCache.entrySet()) {
        ((HStore) entry.getKey()).setDataBlockEncoderInTest(entry.getValue());
    }
}
Also used : HFileDataBlockEncoder(org.apache.hadoop.hbase.io.hfile.HFileDataBlockEncoder) DataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding) HashMap(java.util.HashMap) HFileDataBlockEncoderImpl(org.apache.hadoop.hbase.io.hfile.HFileDataBlockEncoderImpl)

Aggregations

DataBlockEncoding (org.apache.hadoop.hbase.io.encoding.DataBlockEncoding)2 HFileDataBlockEncoder (org.apache.hadoop.hbase.io.hfile.HFileDataBlockEncoder)2 HFileDataBlockEncoderImpl (org.apache.hadoop.hbase.io.hfile.HFileDataBlockEncoderImpl)2 HashMap (java.util.HashMap)1 Path (org.apache.hadoop.fs.Path)1 CacheConfig (org.apache.hadoop.hbase.io.hfile.CacheConfig)1 HFileContext (org.apache.hadoop.hbase.io.hfile.HFileContext)1 HFileContextBuilder (org.apache.hadoop.hbase.io.hfile.HFileContextBuilder)1 Test (org.junit.Test)1