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

colinlee pushed a commit to branch colin_support_read_tree
in repository https://gitbox.apache.org/repos/asf/tsfile.git

commit abb5860e8411a9e9c0e122981321090d083ced39
Author: ColinLee <[email protected]>
AuthorDate: Wed Nov 19 11:05:23 2025 +0800

    fix query table on tree.
---
 cpp/src/common/tsblock/tsblock.h                     | 13 ++++++++++++-
 cpp/src/file/tsfile_io_reader.cc                     |  3 +++
 cpp/src/reader/block/single_device_tsblock_reader.cc | 10 ++++++++--
 cpp/src/reader/table_query_executor.cc               |  4 ++--
 cpp/src/reader/tsfile_reader.cc                      |  2 +-
 5 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/cpp/src/common/tsblock/tsblock.h b/cpp/src/common/tsblock/tsblock.h
index a0e94391..31f24a96 100644
--- a/cpp/src/common/tsblock/tsblock.h
+++ b/cpp/src/common/tsblock/tsblock.h
@@ -161,7 +161,18 @@ class RowAppender {
                              uint32_t len) {
         ASSERT(slot_index < tsblock_->tuple_desc_->get_column_count());
         Vector *vec = tsblock_->vectors_[slot_index];
-        vec->append(value, len);
+        TSDataType datatype = vec->get_vector_type();
+        if (len == 4 && datatype == INT64) {
+            int32_t int32_val = *reinterpret_cast<const int32_t*>(value);
+            int64_t int64_val = static_cast<int64_t>(int32_val);
+            vec->append(reinterpret_cast<const char*>(&int64_val), 8);
+        } else if (len == 4 && datatype == DOUBLE) {
+            float float_val = *reinterpret_cast<const float*>(value);
+            double double_val = static_cast<double>(float_val);
+            vec->append(reinterpret_cast<const char*>(&double_val), 8);
+        } else {
+            vec->append(value, len);
+        }
     }
 
     FORCE_INLINE void append_null(uint32_t slot_index) {
diff --git a/cpp/src/file/tsfile_io_reader.cc b/cpp/src/file/tsfile_io_reader.cc
index c70c429e..a8b6fce0 100644
--- a/cpp/src/file/tsfile_io_reader.cc
+++ b/cpp/src/file/tsfile_io_reader.cc
@@ -304,8 +304,11 @@ int TsFileIOReader::load_device_index_entry(
     assert(index_node != nullptr);
     if (index_node->node_type_ == LEAF_DEVICE) {
         // FIXME
+        std::cout << "binary search children for" << device_name->to_string()
+                  << std::endl;
         ret = index_node->binary_search_children(
             device_name, true, device_index_entry, end_offset);
+        std::cout << "return value is" << ret << std::endl;
     } else {
         ret = search_from_internal_node(device_name, true, index_node,
                                         device_index_entry, end_offset);
diff --git a/cpp/src/reader/block/single_device_tsblock_reader.cc 
b/cpp/src/reader/block/single_device_tsblock_reader.cc
index 1df563cd..b58efe47 100644
--- a/cpp/src/reader/block/single_device_tsblock_reader.cc
+++ b/cpp/src/reader/block/single_device_tsblock_reader.cc
@@ -214,8 +214,14 @@ int SingleDeviceTsBlockReader::fill_ids() {
         const auto& id_column_context = entry.second;
         for (int32_t pos : id_column_context.pos_in_result_) {
             std::string* device_tag = nullptr;
-            device_tag = 
device_query_task_->get_device_id()->get_segments().at(
-                id_column_context.pos_in_device_id_);
+            const auto& segments =
+                device_query_task_->get_device_id()->get_segments();
+            int32_t pos_in_device_id = id_column_context.pos_in_device_id_;
+            if (pos_in_device_id >= 0 &&
+                static_cast<size_t>(pos_in_device_id) < segments.size()) {
+                device_tag = segments[pos_in_device_id];
+            }
+
             if (device_tag == nullptr) {
                 ret = col_appenders_[pos + 1]->fill_null(
                     current_block_->get_row_count());
diff --git a/cpp/src/reader/table_query_executor.cc 
b/cpp/src/reader/table_query_executor.cc
index 1f9d0d19..351969c5 100644
--- a/cpp/src/reader/table_query_executor.cc
+++ b/cpp/src/reader/table_query_executor.cc
@@ -127,7 +127,7 @@ namespace storage {
             std::unordered_set<std::string> 
measurements(field_columns.begin(), field_columns.end());
             std::vector<ITimeseriesIndex *> index(measurements.size());
             if (RET_FAIL(tsfile_io_reader_->get_timeseries_indexes(device, 
measurements, index, pa))) {
-                continue;
+                assert(0);
             }
 
             for (auto *ts_index: index) {
@@ -139,7 +139,7 @@ namespace storage {
                             type == common::TSDataType::INT64 ||
                             type == common::TSDataType::TIMESTAMP ||
                             type == common::TSDataType::DATE) {
-                            type = common::TSDataType::INT64;
+                            type = common::TSDataType::INT32;
                         } else if (type == common::TSDataType::FLOAT) {
                             type = common::TSDataType::DOUBLE;
                         }
diff --git a/cpp/src/reader/tsfile_reader.cc b/cpp/src/reader/tsfile_reader.cc
index 0f66fe18..045dc818 100644
--- a/cpp/src/reader/tsfile_reader.cc
+++ b/cpp/src/reader/tsfile_reader.cc
@@ -134,7 +134,7 @@ int TsFileReader::query_table_on_tree(
     }
     std::vector<std::string> columns_names(max_len);
     for (int i = 0; i < max_len; i++) {
-        columns_names.push_back("L_" + std::to_string(i));
+        columns_names[i] = "L_" + std::to_string(i);
     }
     Filter* time_filter = new TimeBetween(star_time, end_time, false);
     ret = table_query_executor_->query_on_tree(device_ids, columns_names, 
measurement_names, time_filter, result_set);

Reply via email to