/** * @return a table descriptor */ @JsonIgnore public HTableDescriptor getTableDescriptor() { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(getName())); for (Map.Entry<QName, Object> e: getAny().entrySet()) { htd.setValue(e.getKey().getLocalPart(), e.getValue().toString()); } for (ColumnSchemaModel column: getColumns()) { HColumnDescriptor hcd = new HColumnDescriptor(column.getName()); for (Map.Entry<QName, Object> e: column.getAny().entrySet()) { hcd.setValue(e.getKey().getLocalPart(), e.getValue().toString()); } htd.addFamily(hcd); } return htd; }
HColumnDescriptor hcd = new HColumnDescriptor(family.getName()); for (Map.Entry<QName,Object> e: family.getAny().entrySet()) { hcd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
HColumnDescriptor hcd = new HColumnDescriptor(family.getName()); for (Map.Entry<QName,Object> e: family.getAny().entrySet()) { hcd.setValue(e.getKey().getLocalPart(), e.getValue().toString());
@Test public void testHColumnDescriptorCachedMaxVersions() throws Exception { HColumnDescriptor hcd = new HColumnDescriptor(FAMILY); hcd.setMaxVersions(5); // Verify the max version assertEquals(5, hcd.getMaxVersions()); // modify the max version hcd.setValue(Bytes.toBytes(HConstants.VERSIONS), Bytes.toBytes("8")); // Verify the max version assertEquals(8, hcd.getMaxVersions()); }
hcd.setValue("hbase.hstore.compaction.min", String.valueOf(2)); htd.modifyFamily(hcd); admin.modifyTable(tableName, htd); LOG.info("hbase.hstore.compaction.min should now be 5"); hcd = new HColumnDescriptor(htd.getFamily(FAMILY)); hcd.setValue("hbase.hstore.compaction.min", null); htd.modifyFamily(hcd); admin.modifyTable(tableName, htd);
hcdA.setValue(HStore.BLOCK_STORAGE_POLICY_KEY, "ONE_SSD"); admin.modifyColumnFamily(TABLE_NAME, hcdA); while (TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager().
c.setValue(attrName, attrValue);
/** * Sets the external properties. * * @param name * the name * @param hColumnDescriptor * the h column descriptor */ private void setExternalProperties(String name, HColumnDescriptor hColumnDescriptor) { Properties properties = externalProperties != null ? externalProperties.get(name) : null; if (properties != null && !properties.isEmpty()) { for (Object obj : properties.keySet()) { hColumnDescriptor .setValue(Bytes.toBytes(obj.toString()), Bytes.toBytes(properties.get(obj).toString())); } } }
private void modifyColumnFamilyDescriptor(HColumnDescriptor hcd, Pair<byte[],Map<String,Object>> family) throws SQLException { for (Entry<String, Object> entry : family.getSecond().entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); hcd.setValue(key, value == null ? null : value.toString()); } hcd.setKeepDeletedCells(true); }
private HColumnDescriptor generateColumnFamilyDescriptor(Pair<byte[],Map<String,Object>> family, PTableType tableType) throws SQLException { HColumnDescriptor columnDesc = new HColumnDescriptor(family.getFirst()); if (tableType != PTableType.VIEW) { columnDesc.setKeepDeletedCells(true); columnDesc.setDataBlockEncoding(SchemaUtil.DEFAULT_DATA_BLOCK_ENCODING); for (Entry<String,Object> entry : family.getSecond().entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); columnDesc.setValue(key, value == null ? null : value.toString()); } } return columnDesc; }
public static void main(String[] args) throws IOException, InterruptedException { // vv HColumnDescriptorExample HColumnDescriptor desc = new HColumnDescriptor("colfam1") .setValue("test-key", "test-value") .setBloomFilterType(BloomType.ROWCOL); System.out.println("Column Descriptor: " + desc); System.out.print("Values: "); for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> entry : desc.getValues().entrySet()) { System.out.print(Bytes.toString(entry.getKey().get()) + " -> " + Bytes.toString(entry.getValue().get()) + ", "); } System.out.println(); System.out.println("Defaults: " + HColumnDescriptor.getDefaultValues()); System.out.println("Custom: " + desc.toStringCustomizedValues()); System.out.println("Units:"); System.out.println(HColumnDescriptor.TTL + " -> " + desc.getUnit(HColumnDescriptor.TTL)); System.out.println(HColumnDescriptor.BLOCKSIZE + " -> " + desc.getUnit(HColumnDescriptor.BLOCKSIZE)); // ^^ HColumnDescriptorExample } }
final String xtracolName = "xtracol"; HColumnDescriptor xtracol = new HColumnDescriptor(xtracolName); xtracol.setValue(xtracolName, xtracolName); expectedException = false; try {
hcd.setValue(HColumnDescriptor.DFS_REPLICATION, "-1"); checkTableIsIllegal(htd); try {
columnDescriptor.setValue(Bytes.toBytes(o.toString()), Bytes.toBytes(columnProperties.get(o).toString()));
hcd.setTimeToLive(v); hcd.setBlockCacheEnabled(!HColumnDescriptor.DEFAULT_BLOCKCACHE); hcd.setValue("a", "b"); hcd.setMaxVersions(v); assertEquals(v, hcd.getMaxVersions());
/** * Compression types supported in hbase. * LZO is not bundled as part of the hbase distribution. * See <a href="http://wiki.apache.org/hadoop/UsingLzoCompression">LZO Compression</a> * for how to enable it. * @param type Compression type setting. * @return this (for chained invocation) */ public HColumnDescriptor setCompressionType(Compression.Algorithm type) { return setValue(COMPRESSION, type.getName().toUpperCase()); }
public static void setCompaction(Connection conn, TableName table, byte[] columnFamily, String key, String value) throws IOException { try(Admin admin = conn.getAdmin()) { HTableDescriptor desc = admin.getTableDescriptor(table); HColumnDescriptor cfDesc = desc.getFamily(columnFamily); cfDesc.setValue(key, value); admin.modifyColumn(table, cfDesc); } }
@Override public RegionWrapper createRegion(TableId tableId, Map<String, String> familyProperties) throws Exception { HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY); columnDesc.setMaxVersions(Integer.MAX_VALUE); for (Map.Entry<String, String> prop : familyProperties.entrySet()) { columnDesc.setValue(prop.getKey(), prop.getValue()); } return new HBase96RegionWrapper( IncrementSummingScannerTest.createRegion(TEST_HBASE.getConfiguration(), cConf, tableId, columnDesc)); }
@Test public void testHColumnDescriptorCachedMaxVersions() throws Exception { HColumnDescriptor hcd = new HColumnDescriptor(FAMILY); hcd.setMaxVersions(5); // Verify the max version assertEquals(5, hcd.getMaxVersions()); // modify the max version hcd.setValue(Bytes.toBytes(HConstants.VERSIONS), Bytes.toBytes("8")); // Verify the max version assertEquals(8, hcd.getMaxVersions()); }
hcd.setTimeToLive(v); hcd.setBlockCacheEnabled(!HColumnDescriptor.DEFAULT_BLOCKCACHE); hcd.setValue("a", "b"); hcd.setMaxVersions(v); assertEquals(v, hcd.getMaxVersions());