org.apache.hadoop.hbase.client.Table.checkAndPut()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(205)

本文整理了Java中org.apache.hadoop.hbase.client.Table.checkAndPut()方法的一些代码示例,展示了Table.checkAndPut()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.checkAndPut()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Table
类名称:Table
方法名:checkAndPut

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

  1. /**
  2. * Atomically checks if a row/family/qualifier value matches the expected
  3. * value. If it does, it adds the put. If the passed value is null, the check
  4. * is for the lack of column (ie: non-existance)
  5. *
  6. * @param row to check
  7. * @param family column family to check
  8. * @param qualifier column qualifier to check
  9. * @param value the expected value
  10. * @param put data to put if check succeeds
  11. * @throws IOException e
  12. * @return true if the new put was executed, false otherwise
  13. * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])}
  14. */
  15. @Deprecated
  16. default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
  17. throws IOException {
  18. return checkAndPut(row, family, qualifier, CompareOperator.EQUAL, value, put);
  19. }

代码示例来源:origin: apache/nifi

  1. @Override
  2. public boolean checkAndPut(final String tableName, final byte[] rowId, final byte[] family, final byte[] qualifier, final byte[] value, final PutColumn column) throws IOException {
  3. try (final Table table = connection.getTable(TableName.valueOf(tableName))) {
  4. Put put = new Put(rowId);
  5. put.addColumn(
  6. column.getColumnFamily(),
  7. column.getColumnQualifier(),
  8. column.getBuffer());
  9. return table.checkAndPut(rowId, family, qualifier, value, put);
  10. }
  11. }

代码示例来源:origin: apache/nifi

  1. @Override
  2. public boolean checkAndPut(final String tableName, final byte[] rowId, final byte[] family, final byte[] qualifier, final byte[] value, final PutColumn column) throws IOException {
  3. try (final Table table = connection.getTable(TableName.valueOf(tableName))) {
  4. Put put = new Put(rowId);
  5. put.addColumn(
  6. column.getColumnFamily(),
  7. column.getColumnQualifier(),
  8. column.getBuffer());
  9. return table.checkAndPut(rowId, family, qualifier, value, put);
  10. }
  11. }

代码示例来源:origin: apache/drill

  1. @Override
  2. public synchronized boolean putIfAbsent(String key, V value) {
  3. try {
  4. Put put = new Put(row(key));
  5. put.addColumn(FAMILY, QUALIFIER, bytes(value));
  6. return hbaseTable.checkAndPut(put.getRow(), FAMILY, QUALIFIER, null /*absent*/, put);
  7. } catch (IOException e) {
  8. throw UserException.dataReadError(e)
  9. .message("Caught error while putting row '%s' into table '%s'", key, hbaseTableName)
  10. .build(logger);
  11. }
  12. }

代码示例来源:origin: apache/kylin

  1. put.addColumn(B_FAMILY, B_COLUMN_TS, Bytes.toBytes(newTS));
  2. boolean ok = table.checkAndPut(row, B_FAMILY, B_COLUMN_TS, bOldTS, put);
  3. logger.trace("Update row {} from oldTs: {}, to newTs: {}, operation result: {}", resPath, oldTS, newTS, ok);
  4. if (!ok) {

代码示例来源:origin: apache/phoenix

  1. @Override
  2. public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
  3. throws IOException {
  4. return delegate.checkAndPut(row, family, qualifier, value, put);
  5. }

代码示例来源:origin: apache/phoenix

  1. @Override
  2. public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOperator op,
  3. byte[] value, Put put) throws IOException {
  4. return delegate.checkAndPut(row, family, qualifier, op, value, put);
  5. }

代码示例来源:origin: apache/phoenix

  1. @Override
  2. public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOp compareOp,
  3. byte[] value, Put put) throws IOException {
  4. return delegate.checkAndPut(row, family, qualifier, compareOp, value, put);
  5. }

代码示例来源:origin: apache/hbase

  1. assertObserverHasExecuted();
  2. assertTrue(table.checkAndPut(ROW, FAMILY, QUALIFIER, null, put));
  3. assertObserverHasExecuted();

代码示例来源:origin: org.apache.hbase/hbase-client

  1. /**
  2. * Atomically checks if a row/family/qualifier value matches the expected
  3. * value. If it does, it adds the put. If the passed value is null, the check
  4. * is for the lack of column (ie: non-existance)
  5. *
  6. * @param row to check
  7. * @param family column family to check
  8. * @param qualifier column qualifier to check
  9. * @param value the expected value
  10. * @param put data to put if check succeeds
  11. * @throws IOException e
  12. * @return true if the new put was executed, false otherwise
  13. * @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #checkAndMutate(byte[], byte[])}
  14. */
  15. @Deprecated
  16. default boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
  17. throws IOException {
  18. return checkAndPut(row, family, qualifier, CompareOperator.EQUAL, value, put);
  19. }

