PDavid commented on code in PR #6361:
URL: https://github.com/apache/hbase/pull/6361#discussion_r1815157725


##########
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java:
##########
@@ -142,6 +155,31 @@ boolean areSerializedFieldsEqual(Filter o) {
     return Bytes.equals(this.getPrefix(), other.getPrefix());
   }
 
+  @Override
+  public Cell getNextCellHint(Cell cell) {
+    byte[] hintBytes;
+    if (reversed) {
+      // On reversed scan hint should be the prefix with last byte incremented
+      hintBytes = increaseLastNonMaxByte(this.prefix);
+    } else {
+      // On forward scan hint should be the prefix
+      hintBytes = prefix;
+    }
+    return PrivateCellUtil.createFirstOnRow(hintBytes, 0, (short) 
hintBytes.length);
+  }
+
+  private byte[] increaseLastNonMaxByte(byte[] bytes) {
+    byte[] result = Arrays.copyOf(bytes, bytes.length);
+    for (int i = bytes.length - 1; i >= 0; i--) {
+      byte b = bytes[i];
+      if (b < Byte.MAX_VALUE) {
+        result[i] = (byte) (b + 1);
+        break;
+      }
+    }
+    return result;
+  }

Review Comment:
   Unfortunately I did not yet found an existing util method which would do the 
same.
   What I tried for example `PrivateCellUtil.createFirstOnNextRow(Cell)` which 
is similar but not the same (and tests are failing if that is used).



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to