/** * Returns a list of all the column families for a given Table. * * @param table table * @throws IOException */ byte[][] getAllColumns(Table table) throws IOException { HColumnDescriptor[] cds = table.getTableDescriptor().getColumnFamilies(); byte[][] columns = new byte[cds.length][]; for (int i = 0; i < cds.length; i++) { columns[i] = Bytes.add(cds[i].getName(), KeyValue.COLUMN_FAMILY_DELIM_ARRAY); } return columns; }
Cell cell = result.getColumnLatestCell(hcd1.getName(), Bytes.toBytes(qf1)); assertEquals("Before compaction: mob value of k0", newValue0, Bytes.toString(CellUtil.cloneValue(cell))); admin.majorCompact(tableName, hcd1.getName(), CompactType.MOB); waitUntilMobCompactionFinished(tableName); cell = result.getColumnLatestCell(hcd1.getName(), Bytes.toBytes(qf1)); assertEquals("After compaction: mob value of k0", newValue0, Bytes.toString(CellUtil.cloneValue(cell))); get.setAttribute(MobConstants.MOB_SCAN_RAW, Bytes.toBytes(true)); result = table.get(get); cell = result.getColumnLatestCell(hcd1.getName(), Bytes.toBytes(qf1));
hcd.setValue(e.getKey().getLocalPart(), e.getValue().toString()); if (htd.hasFamily(hcd.getName())) { admin.modifyColumnFamily(name, hcd); } else {
long seqid = region.getOpenSeqNum(); for (HColumnDescriptor hcd: htd.getFamilies()) { addRegionEdits(rowName, hcd.getName(), countPerFamily, this.ee, region, "x");
/** * This utility method creates a new Thrift ColumnDescriptor "struct" based on * an Hbase HColumnDescriptor object. * * @param in * Hbase HColumnDescriptor object * @return Thrift ColumnDescriptor */ static public ColumnDescriptor colDescFromHbase(HColumnDescriptor in) { ColumnDescriptor col = new ColumnDescriptor(); col.name = ByteBuffer.wrap(Bytes.add(in.getName(), KeyValue.COLUMN_FAMILY_DELIM_ARRAY)); col.maxVersions = in.getMaxVersions(); col.compression = in.getCompressionType().toString(); col.inMemory = in.isInMemory(); col.blockCacheEnabled = in.isBlockCacheEnabled(); col.bloomFilterType = in.getBloomFilterType().toString(); col.timeToLive = in.getTimeToLive(); return col; }
/** * Create the mob store file */ private Path createMobStoreFile(HColumnDescriptor hcd) throws IOException { // Setting up a Store TableName tn = TableName.valueOf(TABLE); HTableDescriptor htd = new HTableDescriptor(tn); htd.addFamily(hcd); HMobStore mobStore = (HMobStore) region.getStore(hcd.getName()); KeyValue key1 = new KeyValue(ROW, hcd.getName(), QF1, 1, VALUE); KeyValue key2 = new KeyValue(ROW, hcd.getName(), QF2, 1, VALUE); KeyValue key3 = new KeyValue(ROW2, hcd.getName(), QF3, 1, VALUE2); KeyValue[] keys = new KeyValue[] { key1, key2, key3 }; int maxKeyCount = keys.length; HRegionInfo regionInfo = new HRegionInfo(tn); StoreFileWriter mobWriter = mobStore.createWriterInTmp(currentDate, maxKeyCount, hcd.getCompactionCompression(), regionInfo.getStartKey(), false); Path mobFilePath = mobWriter.getPath(); String fileName = mobFilePath.getName(); mobWriter.append(key1); mobWriter.append(key2); mobWriter.append(key3); mobWriter.close(); String targetPathName = MobUtils.formatDate(currentDate); Path targetPath = new Path(mobStore.getPath(), targetPathName); mobStore.commitFile(mobFilePath, targetPath); return new Path(targetPath, fileName); }
@BeforeClass public static void setUp() throws Exception { conf.setInt("hfile.format.version", 3); conf.set(HConstants.CRYPTO_KEYPROVIDER_CONF_KEY, KeyProviderForTesting.class.getName()); conf.set(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY, "hbase"); // Create the table schema // Specify an encryption algorithm without a key htd = new HTableDescriptor(TableName.valueOf("default", "TestEncryptionRandomKeying")); HColumnDescriptor hcd = new HColumnDescriptor("cf"); String algorithm = conf.get(HConstants.CRYPTO_KEY_ALGORITHM_CONF_KEY, HConstants.CIPHER_AES); hcd.setEncryptionType(algorithm); htd.addFamily(hcd); // Start the minicluster TEST_UTIL.startMiniCluster(1); // Create the test table TEST_UTIL.getAdmin().createTable(htd); TEST_UTIL.waitTableAvailable(htd.getTableName(), 5000); // Create a store file Table table = TEST_UTIL.getConnection().getTable(htd.getTableName()); try { table.put(new Put(Bytes.toBytes("testrow")) .addColumn(hcd.getName(), Bytes.toBytes("q"), Bytes.toBytes("value"))); } finally { table.close(); } TEST_UTIL.getAdmin().flush(htd.getTableName()); }
private void createTableAndFlush(HTableDescriptor htd) throws Exception { HColumnDescriptor hcd = htd.getFamilies().iterator().next(); // Create the test table TEST_UTIL.getAdmin().createTable(htd); TEST_UTIL.waitTableAvailable(htd.getTableName(), 5000); // Create a store file Table table = TEST_UTIL.getConnection().getTable(htd.getTableName()); try { table.put(new Put(Bytes.toBytes("testrow")) .addColumn(hcd.getName(), Bytes.toBytes("q"), Bytes.toBytes("value"))); } finally { table.close(); } TEST_UTIL.getAdmin().flush(htd.getTableName()); }
if (htd.hasFamily(hcd.getName())) { htd.modifyFamily(hcd); } else {
@Test public void disableNotFullReplication() throws Exception { HTableDescriptor table = new HTableDescriptor(admin2.getTableDescriptor(tableName)); HColumnDescriptor f = new HColumnDescriptor("notReplicatedFamily"); table.addFamily(f); admin1.disableTable(tableName); admin1.modifyTable(tableName, table); admin1.enableTable(tableName); admin1.disableTableReplication(tableName); table = admin1.getTableDescriptor(tableName); for (HColumnDescriptor fam : table.getColumnFamilies()) { assertEquals(HConstants.REPLICATION_SCOPE_LOCAL, fam.getScope()); } admin1.deleteColumnFamily(table.getTableName(), f.getName()); }
if (htd.hasFamily(hcd.getName())) { htd.modifyFamily(hcd); } else {
final byte[] family = htd.getColumnFamilies()[0].getName(); final byte[] rowName = tableName.getName(); FSWALEntry entry1 = createFSWALEntry(htd, hri, 1L, rowName, family, ee, mvcc, 1, scopes);
@Test public void testEnableReplicationWhenTableDescriptorIsNotSameInClusters() throws Exception { HTableDescriptor table = new HTableDescriptor(admin2.getTableDescriptor(tableName)); HColumnDescriptor f = new HColumnDescriptor("newFamily"); table.addFamily(f); admin2.disableTable(tableName); admin2.modifyTable(tableName, table); admin2.enableTable(tableName); try { admin1.enableTableReplication(tableName); fail("Exception should be thrown if table descriptors in the clusters are not same."); } catch (RuntimeException ignored) { } admin1.disableTable(tableName); admin1.modifyTable(tableName, table); admin1.enableTable(tableName); admin1.enableTableReplication(tableName); table = admin1.getTableDescriptor(tableName); for (HColumnDescriptor fam : table.getColumnFamilies()) { assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope()); } admin1.deleteColumnFamily(tableName, f.getName()); admin2.deleteColumnFamily(tableName, f.getName()); }
HRegion region = HRegion.openHRegion(hri, htd, wal, this.conf); byte [] family = htd.getFamilies().iterator().next().getName(); Path f = new Path(basedir, "hfile"); HFileTestUtil.createHFile(this.conf, fs, f, family, family, Bytes.toBytes(""),
byte [] family = htd.getFamilies().iterator().next().getName(); region.put((new Put(row)).addColumn(family, family, family)); wal.sync();
admin.majorCompact(tableName, hcd1.getName(), CompactType.MOB);
final int newMaxVersions = maxversions + 1; hcd.setMaxVersions(newMaxVersions); final byte [] hcdName = hcd.getName(); expectedException = false; try { hcd = modifiedHtd.getFamily(xtracol.getName()); assertTrue(hcd != null); assertTrue(hcd.getValue(xtracolName).equals(xtracolName)); this.admin.deleteColumnFamily(tableName, xtracol.getName()); modifiedHtd = this.admin.getTableDescriptor(tableName); hcd = modifiedHtd.getFamily(xtracol.getName()); assertTrue(hcd == null);