761417898 commented on code in PR #522: URL: https://github.com/apache/tsfile/pull/522#discussion_r2163247750
########## cpp/src/file/tsfile_io_reader.cc: ########## @@ -223,15 +223,52 @@ int TsFileIOReader::load_timeseries_index_for_ssi( if (RET_FAIL(load_device_index_entry( std::make_shared<DeviceIDComparable>(device_id), device_index_entry, device_ie_end_offset))) { - } else if (RET_FAIL(load_measurement_index_entry( - measurement_name, device_index_entry->get_offset(), - device_ie_end_offset, measurement_index_entry, + return ret; + } + auto& pa = ssi->timeseries_index_pa_; + + int start_offset = device_index_entry->get_offset(), end_offset = + device_ie_end_offset; + ASSERT(start_offset < end_offset); + const int32_t read_size = end_offset - start_offset; + int32_t ret_read_len = 0; + char* data_buf = (char*)pa.alloc(read_size); + void* m_idx_node_buf = pa.alloc(sizeof(MetaIndexNode)); + if (IS_NULL(data_buf) || IS_NULL(m_idx_node_buf)) { + return E_OOM; + } + auto* top_node_ptr = new(m_idx_node_buf) MetaIndexNode(&pa); + auto top_node = std::shared_ptr<MetaIndexNode>( + top_node_ptr, MetaIndexNode::self_deleter); + + if (RET_FAIL(read_file_->read(start_offset, data_buf, read_size, + ret_read_len))) { + } else if (RET_FAIL(top_node->deserialize_from(data_buf, read_size))) { + } Review Comment: Memory is managed by SingleDeviceTsBlockReader.PageArena and freed upon SingleDeviceTsBlockReader destruction ########## cpp/src/file/tsfile_io_reader.cc: ########## @@ -223,15 +223,52 @@ int TsFileIOReader::load_timeseries_index_for_ssi( if (RET_FAIL(load_device_index_entry( std::make_shared<DeviceIDComparable>(device_id), device_index_entry, device_ie_end_offset))) { - } else if (RET_FAIL(load_measurement_index_entry( - measurement_name, device_index_entry->get_offset(), - device_ie_end_offset, measurement_index_entry, + return ret; + } + auto& pa = ssi->timeseries_index_pa_; + + int start_offset = device_index_entry->get_offset(), end_offset = + device_ie_end_offset; + ASSERT(start_offset < end_offset); + const int32_t read_size = end_offset - start_offset; + int32_t ret_read_len = 0; + char* data_buf = (char*)pa.alloc(read_size); + void* m_idx_node_buf = pa.alloc(sizeof(MetaIndexNode)); + if (IS_NULL(data_buf) || IS_NULL(m_idx_node_buf)) { + return E_OOM; + } Review Comment: Memory is managed by SingleDeviceTsBlockReader.PageArena and freed upon SingleDeviceTsBlockReader destruction -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@tsfile.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org