Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPP. multi-flush error when data is minimal. #171

Open
ColinLeeo opened this issue Jul 9, 2024 · 0 comments
Open

CPP. multi-flush error when data is minimal. #171

ColinLeeo opened this issue Jul 9, 2024 · 0 comments

Comments

@ColinLeeo
Copy link
Contributor

When the amount of data written is minimal, multiple flush operations may lead to exceptions during the writing process to the file index.

pass:

TEST_F(TsFileWriterTest, MultiFlush) {
    std::string device_path = "device1";
    std::string measurement_name = "temperature";
    common::TSDataType data_type = common::TSDataType::INT32;
    common::TSEncoding encoding = common::TSEncoding::PLAIN;
    common::CompressionType compression_type =
        common::CompressionType::UNCOMPRESSED;
    ASSERT_EQ(tsfile_writer_->register_timeseries(device_path, measurement_name,
                                                  data_type, encoding,
                                                  compression_type),
              E_OK);
    for (int i = 1; i < 2; i++) {
        TsRecord record(i, device_path);
        DataPoint point(measurement_name, i);
        record.append_data_point(point);
        ASSERT_EQ(tsfile_writer_->write_record(record), E_OK);
    }
    ASSERT_EQ(tsfile_writer_->flush(), E_OK);

    for (int i = 2; i < 10; i++) {
        TsRecord record(i, device_path);
        DataPoint point(measurement_name, i);
        record.append_data_point(point);
        ASSERT_EQ(tsfile_writer_->write_record(record), E_OK);
    }
    ASSERT_EQ(tsfile_writer_->flush(), E_OK);
    ASSERT_EQ(tsfile_writer_->close(), E_OK);
}

FAILED

TEST_F(TsFileWriterTest, MultiFlush) {
    std::string device_path = "device1";
    std::string measurement_name = "temperature";
    common::TSDataType data_type = common::TSDataType::INT32;
    common::TSEncoding encoding = common::TSEncoding::PLAIN;
    common::CompressionType compression_type =
        common::CompressionType::UNCOMPRESSED;
    ASSERT_EQ(tsfile_writer_->register_timeseries(device_path, measurement_name,
                                                  data_type, encoding,
                                                  compression_type),
              E_OK);
    for (int i = 1; i < 2; i++) {
        TsRecord record(i, device_path);
        DataPoint point(measurement_name, i);
        record.append_data_point(point);
        ASSERT_EQ(tsfile_writer_->write_record(record), E_OK);
    }
    ASSERT_EQ(tsfile_writer_->flush(), E_OK);

    for (int i = 2; i < 3; i++) {
        TsRecord record(i, device_path);
        DataPoint point(measurement_name, i);
        record.append_data_point(point);
        ASSERT_EQ(tsfile_writer_->write_record(record), E_OK);
    }
    ASSERT_EQ(tsfile_writer_->flush(), E_OK);
    ASSERT_EQ(tsfile_writer_->close(), E_OK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant