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

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

commit 1caad90573a0fed4772760fb48e941f5661448ce
Author: HTHou <[email protected]>
AuthorDate: Thu Mar 20 18:16:14 2025 +0800

    dev more
---
 .../client-py/iotdb/tsfile/utils/tsblock_serde.py  | 21 +++------
 .../client-py/iotdb/utils/IoTDBRpcDataSet.py       | 50 ++++++----------------
 2 files changed, 19 insertions(+), 52 deletions(-)

diff --git a/iotdb-client/client-py/iotdb/tsfile/utils/tsblock_serde.py 
b/iotdb-client/client-py/iotdb/tsfile/utils/tsblock_serde.py
index be86c26666c..ccc091d791b 100644
--- a/iotdb-client/client-py/iotdb/tsfile/utils/tsblock_serde.py
+++ b/iotdb-client/client-py/iotdb/tsfile/utils/tsblock_serde.py
@@ -271,7 +271,9 @@ def deserialize(buffer):
     position_count, buffer = read_int_from_buffer(buffer)
     column_encodings, buffer = read_column_encoding(buffer, value_column_count 
+ 1)
 
-    time_column_values, buffer = read_time_column(buffer, position_count)
+    time_column_values, _, buffer = read_column(
+        column_encodings[0], buffer, TSDataType.INT64, position_count
+    )
     column_values = [None] * value_column_count
     null_indicators = [None] * value_column_count
     for i in range(value_column_count):
@@ -384,15 +386,6 @@ def deserialize_null_indicators(buffer, size):
 #    +---------------+-----------------+-------------+
 
 
-def read_time_column(buffer, size):
-    null_indicators, buffer = deserialize_null_indicators(buffer, size)
-    if null_indicators is None:
-        values, buffer = read_from_buffer(buffer, size * 8)
-    else:
-        raise Exception("TimeColumn should not contains null value")
-    return values, buffer
-
-
 def read_int64_column(buffer, data_type, position_count):
     null_indicators, buffer = deserialize_null_indicators(buffer, 
position_count)
     if null_indicators is None:
@@ -537,7 +530,7 @@ def read_run_length_column(buffer, data_type, 
position_count):
 
     return (
         repeat(column, data_type, position_count),
-        null_indicators * position_count,
+        None if null_indicators is None else null_indicators * position_count,
         buffer,
     )
 
@@ -546,7 +539,7 @@ def repeat(buffer, data_type, position_count):
     if data_type == TSDataType.BOOLEAN or data_type == TSDataType.TEXT:
         return buffer * position_count
     else:
-        res = bytes(0)
+        res = bytearray()
         for _ in range(position_count):
-            res.join(buffer)
-        return res
+            res.extend(buffer if isinstance(buffer, bytes) else bytes(buffer))
+        return bytes(res)
diff --git a/iotdb-client/client-py/iotdb/utils/IoTDBRpcDataSet.py 
b/iotdb-client/client-py/iotdb/utils/IoTDBRpcDataSet.py
index c4e36a0f794..c9e45304707 100644
--- a/iotdb-client/client-py/iotdb/utils/IoTDBRpcDataSet.py
+++ b/iotdb-client/client-py/iotdb/utils/IoTDBRpcDataSet.py
@@ -205,20 +205,11 @@ class IoTDBRpcDataSet(object):
                 )
             # TEXT, STRING, BLOB
             elif data_type == 5 or data_type == 11 or data_type == 10:
-                j = 0
-                offset = 0
+                index = 0
                 data_array = []
-                while offset < value_buffer_len:
-                    length = int.from_bytes(
-                        value_buffer[offset : offset + 4],
-                        byteorder="big",
-                        signed=False,
-                    )
-                    offset += 4
-                    value = bytes(value_buffer[offset : offset + length])
-                    data_array.append(value)
-                    j += 1
-                    offset += length
+                while index < value_buffer_len:
+                    data_array.append(value_buffer[index])
+                    index += 1
                 data_array = np.array(data_array, dtype=object)
             else:
                 raise RuntimeError("unsupported data type 
{}.".format(data_type))
@@ -331,38 +322,21 @@ class IoTDBRpcDataSet(object):
                     )
                 # TEXT, STRING
                 elif data_type == 5 or data_type == 11:
-                    j = 0
-                    offset = 0
+                    index = 0
                     data_array = []
-                    while offset < value_buffer_len:
-                        length = int.from_bytes(
-                            value_buffer[offset : offset + 4],
-                            byteorder="big",
-                            signed=False,
-                        )
-                        offset += 4
-                        value_bytes = bytes(value_buffer[offset : offset + 
length])
+                    while index < value_buffer_len:
+                        value_bytes = value_buffer[index]
                         value = value_bytes.decode("utf-8")
                         data_array.append(value)
-                        j += 1
-                        offset += length
+                        index += 1
                     data_array = pd.Series(data_array).astype(str)
                 # BLOB
                 elif data_type == 10:
-                    j = 0
-                    offset = 0
+                    index = 0
                     data_array = []
-                    while offset < value_buffer_len:
-                        length = int.from_bytes(
-                            value_buffer[offset : offset + 4],
-                            byteorder="big",
-                            signed=False,
-                        )
-                        offset += 4
-                        value = value_buffer[offset : offset + length]
-                        data_array.append(value)
-                        j += 1
-                        offset += length
+                    while index < value_buffer_len:
+                        data_array.append(value_buffer[index])
+                        index += 1
                     data_array = pd.Series(data_array)
                 # DATE
                 elif data_type == 9:

Reply via email to