代码示例来源:origin: larsgeorge/hbase-book

  1. Bytes.toBytes("val1")); // co CheckAndPutExample-01-Put1 Create a new Put instance.
  2. boolean res1 = table.checkAndPut(Bytes.toBytes("row1"),
  3. Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), null, put1); // co CheckAndPutExample-02-CAS1 Check if column does not exist and perform optional put operation.
  4. System.out.println("Put 1a applied: " + res1); // co CheckAndPutExample-03-SOUT1 Print out the result, should be "Put 1a applied: true".
  5. boolean res2 = table.checkAndPut(Bytes.toBytes("row1"),
  6. Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), null, put1); // co CheckAndPutExample-04-CAS2 Attempt to store same cell again.
  7. 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.
  8. Bytes.toBytes("val2")); // co CheckAndPutExample-06-Put2 Create another Put instance, but using a different column qualifier.
  9. boolean res3 = table.checkAndPut(Bytes.toBytes("row1"),
  10. Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), // co CheckAndPutExample-07-CAS3 Store new data only if the previous data has been saved.
  11. Bytes.toBytes("val1"), put2);
  12. Bytes.toBytes("val3")); // co CheckAndPutExample-09-Put3 Create yet another Put instance, but using a different row.
  13. boolean res4 = table.checkAndPut(Bytes.toBytes("row1"),
  14. Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), // co CheckAndPutExample-10-CAS4 Store new data while checking a different row.
  15. Bytes.toBytes("val1"), put3);

代码示例来源:origin: apache/phoenix

  1. put.addColumn(family, qualifier, value);
  2. boolean checkAndPut =
  3. sysMutexTable.checkAndPut(rowKey, family, qualifier, null, put);
  4. String processName = ManagementFactory.getRuntimeMXBean().getName();
  5. String msg =

代码示例来源:origin: larsgeorge/hbase-book

  1. put.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual17"),
  2. Bytes.toBytes("val17"));
  3. boolean cap = table.checkAndPut(Bytes.toBytes("row10"),
  4. Bytes.toBytes("colfam1"), Bytes.toBytes("qual15"), null, put);
  5. System.out.println(" -> success: " + cap);
  6. cap = table.checkAndPut(Bytes.toBytes("row10"),
  7. Bytes.toBytes("colfam1"), Bytes.toBytes("qual16"), null, put);
  8. System.out.println(" -> success: " + cap);

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

  1. @Override
  2. public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOp compareOp,
  3. byte[] value, Put put) throws IOException {
  4. return delegate.checkAndPut(row, family, qualifier, compareOp, value, put);
  5. }

代码示例来源:origin: org.apache.phoenix/phoenix-core

  1. @Override
  2. public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareOperator op,
  3. byte[] value, Put put) throws IOException {
  4. return delegate.checkAndPut(row, family, qualifier, op, value, put);
  5. }

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

  1. @Override
  2. public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put)
  3. throws IOException {
  4. return delegate.checkAndPut(row, family, qualifier, value, put);
  5. }

代码示例来源:origin: apache/phoenix

  1. if (metaTable.checkAndPut(statsTableKey, PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
  2. UPGRADE_TO_4_7_COLUMN_NAME, null, upgradePut)) {
  3. List<Mutation> mutations = Lists.newArrayListWithExpectedSize(1000);

代码示例来源:origin: apache/phoenix

  1. saltPut.add(saltKV);
  2. if (!sysTable.checkAndPut(seqTableKey,
  3. PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
  4. PhoenixDatabaseMetaData.SALT_BUCKETS_BYTES, null, saltPut)) {
  5. if (sysTable.checkAndPut(seqTableKey,
  6. PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES,
  7. PhoenixDatabaseMetaData.TABLE_SEQ_NUM_BYTES, oldSeqNum, seqNumPut)) {

代码示例来源:origin: org.apache.tephra/tephra-hbase-compat-1.1

  1. @Override
  2. public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, byte[] value, Put put) throws IOException {
  3. if (allowNonTransactional) {
  4. return hTable.checkAndPut(row, family, qualifier, value, put);
  5. } else {
  6. throw new UnsupportedOperationException("Operation is not supported transactionally");
  7. }
  8. }

代码示例来源:origin: org.apache.nifi/nifi-hbase_1_1

  1. @Override
  2. public boolean checkAndPut(final String tableName, final byte[] rowId, final byte[] family, final byte[] qualifier, final byte[] value, final PutColumn column) throws IOException {
  3. try (final Table table = connection.getTable(TableName.valueOf(tableName))) {
  4. Put put = new Put(rowId);
  5. put.addColumn(
  6. column.getColumnFamily(),
  7. column.getColumnQualifier(),
  8. column.getBuffer());
  9. return table.checkAndPut(rowId, family, qualifier, value, put);
  10. }
  11. }

相关文章