This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch OffsetBug
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit c2182a4d8aa0c98f0a0b6600429336a1e4f4e0f7
Author: JackieTien97 <[email protected]>
AuthorDate: Tue Apr 11 19:19:46 2023 +0800

    Fix offset overflow bug
---
 .../iotdb/db/mpp/execution/operator/process/OffsetOperator.java       | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/OffsetOperator.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/OffsetOperator.java
index 37127e82aa..22429b431e 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/OffsetOperator.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/OffsetOperator.java
@@ -57,7 +57,9 @@ public class OffsetOperator implements ProcessOperator {
       return null;
     }
     if (remainingOffset > 0) {
-      int offset = Math.min((int) remainingOffset, block.getPositionCount());
+      // It's safe to narrow long to int here, because 
block.getPositionCount() will always be less
+      // than Integer.MAX_VALUE
+      int offset = (int) Math.min(remainingOffset, block.getPositionCount());
       remainingOffset -= offset;
       return block.getRegion(offset, block.getPositionCount() - offset);
     } else {

Reply via email to