Java Code Examples for org.apache.hadoop.hbase.HColumnDescriptor.setBloomFilterType()

The following are Jave code examples for showing how to use setBloomFilterType() of the org.apache.hadoop.hbase.HColumnDescriptor class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ditb   File: VisibilityController.java   Source Code and License Vote up 7 votes
/********************************* Master related hooks **********************************/

  @Override
  public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
    // Need to create the new system table for labels here
    MasterServices master = ctx.getEnvironment().getMasterServices();
    if (!MetaTableAccessor.tableExists(master.getConnection(), LABELS_TABLE_NAME)) {
      HTableDescriptor labelsTable = new HTableDescriptor(LABELS_TABLE_NAME);
      HColumnDescriptor labelsColumn = new HColumnDescriptor(LABELS_TABLE_FAMILY);
      labelsColumn.setBloomFilterType(BloomType.NONE);
      labelsColumn.setBlockCacheEnabled(false); // We will cache all the labels. No need of normal
                                                 // table block cache.
      labelsTable.addFamily(labelsColumn);
      // Let the "labels" table having only one region always. We are not expecting too many labels in
      // the system.
      labelsTable.setValue(HTableDescriptor.SPLIT_POLICY,
          DisabledRegionSplitPolicy.class.getName());
      labelsTable.setValue(Bytes.toBytes(HConstants.DISALLOW_WRITES_IN_RECOVERING),
          Bytes.toBytes(true));
      master.createTable(labelsTable, null, HConstants.NO_NONCE, HConstants.NO_NONCE);
    }
  }
 
Example 2
Project: ditb   File: TestSnapshotMetadata.java   Source Code and License Vote up 5 votes
private void createTableWithNonDefaultProperties() throws Exception {
  final long startTime = System.currentTimeMillis();
  final String sourceTableNameAsString = STRING_TABLE_NAME + startTime;
  originalTableName = TableName.valueOf(sourceTableNameAsString);

  // enable replication on a column family
  HColumnDescriptor maxVersionsColumn = new HColumnDescriptor(MAX_VERSIONS_FAM);
  HColumnDescriptor bloomFilterColumn = new HColumnDescriptor(BLOOMFILTER_FAM);
  HColumnDescriptor dataBlockColumn = new HColumnDescriptor(COMPRESSED_FAM);
  HColumnDescriptor blockSizeColumn = new HColumnDescriptor(BLOCKSIZE_FAM);

  maxVersionsColumn.setMaxVersions(MAX_VERSIONS);
  bloomFilterColumn.setBloomFilterType(BLOOM_TYPE);
  dataBlockColumn.setDataBlockEncoding(DATA_BLOCK_ENCODING_TYPE);
  blockSizeColumn.setBlocksize(BLOCK_SIZE);

  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(sourceTableNameAsString));
  htd.addFamily(maxVersionsColumn);
  htd.addFamily(bloomFilterColumn);
  htd.addFamily(dataBlockColumn);
  htd.addFamily(blockSizeColumn);
  htd.setValue(TEST_CUSTOM_VALUE, TEST_CUSTOM_VALUE);
  htd.setConfiguration(TEST_CONF_CUSTOM_VALUE, TEST_CONF_CUSTOM_VALUE);
  assertTrue(htd.getConfiguration().size() > 0);

  admin.createTable(htd);
  Table original = new HTable(UTIL.getConfiguration(), originalTableName);
  originalTableName = TableName.valueOf(sourceTableNameAsString);
  originalTableDescriptor = admin.getTableDescriptor(originalTableName);
  originalTableDescription = originalTableDescriptor.toStringCustomizedValues();

  original.close();
}
 
Example 3
Project: ditb   File: TestLoadIncrementalHFiles.java   Source Code and License Vote up 5 votes
private HTableDescriptor buildHTD(TableName tableName, BloomType bloomType) {
  HTableDescriptor htd = new HTableDescriptor(tableName);
  HColumnDescriptor familyDesc = new HColumnDescriptor(FAMILY);
  familyDesc.setBloomFilterType(bloomType);
  htd.addFamily(familyDesc);
  return htd;
}
 
Example 4
Project: ditb   File: TestCacheOnWriteInSchema.java   Source Code and License Vote up 5 votes
@Before
public void setUp() throws IOException {
  // parameterized tests add [#] suffix get rid of [ and ].
  table = Bytes.toBytes(name.getMethodName().replaceAll("[\\[\\]]", "_"));

  conf = TEST_UTIL.getConfiguration();
  conf.setInt(HFile.FORMAT_VERSION_KEY, HFile.MAX_FORMAT_VERSION);
  conf.setBoolean(CacheConfig.CACHE_BLOCKS_ON_WRITE_KEY, false);
  conf.setBoolean(CacheConfig.CACHE_INDEX_BLOCKS_ON_WRITE_KEY, false);
  conf.setBoolean(CacheConfig.CACHE_BLOOM_BLOCKS_ON_WRITE_KEY, false);

  fs = HFileSystem.get(conf);

  // Create the schema
  HColumnDescriptor hcd = new HColumnDescriptor(family);
  hcd.setBloomFilterType(BloomType.ROWCOL);
  cowType.modifyFamilySchema(hcd);
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(table));
  htd.addFamily(hcd);

  // Create a store based on the schema
  final String id = TestCacheOnWriteInSchema.class.getName();
  final Path logdir = new Path(FSUtils.getRootDir(conf),
      DefaultWALProvider.getWALDirectoryName(id));
  fs.delete(logdir, true);

  HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
  walFactory = new WALFactory(conf, null, id);

  region = TEST_UTIL.createLocalHRegion(info, htd,
      walFactory.getWAL(info.getEncodedNameAsBytes()));
  store = new HStore(region, hcd, conf);
}
 
Example 5
Project: ditb   File: ChangeBloomFilterAction.java   Source Code and License Vote up 5 votes
@Override
public void perform() throws Exception {
  Random random = new Random();
  HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
  Admin admin = util.getHBaseAdmin();

  LOG.info("Performing action: Change bloom filter on all columns of table "
      + tableName);
  HTableDescriptor tableDescriptor = admin.getTableDescriptor(tableName);
  HColumnDescriptor[] columnDescriptors = tableDescriptor.getColumnFamilies();

  if (columnDescriptors == null || columnDescriptors.length == 0) {
    return;
  }

  final BloomType[] bloomArray = BloomType.values();
  final int bloomArraySize = bloomArray.length;

  for (HColumnDescriptor descriptor : columnDescriptors) {
    int bloomFilterIndex = random.nextInt(bloomArraySize);
    LOG.debug("Performing action: About to set bloom filter type to "
        + bloomArray[bloomFilterIndex] + " on column "
        + descriptor.getNameAsString() + " of table " + tableName);
    descriptor.setBloomFilterType(bloomArray[bloomFilterIndex]);
    LOG.debug("Performing action: Just set bloom filter type to "
        + bloomArray[bloomFilterIndex] + " on column "
        + descriptor.getNameAsString() + " of table " + tableName);
  }

  // Don't try the modify if we're stopping
  if (context.isStopping()) {
    return;
  }
  admin.modifyTable(tableName, tableDescriptor);
}