junegunn commented on code in PR #7934:
URL: https://github.com/apache/hbase/pull/7934#discussion_r2938753420


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/util/RowColBloomHashKey.java:
##########
@@ -80,9 +84,116 @@ public byte get(int offset) {
 
   @Override
   public int length() {
-    // For ROW_COL blooms we use bytes
-    // <RK length> (2 bytes) , <RK>, 0 (one byte CF length), <CQ>, <TS> (8 
btes), <TYPE> ( 1 byte)
-    return KeyValue.ROW_LENGTH_SIZE + this.t.getRowLength() + 
KeyValue.FAMILY_LENGTH_SIZE
-      + this.t.getQualifierLength() + KeyValue.TIMESTAMP_TYPE_SIZE;
+    return totalLength;
+  }
+
+  @Override
+  public int getIntLE(int offset) {
+    // Handle fast path that can return the row key as int directly
+    // Compute rowkey section range.
+    final int rowEnd = KeyValue.ROW_LENGTH_SIZE + rowLength;
+    if (offset >= KeyValue.ROW_LENGTH_SIZE && offset + Bytes.SIZEOF_INT <= 
rowEnd) {
+      return LittleEndianBytes.getRowAsInt(t, offset - 
KeyValue.ROW_LENGTH_SIZE);
+    }
+
+    // Compute qualifier section range.
+    final int qualStart = rowEnd + KeyValue.FAMILY_LENGTH_SIZE;
+    final int qualEnd = qualStart + qualLength;
+    if (offset >= qualStart && offset + Bytes.SIZEOF_INT <= qualEnd) {
+      return LittleEndianBytes.getQualifierAsInt(t, offset - qualStart);
+    }
+
+    // Compute timestamp section range.
+    final int tsEnd = qualEnd + KeyValue.TIMESTAMP_SIZE;
+    if (offset >= qualEnd && offset + Bytes.SIZEOF_INT <= tsEnd) {
+      return LittleEndianBytes.toInt(LATEST_TS, offset - qualEnd);
+    }
+
+    return (int) assembleCrossingLE(offset, Bytes.SIZEOF_INT);
+  }
+
+  private long assembleCrossingLE(int offset, int wordBytes) {

Review Comment:
   So we're adding a non-trivial amount of code here, and it seems to overlap 
with the existing `get(int offset)` implementation to some degree. Would it 
make sense to refactor `get` to call this new method instead, so we can reduce 
code duplication? We could consider that approach as long as the performance 
overhead is negligible.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to