本文整理了Java中org.apache.hadoop.hbase.client.Table.increment()
方法的一些代码示例,展示了Table.increment()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.increment()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Table
类名称:Table
方法名:increment
[英]Increments one or more columns within a single row.
This operation does not appear atomic to readers. Increments are done under a single row lock, so write operations to a row are synchronized, but readers do not take row locks so get and scan operations can see this operation partially completed.
[中]在一行中增加一列或多列。
在读者看来,此操作不是原子操作。增量是在单行锁下完成的,因此对行的写入操作是同步的,但读卡器不接受行锁,因此get和scan操作可以看到此操作部分完成。
代码示例来源:origin: apache/hbase
private void testAppend(Increment inc) throws Exception {
checkResult(table.increment(inc));
List<Row> actions = Arrays.asList(inc, inc);
Object[] results = new Object[actions.size()];
table.batch(actions, results);
checkResult(results);
}
代码示例来源: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(expected = InvalidMutationDurabilityException.class)
public void testIncrementToTableNeedReplicate() throws Exception {
tableNeedReplicate.increment(newIncrementWithSkipWAL());
}
代码示例来源:origin: apache/hbase
@Override
protected void execute(Table table) throws IOException {
table.increment(new Increment(FAM_NAM).addColumn(FAM_NAM, FAM_NAM, 1));
}
}
代码示例来源:origin: apache/hbase
@Test
public void testIncrementToTableNotReplicate() throws Exception {
tableNotReplicate.increment(newIncrementWithSkipWAL());
}
代码示例来源:origin: apache/hbase
private static void increment(int sleepSteps) throws IOException {
for (long i = 1; i <= UPPER; i++) {
TABLE.increment(new Increment(ROW).addColumn(FAMILY, CQ1, i).addColumn(FAMILY, CQ2, 2 * i));
if (sleepSteps > 0 && i % sleepSteps == 0) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
}
}
}
代码示例来源:origin: apache/hbase
@Override
public TResult increment(ByteBuffer table, TIncrement increment) throws TIOError, TException {
checkReadOnlyMode();
Table htable = getTable(table);
try {
return resultFromHBase(htable.increment(incrementFromThrift(increment)));
} catch (IOException e) {
throw getTIOError(e);
} finally {
closeTable(htable);
}
}
代码示例来源:origin: apache/hbase
@Test(expected = DoNotRetryIOException.class)
public void testIncrementWithDoNotRetryIOException() throws Exception {
tableDoNotRetry.increment(new Increment(Bytes.toBytes("row")).addColumn(CF, CQ, 1));
}
代码示例来源:origin: apache/hbase
@Test(expected = RetriesExhaustedException.class)
public void testIncrementWithIOException() throws Exception {
tableRetry.increment(new Increment(Bytes.toBytes("row")).addColumn(CF, CQ, 1));
}
代码示例来源:origin: apache/hbase
/**
* See {@link #incrementColumnValue(byte[], byte[], byte[], long, Durability)}
* <p>
* The {@link Durability} is defaulted to {@link Durability#SYNC_WAL}.
* @param row The row that contains the cell to increment.
* @param family The column family of the cell to increment.
* @param qualifier The column qualifier of the cell to increment.
* @param amount The amount to increment the cell with (or decrement, if the
* amount is negative).
* @return The new value, post increment.
* @throws IOException if a remote or network exception occurs.
*/
default long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, long amount)
throws IOException {
Increment increment = new Increment(row).addColumn(family, qualifier, amount);
Cell cell = increment(increment).getColumnLatestCell(family, qualifier);
return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
代码示例来源:origin: apache/hbase
@Override
boolean testRow(final int i) throws IOException {
Increment increment = new Increment(format(i));
// unlike checkAndXXX tests, which make most sense to do on a single value,
// if multiple families are specified for an increment test we assume it is
// meant to raise the work factor
for (int family = 0; family < opts.families; family++) {
byte[] familyName = Bytes.toBytes(FAMILY_NAME_BASE + family);
increment.addColumn(familyName, getQualifier(), 1l);
}
updateValueSize(this.table.increment(increment));
return true;
}
}
代码示例来源:origin: apache/hbase
@Override
public Object run() throws Exception {
Increment inc = new Increment(TEST_ROW);
inc.addColumn(TEST_FAMILY, TEST_QUALIFIER, 1);
try(Connection conn = ConnectionFactory.createConnection(conf);
Table t = conn.getTable(TEST_TABLE)) {
t.increment(inc);
}
return null;
}
};
代码示例来源:origin: apache/hbase
@Test
public void testIncrement() throws Exception {
Put p = new Put(row).addColumn(cf, qualifier, Bytes.toBytes(0L));
table.put(p);
for(int count = 0; count < 13; count++) {
Increment inc = new Increment(row);
inc.addColumn(cf, qualifier, 100);
table.increment(inc);
}
metricsRegionServer.getRegionServerWrapper().forceRecompute();
assertCounter("incrementNumOps", 13);
}
代码示例来源:origin: apache/hbase
@Test
public void testIncrement() throws IOException {
try (Table t = TEST_UTIL.getConnection().getTable(TABLE_NAME)) {
Put put = new Put(ROW);
put.addColumn(FAMILY, QUAL, VALUE);
t.put(put);
assertRowAndValue(t.get(new Get(ROW)), ROW, VALUE);
Increment inc = new Increment(ROW);
inc.addColumn(FAMILY, QUAL, 99);
assertRowAndValue(t.increment(inc), ROW, FIXED_VALUE);
assertRowAndValue(t.get(new Get(ROW)), ROW, Bytes.toBytes(199L));
}
}
代码示例来源:origin: apache/hbase
@Override
public Object run() throws Exception {
Increment i = new Increment(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q1, 1L);
try(Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(TEST_TABLE.getTableName())) {
t.increment(i);
}
return null;
}
};
代码示例来源:origin: apache/hbase
@Override
public Object run() throws Exception {
Increment i = new Increment(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q2, 1L);
try(Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(TEST_TABLE.getTableName())) {
t.increment(i);
}
return null;
}
};
代码示例来源:origin: apache/hbase
@Override
public Object run() throws Exception {
Increment i = new Increment(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q3, 1L);
try(Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(TEST_TABLE.getTableName())) {
t.increment(i);
}
return null;
}
};
代码示例来源:origin: apache/hbase
@Override
public Object run() throws Exception {
Increment i = new Increment(TEST_ROW).addColumn(TEST_FAMILY, TEST_Q2, 1L);
// Tag this increment with an ACL that denies write permissions to USER_OTHER and GROUP
i.setACL(prepareCellPermissions(usersAndGroups, Action.READ));
try(Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(TEST_TABLE.getTableName())) {
t.increment(i);
}
return null;
}
};
代码示例来源: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(row);
inc.setTimeRange(0, 127);
inc.addColumn(TEST_FAMILY1, q1, 2L);
t.increment(inc);
fail(user.getShortName() + " cannot do the increment.");
} catch (Exception e) {
}
}
return null;
}
});
代码示例来源:origin: apache/hbase
@Test
public void testIncrementWithCustomTimestamp() throws IOException {
TableName TABLENAME = TableName.valueOf(name.getMethodName());
Table table = TEST_UTIL.createTable(TABLENAME, FAMILY);
long timestamp = 999;
Increment increment = new Increment(ROW);
increment.add(CellUtil.createCell(ROW, FAMILY, QUALIFIER, timestamp, KeyValue.Type.Put.getCode(), Bytes.toBytes(100L)));
Result r = table.increment(increment);
assertEquals(1, r.size());
assertEquals(timestamp, r.rawCells()[0].getTimestamp());
r = table.get(new Get(ROW));
assertEquals(1, r.size());
assertEquals(timestamp, r.rawCells()[0].getTimestamp());
r = table.increment(increment);
assertEquals(1, r.size());
assertNotEquals(timestamp, r.rawCells()[0].getTimestamp());
r = table.get(new Get(ROW));
assertEquals(1, r.size());
assertNotEquals(timestamp, r.rawCells()[0].getTimestamp());
}
内容来源于网络,如有侵权,请联系作者删除!