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

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

commit e5e520d9dd0cb6a7c0cdbf5ee50eb12b6e60364a
Author: JackieTien97 <[email protected]>
AuthorDate: Fri Aug 15 15:20:30 2025 +0800

    Print file name while encountering error
---
 .../unary/scalar/ReadObjectColumnTransformer.java  | 29 ++++++++++++++--------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/transformation/dag/column/unary/scalar/ReadObjectColumnTransformer.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/transformation/dag/column/unary/scalar/ReadObjectColumnTransformer.java
index 9bde98b351a..9504c6c2282 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/transformation/dag/column/unary/scalar/ReadObjectColumnTransformer.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/transformation/dag/column/unary/scalar/ReadObjectColumnTransformer.java
@@ -108,16 +108,7 @@ public class ReadObjectColumnTransformer extends 
UnaryColumnTransformer {
 
   private Binary readObject(Binary binary) {
     File file = ObjectTypeUtils.getObjectPathFromBinary(binary);
-    long fileSize = file.length();
-    if (offset >= fileSize) {
-      throw new SemanticException(
-          "offset is greater than object size, file path is " + 
file.getAbsolutePath());
-    }
-    long actualReadSize = Math.min(length < 0 ? fileSize : length, fileSize - 
offset);
-    if (actualReadSize > Integer.MAX_VALUE) {
-      throw new SemanticException(
-          "Read object size is too large (size > 2G), file path is " + 
file.getAbsolutePath());
-    }
+    long actualReadSize = getActualReadSize(file);
     fragmentInstanceContext.ifPresent(
         context -> 
context.getMemoryReservationContext().reserveMemoryCumulatively(actualReadSize));
     byte[] bytes = new byte[(int) actualReadSize];
@@ -129,4 +120,22 @@ public class ReadObjectColumnTransformer extends 
UnaryColumnTransformer {
     }
     return new Binary(bytes);
   }
+
+  private long getActualReadSize(File file) {
+    long fileSize = file.length();
+    if (offset >= fileSize) {
+      throw new SemanticException(
+          String.format(
+              "offset %d is greater than object size %d, file path is %s",
+              offset, fileSize, file.getAbsolutePath()));
+    }
+    long actualReadSize = Math.min(length < 0 ? fileSize : length, fileSize - 
offset);
+    if (actualReadSize > Integer.MAX_VALUE) {
+      throw new SemanticException(
+          String.format(
+              "Read object size %s is too large (size > 2G), file path is %s",
+              actualReadSize, file.getAbsolutePath()));
+    }
+    return actualReadSize;
+  }
 }

Reply via email to