Java Code Examples for org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder#setInMemory()

The following examples show how to use org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder#setInMemory() . 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: ThriftUtilities.java    From hbase with Apache License 2.0 4 votes vote down vote up
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 2
Source File: LoadTestTool.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
  }
}