/** * Atomically checks if a row/family/qualifier value matches the expected value and if it does, * it performs the mutation. If the passed value is null, the lack of column value * (ie: non-existence) is used. See checkAndRowMutate to do many checkAndPuts at a time on a * single row. * @param row to check * @param family column family to check * @param qualifier column qualifier to check * @param op the comparison operator * @param comparator the expected value * @param mutation data to put if check succeeds * @return true if mutation was applied, false otherwise */ default boolean checkAndMutate(byte [] row, byte [] family, byte [] qualifier, CompareOperator op, ByteArrayComparable comparator, Mutation mutation) throws IOException { return checkAndMutate(row, family, qualifier, op, comparator, TimeRange.allTime(), mutation); }
@Override public void doWork() throws Exception { Put[] puts = new Put[1]; Put put = new Put(Bytes.toBytes("r1")); put.addColumn(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("11")); puts[0] = put; while (testStep != TestStep.PUT_COMPLETED) { Thread.sleep(100); } testStep = TestStep.CHECKANDPUT_STARTED; region.checkAndMutate(Bytes.toBytes("r1"), Bytes.toBytes(family), Bytes.toBytes("q1"), CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("10")), put); testStep = TestStep.CHECKANDPUT_COMPLETED; } }
@Override public void doWork() throws Exception { Put[] puts = new Put[1]; Put put = new Put(Bytes.toBytes("r1")); put.addColumn(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("11")); puts[0] = put; while (testStep != TestStep.PUT_COMPLETED) { Thread.sleep(100); } testStep = TestStep.CHECKANDPUT_STARTED; region.checkAndMutate(Bytes.toBytes("r1"), Bytes.toBytes(family), Bytes.toBytes("q1"), CompareOperator.EQUAL, new BinaryComparator(Bytes.toBytes("10")), put); testStep = TestStep.CHECKANDPUT_COMPLETED; } }
boolean result = region.checkAndMutate(row, family, qualifier, compareOp, comparator, put, true); if (region.getCoprocessorHost() != null) { boolean result = region.checkAndMutate(row, family, qualifier, compareOp, comparator, delete, true); if (region.getCoprocessorHost() != null) {