Search in sources :

Example 26 with DataBlockEncoding

use of org.apache.hadoop.hbase.io.encoding.DataBlockEncoding in project hbase by apache.

the class ChangeEncodingAction method perform.

@Override
public void perform() throws IOException {
    getLogger().debug("Performing action: Changing encodings on " + tableName);
    // possible DataBlockEncoding id's
    final int[] possibleIds = { 0, 2, 3, 4, 7 };
    modifyAllTableColumns(tableName, (columnName, columnBuilder) -> {
        short id = (short) possibleIds[random.nextInt(possibleIds.length)];
        DataBlockEncoding encoding = DataBlockEncoding.getEncodingById(id);
        columnBuilder.setDataBlockEncoding(encoding);
        getLogger().debug("Set encoding of column family " + columnName + " to: " + encoding);
    });
}
Also used : DataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding)

Example 27 with DataBlockEncoding

use of org.apache.hadoop.hbase.io.encoding.DataBlockEncoding in project hbase by apache.

the class IntegrationTestLazyCfLoading method createTable.

private void createTable() throws Exception {
    deleteTable();
    LOG.info("Creating table");
    Configuration conf = util.getConfiguration();
    String encodingKey = String.format(ENCODING_KEY, this.getClass().getSimpleName());
    DataBlockEncoding blockEncoding = DataBlockEncoding.valueOf(conf.get(encodingKey, "FAST_DIFF"));
    TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(TABLE_NAME);
    for (byte[] cf : dataGen.getColumnFamilies()) {
        ColumnFamilyDescriptor familyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(cf).setDataBlockEncoding(blockEncoding).build();
        builder.setColumnFamily(familyDescriptor);
    }
    int serverCount = util.getHBaseClusterInterface().getClusterMetrics().getLiveServerMetrics().size();
    byte[][] splits = new RegionSplitter.HexStringSplit().split(serverCount * REGIONS_PER_SERVER);
    util.getAdmin().createTable(builder.build(), splits);
    LOG.info("Created table");
}
Also used : DataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding) Configuration(org.apache.hadoop.conf.Configuration) TableDescriptorBuilder(org.apache.hadoop.hbase.client.TableDescriptorBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor) RegionSplitter(org.apache.hadoop.hbase.util.RegionSplitter)

Example 28 with DataBlockEncoding

use of org.apache.hadoop.hbase.io.encoding.DataBlockEncoding in project hbase by apache.

the class LruAdaptiveBlockCache method getEncodingCountsForTest.

public Map<DataBlockEncoding, Integer> getEncodingCountsForTest() {
    Map<DataBlockEncoding, Integer> counts = new EnumMap<>(DataBlockEncoding.class);
    for (LruCachedBlock block : map.values()) {
        DataBlockEncoding encoding = ((HFileBlock) block.getBuffer()).getDataBlockEncoding();
        Integer count = counts.get(encoding);
        counts.put(encoding, (count == null ? 0 : count) + 1);
    }
    return counts;
}
Also used : DataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding) EnumMap(java.util.EnumMap)

Example 29 with DataBlockEncoding

use of org.apache.hadoop.hbase.io.encoding.DataBlockEncoding in project hbase by apache.

the class HBaseTestingUtil method generateColumnDescriptors.

/**
 * Create a set of column descriptors with the combination of compression, encoding, bloom codecs
 * available.
 * @param prefix family names prefix
 * @return the list of column descriptors
 */
public static List<ColumnFamilyDescriptor> generateColumnDescriptors(final String prefix) {
    List<ColumnFamilyDescriptor> columnFamilyDescriptors = new ArrayList<>();
    long familyId = 0;
    for (Compression.Algorithm compressionType : getSupportedCompressionAlgorithms()) {
        for (DataBlockEncoding encodingType : DataBlockEncoding.values()) {
            for (BloomType bloomType : BloomType.values()) {
                String name = String.format("%s-cf-!@#&-%d!@#", prefix, familyId);
                ColumnFamilyDescriptorBuilder columnFamilyDescriptorBuilder = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(name));
                columnFamilyDescriptorBuilder.setCompressionType(compressionType);
                columnFamilyDescriptorBuilder.setDataBlockEncoding(encodingType);
                columnFamilyDescriptorBuilder.setBloomFilterType(bloomType);
                columnFamilyDescriptors.add(columnFamilyDescriptorBuilder.build());
                familyId++;
            }
        }
    }
    return columnFamilyDescriptors;
}
Also used : DataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding) Compression(org.apache.hadoop.hbase.io.compress.Compression) Algorithm(org.apache.hadoop.hbase.io.compress.Compression.Algorithm) BloomType(org.apache.hadoop.hbase.regionserver.BloomType) ArrayList(java.util.ArrayList) ColumnFamilyDescriptorBuilder(org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder) ColumnFamilyDescriptor(org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)

Aggregations

DataBlockEncoding (org.apache.hadoop.hbase.io.encoding.DataBlockEncoding)29 Path (org.apache.hadoop.fs.Path)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 Configuration (org.apache.hadoop.conf.Configuration)6 HFileContext (org.apache.hadoop.hbase.io.hfile.HFileContext)6 HFileContextBuilder (org.apache.hadoop.hbase.io.hfile.HFileContextBuilder)6 Compression (org.apache.hadoop.hbase.io.compress.Compression)5 Algorithm (org.apache.hadoop.hbase.io.compress.Compression.Algorithm)5 IOException (java.io.IOException)4 KeyValue (org.apache.hadoop.hbase.KeyValue)4 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)4 ColumnFamilyDescriptorBuilder (org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder)4 BloomType (org.apache.hadoop.hbase.regionserver.BloomType)4 EnumMap (java.util.EnumMap)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 Cell (org.apache.hadoop.hbase.Cell)3 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)3 CacheConfig (org.apache.hadoop.hbase.io.hfile.CacheConfig)3 ByteBuffer (java.nio.ByteBuffer)2