本文整理了Java中org.apache.hadoop.hbase.client.Table.incrementColumnValue()
方法的一些代码示例,展示了Table.incrementColumnValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.incrementColumnValue()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Table
类名称:Table
方法名:incrementColumnValue
[英]See #incrementColumnValue(byte[],byte[],byte[],long,Durability)
The Durability is defaulted to Durability#SYNC_WAL.
[中]参见#incrementColumnValue(字节[],字节[],字节[],长,耐久性)
耐久性默认为耐久性#SYNC_WAL。
代码示例来源:origin: apache/hbase
protected long atomicIncrement(ByteBuffer tableName, ByteBuffer row,
byte [] family, byte [] qualifier, long amount)
throws IOError, IllegalArgument, TException {
Table table = null;
try {
table = getTable(tableName);
return table.incrementColumnValue(
getBytes(row), family, qualifier, amount);
} catch (IOException e) {
LOG.warn(e.getMessage(), e);
throw getIOError(e);
} finally {
closeTable(table);
}
}
代码示例来源:origin: apache/hbase
throw new IOException("Auto-Fail rest of ICVs");
table.incrementColumnValue(row.getRowKey(), row.getFamily(), row.getQualifier(),
counter);
} catch (IOException e) {
代码示例来源:origin: apache/hbase
@Test
public void testIncrementWithDeletes() throws Exception {
LOG.info("Starting " + this.name.getMethodName());
final TableName TABLENAME =
TableName.valueOf(filterStringSoTableNameSafe(this.name.getMethodName()));
Table ht = TEST_UTIL.createTable(TABLENAME, FAMILY);
final byte[] COLUMN = Bytes.toBytes("column");
ht.incrementColumnValue(ROW, FAMILY, COLUMN, 5);
TEST_UTIL.flush(TABLENAME);
Delete del = new Delete(ROW);
ht.delete(del);
ht.incrementColumnValue(ROW, FAMILY, COLUMN, 5);
Get get = new Get(ROW);
Result r = ht.get(get);
assertEquals(1, r.size());
assertEquals(5, Bytes.toLong(r.getValue(FAMILY, COLUMN)));
}
代码示例来源:origin: apache/phoenix
@Override
public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount,
Durability durability) throws IOException {
return delegate.incrementColumnValue(row, family, qualifier, amount, durability);
}
代码示例来源:origin: apache/phoenix
@Override
public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount)
throws IOException {
return delegate.incrementColumnValue(row, family, qualifier, amount);
}
代码示例来源:origin: apache/hbase
@Test
public void testIncrementingInvalidValue() throws Exception {
LOG.info("Starting " + this.name.getMethodName());
final TableName TABLENAME =
TableName.valueOf(filterStringSoTableNameSafe(this.name.getMethodName()));
Table ht = TEST_UTIL.createTable(TABLENAME, FAMILY);
final byte[] COLUMN = Bytes.toBytes("column");
Put p = new Put(ROW);
// write an integer here (not a Long)
p.addColumn(FAMILY, COLUMN, Bytes.toBytes(5));
ht.put(p);
try {
ht.incrementColumnValue(ROW, FAMILY, COLUMN, 5);
fail("Should have thrown DoNotRetryIOException");
} catch (DoNotRetryIOException iox) {
// success
}
Increment inc = new Increment(ROW);
inc.addColumn(FAMILY, COLUMN, 5);
try {
ht.increment(inc);
fail("Should have thrown DoNotRetryIOException");
} catch (DoNotRetryIOException iox) {
// success
}
}
代码示例来源:origin: apache/hbase
try {
try( Table table = TEST_UTIL.getConnection().getTable(tableName)) {
table.incrementColumnValue(ROW1, FAM, FAM, 1);
代码示例来源:origin: apache/hbase
ht.incrementColumnValue(ROW, FAMILY, QUALIFIERS[0], 1);
ht.incrementColumnValue(ROW, FAMILY, QUALIFIERS[1], 2);
ht.incrementColumnValue(ROW, FAMILY, QUALIFIERS[2], 3);
ht.incrementColumnValue(ROW, FAMILY, QUALIFIERS[3], 4);
代码示例来源:origin: apache/hbase
try {
ht.incrementColumnValue(null, FAMILY, COLUMN, 5);
fail("Should have thrown IOException");
} catch (IOException iox) {
ht.incrementColumnValue(ROW, null, COLUMN, 5);
fail("Should have thrown IOException");
} catch (IOException iox) {
代码示例来源:origin: apache/hbase
t -> t.put(new Put(Bytes.toBytes("row")).addColumn(CF, CQ, Bytes.toBytes("row"))));
assertDisallow(table, t -> t.delete(new Delete(Bytes.toBytes("row"))));
assertDisallow(table, t -> t.incrementColumnValue(Bytes.toBytes("row"), CF, CQ, 1));
assertDisallow(table,
t -> t.append(new Append(Bytes.toBytes("row")).addColumn(CF, CQ, Bytes.toBytes("row"))));
代码示例来源:origin: apache/hbase
@Override
public Void run() throws Exception {
try (Connection connection = ConnectionFactory.createConnection(conf)) {
try (Table t = connection.getTable(TEST_TABLE.getTableName())) {
Increment inc = new Increment(TEST_ROW1);
inc.setTimeRange(0, 123);
inc.addColumn(TEST_FAMILY1, TEST_Q1, 2L);
t.increment(inc);
t.incrementColumnValue(TEST_ROW1, TEST_FAMILY1, TEST_Q2, 1L);
}
}
return null;
}
});
代码示例来源:origin: apache/hbase
@Test
public void testLabelsWithIncrement() throws Throwable {
TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
try (Table table = TEST_UTIL.createTable(tableName, fam)) {
byte[] row1 = Bytes.toBytes("row1");
byte[] val = Bytes.toBytes(1L);
Put put = new Put(row1);
put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, val);
put.setCellVisibility(new CellVisibility(SECRET + " & " + CONFIDENTIAL));
table.put(put);
Get get = new Get(row1);
get.setAuthorizations(new Authorizations(SECRET));
Result result = table.get(get);
assertTrue(result.isEmpty());
table.incrementColumnValue(row1, fam, qual, 2L);
result = table.get(get);
assertTrue(result.isEmpty());
Increment increment = new Increment(row1);
increment.addColumn(fam, qual, 2L);
increment.setCellVisibility(new CellVisibility(SECRET));
table.increment(increment);
result = table.get(get);
assertTrue(!result.isEmpty());
}
}
代码示例来源:origin: apache/hbase
getTestNull(table, ROW, FAMILY, 1L);
table.incrementColumnValue(ROW, FAMILY, null, 1L);
getTestNull(table, ROW, FAMILY, 2L);
代码示例来源:origin: hugegraph/hugegraph
/**
* Increase a counter by rowkey and qualifier to a table
*/
public long increase(String table, byte[] family, byte[] rowkey,
byte[] qualifier, long value) {
try (Table htable = table(table)) {
return htable.incrementColumnValue(rowkey, family,
qualifier, value);
} catch (IOException e) {
throw new BackendException(e);
}
}
代码示例来源:origin: larsgeorge/hbase-book
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "daily");
Connection connection = ConnectionFactory.createConnection(conf);
Table table = connection.getTable(TableName.valueOf("testtable"));
// vv IncrementSingleExample
long cnt1 = table.incrementColumnValue(Bytes.toBytes("20110101"), // co IncrementSingleExample-1-Incr1 Increase counter by one.
Bytes.toBytes("daily"), Bytes.toBytes("hits"), 1);
long cnt2 = table.incrementColumnValue(Bytes.toBytes("20110101"), // co IncrementSingleExample-2-Incr2 Increase counter by one a second time.
Bytes.toBytes("daily"), Bytes.toBytes("hits"), 1);
long current = table.incrementColumnValue(Bytes.toBytes("20110101"), // co IncrementSingleExample-3-GetCurrent Get current value of the counter without increasing it.
Bytes.toBytes("daily"), Bytes.toBytes("hits"), 0);
long cnt3 = table.incrementColumnValue(Bytes.toBytes("20110101"), // co IncrementSingleExample-4-Decr1 Decrease counter by one.
Bytes.toBytes("daily"), Bytes.toBytes("hits"), -1);
// ^^ IncrementSingleExample
System.out.println("cnt1: " + cnt1 + ", cnt2: " + cnt2 +
", current: " + current + ", cnt3: " + cnt3);
}
}
代码示例来源:origin: larsgeorge/hbase-book
table.incrementColumnValue(Bytes.toBytes("row10"),
Bytes.toBytes("colfam1"), Bytes.toBytes("qual12"), 1);
printStatistics(true, true);
代码示例来源:origin: Impetus/Kundera
@Override
public Object generate(TableGeneratorDiscriptor discriptor, ClientBase client, String dataType)
{
String tableName = HBaseUtils.getHTableName(discriptor.getSchema(), discriptor.getPkColumnValue());
try
{
Table hTable = ((HBaseDataHandler) ((HBaseClient) client).handler).gethTable(tableName);
Long latestCount = hTable.incrementColumnValue(HBaseUtils.AUTO_ID_ROW.getBytes(), discriptor
.getPkColumnValue().getBytes(), discriptor.getValueColumnName().getBytes(), 1);
if (latestCount == 1)
{
return (long) discriptor.getInitialValue();
}
else if (discriptor.getAllocationSize() == 1)
{
return latestCount + discriptor.getInitialValue();
}
else
{
return (latestCount - 1) * discriptor.getAllocationSize() + discriptor.getInitialValue();
}
}
catch (IOException ioex)
{
log.error("Error while generating id for entity, Caused by: .", ioex);
throw new KunderaException(ioex);
}
}
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
@Override
public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount)
throws IOException {
return delegate.incrementColumnValue(row, family, qualifier, amount);
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
@Override
public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount,
Durability durability) throws IOException {
return delegate.incrementColumnValue(row, family, qualifier, amount, durability);
}
代码示例来源:origin: org.apache.tephra/tephra-hbase-compat-1.1
@Override
public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount, Durability durability)
throws IOException {
if (allowNonTransactional) {
return hTable.incrementColumnValue(row, family, qualifier, amount, durability);
} else {
throw new UnsupportedOperationException("Operation is not supported transactionally");
}
}
内容来源于网络,如有侵权,请联系作者删除!