Atomically increments a value in HBase. A note on passing byte arrays in argument None of the method that receive a byte[] in argument will copy it. For more info, please refer to the documentation of HBaseRpc. A note on passing Strings in argument
| 44 | * All strings are assumed to use the platform's default charset. |
| 45 | */ |
| 46 | public final class AtomicIncrementRequest extends HBaseRpc |
| 47 | implements HBaseRpc.HasTable, HBaseRpc.HasKey, |
| 48 | HBaseRpc.HasFamily, HBaseRpc.HasQualifier, HBaseRpc.IsEdit { |
| 49 | |
| 50 | private static final byte[] INCREMENT_COLUMN_VALUE = new byte[] { |
| 51 | 'i', 'n', 'c', 'r', 'e', 'm', 'e', 'n', 't', |
| 52 | 'C', 'o', 'l', 'u', 'm', 'n', |
| 53 | 'V', 'a', 'l', 'u', 'e' |
| 54 | }; |
| 55 | |
| 56 | private final byte[] family; |
| 57 | private final byte[] qualifier; |
| 58 | private long amount; |
| 59 | private boolean durable = true; |
| 60 | |
| 61 | /** |
| 62 | * Constructor. |
| 63 | * <strong>These byte arrays will NOT be copied.</strong> |
| 64 | * @param table The non-empty name of the table to use. |
| 65 | * @param key The row key of the value to increment. |
| 66 | * @param family The column family of the value to increment. |
| 67 | * @param qualifier The column qualifier of the value to increment. |
| 68 | * @param amount Amount by which to increment the value in HBase. |
| 69 | * If negative, the value in HBase will be decremented. |
| 70 | */ |
| 71 | public AtomicIncrementRequest(final byte[] table, |
| 72 | final byte[] key, |
| 73 | final byte[] family, |
| 74 | final byte[] qualifier, |
| 75 | final long amount) { |
| 76 | super(table, key); |
| 77 | KeyValue.checkFamily(family); |
| 78 | KeyValue.checkQualifier(qualifier); |
| 79 | this.family = family; |
| 80 | this.qualifier = qualifier; |
| 81 | this.amount = amount; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Constructor. This is equivalent to: |
| 86 | * {@link #AtomicIncrementRequest(byte[], byte[], byte[], byte[], long) |
| 87 | * AtomicIncrementRequest}{@code (table, key, family, qualifier, 1)} |
| 88 | * <p> |
| 89 | * <strong>These byte arrays will NOT be copied.</strong> |
| 90 | * @param table The non-empty name of the table to use. |
| 91 | * @param key The row key of the value to increment. |
| 92 | * @param family The column family of the value to increment. |
| 93 | * @param qualifier The column qualifier of the value to increment. |
| 94 | */ |
| 95 | public AtomicIncrementRequest(final byte[] table, |
| 96 | final byte[] key, |
| 97 | final byte[] family, |
| 98 | final byte[] qualifier) { |
| 99 | this(table, key, family, qualifier, 1); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Constructor. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…