Class CheckAndMutateUtil.RequestBuilder
- java.lang.Object
-
- com.google.cloud.bigtable.hbase.adapters.CheckAndMutateUtil.RequestBuilder
-
- Enclosing class:
- CheckAndMutateUtil
public static class CheckAndMutateUtil.RequestBuilder extends Object
This class can be used to convert HBase checkAnd* operations to BigtableConditionalRowMutation
s.
-
-
Constructor Summary
Constructors Constructor and Description RequestBuilder(HBaseRequestAdapter hbaseAdapter, byte[] row, byte[] family)
RequestBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation
build()
CheckAndMutateUtil.RequestBuilder
ifMatches(CompareFilter.CompareOp compareOp, byte[] value)
For non-null values, this produces aRowFilter
equivalent to:CheckAndMutateUtil.RequestBuilder
ifNotExists()
CheckAndMutateUtil.RequestBuilder
qualifier(byte[] qualifier)
CheckAndMutateUtil.RequestBuilder
timeRange(long start, long end)
CheckAndMutateUtil.RequestBuilder
withDelete(Delete delete)
CheckAndMutateUtil.RequestBuilder
withMutations(RowMutations rm)
CheckAndMutateUtil.RequestBuilder
withPut(Put put)
-
-
-
Constructor Detail
-
RequestBuilder
public RequestBuilder(HBaseRequestAdapter hbaseAdapter, byte[] row, byte[] family)
RequestBuilder.- Parameters:
hbaseAdapter
- aHBaseRequestAdapter
used to convert HBaseMutation
to Cloud BigtableMutation
row
- the RowKey in which to to check value matchingfamily
- the family in which to check value matching.
-
-
Method Detail
-
qualifier
public CheckAndMutateUtil.RequestBuilder qualifier(byte[] qualifier)
-
ifNotExists
public CheckAndMutateUtil.RequestBuilder ifNotExists()
-
ifMatches
public CheckAndMutateUtil.RequestBuilder ifMatches(CompareFilter.CompareOp compareOp, @Nullable byte[] value)
For non-null values, this produces aRowFilter
equivalent to:new ValueFilter(reverseCompareOp(compareOp), new BinaryComparator(value)
Null values are bit tricky. In HBase 1.* style check and mutate, value == null always means `check non-existence` regardless of compareOp. That's semantically confusing for CompareOperators other than EQUALS. It's even more confusing if value == null and compareOp = NOT_EQUALS.
HBase 2.* APIs introduced an explicit method of checking for "Non-Existence" as an independent concept from compareOp, which is the inspiration for the
ifNotExists()
method.Checking for existence in HBase can be expressed as follows:
compareOp = CompareOp.GREATER_OR_EQUAL, value = new byte[]{Byte.MIN_VALUE})
Bigtable decided that value == null with a compareOp of NOT_EQUALS actually means check for existence, even though HBase will still treat it as non-existence.
- Parameters:
compareOp
- aCompareFilter.CompareOp
value
- a byte array.- Returns:
- a
CheckAndMutateUtil.RequestBuilder
object with compareOp and byte array value.
-
timeRange
public CheckAndMutateUtil.RequestBuilder timeRange(long start, long end)
-
withPut
public CheckAndMutateUtil.RequestBuilder withPut(Put put) throws DoNotRetryIOException
- Throws:
DoNotRetryIOException
-
withDelete
public CheckAndMutateUtil.RequestBuilder withDelete(Delete delete) throws DoNotRetryIOException
- Throws:
DoNotRetryIOException
-
withMutations
public CheckAndMutateUtil.RequestBuilder withMutations(RowMutations rm) throws DoNotRetryIOException
- Throws:
DoNotRetryIOException
-
build
public com.google.cloud.bigtable.data.v2.models.ConditionalRowMutation build()
-
-