This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 19a4bef273d Support objectLength in Record interface of udf-api
(#16946)
19a4bef273d is described below
commit 19a4bef273d26c234927fbdfa150ea08bd5f3620
Author: Jackie Tien <[email protected]>
AuthorDate: Tue Dec 23 17:35:10 2025 +0800
Support objectLength in Record interface of udf-api (#16946)
---
.../java/org/apache/iotdb/udf/api/relational/access/Record.java | 8 ++++++++
.../execution/operator/process/function/partition/Slice.java | 9 +++++++++
.../operator/source/relational/aggregation/RecordIterator.java | 9 +++++++++
.../iotdb/db/queryengine/plan/function/RecordObjectTypeTest.java | 2 ++
4 files changed, 28 insertions(+)
diff --git
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/relational/access/Record.java
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/relational/access/Record.java
index 538b8c296c1..d9a65ad654b 100644
---
a/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/relational/access/Record.java
+++
b/iotdb-api/udf-api/src/main/java/org/apache/iotdb/udf/api/relational/access/Record.java
@@ -124,6 +124,14 @@ public interface Record {
*/
Optional<File> getObjectFile(int columnIndex);
+ /**
+ * Returns the OBJECT value's real file length at the specified column in
this row.
+ *
+ * @param columnIndex index of the specified column
+ * @return length of the object
+ */
+ long objectLength(int columnIndex);
+
/**
* Returns the Binary representation of an object stored at the specified
column in this row.
*
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/Slice.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/Slice.java
index 57f04be9e00..e05381f6de4 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/Slice.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/partition/Slice.java
@@ -219,6 +219,15 @@ public class Slice {
return
ObjectTypeUtils.getObjectPathFromBinary(getBinarySafely(columnIndex));
}
+ @Override
+ public long objectLength(int columnIndex) {
+ if (getDataType(columnIndex) != Type.OBJECT) {
+ throw new UnsupportedOperationException("current column is not object
column");
+ }
+ Binary binary = getBinarySafely(columnIndex);
+ return ObjectTypeUtils.getObjectLength(binary);
+ }
+
@Override
public Binary readObject(int columnIndex, long offset, int length) {
if (getDataType(columnIndex) != Type.OBJECT) {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/RecordIterator.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/RecordIterator.java
index 234723b229b..3f3943f9bc3 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/RecordIterator.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/RecordIterator.java
@@ -164,6 +164,15 @@ public class RecordIterator implements Iterator<Record> {
return
ObjectTypeUtils.getObjectPathFromBinary(getBinarySafely(columnIndex));
}
+ @Override
+ public long objectLength(int columnIndex) {
+ if (getDataType(columnIndex) != Type.OBJECT) {
+ throw new UnsupportedOperationException("current column is not object
column");
+ }
+ Binary binary = getBinarySafely(columnIndex);
+ return ObjectTypeUtils.getObjectLength(binary);
+ }
+
@Override
public Binary readObject(int columnIndex, long offset, int length) {
if (getDataType(columnIndex) != Type.OBJECT) {
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/function/RecordObjectTypeTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/function/RecordObjectTypeTest.java
index 876f116a2c2..64d70eb63fa 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/function/RecordObjectTypeTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/function/RecordObjectTypeTest.java
@@ -133,6 +133,8 @@ public class RecordObjectTypeTest {
Optional<File> objectFile = record.getObjectFile(0);
assertTrue(objectFile.isPresent());
+ assertEquals(100L, record.objectLength(0));
+
assertEquals("(Object) 100 B", record.getString(0));
Assert.assertFalse(recordIterator.hasNext());
}