MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / CompareAndSetRequest

Class CompareAndSetRequest

src/CompareAndSetRequest.java:49–255  ·  view source on GitHub ↗

Atomically executes a Compare-And-Set (CAS) on an HBase cell. This class is package-private just to reduce the amount of public API, but it could be exposed if needed. @since 1.3

Source from the content-addressed store, hash-verified

47 * @since 1.3
48 */
49final class CompareAndSetRequest extends HBaseRpc
50 implements HBaseRpc.HasTable, HBaseRpc.HasKey,
51 HBaseRpc.HasFamily, HBaseRpc.HasQualifier, HBaseRpc.HasValue,
52 HBaseRpc.IsEdit {
53
54 /** Awesome RPC method name... For HBase 0.94 and earlier only. */
55 private static final byte[] CHECKANDPUT = {
56 'c', 'h', 'e', 'c', 'k', 'A', 'n', 'd', 'P', 'u', 't'
57 };
58
59 /** Comparator named used for HBase 0.95+. */
60 private static final ByteString BINARYCOMPARATOR =
61 ByteString.copyFromUtf8("org.apache.hadoop.hbase.filter.BinaryComparator");
62
63 /** New value. */
64 private final PutRequest put;
65
66 /** Expected value. */
67 private final byte[] expected;
68
69 /**
70 * Constructor.
71 * @param put Put request to execute if value matches.
72 * @param value The expected value to compare against.
73 * <strong>This byte array will NOT be copied.</strong>
74 */
75 public CompareAndSetRequest(final PutRequest put,
76 final byte[] expected) {
77 super(put.table(), put.key());
78 KeyValue.checkValue(expected);
79 this.put = put;
80 this.expected = expected;
81 }
82
83 @Override
84 byte[] method(final byte server_version) {
85 return (server_version >= RegionClient.SERVER_VERSION_095_OR_ABOVE
86 ? MUTATE
87 : CHECKANDPUT);
88 }
89
90 @Override
91 public byte[] table() {
92 return put.table();
93 }
94
95 @Override
96 public byte[] key() {
97 return put.key();
98 }
99
100 @Override
101 public byte[] family() {
102 return put.family();
103 }
104
105 @Override
106 public byte[] qualifier() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…