/** * Set minimum and maximum versions to keep * * @param minVersions minimal number of versions * @param maxVersions maximum number of versions * @return this (for chained invocation) */ public HColumnDescriptor setVersions(int minVersions, int maxVersions) { if (minVersions <= 0) { // TODO: Allow minVersion and maxVersion of 0 to be the way you say "Keep all versions". // Until there is support, consider 0 or < 0 -- a configuration error. throw new IllegalArgumentException("Minimum versions must be positive"); } if (maxVersions < minVersions) { throw new IllegalArgumentException("Unable to set MaxVersion to " + maxVersions + " and set MinVersion to " + minVersions + ", as maximum versions must be >= minimum versions."); } setMinVersions(minVersions); setMaxVersions(maxVersions); return this; }
/** * Create a table of name <code>name</code> with {@link COLUMNS} for * families. * @param name Name to give table. * @param versions How many versions to allow per column. * @return Column descriptor. */ protected HTableDescriptor createTableDescriptor(final String name, final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name)); for (byte[] cfName : new byte[][]{ fam1, fam2, fam3 }) { htd.addFamily(new HColumnDescriptor(cfName) .setMinVersions(minVersions) .setMaxVersions(versions) .setKeepDeletedCells(keepDeleted) .setBlockCacheEnabled(false) .setTimeToLive(ttl) ); } return htd; }
public HTableDescriptor createTableDescriptor(final TableName name, final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) { HTableDescriptor htd = new HTableDescriptor(name); for (byte[] cfName : new byte[][]{ fam1, fam2, fam3 }) { HColumnDescriptor hcd = new HColumnDescriptor(cfName) .setMinVersions(minVersions) .setMaxVersions(versions) .setKeepDeletedCells(keepDeleted) .setBlockCacheEnabled(false) .setTimeToLive(ttl); if (isNewVersionBehaviorEnabled()) { hcd.setNewVersionBehavior(true); } htd.addFamily(hcd); } return htd; }
/** * Set minimum and maximum versions to keep * * @param minVersions minimal number of versions * @param maxVersions maximum number of versions * @return this (for chained invocation) */ public HColumnDescriptor setVersions(int minVersions, int maxVersions) { if (minVersions <= 0) { // TODO: Allow minVersion and maxVersion of 0 to be the way you say "Keep all versions". // Until there is support, consider 0 or < 0 -- a configuration error. throw new IllegalArgumentException("Minimum versions must be positive"); } if (maxVersions < minVersions) { throw new IllegalArgumentException("Unable to set MaxVersion to " + maxVersions + " and set MinVersion to " + minVersions + ", as maximum versions must be >= minimum versions."); } setMinVersions(minVersions); setMaxVersions(maxVersions); return this; }
checkTableIsLegal(htd); hcd.setMinVersions(-1); checkTableIsIllegal(htd); hcd.setMinVersions(3); try { hcd.setMaxVersions(2); hcd.setMinVersions(5); checkTableIsIllegal(htd); hcd.setMinVersions(3);
hcd.setMaxVersions(v); assertEquals(v, hcd.getMaxVersions()); hcd.setMinVersions(v); assertEquals(v, hcd.getMinVersions()); hcd.setKeepDeletedCells(KeepDeletedCells.TRUE);
/** * Set minimum and maximum versions to keep * * @param minVersions minimal number of versions * @param maxVersions maximum number of versions * @return this (for chained invocation) */ public HColumnDescriptor setVersions(int minVersions, int maxVersions) { if (minVersions <= 0) { // TODO: Allow minVersion and maxVersion of 0 to be the way you say "Keep all versions". // Until there is support, consider 0 or < 0 -- a configuration error. throw new IllegalArgumentException("Minimum versions must be positive"); } if (maxVersions < minVersions) { throw new IllegalArgumentException("Unable to set MaxVersion to " + maxVersions + " and set MinVersion to " + minVersions + ", as maximum versions must be >= minimum versions."); } setMinVersions(minVersions); setMaxVersions(maxVersions); return this; }
/** * Set minimum and maximum versions to keep * * @param minVersions minimal number of versions * @param maxVersions maximum number of versions * @return this (for chained invocation) */ public HColumnDescriptor setVersions(int minVersions, int maxVersions) { if (minVersions <= 0) { // TODO: Allow minVersion and maxVersion of 0 to be the way you say "Keep all versions". // Until there is support, consider 0 or < 0 -- a configuration error. throw new IllegalArgumentException("Minimum versions must be positive"); } if (maxVersions < minVersions) { throw new IllegalArgumentException("Unable to set MaxVersion to " + maxVersions + " and set MinVersion to " + minVersions + ", as maximum versions must be >= minimum versions."); } setMinVersions(minVersions); setMaxVersions(maxVersions); return this; }
/** * <p>processIntersection.</p> * * @param gcRule a {@link com.google.bigtable.admin.v2.GcRule} object. * @param columnDescriptor a {@link org.apache.hadoop.hbase.HColumnDescriptor} object. */ protected static void processIntersection(GcRule gcRule, HColumnDescriptor columnDescriptor) { // minVersions and maxAge are set. List<GcRule> intersectionRules = gcRule.getIntersection().getRulesList(); Preconditions.checkArgument(intersectionRules.size() == 2, "Cannot process rule " + gcRule); columnDescriptor.setMinVersions(getVersionCount(intersectionRules)); columnDescriptor.setTimeToLive(getTtl(intersectionRules)); }
/** * <p>processIntersection.</p> * * @param gcRule a {@link com.google.bigtable.admin.v2.GcRule} object. * @param columnDescriptor a {@link org.apache.hadoop.hbase.HColumnDescriptor} object. */ protected static void processIntersection(GcRule gcRule, HColumnDescriptor columnDescriptor) { // minVersions and maxAge are set. List<GcRule> intersectionRules = gcRule.getIntersection().getRulesList(); Preconditions.checkArgument(intersectionRules.size() == 2, "Cannot process rule " + gcRule); columnDescriptor.setMinVersions(getVersionCount(intersectionRules)); columnDescriptor.setTimeToLive(getTtl(intersectionRules)); }
infoCF.setBloomFilterType(BloomType.ROWCOL); flowRunTableDescp.addFamily(infoCF); infoCF.setMinVersions(1); infoCF.setMaxVersions(DEFAULT_METRICS_MAX_VERSIONS);
public void createTable(Admin admin, Configuration hbaseConf) throws IOException { TableName table = getTableName(hbaseConf); if (admin.tableExists(table)) { // do not disable / delete existing table // similar to the approach taken by map-reduce jobs when // output directory exists throw new IOException("Table " + table.getNameAsString() + " already exists."); } HTableDescriptor flowActivityTableDescp = new HTableDescriptor(table); HColumnDescriptor infoCF = new HColumnDescriptor(FlowActivityColumnFamily.INFO.getBytes()); infoCF.setBloomFilterType(BloomType.ROWCOL); flowActivityTableDescp.addFamily(infoCF); infoCF.setMinVersions(1); infoCF.setMaxVersions(DEFAULT_METRICS_MAX_VERSIONS); // TODO: figure the split policy before running in production admin.createTable(flowActivityTableDescp); LOG.info("Status of table creation for " + table.getNameAsString() + "=" + admin.tableExists(table)); } }
metricsCF.setBlockCacheEnabled(true); metricsCF.setMinVersions(1); metricsCF.setMaxVersions( hbaseConf.getInt(METRICS_MAX_VERSIONS, DEFAULT_METRICS_MAX_VERSIONS));
metricsCF.setBlockCacheEnabled(true); metricsCF.setMinVersions(1); metricsCF.setMaxVersions( hbaseConf.getInt(METRICS_MAX_VERSIONS, DEFAULT_METRICS_MAX_VERSIONS));
metricsCF.setBlockCacheEnabled(true); metricsCF.setMinVersions(1); metricsCF.setMaxVersions( hbaseConf.getInt(METRICS_MAX_VERSIONS, DEFAULT_METRICS_MAX_VERSIONS));
/** * Create a table of name <code>name</code> with {@link COLUMNS} for * families. * @param name Name to give table. * @param versions How many versions to allow per column. * @return Column descriptor. */ protected HTableDescriptor createTableDescriptor(final String name, final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name)); for (byte[] cfName : new byte[][]{ fam1, fam2, fam3 }) { htd.addFamily(new HColumnDescriptor(cfName) .setMinVersions(minVersions) .setMaxVersions(versions) .setKeepDeletedCells(keepDeleted) .setBlockCacheEnabled(false) .setTimeToLive(ttl) ); } return htd; }
hcd.setMaxVersions(v); assertEquals(v, hcd.getMaxVersions()); hcd.setMinVersions(v); assertEquals(v, hcd.getMinVersions()); hcd.setKeepDeletedCells(KeepDeletedCells.TRUE);
public HTableDescriptor createTableDescriptor(final TableName name, final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) { HTableDescriptor htd = new HTableDescriptor(name); for (byte[] cfName : new byte[][]{ fam1, fam2, fam3 }) { HColumnDescriptor hcd = new HColumnDescriptor(cfName) .setMinVersions(minVersions) .setMaxVersions(versions) .setKeepDeletedCells(keepDeleted) .setBlockCacheEnabled(false) .setTimeToLive(ttl); if (isNewVersionBehaviorEnabled()) { hcd.setNewVersionBehavior(true); } htd.addFamily(hcd); } return htd; }
setMinVersions(minVersions); setKeepDeletedCells(keepDeletedCells); setInMemory(inMemory);
private static void createTable(HBaseGraphConfiguration config, Admin admin, String name, int ttl) throws IOException { TableName tableName = getTableName(config, name); if (admin.tableExists(tableName)) return; try { HTableDescriptor tableDescriptor = new HTableDescriptor(tableName); tableDescriptor.setDurability(config.getTableAsyncWAL() ? Durability.ASYNC_WAL : Durability.USE_DEFAULT); HColumnDescriptor columnDescriptor = new HColumnDescriptor(DEFAULT_FAMILY) .setCompressionType(Compression.Algorithm.valueOf(config.getCompressionAlgorithm().toUpperCase())) .setBloomFilterType(BloomType.ROW) .setDataBlockEncoding(DataBlockEncoding.FAST_DIFF) .setMaxVersions(1) .setMinVersions(0) .setBlocksize(32768) .setBlockCacheEnabled(true) .setTimeToLive(ttl); tableDescriptor.addFamily(columnDescriptor); int regionCount = config.getRegionCount(); if (regionCount <= 1) { admin.createTable(tableDescriptor); } else { admin.createTable(tableDescriptor, getStartKey(regionCount), getEndKey(regionCount), regionCount); } } catch (IOException e) { LOGGER.error("Could not create table " + tableName, e); throw e; } }