Java Code Examples for org.apache.hadoop.hbase.HColumnDescriptor#setInMemory()
The following examples show how to use
org.apache.hadoop.hbase.HColumnDescriptor#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: BasicHadoopTest.java From Kylin with Apache License 2.0 | 6 votes |
@Test public void testCreateHtable() throws IOException { HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf("testhbase")); tableDesc.setValue("KYLIN_HOST", "dev01"); HColumnDescriptor cf = new HColumnDescriptor("f"); cf.setMaxVersions(1); cf.setInMemory(true); cf.setBlocksize(4 * 1024 * 1024); // set to 4MB tableDesc.addFamily(cf); Configuration conf = HBaseConfiguration.create(); HBaseAdmin admin = new HBaseAdmin(conf); admin.createTable(tableDesc); admin.close(); }
Example 2
Source File: HBaseConnection.java From Kylin with Apache License 2.0 | 5 votes |
public static void createHTableIfNeeded(HConnection conn, String tableName, String... families) throws IOException { HBaseAdmin hbase = new HBaseAdmin(conn); try { boolean tableExist = false; try { hbase.getTableDescriptor(TableName.valueOf(tableName)); tableExist = true; } catch (TableNotFoundException e) { } if (tableExist) { logger.debug("HTable '" + tableName + "' already exists"); return; } logger.debug("Creating HTable '" + tableName + "'"); HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); if (null != families && families.length > 0) { for (String family : families) { HColumnDescriptor fd = new HColumnDescriptor(family); fd.setInMemory(true); // metadata tables are best in memory desc.addFamily(fd); } } hbase.createTable(desc); logger.debug("HTable '" + tableName + "' created"); } finally { hbase.close(); } }
Example 3
Source File: Create3.java From examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws MasterNotRunningException, ZooKeeperConnectionException, IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin admin = new HBaseAdmin(conf); // tag::CREATE3[] HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("crc")); desc.setMaxFileSize((long)20*1024*1024*1024); desc.setConfiguration("hbase.hstore.compaction.min", "5"); HColumnDescriptor family = new HColumnDescriptor("c"); family.setInMemory(true); desc.addFamily(family); UniformSplit uniformSplit = new UniformSplit(); admin.createTable(desc, uniformSplit.split(64)); // end::CREATE3[] admin.close(); }
Example 4
Source File: HBaseSITestEnv.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private static HTableDescriptor generateTransactionTable() throws IOException{ HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("splice",HConfiguration.TRANSACTION_TABLE)); desc.addCoprocessor(TxnLifecycleEndpoint.class.getName()); HColumnDescriptor columnDescriptor = new HColumnDescriptor(SIConstants.DEFAULT_FAMILY_BYTES); columnDescriptor.setMaxVersions(5); columnDescriptor.setCompressionType(Compression.Algorithm.NONE); columnDescriptor.setInMemory(true); columnDescriptor.setBlockCacheEnabled(true); columnDescriptor.setBloomFilterType(BloomType.ROWCOL); desc.addFamily(columnDescriptor); desc.addFamily(new HColumnDescriptor(Bytes.toBytes(SIConstants.SI_PERMISSION_FAMILY))); return desc; }
Example 5
Source File: HBaseSITestEnv.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public static HColumnDescriptor createDataFamily() { HColumnDescriptor snapshot = new HColumnDescriptor(SIConstants.DEFAULT_FAMILY_BYTES); snapshot.setMaxVersions(Integer.MAX_VALUE); snapshot.setCompressionType(Compression.Algorithm.NONE); snapshot.setInMemory(true); snapshot.setBlockCacheEnabled(true); snapshot.setBloomFilterType(BloomType.ROW); return snapshot; }
Example 6
Source File: CubeHTableUtil.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public static HColumnDescriptor createColumnFamily(KylinConfig kylinConfig, String cfName, boolean isMemoryHungry) { HColumnDescriptor cf = new HColumnDescriptor(cfName); cf.setMaxVersions(1); if (isMemoryHungry) { cf.setBlocksize(kylinConfig.getHbaseDefaultBlockSize()); } else { cf.setBlocksize(kylinConfig.getHbaseSmallFamilyBlockSize()); } String hbaseDefaultCC = kylinConfig.getHbaseDefaultCompressionCodec().toLowerCase(Locale.ROOT); switch (hbaseDefaultCC) { case "snappy": { logger.info("hbase will use snappy to compress data"); cf.setCompressionType(Algorithm.SNAPPY); break; } case "lzo": { logger.info("hbase will use lzo to compress data"); cf.setCompressionType(Algorithm.LZO); break; } case "gz": case "gzip": { logger.info("hbase will use gzip to compress data"); cf.setCompressionType(Algorithm.GZ); break; } case "lz4": { logger.info("hbase will use lz4 to compress data"); cf.setCompressionType(Algorithm.LZ4); break; } case "none": default: { logger.info("hbase will not use any compression algorithm to compress data"); cf.setCompressionType(Algorithm.NONE); } } try { String encodingStr = kylinConfig.getHbaseDefaultEncoding(); DataBlockEncoding encoding = DataBlockEncoding.valueOf(encodingStr); cf.setDataBlockEncoding(encoding); } catch (Exception e) { logger.info("hbase will not use any encoding", e); cf.setDataBlockEncoding(DataBlockEncoding.NONE); } cf.setInMemory(false); cf.setBloomFilterType(BloomType.NONE); cf.setScope(kylinConfig.getHBaseReplicationScope()); return cf; }
Example 7
Source File: HBaseConnection.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private static HColumnDescriptor newFamilyDescriptor(String family) { HColumnDescriptor fd = new HColumnDescriptor(family); fd.setInMemory(true); // metadata tables are best in memory return fd; }
Example 8
Source File: CubeHTableUtil.java From kylin with Apache License 2.0 | 4 votes |
public static HColumnDescriptor createColumnFamily(KylinConfig kylinConfig, String cfName, boolean isMemoryHungry) { HColumnDescriptor cf = new HColumnDescriptor(cfName); cf.setMaxVersions(1); if (isMemoryHungry) { cf.setBlocksize(kylinConfig.getHbaseDefaultBlockSize()); } else { cf.setBlocksize(kylinConfig.getHbaseSmallFamilyBlockSize()); } String hbaseDefaultCC = kylinConfig.getHbaseDefaultCompressionCodec().toLowerCase(Locale.ROOT); switch (hbaseDefaultCC) { case "snappy": { logger.info("hbase will use snappy to compress data"); cf.setCompressionType(Algorithm.SNAPPY); break; } case "lzo": { logger.info("hbase will use lzo to compress data"); cf.setCompressionType(Algorithm.LZO); break; } case "gz": case "gzip": { logger.info("hbase will use gzip to compress data"); cf.setCompressionType(Algorithm.GZ); break; } case "lz4": { logger.info("hbase will use lz4 to compress data"); cf.setCompressionType(Algorithm.LZ4); break; } case "none": default: { logger.info("hbase will not use any compression algorithm to compress data"); cf.setCompressionType(Algorithm.NONE); } } try { String encodingStr = kylinConfig.getHbaseDefaultEncoding(); DataBlockEncoding encoding = DataBlockEncoding.valueOf(encodingStr); cf.setDataBlockEncoding(encoding); } catch (Exception e) { logger.info("hbase will not use any encoding", e); cf.setDataBlockEncoding(DataBlockEncoding.NONE); } cf.setInMemory(false); cf.setBloomFilterType(BloomType.NONE); cf.setScope(kylinConfig.getHBaseReplicationScope()); return cf; }
Example 9
Source File: HBaseConnection.java From kylin with Apache License 2.0 | 4 votes |
private static HColumnDescriptor newFamilyDescriptor(String family) { HColumnDescriptor fd = new HColumnDescriptor(family); fd.setInMemory(true); // metadata tables are best in memory return fd; }
Example 10
Source File: CreateHTableJob.java From Kylin with Apache License 2.0 | 4 votes |
@Override public int run(String[] args) throws Exception { Options options = new Options(); options.addOption(OPTION_CUBE_NAME); options.addOption(OPTION_PARTITION_FILE_PATH); options.addOption(OPTION_HTABLE_NAME); parseOptions(options, args); Path partitionFilePath = new Path(getOptionValue(OPTION_PARTITION_FILE_PATH)); String cubeName = getOptionValue(OPTION_CUBE_NAME).toUpperCase(); KylinConfig config = KylinConfig.getInstanceFromEnv(); CubeManager cubeMgr = CubeManager.getInstance(config); CubeInstance cube = cubeMgr.getCube(cubeName); CubeDesc cubeDesc = cube.getDescriptor(); String tableName = getOptionValue(OPTION_HTABLE_NAME).toUpperCase(); HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(tableName)); // https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/regionserver/ConstantSizeRegionSplitPolicy.html tableDesc.setValue(HTableDescriptor.SPLIT_POLICY, ConstantSizeRegionSplitPolicy.class.getName()); tableDesc.setValue(IRealizationConstants.HTableTag, config.getMetadataUrlPrefix()); Configuration conf = HBaseConfiguration.create(getConf()); HBaseAdmin admin = new HBaseAdmin(conf); try { if (User.isHBaseSecurityEnabled(conf)) { // add coprocessor for bulk load tableDesc.addCoprocessor("org.apache.hadoop.hbase.security.access.SecureBulkLoadEndpoint"); } for (HBaseColumnFamilyDesc cfDesc : cubeDesc.getHBaseMapping().getColumnFamily()) { HColumnDescriptor cf = new HColumnDescriptor(cfDesc.getName()); cf.setMaxVersions(1); if (LZOSupportnessChecker.getSupportness()) { logger.info("hbase will use lzo to compress data"); cf.setCompressionType(Algorithm.LZO); } else { logger.info("hbase will not use lzo to compress data"); } cf.setDataBlockEncoding(DataBlockEncoding.FAST_DIFF); cf.setInMemory(false); cf.setBlocksize(4 * 1024 * 1024); // set to 4MB tableDesc.addFamily(cf); } byte[][] splitKeys = getSplits(conf, partitionFilePath); if (admin.tableExists(tableName)) { // admin.disableTable(tableName); // admin.deleteTable(tableName); throw new RuntimeException("HBase table " + tableName + " exists!"); } DeployCoprocessorCLI.deployCoprocessor(tableDesc); admin.createTable(tableDesc, splitKeys); logger.info("create hbase table " + tableName + " done."); return 0; } catch (Exception e) { printUsage(options); e.printStackTrace(System.err); logger.error(e.getLocalizedMessage(), e); return 2; } finally { admin.close(); } }
Example 11
Source File: TableCommand.java From pinpoint with Apache License 2.0 | 4 votes |
private HColumnDescriptor newColumnDescriptor(ColumnFamilyChange columnFamilyChange) { HColumnDescriptor hcd = new HColumnDescriptor(columnFamilyChange.getName()); ColumnFamilyConfiguration columnFamilyConfiguration = columnFamilyChange.getColumnFamilyConfiguration(); Boolean blockCacheEnabled = columnFamilyConfiguration.getBlockCacheEnabled(); if (blockCacheEnabled != null) { hcd.setBlockCacheEnabled(blockCacheEnabled); } Integer replicationScope = columnFamilyConfiguration.getReplicationScope(); if (replicationScope != null) { hcd.setScope(replicationScope); } Boolean inMemory = columnFamilyConfiguration.getInMemory(); if (inMemory != null) { hcd.setInMemory(inMemory); } Integer timeToLive = columnFamilyConfiguration.getTimeToLive(); if (timeToLive != null) { hcd.setTimeToLive(timeToLive); } ColumnFamilyConfiguration.DataBlockEncoding dataBlockEncoding = columnFamilyConfiguration.getDataBlockEncoding(); if (dataBlockEncoding != null) { hcd.setDataBlockEncoding(DataBlockEncoding.valueOf(dataBlockEncoding.name())); } Integer blockSize = columnFamilyConfiguration.getBlockSize(); if (blockSize != null) { hcd.setBlocksize(blockSize); } Integer maxVersions = columnFamilyConfiguration.getMaxVersions(); if (maxVersions != null) { hcd.setMaxVersions(maxVersions); } Integer minVersions = columnFamilyConfiguration.getMinVersions(); if (minVersions != null) { hcd.setMinVersions(minVersions); } ColumnFamilyConfiguration.BloomFilter bloomFilter = columnFamilyConfiguration.getBloomFilter(); if (bloomFilter != null) { hcd.setBloomFilterType(BloomType.valueOf(bloomFilter.name())); } if (compressionAlgorithm != Compression.Algorithm.NONE) { hcd.setCompressionType(compressionAlgorithm); } return hcd; }