use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtility method createTable.
/**
* Create a table.
* @param htd table descriptor
* @param families array of column families
* @param splitKeys array of split keys
* @param type Bloom type
* @param blockSize block size
* @param c Configuration to use
* @return A Table instance for the created table.
* @throws IOException if getAdmin or createTable fails
*/
public Table createTable(TableDescriptor htd, byte[][] families, byte[][] splitKeys, BloomType type, int blockSize, Configuration c) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(htd);
for (byte[] family : families) {
ColumnFamilyDescriptorBuilder cfdb = ColumnFamilyDescriptorBuilder.newBuilder(family).setBloomFilterType(type).setBlocksize(blockSize);
if (isNewVersionBehaviorEnabled()) {
cfdb.setNewVersionBehavior(true);
}
builder.setColumnFamily(cfdb.build());
}
TableDescriptor td = builder.build();
if (splitKeys != null) {
getAdmin().createTable(td, splitKeys);
} else {
getAdmin().createTable(td);
}
// HBaseAdmin only waits for regions to appear in hbase:meta
// we should wait until they are assigned
waitUntilAllRegionsAssigned(td.getTableName());
return getConnection().getTable(td.getTableName());
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtility method createPreSplitLoadTestTable.
/**
* Creates a pre-split table for load testing. If the table already exists,
* logs a warning and continues.
* @return the number of regions the table was split into
*/
public static int createPreSplitLoadTestTable(Configuration conf, TableName tableName, byte[][] columnFamilies, Algorithm compression, DataBlockEncoding dataBlockEncoding, int numRegionsPerServer, int regionReplication, Durability durability) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
builder.setDurability(durability);
builder.setRegionReplication(regionReplication);
ColumnFamilyDescriptor[] hcds = new ColumnFamilyDescriptor[columnFamilies.length];
for (int i = 0; i < columnFamilies.length; i++) {
ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(columnFamilies[i]);
cfBuilder.setDataBlockEncoding(dataBlockEncoding);
cfBuilder.setCompressionType(compression);
hcds[i] = cfBuilder.build();
}
return createPreSplitLoadTestTable(conf, builder.build(), hcds, numRegionsPerServer);
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtility method createTable.
/**
* Create a table.
* @return A Table instance for the created table.
*/
public Table createTable(TableName tableName, byte[][] families, int numVersions, byte[][] splitKeys) throws IOException {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
for (byte[] family : families) {
ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(family).setMaxVersions(numVersions);
if (isNewVersionBehaviorEnabled()) {
cfBuilder.setNewVersionBehavior(true);
}
builder.setColumnFamily(cfBuilder.build());
}
if (splitKeys != null) {
getAdmin().createTable(builder.build(), splitKeys);
} else {
getAdmin().createTable(builder.build());
}
// HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are
// assigned
waitUntilAllRegionsAssigned(tableName);
return getConnection().getTable(tableName);
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class HBaseTestingUtility method createTableDescriptor.
public TableDescriptor createTableDescriptor(final TableName name, final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) {
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(name);
for (byte[] cfName : new byte[][] { fam1, fam2, fam3 }) {
ColumnFamilyDescriptorBuilder cfBuilder = ColumnFamilyDescriptorBuilder.newBuilder(cfName).setMinVersions(minVersions).setMaxVersions(versions).setKeepDeletedCells(keepDeleted).setBlockCacheEnabled(false).setTimeToLive(ttl);
if (isNewVersionBehaviorEnabled()) {
cfBuilder.setNewVersionBehavior(true);
}
builder.setColumnFamily(cfBuilder.build());
}
return builder.build();
}
use of org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder in project hbase by apache.
the class TestMaxResultsPerColumnFamily method testSetMaxResultsPerColumnFamilySimple.
@Test
public void testSetMaxResultsPerColumnFamilySimple() throws Exception {
TableName tableName = TableName.valueOf(name.getMethodName());
Admin admin = UTIL.getAdmin();
ColumnFamilyDescriptorBuilder cfBuilder0 = ColumnFamilyDescriptorBuilder.newBuilder(FAMILIES[0]);
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(cfBuilder0.build()).build();
admin.createTable(tableDescriptor);
try (Table table = UTIL.getConnection().getTable(tableName)) {
for (int i = 0; i < 30000; i++) {
byte[] ROW = Bytes.toBytes("" + i);
Put p = new Put(ROW);
p.addColumn(FAMILIES[0], Bytes.toBytes("" + 1), VALUES[1]);
p.addColumn(FAMILIES[0], Bytes.toBytes("" + 2), VALUES[0]);
table.put(p);
}
}
try (Table t = UTIL.getConnection().getTable(tableName)) {
int expected = 30000;
Scan limits = new Scan().setReadType(Scan.ReadType.PREAD);
limits.setMaxResultsPerColumnFamily(1);
int count1 = countScanRows(t, limits);
assertEquals(expected, count1);
}
}
Aggregations