Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions iotdb-client/client-py/iotdb/tsfile/utils/tsblock_serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,7 @@ def repeat(column, data_type, position_count):
else:
return np.array(column * position_count, dtype=object)
else:
res = bytearray()
for _ in range(position_count):
res.extend(column if isinstance(column, bytes) else bytes(column))
return bytes(res)
return column.repeat(position_count)


def read_dictionary_column(buffer, data_type, position_count):
Expand Down
62 changes: 62 additions & 0 deletions iotdb-client/client-py/tests/unit/test_run_length_column.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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.
#

import struct

import pytest

from iotdb.utils.SessionDataSet import SessionDataSet


@pytest.fixture
def constant_int32_result():
# One INT32 column, two rows. The time column is plain INT64 and the
# value column uses RLE with a single non-null INT32 inside it.
header = struct.pack(">iBiBB", 1, 1, 2, 2, 4)
timestamps = struct.pack(">?qq", False, 1, 2)
constant = struct.pack(">B?i", 1, False, 42)
return SessionDataSet(
sql="select 42 as v from t",
column_name_list=["v"],
column_type_list=["INT32"],
column_name_index={"v": 0},
query_id=1,
statement_id=1,
client=None,
session_id=1,
query_result=[header + timestamps + constant],
ignore_timestamp=True,
time_out=0,
more_data=False,
fetch_size=100,
zone_id="UTC",
time_precision="ms",
column_index_2_tsblock_column_index_list=[0],
)


def test_run_length_int32_rows(constant_int32_result):
values = []
while constant_int32_result.has_next():
row = constant_int32_result.next()
values.append(row.get_fields()[0].get_int_value())
assert values == [42, 42]


def test_run_length_int32_dataframe(constant_int32_result):
assert constant_int32_result.todf()["v"].tolist() == [42, 42]