This is an automated email from the ASF dual-hosted git repository.
colinlee pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new 87c02d84 Remove unused code (#725)
87c02d84 is described below
commit 87c02d84ab8af501de9bbb96fb3f5f72db1e1035
Author: Colin Lee <[email protected]>
AuthorDate: Mon Feb 23 18:15:07 2026 +0800
Remove unused code (#725)
---
cpp/src/common/config/config.h | 6 -
cpp/src/common/tsfile_common.h | 15 --
cpp/src/common/tsfile_mgr.cc | 139 ------------------
cpp/src/common/tsfile_mgr.h | 95 ------------
cpp/src/file/open_file.cc | 112 --------------
cpp/src/file/open_file.h | 137 -----------------
cpp/src/file/tsfile_io_writer.cc | 30 ----
cpp/src/file/tsfile_io_writer.h | 14 --
cpp/src/file/write_file.cc | 13 --
cpp/src/file/write_file.h | 18 +--
cpp/src/reader/scan_iterator.cc | 260 ---------------------------------
cpp/src/reader/scan_iterator.h | 193 ------------------------
cpp/src/utils/db_utils.h | 116 ---------------
cpp/src/utils/storage_utils.h | 8 -
cpp/test/common/tsblock/tslock_test.cc | 1 -
cpp/test/common/tsfile_common_test.cc | 1 -
cpp/test/file/open_file_test.cc | 108 --------------
cpp/test/utils/db_utils_test.cc | 93 ------------
18 files changed, 2 insertions(+), 1357 deletions(-)
diff --git a/cpp/src/common/config/config.h b/cpp/src/common/config/config.h
index e18f6d9c..0f192c8d 100644
--- a/cpp/src/common/config/config.h
+++ b/cpp/src/common/config/config.h
@@ -24,12 +24,6 @@
#include "utils/db_utils.h"
namespace common {
-enum ConfigLevel {
- INIT, // Unchangeable, initialized during database init
- RESTART, // Can be changed, but the database must be restarted to take
- // effect
- USERSET // Session level update
-};
typedef struct ConfigValue {
uint32_t
diff --git a/cpp/src/common/tsfile_common.h b/cpp/src/common/tsfile_common.h
index 39cd027e..d12c6ed8 100644
--- a/cpp/src/common/tsfile_common.h
+++ b/cpp/src/common/tsfile_common.h
@@ -48,8 +48,6 @@ extern const char ONLY_ONE_PAGE_CHUNK_HEADER_MARKER;
extern const char SEPARATOR_MARKER;
extern const char OPERATION_INDEX_RANGE;
-typedef int64_t TsFileID;
-
// TODO review the String.len_ used
// Note, in tsfile_io_writer, we just writer fields of PageHeader
@@ -340,7 +338,6 @@ class TimeseriesIndex : public ITimeseriesIndex {
: timeseries_meta_type_((char)255),
chunk_meta_list_data_size_(0),
measurement_name_(),
- ts_id_(),
data_type_(common::INVALID_DATATYPE),
statistic_(nullptr),
statistic_from_pa_(false),
@@ -359,7 +356,6 @@ class TimeseriesIndex : public ITimeseriesIndex {
timeseries_meta_type_ = 0;
chunk_meta_list_data_size_ = 0;
measurement_name_.reset();
- ts_id_.reset();
data_type_ = common::VECTOR;
chunk_meta_list_serialized_buf_.reset();
if (statistic_ != nullptr && !statistic_from_pa_) {
@@ -405,8 +401,6 @@ class TimeseriesIndex : public ITimeseriesIndex {
return common::E_OK;
}
virtual Statistic* get_statistic() const { return statistic_; }
- common::TsID get_ts_id() const { return ts_id_; }
-
FORCE_INLINE void finish() {
chunk_meta_list_data_size_ =
chunk_meta_list_serialized_buf_.total_size();
@@ -480,7 +474,6 @@ class TimeseriesIndex : public ITimeseriesIndex {
int ret = common::E_OK;
timeseries_meta_type_ = that.timeseries_meta_type_;
chunk_meta_list_data_size_ = that.chunk_meta_list_data_size_;
- ts_id_ = that.ts_id_;
data_type_ = that.data_type_;
statistic_ = StatisticFactory::alloc_statistic_with_pa(data_type_, pa);
@@ -523,7 +516,6 @@ class TimeseriesIndex : public ITimeseriesIndex {
os << "{meta_type=" << (int)tsi.timeseries_meta_type_
<< ", chunk_meta_list_data_size=" << tsi.chunk_meta_list_data_size_
<< ", measurement_name=" << tsi.measurement_name_
- << ", ts_id=" << tsi.ts_id_.to_string()
<< ", data_type=" << common::get_data_type_name(tsi.data_type_)
<< ", statistic=" << tsi.statistic_->to_string();
@@ -556,7 +548,6 @@ class TimeseriesIndex : public ITimeseriesIndex {
// std::string measurement_name_;
common::String measurement_name_;
- common::TsID ts_id_;
common::TSDataType data_type_;
/*
@@ -1134,11 +1125,5 @@ struct TsFileMeta {
#endif
};
-// Timeseries ID and its [start_time, end_time] in a tsfile
-struct TimeseriesTimeIndexEntry {
- common::TsID ts_id_;
- TimeRange time_range_;
-};
-
} // end namespace storage
#endif // COMMON_TSFILE_COMMON_H
diff --git a/cpp/src/common/tsfile_mgr.cc b/cpp/src/common/tsfile_mgr.cc
deleted file mode 100644
index 6b3f9f45..00000000
--- a/cpp/src/common/tsfile_mgr.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.
- */
-
-#include "tsfile_mgr.h"
-
-#include <algorithm> // std::sort
-#include <iomanip>
-#include <iostream>
-
-#include "utils/errno_define.h"
-
-using namespace common;
-
-namespace storage {
-
-TsFileMgr& TsFileMgr::get_instance() {
- static TsFileMgr g_s_tsfile_mgr;
- return g_s_tsfile_mgr;
-}
-
-int TsFileMgr::init() {
- int ret = E_OK;
- return ret;
-}
-
-// used when recover
-int TsFileMgr::add_new_file(const std::string& file_path) {
- int ret = E_OK;
- MutexGuard mg(all_open_files_mutex_);
- // TODO
- return ret;
-}
-
-int TsFileMgr::add_new_file(const FileID& file_id, OpenFile* open_file) {
- MutexGuard mg(all_open_files_mutex_);
- AllOpenFileMapIter find_iter = all_open_files_.find(file_id);
- if (find_iter != all_open_files_.end()) {
- return E_ALREADY_EXIST;
- }
- std::pair<FileID, OpenFile*> pair;
- pair.first = file_id;
- pair.second = open_file;
- std::pair<AllOpenFileMapIter, bool> ins_res = all_open_files_.insert(pair);
- if (!ins_res.second) {
- ASSERT(false);
- }
- version_++;
- return E_OK;
-}
-
-/*
- * Currently, we only allow sequence data writing,
- * So we have only one DataRun returned.
- */
-int TsFileMgr::get_files_for_query(const TsID& ts_id,
- const TimeFilter* time_filter,
- DataRun* ret_data_run,
- int64_t& ret_version) {
- int ret = E_OK;
-
- // Step 1: get all tsfiles that contain this ts_id, store them in
tsfile_vec
- std::vector<TimeRangeOpenFilePair> tsfile_vec;
-
- all_open_files_mutex_.lock();
- for (AllOpenFileMapIter iter = all_open_files_.begin();
- iter != all_open_files_.end() && IS_SUCC(ret); iter++) {
- OpenFile* open_file = iter->second;
- TimeRange time_range;
- int tmp_ret = open_file->get_time_range(ts_id, time_range);
- if (tmp_ret == E_OK) {
- if (time_range_stasify(time_filter, time_range)) {
- TimeRangeOpenFilePair pair;
- pair.open_file_ = open_file;
- pair.time_range_ = time_range;
- tsfile_vec.push_back(pair);
- }
- } else if (tmp_ret == E_NOT_EXIST) {
- // continue next
- } else {
- ret = tmp_ret;
- // log_err("get time range for ts_id error, ret=%d, ts_id=%s", ret,
- // ts_id.to_string().c_str());
- }
- } // end for
- ret_version = version_;
- all_open_files_mutex_.unlock();
-
- // Step 2: since we have only one DataRun, sort these tsfiles
- std::sort(tsfile_vec.begin(), tsfile_vec.end(),
- compare_timerange_openfile_pair);
-
- // Step 3: wrap them as DataRun
- for (size_t i = 0; i < tsfile_vec.size() && IS_SUCC(ret); i++) {
- merge_time_range(ret_data_run->time_range_, tsfile_vec[i].time_range_);
- ret = ret_data_run->tsfile_list_.push_back(tsfile_vec[i].open_file_);
- }
- return ret;
-}
-
-bool TsFileMgr::time_range_stasify(const TimeFilter* time_filter,
- const TimeRange& time_range) {
- // TODO
- UNUSED(time_filter);
- UNUSED(time_range);
- return true;
-}
-
-#ifndef NDEBUG
-void TsFileMgr::DEBUG_dump(const char* tag) {
- MutexGuard mg(all_open_files_mutex_);
- AllOpenFileMapIter it;
- std::cout << tag << "Dump TsFileMgr Start" << std::endl;
- int count = 0;
- for (it = all_open_files_.begin(); it != all_open_files_.end(); it++) {
- std::cout << tag << "Dump TsFileMgr:\n [" << std::setw(3)
- << std::setfill(' ') << count << "]\n file_id=" << it->first
- << "\n open_file=" << *it->second;
- }
- std::cout << tag << "Dump TsFileMgr End" << std::endl;
-}
-#endif
-
-} // end namespace storage
\ No newline at end of file
diff --git a/cpp/src/common/tsfile_mgr.h b/cpp/src/common/tsfile_mgr.h
deleted file mode 100644
index 5dac4e36..00000000
--- a/cpp/src/common/tsfile_mgr.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef COMMON_TSFILE_MGR_H
-#define COMMON_TSFILE_MGR_H
-
-#include "common/db_common.h"
-#include "common/mutex/mutex.h"
-#include "reader/scan_iterator.h"
-
-namespace storage {
-
-// TODO use header file instead
-class TimeFilter;
-
-struct TimeRangeOpenFilePair {
- TimeRange time_range_;
- OpenFile* open_file_;
-};
-
-FORCE_INLINE bool compare_timerange_openfile_pair(
- const TimeRangeOpenFilePair& x, const TimeRangeOpenFilePair& y) {
- return x.time_range_.start_time_ < y.time_range_.start_time_;
-}
-
-FORCE_INLINE void merge_time_range(TimeRange& dest, const TimeRange& src) {
- dest.start_time_ = UTIL_MIN(dest.start_time_, src.start_time_);
- dest.end_time_ = UTIL_MAX(dest.end_time_, src.end_time_);
-}
-
-class TsFileMgr {
- public:
- typedef std::map<common::FileID, OpenFile*> AllOpenFileMap;
- typedef AllOpenFileMap::iterator AllOpenFileMapIter;
-
- public:
- TsFileMgr() : all_open_files_(), version_(0), all_open_files_mutex_() {}
- static TsFileMgr& get_instance();
- int init();
- void destroy() { all_open_files_.clear(); }
-
- int add_new_file(const std::string& file_path);
- int add_new_file(const common::FileID& file_id, OpenFile* open_file);
-
- // int get_files_for_query(const common::TsID &ts_id,
- // const TimeFilter &time_filter,
- // common::SimpleList<DataRun> &ret_data_runs);
- int get_files_for_query(const common::TsID& ts_id,
- const TimeFilter* time_filter,
- DataRun* ret_data_run, int64_t& ret_version);
- int64_t get_version() {
- common::MutexGuard mg(all_open_files_mutex_);
- return version_;
- }
-
-#ifndef NDEBUG
- void DEBUG_dump(const char* tag);
-#endif
-
- private:
- bool time_range_stasify(const TimeFilter* time_filter,
- const TimeRange& time_range);
-
- private:
- // Map<file_path, OpenFile>
- AllOpenFileMap all_open_files_;
- int64_t version_;
- common::Mutex all_open_files_mutex_;
-};
-
-#ifndef NDEBUG
-#define DUMP_TSFILE_MGR(tag) TsFileMgr::get_instance().DEBUG_dump(tag)
-#else
-#define DUMP_TSFILE_MGR(tag) (void)
-#endif
-
-} // namespace storage
-
-#endif // COMMON_TSFILE_MGR_H
diff --git a/cpp/src/file/open_file.cc b/cpp/src/file/open_file.cc
deleted file mode 100644
index 1fe5a368..00000000
--- a/cpp/src/file/open_file.cc
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.
- */
-
-#include "open_file.h"
-
-using namespace common;
-
-namespace storage {
-
-int OpenFile::init() {
- void* buf = mem_alloc(sizeof(TsTimeRangeMap), MOD_OPEN_FILE_OBJ);
- fd_ = -1;
- if (IS_NULL(buf)) {
- return E_OOM;
- }
- ts_time_range_map_ = new (buf) TsTimeRangeMap;
- return E_OK;
-}
-
-void OpenFile::reset() {
- MutexGuard mg(mutex_);
- if (ts_time_range_map_ != nullptr) {
- ts_time_range_map_->clear();
- mem_free(ts_time_range_map_);
- ts_time_range_map_ = nullptr;
- }
- if (bloom_filter_ != nullptr) {
- mem_free(bloom_filter_);
- bloom_filter_ = nullptr;
- }
-}
-
-void OpenFile::set_file_id_and_path(const FileID& file_id,
- const std::string& file_path) {
- ASSERT(file_id.is_valid());
- file_id_ = file_id;
- file_path_ = file_path;
-}
-
-int OpenFile::build_from(
- const std::vector<TimeseriesTimeIndexEntry>& time_index_vec) {
- MutexGuard mg(mutex_);
- ASSERT(ts_time_range_map_ != nullptr);
- for (size_t i = 0; i < time_index_vec.size(); i++) {
- const TimeseriesTimeIndexEntry& ti_entry = time_index_vec[i];
- std::pair<TsID, TimeRange> pair;
- pair.first = ti_entry.ts_id_;
- pair.second = ti_entry.time_range_;
- std::pair<TsTimeRangeMapIterator, bool> ins_res =
- ts_time_range_map_->insert(pair);
- if (!ins_res.second) {
- return E_OOM;
- }
- }
- return E_OK;
-}
-
-int OpenFile::add(const TsID& ts_id, const TimeRange& time_range) {
- MutexGuard mg(mutex_);
- TsTimeRangeMapIterator find_iter = ts_time_range_map_->find(ts_id);
- if (find_iter != ts_time_range_map_->end()) {
- ASSERT(false);
- return E_ALREADY_EXIST;
- }
-
- std::pair<TsID, TimeRange> pair;
- pair.first = ts_id;
- pair.second = time_range;
- std::pair<TsTimeRangeMapIterator, bool> ins_res =
- ts_time_range_map_->insert(pair);
- if (!ins_res.second) {
- return E_OOM;
- }
- return E_OK;
-}
-
-bool OpenFile::contain_timeseries(const TsID& ts_id) const {
- MutexGuard mg(mutex_);
- TsTimeRangeMapIterator find_iter = ts_time_range_map_->find(ts_id);
- return find_iter != ts_time_range_map_->end();
-}
-
-int OpenFile::get_time_range(const TsID& ts_id,
- TimeRange& ret_time_range) const {
- int ret = E_OK;
- MutexGuard mg(mutex_);
- TsTimeRangeMapIterator find_iter = ts_time_range_map_->find(ts_id);
- if (find_iter == ts_time_range_map_->end()) {
- ret = E_NOT_EXIST;
- } else {
- ret_time_range = find_iter->second;
- }
- return ret;
-}
-
-} // end namespace storage
diff --git a/cpp/src/file/open_file.h b/cpp/src/file/open_file.h
deleted file mode 100644
index 7b42ff95..00000000
--- a/cpp/src/file/open_file.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef FILE_OPEN_FILE_H
-#define FILE_OPEN_FILE_H
-
-#include <map>
-#include <vector>
-
-#include "common/container/list.h"
-#include "common/mutex/mutex.h"
-#include "common/tsfile_common.h"
-#include "reader/bloom_filter.h"
-#include "utils/storage_utils.h"
-
-namespace storage {
-
-/*
- * Data of a TSStore consist of:
- * - some tsfiles
- * - some immutable tvlists
- * - the active tvlist.
- *
- * When some immutable tvlists are flushed into tsfile, we
- * should guarantee that we have a consisteny view of TSStore
- * data. That means we should see one and only one of the
- * flushed immutable tvlist or the corresponding tsfile.
- * Otherwise, we may see duplicated data in the immutable tvlist
- * and the tsfile, or we may lose the data if we see neither
- * of them.
- * So we should do the following steps atomically:
- * - remove the immutable tvlist from tsstore
- * - make it visible in tsfile_mgr
- */
-
-// opened tsfile
-class OpenFile {
- public:
- // maybe use sorted array instead of map.
- typedef std::map<common::TsID, TimeRange> TsTimeRangeMap;
- typedef std::map<common::TsID, TimeRange>::iterator TsTimeRangeMapIterator;
-
- public:
- OpenFile()
- : file_id_(),
- file_path_(),
- fd_(-1),
- bloom_filter_(nullptr),
- ts_time_range_map_(nullptr),
- mutex_() {}
- int init();
- // reset the map to reclaim memory
- void reset();
-
- void set_file_id_and_path(const common::FileID& file_id,
- const std::string& file_path);
- FORCE_INLINE common::FileID get_file_id() { return file_id_; }
- FORCE_INLINE std::string get_file_path() { return file_path_; }
- int build_from(const std::vector<TimeseriesTimeIndexEntry>&
time_index_vec);
- int add(const common::TsID& ts_id, const TimeRange& time_range);
-
- bool contain_timeseries(const common::TsID& ts_id) const;
- int get_time_range(const common::TsID& ts_id,
- TimeRange& ret_time_range) const;
-
-#ifndef NDEBUG
- friend std::ostream& operator<<(std::ostream& out, OpenFile& open_file) {
- out << "file_id=" << open_file.file_id_
- << ", file_path=" << open_file.file_path_
- << ", fd=" << open_file.fd_ << ", ts_time_range_map=";
- if (open_file.ts_time_range_map_ == nullptr) {
- out << "nil" << std::endl;
- } else {
- TsTimeRangeMapIterator it;
- out << std::endl;
- for (it = open_file.ts_time_range_map_->begin();
- it != open_file.ts_time_range_map_->end();
- it++) { // cppcheck-suppress postfixOperator
- out << "{ts_id=" << it->first.to_string()
- << ", ts_time_range={start_time=" << it->second.start_time_
- << ", end_time=" << it->second.end_time_ << "}}";
- }
- }
- return out;
- }
-#endif
-
- private:
- common::FileID file_id_;
- std::string file_path_;
- int fd_;
- /*
- * Why use pointer instead of object:
- * we may want to reclaim the memory in case of memory overused.
- */
- BloomFilter* bloom_filter_;
- TsTimeRangeMap*
- ts_time_range_map_; // TODO: use custom hashtable to monitor memory.
- mutable common::Mutex mutex_;
-};
-
-class OpenFileFactory {
- public:
- static OpenFile* alloc() {
- void* buf =
- common::mem_alloc(sizeof(OpenFile), common::MOD_OPEN_FILE_OBJ);
- if (IS_NULL(buf)) {
- return nullptr;
- }
- return new (buf) OpenFile;
- }
-
- static void free(OpenFile* of) {
- if (of != nullptr) {
- common::mem_free(of);
- }
- }
-};
-
-} // end namespace storage
-#endif // FILE_OPEN_FILE_H
diff --git a/cpp/src/file/tsfile_io_writer.cc b/cpp/src/file/tsfile_io_writer.cc
index d6888086..200ab84f 100644
--- a/cpp/src/file/tsfile_io_writer.cc
+++ b/cpp/src/file/tsfile_io_writer.cc
@@ -40,26 +40,6 @@ namespace storage {
#define OFFSET_DEBUG(msg) void(msg)
#endif
-#ifndef LIBTSFILE_SDK
-int TsFileIOWriter::init() {
- int ret = E_OK;
- const uint32_t page_size = 1024;
- meta_allocator_.init(page_size, MOD_TSFILE_WRITER_META);
- chunk_meta_count_ = 0;
- file_ = new WriteFile;
- write_file_created_ = true;
-
- FileID file_id;
- file_id.seq_ = get_cur_timestamp();
- file_id.version_ = 0;
- file_id.merge_ = 0;
- if (RET_FAIL(file_->create(file_id, O_RDWR | O_CREAT, 0644))) {
- // log_err("file open error, ret=%d", ret);
- }
- return ret;
-}
-#endif
-
int TsFileIOWriter::init(WriteFile* write_file) {
int ret = E_OK;
const uint32_t page_size = 1024;
@@ -876,14 +856,4 @@ int TsFileIOWriter::flush_stream_to_file() {
return ret;
}
-void TsFileIOWriter::add_ts_time_index_entry(TimeseriesIndex& ts_index) {
- TimeseriesTimeIndexEntry time_index_entry;
- time_index_entry.ts_id_ = ts_index.get_ts_id();
- time_index_entry.time_range_.start_time_ =
- ts_index.get_statistic()->start_time_;
- time_index_entry.time_range_.end_time_ =
- ts_index.get_statistic()->end_time_;
- ts_time_index_vector_.push_back(time_index_entry);
-}
-
} // namespace storage
diff --git a/cpp/src/file/tsfile_io_writer.h b/cpp/src/file/tsfile_io_writer.h
index 901b2a5b..a7d0a140 100644
--- a/cpp/src/file/tsfile_io_writer.h
+++ b/cpp/src/file/tsfile_io_writer.h
@@ -70,7 +70,6 @@ class TsFileIOWriter {
use_prev_alloc_cgm_(false),
cur_device_name_(),
file_(nullptr),
- ts_time_index_vector_(),
write_file_created_(false),
generate_table_schema_(false),
schema_(std::make_shared<Schema>()) {
@@ -86,11 +85,6 @@ class TsFileIOWriter {
}
}
~TsFileIOWriter() { destroy(); }
-
-#ifndef LIBTSFILE_SDK
- int init();
- FORCE_INLINE common::FileID get_file_id() { return file_->get_file_id(); }
-#endif
int init(WriteFile* write_file);
void destroy();
@@ -112,10 +106,6 @@ class TsFileIOWriter {
int end_flush_chunk_group(bool is_aligned = false);
int end_file();
- FORCE_INLINE std::vector<TimeseriesTimeIndexEntry>&
- get_ts_time_index_vector() {
- return ts_time_index_vector_;
- }
FORCE_INLINE std::string get_file_path() { return file_->get_file_path(); }
FORCE_INLINE std::shared_ptr<Schema> get_schema() { return schema_; }
@@ -194,9 +184,6 @@ class TsFileIOWriter {
int init_bloom_filter(BloomFilter& filter);
int32_t get_path_count(common::SimpleList<ChunkGroupMeta*>& cgm_list);
- // for open file
- void add_ts_time_index_entry(TimeseriesIndex& ts_index);
-
private:
common::PageArena meta_allocator_;
common::ByteStream write_stream_;
@@ -208,7 +195,6 @@ class TsFileIOWriter {
bool use_prev_alloc_cgm_; // chunk group meta
std::shared_ptr<IDeviceID> cur_device_name_;
WriteFile* file_;
- std::vector<TimeseriesTimeIndexEntry> ts_time_index_vector_;
bool write_file_created_;
bool generate_table_schema_;
std::shared_ptr<Schema> schema_;
diff --git a/cpp/src/file/write_file.cc b/cpp/src/file/write_file.cc
index 004a3e9d..d8a17aa5 100644
--- a/cpp/src/file/write_file.cc
+++ b/cpp/src/file/write_file.cc
@@ -39,19 +39,6 @@ using namespace common;
namespace storage {
-#ifndef LIBTSFILE_SDK
-int WriteFile::create(const FileID& file_id, int flags, mode_t mode) {
- if (fd_ > 0) {
- // log_err("file already opened, fd=%d", fd_);
- ASSERT(false);
- return E_ALREADY_EXIST;
- }
- file_id_ = file_id;
- path_ = get_file_path_from_file_id(file_id_);
- return do_create(flags, mode);
-}
-#endif
-
int WriteFile::create(const std::string& file_path, int flags, mode_t mode) {
if (fd_ > 0) {
// log_err("file already opened, fd=%d", fd_);
diff --git a/cpp/src/file/write_file.h b/cpp/src/file/write_file.h
index 1c1f8511..6b5a506a 100644
--- a/cpp/src/file/write_file.h
+++ b/cpp/src/file/write_file.h
@@ -22,39 +22,25 @@
#include <string>
-#include "utils/util_define.h"
-#ifndef LIBTSFILE_SDK
#include "utils/storage_utils.h"
-#endif
+#include "utils/util_define.h"
namespace storage {
class WriteFile {
public:
-#ifndef LIBTSFILE_SDK
- WriteFile() : path_(), file_id_(), fd_(-1) {}
- FORCE_INLINE common::FileID get_file_id() const { return file_id_; }
- FORCE_INLINE int get_fd() const { return fd_; }
- int create(const common::FileID& file_id, int flags, mode_t mode);
-#else
WriteFile() : path_(), fd_(-1) {}
-#endif
int create(const std::string& file_name, int flags, mode_t mode);
bool file_opened() const { return fd_ > 0; }
int write(const char* buf, uint32_t len);
- // int flush() { return common::E_OK; } // TODO
+ FORCE_INLINE int get_fd() const { return fd_; }
int sync();
int close();
FORCE_INLINE std::string get_file_path() { return path_; }
private:
int do_create(int flags, mode_t mode);
-
- private:
std::string path_;
-#ifndef LIBTSFILE_SDK
- common::FileID file_id_;
-#endif
int fd_;
};
diff --git a/cpp/src/reader/scan_iterator.cc b/cpp/src/reader/scan_iterator.cc
deleted file mode 100644
index 2d1d66fd..00000000
--- a/cpp/src/reader/scan_iterator.cc
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * 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.
- */
-
-#include "scan_iterator.h"
-
-using namespace common;
-
-namespace storage {
-
-int DataRun::remove_tsfile(const FileID& to_remove) {
- ASSERT(run_type_ == DRT_TSFILE);
- int ret = E_OK;
-
- SimpleList<OpenFile*>::Iterator it = tsfile_list_.begin();
- OpenFile* of = nullptr;
- for (; it != tsfile_list_.end(); it++) {
- OpenFile* cur = it.get();
- if (cur->get_file_id() == to_remove) {
- of = cur;
- break;
- }
- }
- if (of != nullptr) {
- ret = tsfile_list_.remove(of);
- }
- return ret;
-}
-
-int DataRun::get_next(TsBlock* ret_block, TimeRange& ret_time_range,
- bool alloc_tsblock) {
- if (run_type_ == DRT_TVLIST) {
- return tvlist_get_next(ret_block, ret_time_range, alloc_tsblock);
- } else {
- ASSERT(run_type_ == DRT_TSFILE);
- return tsfile_get_next(ret_block, ret_time_range, alloc_tsblock);
- }
-}
-
-TsBlock* DataRun::alloc_tsblock() {
- tuple_desc_.reset();
- // TODO default config of time_cd
- tuple_desc_.push_back(g_time_column_schema);
- tuple_desc_.push_back(*col_schema_);
- return (new TsBlock(&tuple_desc_));
-}
-
-int DataRun::tvlist_get_next(TsBlock* ret_block, TimeRange& ret_time_range,
- bool tsblock) {
- // TODO @tsblock
- int ret = E_OK;
- if (UNLIKELY(!tvlist_list_iter_.is_inited())) {
- tvlist_list_iter_ = tvlist_list_.begin();
- }
-
- while (true) {
- if (tvlist_list_iter_ == tvlist_list_.end()) {
- return E_NO_MORE_DATA;
- } else {
- SeqTVListBase* tvlist_base = tvlist_list_iter_.get();
- if (!tvlist_base->is_immutable()) {
- tvlist_base->lock();
- }
- ret = fill_tsblock_from_tvlist(tvlist_base, ret_block,
- ret_time_range);
- if (ret == E_NO_MORE_DATA) {
- ret = E_OK;
- }
- if (!tvlist_base->is_immutable()) {
- tvlist_base->unlock();
- }
- tvlist_list_iter_++;
- return ret;
- }
- }
- return ret;
-}
-
-int DataRun::fill_tsblock_from_tvlist(SeqTVListBase* tvlist, TsBlock*
ret_block,
- TimeRange& ret_time_range) {
- int ret = E_OK;
- switch (col_schema_->data_type_) {
- case common::BOOLEAN:
- ret = fill_tsblock_from_typed_tvlist<bool>(tvlist, ret_block,
- ret_time_range);
- break;
- case common::INT32:
- ret = fill_tsblock_from_typed_tvlist<int32_t>(tvlist, ret_block,
- ret_time_range);
- break;
- case common::INT64:
- ret = fill_tsblock_from_typed_tvlist<int64_t>(tvlist, ret_block,
- ret_time_range);
- break;
- case common::FLOAT:
- ret = fill_tsblock_from_typed_tvlist<float>(tvlist, ret_block,
- ret_time_range);
- break;
- case common::DOUBLE:
- ret = fill_tsblock_from_typed_tvlist<double>(tvlist, ret_block,
- ret_time_range);
- break;
- default:
- ASSERT(false);
- break;
- }
- return ret;
-}
-
-template <typename T>
-int DataRun::fill_tsblock_from_typed_tvlist(SeqTVListBase* tvlist,
- TsBlock* ret_block,
- TimeRange& ret_time_range) {
- int ret = E_OK;
-
- SeqTVList<T>* typed_tvlist = static_cast<SeqTVList<T>*>(tvlist);
- typename SeqTVList<T>::Iterator it;
- it = typed_tvlist->scan_without_lock();
- typename SeqTVList<T>::TV tv;
-
- // FIXME do not append all tvlist data into tsblock in one time.
- ret_time_range.start_time_ = typed_tvlist->time_at(0);
- RowAppender row_appender(ret_block);
-#ifndef NDEBUG
- int count = 0;
-#endif
- while (E_OK == (ret = it.next(tv))) {
- ret_time_range.end_time_ = tv.time_;
-#ifndef NDEBUG
- std::cout << "DataRun::fill_tsblock_from_typed_tvlist: [" << count
- << "] = <" << tv.time_ << ", " << tv.value_ << ">"
- << std::endl;
-#endif
- row_appender.add_row();
- row_appender.append(0, reinterpret_cast<char*>(&tv.time_),
- sizeof(tv.time_));
- row_appender.append(1, reinterpret_cast<char*>(&tv.value_),
- sizeof(tv.value_));
- }
- return ret;
-}
-
-int DataRun::reinit_io_reader(SimpleList<OpenFile*>::Iterator& it,
- common::PageArena* pa) {
- int ret = E_OK;
- // maybe io_reader_ destroy before re-init
- OpenFile* open_file = it.get();
- io_reader_.reset();
- if (RET_FAIL(io_reader_.init(open_file->get_file_path()))) {
- ////log_err("io_reader init error, ret=%d, file_path=%s",
- // ret, open_file->get_file_path().c_str());
- } else {
- std::shared_ptr<IDeviceID> device_id =
- std::make_shared<StringArrayDeviceID>(
- col_schema_->get_device_name_str());
- std::string measurement_name = col_schema_->get_measurement_name_str();
- if (ssi_ != nullptr) {
- delete ssi_;
- ssi_ = nullptr;
- }
- if (RET_FAIL(
- io_reader_.alloc_ssi(device_id, measurement_name, ssi_, *pa)))
{
- }
- }
- return ret;
-}
-
-int DataRun::tsfile_get_next(TsBlock* ret_tsblock, TimeRange& ret_time_range,
- bool alloc_tsblock) {
- int ret = E_OK;
- if (UNLIKELY(!tsfile_list_iter_.is_inited())) {
- tsfile_list_iter_ = tsfile_list_.begin();
- if (tsfile_list_iter_ == tsfile_list_.end()) { // all file iterated
- ret = E_NO_MORE_DATA;
- } else if (RET_FAIL(reinit_io_reader(tsfile_list_iter_))) {
- }
- }
-
- if (IS_SUCC(ret)) {
- // ret = io_reader_.get_next(*col_desc_, ret_tsblock, ret_time_range);
- ret = ssi_->get_next(ret_tsblock, alloc_tsblock);
- if (E_NO_MORE_DATA == ret) { // current file reach end
- tsfile_list_iter_++;
- if (tsfile_list_iter_ == tsfile_list_.end()) { // all file
iterated
- ret = E_NO_MORE_DATA;
- } else if (RET_FAIL(reinit_io_reader(tsfile_list_iter_))) {
- }
- }
- }
- return ret;
-}
-
-DataRun* DataScanIterator::alloc_data_run(DataRunType run_type) {
- void* buf = page_arena_.alloc(sizeof(DataRun));
- if (IS_NULL(buf)) {
- return nullptr;
- }
- return (new (buf) DataRun(run_type, &col_schema_, &page_arena_));
-}
-
-#ifndef NDEBUG
-void DataScanIterator::DEBUG_dump_data_run_list() {
- SimpleList<DataRun*>::Iterator it;
- std::cout << "\n/---- DEBUG_dump_data_run_list: size="
- << data_run_list_.size() << "----\\" << std::endl;
- int idx = 0;
- for (it = data_run_list_.begin(); it != data_run_list_.end(); it++) {
- std::cout << "[" << (idx++) << "]" << *it.get() << std::endl;
- }
- std::cout << "\\---- DEBUG_dump_data_run_list: size="
- << data_run_list_.size() << "----/\n"
- << std::endl;
-}
-#endif
-
-int DataScanIterator::get_next(TsBlock* ret_block, bool alloc_tsblock) {
-#ifndef NDEBUG
- DEBUG_dump_data_run_list();
-#endif
- int ret = E_OK;
-
- if (UNLIKELY(!cursor_.is_inited())) {
- cursor_ = data_run_list_.begin();
- }
-
- while (true) {
- TimeRange time_range;
- DataRun* data_run = cursor_.get();
- ret = data_run->get_next(ret_block, time_range, alloc_tsblock);
- if (ret == E_OK) {
- return ret;
- } else if (ret == E_NO_MORE_DATA) {
- cursor_++;
- if (cursor_ == data_run_list_.end()) {
- return E_NO_MORE_DATA;
- }
- } else {
- // log_err("data run get next batch error, ret=%d", ret);
- break;
- }
- }
- return ret;
-}
-
-} // end namespace storage
\ No newline at end of file
diff --git a/cpp/src/reader/scan_iterator.h b/cpp/src/reader/scan_iterator.h
deleted file mode 100644
index 8769624f..00000000
--- a/cpp/src/reader/scan_iterator.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef READER_SCAN_ITERATOR_H
-#define READER_SCAN_ITERATOR_H
-
-#include <stdint.h>
-
-#include "common/container/list.h"
-#include "common/seq_tvlist.h"
-#include "common/tsblock/tsblock.h"
-#include "file/open_file.h"
-#include "file/tsfile_io_reader.h"
-#include "utils/db_utils.h"
-#include "utils/storage_utils.h"
-
-namespace storage {
-
-enum DataRunType {
- DRT_TVLIST = 0,
- DRT_TSFILE = 1,
- DRT_INVALID = 2,
-};
-
-/*
- * All KV range are sorted within one DataRun.
- * KV ranges in different runs may overlap with each other.
- *
- * One or more SeqTVLists are a DataRun,
- * One or more TsFileReader are a DataRun.
- */
-class DataRun {
- public:
- DataRun(DataRunType run_type, common::ColumnSchema* col_schema,
- common::PageArena* pa)
- : run_type_(run_type),
- col_schema_(col_schema),
- time_range_(),
- tvlist_list_(pa),
- tvlist_list_iter_(),
- tsfile_list_(pa),
- tsfile_list_iter_(),
- io_reader_(),
- ssi_(nullptr),
- tuple_desc_() {}
-
- int get_next(common::TsBlock* ret_block, TimeRange& ret_time_range,
- bool alloc);
-
- const char* get_data_run_type_name(DataRunType type) {
- ASSERT(type == DRT_TVLIST || type == DRT_TSFILE);
- static const char* names[2] = {"TVLIST", "TSFILE"};
- return names[type];
- }
- int remove_tsfile(const common::FileID& file_id);
-
-#ifndef NDEBUG
- friend std::ostream& operator<<(std::ostream& out, DataRun& data_run) {
- out << "type=" << data_run.get_data_run_type_name(data_run.run_type_)
- << ", time_range={start=" << data_run.time_range_.start_time_
- << ", end=" << data_run.time_range_.end_time_ << "}";
- if (DRT_TVLIST == data_run.run_type_) {
- common::SimpleList<SeqTVListBase*>::Iterator it;
- int count = 0;
- out << ", tvlist_list={";
- for (it = data_run.tvlist_list_.begin();
- it != data_run.tvlist_list_.end(); it++) {
- if (it == data_run.tvlist_list_.begin()) {
- out << "[" << count << "]" << (void*)it.get();
- } else {
- out << ", [" << count << "]" << (void*)it.get();
- }
- count++;
- }
- out << "}";
- } else if (DRT_TSFILE == data_run.run_type_) {
- common::SimpleList<OpenFile*>::Iterator it;
- int count = 0;
- out << ", tsfile_list={";
- for (it = data_run.tsfile_list_.begin();
- it != data_run.tsfile_list_.end(); it++) {
- if (it == data_run.tsfile_list_.begin()) {
- out << "[" << count << "]" << *it.get();
- } else {
- out << ", [" << count << "]" << *it.get();
- }
- count++;
- }
- out << "}";
- }
- return out;
- }
-#endif
-
- private:
- int tvlist_get_next(common::TsBlock* ret_block, TimeRange& ret_time_range,
- bool alloc);
- int fill_tsblock_from_tvlist(SeqTVListBase* tvlist,
- common::TsBlock* ret_block,
- TimeRange& ret_time_range);
- template <typename T>
- int fill_tsblock_from_typed_tvlist(SeqTVListBase* tvlist,
- common::TsBlock* ret_block,
- TimeRange& ret_time_range);
- int tsfile_get_next(common::TsBlock* ret_block, TimeRange& ret_time_range,
- bool alloc);
- int reinit_io_reader(common::SimpleList<OpenFile*>::Iterator& it,
- common::PageArena* pa = nullptr);
- common::TsBlock* alloc_tsblock();
-
- public:
- DataRunType run_type_;
- common::ColumnSchema* col_schema_;
- TimeRange time_range_;
-
- // invalid if run_type_ is DRT_TSFILE
- common::SimpleList<SeqTVListBase*> tvlist_list_;
- common::SimpleList<SeqTVListBase*>::Iterator tvlist_list_iter_;
-
- // invalid if run_type_ is DRT_TVLIST
- common::SimpleList<OpenFile*> tsfile_list_;
- common::SimpleList<OpenFile*>::Iterator tsfile_list_iter_;
- // TODO may bind TsFileIOReader on OpenFile ?
- TsFileIOReader io_reader_;
- TsFileSeriesScanIterator* ssi_;
- common::TupleDesc tuple_desc_;
-};
-
-class DataScanIterator {
- public:
- DataScanIterator()
- : col_schema_(),
- page_arena_(),
- data_run_list_(&page_arena_),
- cursor_() {}
- ~DataScanIterator() {}
- int init() { return common::E_OK; }
- void destory() {
- close();
- page_arena_.destroy();
- }
- void close() {
- // TODO
- }
-
- DataRun* alloc_data_run(DataRunType run_type);
- FORCE_INLINE int add_data_run(DataRun* data_run) {
- ASSERT(data_run != nullptr);
- return data_run_list_.push_back(data_run);
- }
- void reset_for_retry() { page_arena_.reset(); }
-
- /*
- * get next tsblock
- * return value
- * E_OK - succ
- * E_INVALID_ARG - ret_block not init
- * E_NO_MORE_DATA - reader over
- */
- int get_next(common::TsBlock* block, bool alloc_tsblock = false);
- void set_col_schema(const common::ColumnSchema& col_schema) {
- col_schema_ = col_schema;
- }
-
-#ifndef NDEBUG
- void DEBUG_dump_data_run_list();
-#endif
-
- private:
- common::ColumnSchema col_schema_;
- common::PageArena page_arena_;
- common::SimpleList<DataRun*> data_run_list_;
- common::SimpleList<DataRun*>::Iterator cursor_;
-};
-
-} // end namespace storage
-#endif // READER_SCAN_ITERATOR_H
diff --git a/cpp/src/utils/db_utils.h b/cpp/src/utils/db_utils.h
index d0953afe..832e5c16 100644
--- a/cpp/src/utils/db_utils.h
+++ b/cpp/src/utils/db_utils.h
@@ -36,122 +36,6 @@
namespace common {
extern TSEncoding get_value_encoder(TSDataType data_type);
extern CompressionType get_default_compressor();
-
-// TODO: remove this.
-typedef struct FileID {
- int64_t seq_; // timestamp when create
- int32_t version_;
- int32_t merge_;
-
- FileID() : seq_(0), version_(0), merge_(0) {}
- void reset() {
- seq_ = 0;
- version_ = 0;
- merge_ = 0;
- }
- FORCE_INLINE bool is_valid() const { return seq_ != 0; }
- FORCE_INLINE bool operator<(const FileID& that) const {
- return this->seq_ < that.seq_;
- }
- FORCE_INLINE bool operator==(const FileID& that) const {
- return this->seq_ == that.seq_;
- }
-#ifndef NDEBUG
- friend std::ostream& operator<<(std::ostream& out, const FileID& file_id) {
- out << "{seq_=" << file_id.seq_ << ", version_=" << file_id.version_
- << ", merge_=" << file_id.merge_ << "}";
- return out;
- }
-#endif
-} FileID;
-
-// TODO: remove this.
-typedef uint16_t NodeID;
-struct TsID {
- NodeID db_nid_;
- NodeID device_nid_;
- NodeID measurement_nid_;
-
- TsID() : db_nid_(0), device_nid_(0), measurement_nid_(0){};
-
- TsID(NodeID db_nid, NodeID device_nid, NodeID measurement_nid)
- : db_nid_(db_nid),
- device_nid_(device_nid),
- measurement_nid_(measurement_nid) {}
-
- /*
- * To make TsID to be a trival copyable struct.
- */
-#if 0
- TsID(const TsID &other) : db_nid_(other.db_nid_),
- device_nid_(other.device_nid_),
- measurement_nid_(other.measurement_nid_) {}
-
- TsID & operator = (const TsID &other)
- {
- db_nid_ = other.db_nid_;
- device_nid_ = other.device_nid_;
- measurement_nid_ = other.measurement_nid_;
- return *this;
- }
-#endif
-
- void reset() {
- db_nid_ = 0;
- device_nid_ = 0;
- measurement_nid_ = 0;
- }
-
- bool is_valid() const {
- // TODO
- return true;
- }
-
- FORCE_INLINE bool operator==(const TsID& other) const {
- return db_nid_ == other.db_nid_ && device_nid_ == other.device_nid_ &&
- measurement_nid_ == other.measurement_nid_;
- }
- FORCE_INLINE bool operator!=(const TsID& other) const {
- return db_nid_ != other.db_nid_ || device_nid_ != other.device_nid_ ||
- measurement_nid_ != other.measurement_nid_;
- }
-
- FORCE_INLINE int64_t to_int64() const {
- int64_t res = db_nid_;
- res = (res << 16) | device_nid_;
- res = (res << 16) | measurement_nid_;
- return res;
- }
-
- FORCE_INLINE bool operator<(const TsID& that) const {
- return to_int64() < that.to_int64();
- }
-
- FORCE_INLINE bool operator>(const TsID& other) {
- return to_int64() > other.to_int64();
- }
-
- friend std::ostream& operator<<(std::ostream& out, TsID& ti) {
- out << "(" << ti.db_nid_ << ", " << ti.device_nid_ << ", "
- << ti.measurement_nid_ << ") ";
- return out;
- }
-
- FORCE_INLINE void to_string(char* print_buf, int len) const {
- snprintf(print_buf, len, "<%d,%d,%d>", db_nid_, device_nid_,
- measurement_nid_);
- }
- FORCE_INLINE std::string to_string() const {
- const int buf_len = 32;
- char buf[buf_len];
- snprintf(buf, buf_len, "<%d,%d,%d>", db_nid_, device_nid_,
- measurement_nid_);
- // construct std::string will invoke memory allocation and copy.
- // try to use first to_string instead.
- return std::string(buf);
- }
-};
-
/**
* @brief Represents the schema information for a single measurement.
* @brief Represents the category of a column in a table schema.
diff --git a/cpp/src/utils/storage_utils.h b/cpp/src/utils/storage_utils.h
index 3d1a1895..78cc775c 100644
--- a/cpp/src/utils/storage_utils.h
+++ b/cpp/src/utils/storage_utils.h
@@ -70,14 +70,6 @@ struct InsertResult {
std::string err_msg_;
};
-FORCE_INLINE std::string get_file_path_from_file_id(
- const common::FileID& file_id) {
- std::ostringstream oss;
- oss << "./" << file_id.seq_ << "-" << file_id.version_ << "-"
- << file_id.merge_ << ".tsfile";
- return oss.str();
-}
-
FORCE_INLINE static void to_lowercase_inplace(std::string& str) {
std::transform(
str.begin(), str.end(), str.begin(),
diff --git a/cpp/test/common/tsblock/tslock_test.cc
b/cpp/test/common/tsblock/tslock_test.cc
index 91ee96a3..750585aa 100644
--- a/cpp/test/common/tsblock/tslock_test.cc
+++ b/cpp/test/common/tsblock/tslock_test.cc
@@ -46,7 +46,6 @@ TEST(TsBlockTest, RowAppender_AddRow) {
TEST(TsBlockTest, ColAppender_AddRowAndAppend) {
TupleDesc tuple_desc;
- TsID ts_id(1, 2, 3);
ColumnSchema col("test_col", INT32, SNAPPY, RLE);
tuple_desc.push_back(col);
TsBlock ts_block(&tuple_desc, 50);
diff --git a/cpp/test/common/tsfile_common_test.cc
b/cpp/test/common/tsfile_common_test.cc
index 4b46dd82..01e193f7 100644
--- a/cpp/test/common/tsfile_common_test.cc
+++ b/cpp/test/common/tsfile_common_test.cc
@@ -86,7 +86,6 @@ TEST(ChunkMetaTest, Init) {
char name[] = "test";
common::String measurement_name(name, sizeof(name));
Statistic stat;
- common::TsID ts_id;
common::PageArena pa;
int ret = meta.init(measurement_name, common::TSDataType::INT32, 100,
&stat,
diff --git a/cpp/test/file/open_file_test.cc b/cpp/test/file/open_file_test.cc
deleted file mode 100644
index 665e1234..00000000
--- a/cpp/test/file/open_file_test.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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 a
- *
- * 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.
- */
-#include "file/open_file.h"
-
-#include <gtest/gtest.h>
-
-#include <string>
-#include <vector>
-
-namespace storage {
-
-class OpenFileTest : public ::testing::Test {
- protected:
- void SetUp() override {
- open_file_ = OpenFileFactory::alloc();
- EXPECT_EQ(open_file_->init(), common::E_OK);
- }
-
- void TearDown() override {
- open_file_->reset();
- OpenFileFactory::free(open_file_);
- }
-
- OpenFile* open_file_;
-};
-
-TEST_F(OpenFileTest, SetFileIdAndPath) {
- common::FileID file_id;
- file_id.seq_ = 1;
- std::string file_path = "/path/to/file";
- open_file_->set_file_id_and_path(file_id, file_path);
-
- EXPECT_EQ(open_file_->get_file_id(), file_id);
- EXPECT_EQ(open_file_->get_file_path(), file_path);
-}
-
-TEST_F(OpenFileTest, BuildFrom) {
- std::vector<TimeseriesTimeIndexEntry> time_index_vec = {
- {common::TsID(1, 1, 1), TimeRange{10, 20}},
- {common::TsID(2, 2, 2), TimeRange{30, 40}}};
-
- EXPECT_EQ(open_file_->build_from(time_index_vec), common::E_OK);
-
- TimeRange time_range;
- EXPECT_EQ(open_file_->get_time_range(common::TsID(1, 1, 1), time_range),
- common::E_OK);
- EXPECT_EQ(time_range.start_time_, 10);
- EXPECT_EQ(time_range.end_time_, 20);
-
- EXPECT_EQ(open_file_->get_time_range(common::TsID(2, 2, 2), time_range),
- common::E_OK);
- EXPECT_EQ(time_range.start_time_, 30);
- EXPECT_EQ(time_range.end_time_, 40);
-}
-
-TEST_F(OpenFileTest, Add) {
- TimeRange time_range{50, 60};
- common::TsID ts_id(1, 1, 1);
-
- EXPECT_EQ(open_file_->add(ts_id, time_range), common::E_OK);
-
- TimeRange ret_time_range;
- EXPECT_EQ(open_file_->get_time_range(ts_id, ret_time_range), common::E_OK);
- EXPECT_EQ(ret_time_range.start_time_, 50);
- EXPECT_EQ(ret_time_range.end_time_, 60);
-}
-
-TEST_F(OpenFileTest, ContainTimeseries) {
- TimeRange time_range{90, 100};
- common::TsID ts_id(1, 1, 1);
-
- open_file_->add(ts_id, time_range);
- EXPECT_TRUE(open_file_->contain_timeseries(ts_id));
- EXPECT_FALSE(open_file_->contain_timeseries(common::TsID(2, 2, 2)));
-}
-
-TEST_F(OpenFileTest, GetTimeRange) {
- TimeRange time_range{110, 120};
- common::TsID ts_id(1, 1, 1);
-
- open_file_->add(ts_id, time_range);
-
- TimeRange ret_time_range;
- EXPECT_EQ(open_file_->get_time_range(ts_id, ret_time_range), common::E_OK);
- EXPECT_EQ(ret_time_range.start_time_, 110);
- EXPECT_EQ(ret_time_range.end_time_, 120);
-
- EXPECT_EQ(open_file_->get_time_range(common::TsID(2, 2, 2),
ret_time_range),
- common::E_NOT_EXIST);
-}
-
-} // namespace storage
\ No newline at end of file
diff --git a/cpp/test/utils/db_utils_test.cc b/cpp/test/utils/db_utils_test.cc
index fb455eea..29d7abe8 100644
--- a/cpp/test/utils/db_utils_test.cc
+++ b/cpp/test/utils/db_utils_test.cc
@@ -24,99 +24,6 @@
namespace common {
-TEST(FileIDTest, Constructor) {
- FileID file_id;
- EXPECT_EQ(file_id.seq_, 0);
- EXPECT_EQ(file_id.version_, 0);
- EXPECT_EQ(file_id.merge_, 0);
-}
-
-TEST(FileIDTest, Reset) {
- FileID file_id;
- file_id.seq_ = 123;
- file_id.version_ = 1;
- file_id.merge_ = 2;
- file_id.reset();
- EXPECT_EQ(file_id.seq_, 0);
- EXPECT_EQ(file_id.version_, 0);
- EXPECT_EQ(file_id.merge_, 0);
-}
-
-TEST(FileIDTest, IsValid) {
- FileID file_id;
- EXPECT_FALSE(file_id.is_valid());
- file_id.seq_ = 123;
- EXPECT_TRUE(file_id.is_valid());
-}
-
-TEST(FileIDTest, OperatorLess) {
- FileID file_id1, file_id2;
- file_id1.seq_ = 123;
- file_id2.seq_ = 456;
- EXPECT_TRUE(file_id1 < file_id2);
- EXPECT_FALSE(file_id2 < file_id1);
-}
-
-TEST(FileIDTest, OperatorEqual) {
- FileID file_id1, file_id2;
- file_id1.seq_ = 123;
- file_id2.seq_ = 123;
- EXPECT_TRUE(file_id1 == file_id2);
- file_id2.seq_ = 456;
- EXPECT_FALSE(file_id1 == file_id2);
-}
-
-TEST(TsIDTest, Constructor) {
- TsID ts_id;
- EXPECT_EQ(ts_id.db_nid_, 0);
- EXPECT_EQ(ts_id.device_nid_, 0);
- EXPECT_EQ(ts_id.measurement_nid_, 0);
-}
-
-TEST(TsIDTest, ParameterizedConstructor) {
- TsID ts_id(1, 2, 3);
- EXPECT_EQ(ts_id.db_nid_, 1);
- EXPECT_EQ(ts_id.device_nid_, 2);
- EXPECT_EQ(ts_id.measurement_nid_, 3);
-}
-
-TEST(TsIDTest, Reset) {
- TsID ts_id(1, 2, 3);
- ts_id.reset();
- EXPECT_EQ(ts_id.db_nid_, 0);
- EXPECT_EQ(ts_id.device_nid_, 0);
- EXPECT_EQ(ts_id.measurement_nid_, 0);
-}
-
-TEST(TsIDTest, OperatorEqual) {
- TsID ts_id1(1, 2, 3);
- TsID ts_id2(1, 2, 3);
- EXPECT_TRUE(ts_id1 == ts_id2);
- ts_id2.db_nid_ = 4;
- EXPECT_FALSE(ts_id1 == ts_id2);
-}
-
-TEST(TsIDTest, OperatorNotEqual) {
- TsID ts_id1(1, 2, 3);
- TsID ts_id2(1, 2, 3);
- EXPECT_FALSE(ts_id1 != ts_id2);
- ts_id2.db_nid_ = 4;
- EXPECT_TRUE(ts_id1 != ts_id2);
-}
-
-TEST(TsIDTest, ToInt64) {
- TsID ts_id(1, 2, 3);
- int64_t expected = (1LL << 32) | (2 << 16) | 3;
- EXPECT_EQ(ts_id.to_int64(), expected);
-}
-
-TEST(TsIDTest, OperatorLess) {
- TsID ts_id1(1, 2, 3);
- TsID ts_id2(1, 2, 4);
- EXPECT_TRUE(ts_id1 < ts_id2);
- EXPECT_FALSE(ts_id2 < ts_id1);
-}
-
TEST(ColumnSchemaTest, Constructor) {
ColumnSchema col_schema;
EXPECT_EQ(col_schema.data_type_, INVALID_DATATYPE);