本文整理了Java中org.apache.hadoop.hbase.client.Table.checkAndPut()
方法的一些代码示例,展示了Table.checkAndPut()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.checkAndPut()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Table
类名称:Table
方法名:checkAndPut
[英]Atomically checks if a row/family/qualifier value matches the expected value. If it does, it adds the put. If the passed value is null, the check is for the lack of column (ie: non-existence) The expected value argument of this call is on the left and the current value of the cell is on the right side of the comparison operator. Ie. eg. GREATER operator means expected value > existing add the put.
[中]自动检查行/族/限定符值是否与预期值匹配。如果是这样,它会添加put。如果传递的值为null,则检查是否缺少列(即:不存在)。此调用的预期值参数位于左侧,单元格的当前值位于比较运算符的右侧。更大的运算符意味着期望值>现有加上看跌期权。
代码示例来源:origin: apache/hbase
/**
* Atomically checks if a row/family/qualifier value matches the expected
* value. If it does, it adds the put. If the passed value is null, the check
* is for the lack of column (ie: non-existance)
*
* @param row to check
* @param family column family to check
* @param qualifier column qualifier to check
* @param value the expected value
* @param put data to put if check succeeds
* @throws IOException e
* @return true if the new put was executed, false otherwise
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])}
*/
@Deprecated
default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
throws IOException {
return checkAndPut(row, family, qualifier, CompareOperator.EQUAL, value, put);
}
代码示例来源:origin: apache/nifi
@Override
public boolean checkAndPut(final String tableName, final byte[] rowId, final byte[] family, final byte[] qualifier, final byte[] value, final PutColumn column) throws IOException {
try (final Table table = connection.getTable(TableName.valueOf(tableName))) {
Put put = new Put(rowId);
put.addColumn(
column.getColumnFamily(),
column.getColumnQualifier(),
column.getBuffer());
return table.checkAndPut(rowId, family, qualifier, value, put);
}
}
代码示例来源:origin: apache/nifi
@Override
public boolean checkAndPut(final String tableName, final byte[] rowId, final byte[] family, final byte[] qualifier, final byte[] value, final PutColumn column) throws IOException {
try (final Table table = connection.getTable(TableName.valueOf(tableName))) {
Put put = new Put(rowId);
put.addColumn(
column.getColumnFamily(),
column.getColumnQualifier(),
column.getBuffer());
return table.checkAndPut(rowId, family, qualifier, value, put);
}
}
代码示例来源:origin: apache/drill
@Override
public synchronized boolean putIfAbsent(String key, V value) {
try {
Put put = new Put(row(key));
put.addColumn(FAMILY, QUALIFIER, bytes(value));
return hbaseTable.checkAndPut(put.getRow(), FAMILY, QUALIFIER, null /*absent*/, put);
} catch (IOException e) {
throw UserException.dataReadError(e)
.message("Caught error while putting row '%s' into table '%s'", key, hbaseTableName)
.build(logger);
}
}
代码示例来源:origin: apache/kylin
put.addColumn(B_FAMILY, B_COLUMN_TS, Bytes.toBytes(newTS));
boolean ok = table.checkAndPut(row, B_FAMILY, B_COLUMN_TS, bOldTS, put);
logger.trace("Update row {} from oldTs: {}, to newTs: {}, operation result: {}", resPath, oldTS, newTS, ok);
if (!ok) {
代码示例来源:origin: apache/phoenix
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
throws IOException {
return delegate.checkAndPut(row, family, qualifier, value, put);
}
代码示例来源:origin: apache/phoenix
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOperator op,
byte[] value, Put put) throws IOException {
return delegate.checkAndPut(row, family, qualifier, op, value, put);
}
代码示例来源:origin: apache/phoenix
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOp compareOp,
byte[] value, Put put) throws IOException {
return delegate.checkAndPut(row, family, qualifier, compareOp, value, put);
}
代码示例来源:origin: apache/hbase
assertObserverHasExecuted();
assertTrue(table.checkAndPut(ROW, FAMILY, QUALIFIER, null, put));
assertObserverHasExecuted();
代码示例来源:origin: org.apache.hbase/hbase-client
/**
* Atomically checks if a row/family/qualifier value matches the expected
* value. If it does, it adds the put. If the passed value is null, the check
* is for the lack of column (ie: non-existance)
*
* @param row to check
* @param family column family to check
* @param qualifier column qualifier to check
* @param value the expected value
* @param put data to put if check succeeds
* @throws IOException e
* @return true if the new put was executed, false otherwise
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])}
*/
@Deprecated
default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
throws IOException {
return checkAndPut(row, family, qualifier, CompareOperator.EQUAL, value, put);
}
代码示例来源:origin: larsgeorge/hbase-book
Bytes.toBytes("val1")); // co CheckAndPutExample-01-Put1 Create a new Put instance.
boolean res1 = table.checkAndPut(Bytes.toBytes("row1"),
Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), null, put1); // co CheckAndPutExample-02-CAS1 Check if column does not exist and perform optional put operation.
System.out.println("Put 1a applied: " + res1); // co CheckAndPutExample-03-SOUT1 Print out the result, should be "Put 1a applied: true".
boolean res2 = table.checkAndPut(Bytes.toBytes("row1"),
Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), null, put1); // co CheckAndPutExample-04-CAS2 Attempt to store same cell again.
System.out.println("Put 1b applied: " + res2); // co CheckAndPutExample-05-SOUT2 Print out the result, should be "Put 1b applied: false" as the column now already exists.
Bytes.toBytes("val2")); // co CheckAndPutExample-06-Put2 Create another Put instance, but using a different column qualifier.
boolean res3 = table.checkAndPut(Bytes.toBytes("row1"),
Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), // co CheckAndPutExample-07-CAS3 Store new data only if the previous data has been saved.
Bytes.toBytes("val1"), put2);
Bytes.toBytes("val3")); // co CheckAndPutExample-09-Put3 Create yet another Put instance, but using a different row.
boolean res4 = table.checkAndPut(Bytes.toBytes("row1"),
Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), // co CheckAndPutExample-10-CAS4 Store new data while checking a different row.
Bytes.toBytes("val1"), put3);
代码示例来源:origin: apache/phoenix
put.addColumn(family, qualifier, value);
boolean checkAndPut =
sysMutexTable.checkAndPut(rowKey, family, qualifier, null, put);
String processName = ManagementFactory.getRuntimeMXBean().getName();
String msg =
代码示例来源:origin: larsgeorge/hbase-book
put.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual17"),
Bytes.toBytes("val17"));
boolean cap = table.checkAndPut(Bytes.toBytes("row10"),
Bytes.toBytes("colfam1"), Bytes.toBytes("qual15"), null, put);
System.out.println(" -> success: " + cap);
cap = table.checkAndPut(Bytes.toBytes("row10"),
Bytes.toBytes("colfam1"), Bytes.toBytes("qual16"), null, put);
System.out.println(" -> success: " + cap);
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOp compareOp,
byte[] value, Put put) throws IOException {
return delegate.checkAndPut(row, family, qualifier, compareOp, value, put);
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOperator op,
byte[] value, Put put) throws IOException {
return delegate.checkAndPut(row, family, qualifier, op, value, put);
}
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
throws IOException {
return delegate.checkAndPut(row, family, qualifier, value, put);
}
代码示例来源:origin: apache/phoenix
if (metaTable.checkAndPut(statsTableKey, PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
UPGRADE_TO_4_7_COLUMN_NAME, null, upgradePut)) {
List<Mutation> mutations = Lists.newArrayListWithExpectedSize(1000);
代码示例来源:origin: apache/phoenix
saltPut.add(saltKV);
if (!sysTable.checkAndPut(seqTableKey,
PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
PhoenixDatabaseMetaData.SALT_BUCKETS_BYTES, null, saltPut)) {
if (sysTable.checkAndPut(seqTableKey,
PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES, oldSeqNum, seqNumPut)) {
代码示例来源:origin: org.apache.tephra/tephra-hbase-compat-1.1
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) throws IOException {
if (allowNonTransactional) {
return hTable.checkAndPut(row, family, qualifier, value, put);
} else {
throw new UnsupportedOperationException("Operation is not supported transactionally");
}
}
代码示例来源:origin: org.apache.nifi/nifi-hbase_1_1
@Override
public boolean checkAndPut(final String tableName, final byte[] rowId, final byte[] family, final byte[] qualifier, final byte[] value, final PutColumn column) throws IOException {
try (final Table table = connection.getTable(TableName.valueOf(tableName))) {
Put put = new Put(rowId);
put.addColumn(
column.getColumnFamily(),
column.getColumnQualifier(),
column.getBuffer());
return table.checkAndPut(rowId, family, qualifier, value, put);
}
}
内容来源于网络,如有侵权,请联系作者删除!