This is an automated email from the ASF dual-hosted git repository.
jiangtian 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 8ee83b05 Fix log when closing TsFile. Allow to close TsFile even if no
device is written. Fix tablet generation in test.
8ee83b05 is described below
commit 8ee83b056f1b671e2248bc7fa477e8ece7c5259e
Author: Tian Jiang <[email protected]>
AuthorDate: Wed Aug 7 17:14:33 2024 +0800
Fix log when closing TsFile.
Allow to close TsFile even if no device is written.
Fix tablet generation in test.
---
.gitignore | 1 +
cpp/src/file/write_file.cc | 8 ++++++--
cpp/test/writer/tsfile_writer_test.cc | 12 ++++++------
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 944ecf5a..00adb1bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,4 @@ python/tsfile/*.h
python/tsfile/*.cpp
python/data
python/venv/*
+cpp/cmake-build-debug-mingw/
diff --git a/cpp/src/file/write_file.cc b/cpp/src/file/write_file.cc
index 2fb08c26..112e4349 100644
--- a/cpp/src/file/write_file.cc
+++ b/cpp/src/file/write_file.cc
@@ -120,12 +120,16 @@ int WriteFile::sync() {
int WriteFile::close() {
ASSERT(fd_ > 0);
if (::close(fd_) < 0) {
- std::cout << "feild to close " << path_ << " errorno " << errno
+ #ifdef DEBUG_SE
+ std::cout << "failed to close " << path_ << " errorno " << errno
<< std::endl;
+ #endif
// log_err("file close error, path=%s, errno=%d", path_.c_str(),
errno);
return E_FILE_CLOSE_ERR;
}
- std::cout << "coulse finish" << std::endl;
+ #ifdef DEBUG_SE
+ std::cout << "close finish" << std::endl;
+ #endif
return E_OK;
}
diff --git a/cpp/test/writer/tsfile_writer_test.cc
b/cpp/test/writer/tsfile_writer_test.cc
index 4f52e197..b934bdce 100644
--- a/cpp/test/writer/tsfile_writer_test.cc
+++ b/cpp/test/writer/tsfile_writer_test.cc
@@ -135,22 +135,22 @@ TEST_F(TsFileWriterTest, WriteMultipleTabletsInt64) {
for (int i = 0; i < device_num; i++) {
std::string device_name = "test_device" + std::to_string(i);
+ int max_rows = 100;
+ Tablet tablet(device_name, &schema_vec[i], max_rows);
+ tablet.init();
for (int j = 0; j < measurement_num; j++) {
- int max_rows = 100;
- Tablet tablet(device_name, &schema_vec[i], max_rows);
- tablet.init();
for (int row = 0; row < max_rows; row++) {
tablet.set_timestamp(row, 16225600 + row);
}
for (int row = 0; row < max_rows; row++) {
- tablet.set_value(row, j, row);
+ tablet.set_value(row, j, static_cast<int64_t>(row));
}
- ASSERT_EQ(tsfile_writer_->write_tablet(tablet), E_OK);
}
+ ASSERT_EQ(tsfile_writer_->write_tablet(tablet), E_OK);
}
ASSERT_EQ(tsfile_writer_->flush(), E_OK);
- tsfile_writer_->close();
+ ASSERT_EQ(tsfile_writer_->close(), E_OK);
}
TEST_F(TsFileWriterTest, WriteMultipleTabletsDouble) {