This is an automated email from the ASF dual-hosted git repository. colinlee pushed a commit to branch remove_unused_code in repository https://gitbox.apache.org/repos/asf/tsfile.git
commit 7d0ec9dae39db63c235a7e57457a7b92ecfa77fd Author: ColinLee <[email protected]> AuthorDate: Mon Feb 23 17:44:32 2026 +0800 refine code. --- cpp/src/common/config/config.h | 6 -- cpp/src/file/write_file.h | 1 + cpp/test/common/tsblock/tslock_test.cc | 1 - cpp/test/common/tsfile_common_test.cc | 1 - cpp/test/file/open_file_test.cc | 108 --------------------------------- 5 files changed, 1 insertion(+), 116 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/file/write_file.h b/cpp/src/file/write_file.h index 8803fe43..6b5a506a 100644 --- a/cpp/src/file/write_file.h +++ b/cpp/src/file/write_file.h @@ -29,6 +29,7 @@ namespace storage { class WriteFile { public: + WriteFile() : path_(), fd_(-1) {} 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); 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
