Skip to content

Commit

Permalink
reuse old index file format for empty dmfile and just ignore it's siz…
Browse files Browse the repository at this point in the history
…e in statistical data
  • Loading branch information
lidezhu committed Apr 19, 2022
1 parent 636fcd2 commit a97fce9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
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 because this dmfile is empty.
// This is ok because the index file in this case is really small, 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 because this dmfile is empty.
// This is ok because the index file in this case is really small, 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

0 comments on commit a97fce9

Please sign in to comment.