yihua commented on code in PR #10241:
URL: https://github.com/apache/hudi/pull/10241#discussion_r1456600994


##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileDataBlock.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hudi.io.hfile;
+
+import org.apache.hudi.common.util.Option;
+
+import static org.apache.hudi.io.hfile.HFileReader.SEEK_TO_FOUND;
+import static org.apache.hudi.io.hfile.HFileReader.SEEK_TO_IN_RANGE;
+import static org.apache.hudi.io.hfile.KeyValue.KEY_OFFSET;
+
+/**
+ * Represents a {@link HFileBlockType#DATA} block.
+ */
+public class HFileDataBlock extends HFileBlock {
+  // Hudi does not use HFile MVCC timestamp version so the version
+  // is always 0, thus the byte length of the version is always 1.
+  // This assumption is also validated when parsing {@link HFileInfo},
+  // i.e., the maximum MVCC timestamp in a HFile must be 0.
+  private static final long ZERO_TS_VERSION_BYTE_LENGTH = 1;
+
+  // End offset of content in the block, relative to the start of the byte 
array {@link byteBuff}
+  protected final int uncompressedContentEndOffset;
+
+  protected HFileDataBlock(HFileContext context,
+                           byte[] byteBuff,
+                           int startOffsetInBuff) {
+    super(context, HFileBlockType.DATA, byteBuff, startOffsetInBuff);
+
+    this.uncompressedContentEndOffset = this.uncompressedEndOffset - 
this.sizeCheckSum;
+  }
+
+  /**
+   * Seeks to the key to look up. The key may not have an exact match.
+   *
+   * @param position               {@link HFilePosition} containing the 
current position relative
+   *                               to the beginning of the HFile (not the 
block start offset).
+   * @param key                    key to look up.
+   * @param blockStartOffsetInFile the start offset of the block relative to 
the beginning of the
+   *                               HFile.
+   * @return 0 if the block contains the exact same key as the lookup key, and 
the position points
+   * to the key; or 1 if the lookup key does not exist, and the position 
points to the
+   * lexicographically largest key that is smaller than the lookup key.
+   */
+  public int seekTo(HFilePosition position, Key key, int 
blockStartOffsetInFile) {
+    int offset = position.getOffset() - blockStartOffsetInFile;

Review Comment:
   Yes, this is a relative offset in block.



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