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

fix: ut and more idx error #4777

Merged
merged 3 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dbms/src/Server/DTTool/DTToolMigrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ int migrateServiceMain(DB::Context & context, const MigrateArgs & args)
LOG_FMT_INFO(logger, "source version: {}", (src_file->getConfiguration() ? 2 : 1));
LOG_FMT_INFO(logger, "source bytes: {}", src_file->getBytesOnDisk());
LOG_FMT_INFO(logger, "migration temporary directory: {}", keeper.migration_temp_dir.path().c_str());
LOG_FMT_INFO(logger, "target version: {}", args.version);
LOG_FMT_INFO(logger, "target frame size: {}", args.frame);
DB::DM::DMConfigurationOpt option{};

// if new format is the target, we construct a config file.
Expand Down
23 changes: 15 additions & 8 deletions dbms/src/Server/tests/gtest_dttool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,23 @@ TEST_F(DTToolTest, BlockwiseInvariant)
stream->readSuffix();
}

std::vector<std::tuple<size_t, DB::ChecksumAlgo, DB::CompressionMethod, int>> test_cases{
{2, DB::ChecksumAlgo::XXH3, DB::CompressionMethod::LZ4, -1},
{1, DB::ChecksumAlgo::XXH3, DB::CompressionMethod::ZSTD, 1},
{2, DB::ChecksumAlgo::City128, DB::CompressionMethod::LZ4HC, 0},
{2, DB::ChecksumAlgo::CRC64, DB::CompressionMethod::ZSTD, 22},
{1, DB::ChecksumAlgo::XXH3, DB::CompressionMethod::NONE, -1}};
for (auto [version, algo, comp, level] : test_cases)
std::vector<std::tuple<size_t, size_t, DB::ChecksumAlgo, DB::CompressionMethod, int>> test_cases{
{2, DBMS_DEFAULT_BUFFER_SIZE, DB::ChecksumAlgo::XXH3, DB::CompressionMethod::LZ4, -1},
{1, 64, DB::ChecksumAlgo::XXH3, DB::CompressionMethod::ZSTD, 1},
{2, DBMS_DEFAULT_BUFFER_SIZE * 2, DB::ChecksumAlgo::City128, DB::CompressionMethod::LZ4HC, 0},
{2, DBMS_DEFAULT_BUFFER_SIZE * 4, DB::ChecksumAlgo::City128, DB::CompressionMethod::LZ4HC, 0},
{2, 4, DB::ChecksumAlgo::CRC64, DB::CompressionMethod::ZSTD, 22},
{2, 13, DB::ChecksumAlgo::CRC64, DB::CompressionMethod::ZSTD, 22},
{2, 5261, DB::ChecksumAlgo::CRC64, DB::CompressionMethod::ZSTD, 22},
{1, DBMS_DEFAULT_BUFFER_SIZE, DB::ChecksumAlgo::XXH3, DB::CompressionMethod::NONE, -1}};
for (auto [version, frame_size, algo, comp, level] : test_cases)
{
auto a = DTTool::Migrate::MigrateArgs{
.no_keep = false,
.dry_mode = false,
.file_id = 1,
.version = version,
.frame = DBMS_DEFAULT_BUFFER_SIZE,
.frame = frame_size,
.algorithm = algo,
.workdir = getTemporaryPath(),
.compression_method = comp,
Expand All @@ -260,6 +263,10 @@ TEST_F(DTToolTest, BlockwiseInvariant)
0,
getTemporaryPath(),
DB::DM::DMFile::ReadMetaMode::all());
if (version == 2)
{
EXPECT_EQ(refreshed_file->getConfiguration()->getChecksumFrameLength(), frame_size);
}
auto stream = DB::DM::createSimpleBlockInputStream(*db_context, refreshed_file);
auto size_iter = size_info.begin();
auto prop_iter = dmfile->getPackProperties().property().begin();
Expand Down
5 changes: 3 additions & 2 deletions dbms/src/Storages/DeltaMerge/File/DMFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,9 @@ void DMFile::readMetadata(const FileProviderPtr & file_provider, const ReadMetaM
auto recheck = [&](size_t size) {
if (this->configuration)
{
auto frame_count = size / this->configuration->getChecksumFrameLength()
+ (0 != size % this->configuration->getChecksumFrameLength());
auto total_size = this->configuration->getChecksumFrameLength() + this->configuration->getChecksumHeaderLength();
auto frame_count = size / total_size
+ (0 != size % total_size);
size -= frame_count * this->configuration->getChecksumHeaderLength();
}
return size;
Expand Down