Java Code Examples for org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder#setCompressionType()
The following examples show how to use
org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder#setCompressionType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HBaseTestingUtility.java From hbase with Apache License 2.0 | 6 votes |
/** * 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; }
Example 2
Source File: ThriftUtilities.java From hbase with Apache License 2.0 | 4 votes |
public static ColumnFamilyDescriptor columnFamilyDescriptorFromThrift( TColumnFamilyDescriptor in) { ColumnFamilyDescriptorBuilder builder = ColumnFamilyDescriptorBuilder .newBuilder(in.getName()); if (in.isSetAttributes()) { for (Map.Entry<ByteBuffer, ByteBuffer> attribute : in.getAttributes().entrySet()) { builder.setValue(attribute.getKey().array(), attribute.getValue().array()); } } if (in.isSetConfiguration()) { for (Map.Entry<String, String> conf : in.getConfiguration().entrySet()) { builder.setConfiguration(conf.getKey(), conf.getValue()); } } if (in.isSetBlockSize()) { builder.setBlocksize(in.getBlockSize()); } if (in.isSetBloomnFilterType()) { builder.setBloomFilterType(bloomFilterFromThrift(in.getBloomnFilterType())); } if (in.isSetCompressionType()) { builder.setCompressionType(compressionAlgorithmFromThrift(in.getCompressionType())); } if (in.isSetDfsReplication()) { builder.setDFSReplication(in.getDfsReplication()); } if (in.isSetDataBlockEncoding()) { builder.setDataBlockEncoding(dataBlockEncodingFromThrift(in.getDataBlockEncoding())); } if (in.isSetKeepDeletedCells()) { builder.setKeepDeletedCells(keepDeletedCellsFromThrift(in.getKeepDeletedCells())); } if (in.isSetMaxVersions()) { builder.setMaxVersions(in.getMaxVersions()); } if (in.isSetMinVersions()) { builder.setMinVersions(in.getMinVersions()); } if (in.isSetScope()) { builder.setScope(in.getScope()); } if (in.isSetTimeToLive()) { builder.setTimeToLive(in.getTimeToLive()); } if (in.isSetBlockCacheEnabled()) { builder.setBlockCacheEnabled(in.isBlockCacheEnabled()); } if (in.isSetCacheBloomsOnWrite()) { builder.setCacheBloomsOnWrite(in.isCacheBloomsOnWrite()); } if (in.isSetCacheDataOnWrite()) { builder.setCacheDataOnWrite(in.isCacheDataOnWrite()); } if (in.isSetCacheIndexesOnWrite()) { builder.setCacheIndexesOnWrite(in.isCacheIndexesOnWrite()); } if (in.isSetCompressTags()) { builder.setCompressTags(in.isCompressTags()); } if (in.isSetEvictBlocksOnClose()) { builder.setEvictBlocksOnClose(in.isEvictBlocksOnClose()); } if (in.isSetInMemory()) { builder.setInMemory(in.isInMemory()); } return builder.build(); }
Example 3
Source File: LoadTestTool.java From hbase with Apache License 2.0 | 4 votes |
/** * Apply column family options such as Bloom filters, compression, and data * block encoding. */ protected void applyColumnFamilyOptions(TableName tableName, byte[][] columnFamilies) throws IOException { try (Connection conn = ConnectionFactory.createConnection(conf); Admin admin = conn.getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(tableName); LOG.info("Disabling table " + tableName); admin.disableTable(tableName); for (byte[] cf : columnFamilies) { ColumnFamilyDescriptor columnDesc = tableDesc.getColumnFamily(cf); boolean isNewCf = columnDesc == null; ColumnFamilyDescriptorBuilder columnDescBuilder = isNewCf ? ColumnFamilyDescriptorBuilder.newBuilder(cf) : ColumnFamilyDescriptorBuilder.newBuilder(columnDesc); if (bloomType != null) { columnDescBuilder.setBloomFilterType(bloomType); } if (compressAlgo != null) { columnDescBuilder.setCompressionType(compressAlgo); } if (dataBlockEncodingAlgo != null) { columnDescBuilder.setDataBlockEncoding(dataBlockEncodingAlgo); } if (inMemoryCF) { columnDescBuilder.setInMemory(inMemoryCF); } if (cipher != null) { byte[] keyBytes = new byte[cipher.getKeyLength()]; new SecureRandom().nextBytes(keyBytes); columnDescBuilder.setEncryptionType(cipher.getName()); columnDescBuilder.setEncryptionKey( EncryptionUtil.wrapKey(conf, User.getCurrent().getShortName(), new SecretKeySpec(keyBytes, cipher.getName()))); } if (mobThreshold >= 0) { columnDescBuilder.setMobEnabled(true); columnDescBuilder.setMobThreshold(mobThreshold); } if (isNewCf) { admin.addColumnFamily(tableName, columnDescBuilder.build()); } else { admin.modifyColumnFamily(tableName, columnDescBuilder.build()); } } LOG.info("Enabling table " + tableName); admin.enableTable(tableName); } }