ijokarumawak commented on a change in pull request #3462: NIFI-6243 Add Support
for AtomicDistributedCache to the HBase 1.x and…
URL: https://github.com/apache/nifi/pull/3462#discussion_r282366880
##########
File path:
nifi-nar-bundles/nifi-standard-services/nifi-hbase_2-client-service-bundle/nifi-hbase_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_2_ClientService.java
##########
@@ -485,6 +486,22 @@ public boolean checkAndPut(final String tableName, final
byte[] rowId, final byt
}
}
+ @Override
+ public boolean checkAndPut(String tableName, byte[] rowId, byte[] family,
byte[] qualifier, byte[] value, long timestamp, PutColumn column) throws
IOException {
+ try (final Table table =
connection.getTable(TableName.valueOf(tableName))) {
+ Put put = new Put(rowId);
+ put.addColumn(
+ column.getColumnFamily(),
+ column.getColumnQualifier(),
+ column.getBuffer());
+ if ( value == null || timestamp == 0L ) {
+ return table.checkAndMutate(rowId,
family).qualifier(qualifier).ifNotExists().thenPut(put);
+ } else {
+ return table.checkAndMutate(rowId,
family).qualifier(qualifier).ifEquals(value).timeRange(TimeRange.at(timestamp)).thenPut(put);
Review comment:
How does this `timeRange(TimeRange.at(timestamp))` affect the operation? I
talked with my colleague who has better knowledge on HBase than me said it is
used to get the persisted value at the specified timestamp to compare the value
specified with `ifEquals(value)`. I haven't tested myself though.
I feel we can remove the `timeRange(TimeRange.at(timestamp))` part. If we
don't specify timestamp, HBase will compare with the latest value.
Also, if HBase requires the original value for atomic mutation (and
specifying timestamp doesn't add any benefit for NiFi use-case), I don't think
we need to add this `checkAndPut` method. The existing `checkAndPut` would be
sufficient.
How do you think?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services