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

reuse old index file format for empty dmfile and just ignore it's size in statistical data #4711

Merged
merged 3 commits into from
Apr 20, 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
18 changes: 12 additions & 6 deletions dbms/src/Storages/DeltaMerge/File/DMFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,13 @@ void DMFileWriter::finalizeColumn(ColId col_id, DataTypePtr type)
dmfile->encryptionIndexPath(stream_name),
false,
write_limiter);
if (!is_empty_file)
stream->minmaxes->write(*type, buf);
stream->minmaxes->write(*type, buf);
buf.sync();
bytes_written += buf.getMaterializedBytes();
// Ignore data written in index file when the dmfile is empty.
// This is ok because the index file in this case is tiny, and we already ignore other small files like meta and pack stat file.
// The motivation to do this is to show a zero `stable_size_on_disk` for empty segments,
// and we cannot change the index file format for empty dmfile because of backward compatibility.
bytes_written += is_empty_file ? 0 : buf.getMaterializedBytes();
}
else
{
Expand All @@ -374,10 +377,13 @@ void DMFileWriter::finalizeColumn(ColId col_id, DataTypePtr type)
write_limiter,
dmfile->configuration->getChecksumAlgorithm(),
dmfile->configuration->getChecksumFrameLength());
if (!is_empty_file)
stream->minmaxes->write(*type, *buf);
stream->minmaxes->write(*type, *buf);
buf->sync();
bytes_written += buf->getMaterializedBytes();
// Ignore data written in index file when the dmfile is empty.
// This is ok because the index file in this case is tiny, and we already ignore other small files like meta and pack stat file.
// The motivation to do this is to show a zero `stable_size_on_disk` for empty segments,
// and we cannot change the index file format for empty dmfile because of backward compatibility.
bytes_written += is_empty_file ? 0 : buf->getMaterializedBytes();
#ifndef NDEBUG
examine_buffer_size(*buf, *this->file_provider);
#endif
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/DeltaMerge/File/DMFileWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class DMFileWriter
FileProviderPtr file_provider;
WriteLimiterPtr write_limiter;

// use to avoid write index data for empty file
// use to avoid count data written in index file for empty dmfile
bool is_empty_file = true;
};

Expand Down