This commit is contained in:
Alexey Milovidov 2019-03-02 04:05:36 +03:00
parent 526e6488e0
commit dbab34e21f
2 changed files with 14 additions and 5 deletions

View File

@ -29,6 +29,8 @@ MergeTreeReaderStream::MergeTreeReaderStream(
size_t max_mark_range_bytes = 0; size_t max_mark_range_bytes = 0;
size_t sum_mark_range_bytes = 0; size_t sum_mark_range_bytes = 0;
/// Care should be taken to not load marks when the part is empty (marks_count == 0).
for (const auto & mark_range : all_mark_ranges) for (const auto & mark_range : all_mark_ranges)
{ {
size_t left_mark = mark_range.begin; size_t left_mark = mark_range.begin;
@ -54,7 +56,7 @@ MergeTreeReaderStream::MergeTreeReaderStream(
|| (right_mark + 1 == marks_count || (right_mark + 1 == marks_count
&& getMark(right_mark).offset_in_compressed_file == getMark(mark_range.end).offset_in_compressed_file)) && getMark(right_mark).offset_in_compressed_file == getMark(mark_range.end).offset_in_compressed_file))
{ {
mark_range_bytes = file_size - getMark(left_mark).offset_in_compressed_file; mark_range_bytes = file_size - (left_mark < marks_count ? getMark(left_mark).offset_in_compressed_file : 0);
} }
else else
{ {
@ -119,7 +121,7 @@ void MergeTreeReaderStream::loadMarks()
size_t expected_file_size = sizeof(MarkInCompressedFile) * marks_count; size_t expected_file_size = sizeof(MarkInCompressedFile) * marks_count;
if (expected_file_size != file_size) if (expected_file_size != file_size)
throw Exception( throw Exception(
"bad size of marks file `" + mrk_path + "':" + std::to_string(file_size) + ", must be: " + std::to_string(expected_file_size), "Bad size of marks file '" + mrk_path + "': " + std::to_string(file_size) + ", must be: " + std::to_string(expected_file_size),
ErrorCodes::CORRUPTED_DATA); ErrorCodes::CORRUPTED_DATA);
auto res = std::make_shared<MarksInCompressedFile>(marks_count); auto res = std::make_shared<MarksInCompressedFile>(marks_count);

View File

@ -23,9 +23,16 @@ MergeTreeSequentialBlockInputStream::MergeTreeSequentialBlockInputStream(
, mark_cache(storage.global_context.getMarkCache()) , mark_cache(storage.global_context.getMarkCache())
{ {
if (!quiet) if (!quiet)
LOG_TRACE(log, "Reading " << data_part->marks_count << " marks from part " << data_part->name {
std::stringstream message;
message << "Reading " << data_part->marks_count << " marks from part " << data_part->name
<< ", totaly " << data_part->rows_count << ", totaly " << data_part->rows_count
<< " rows starting from the beginning of the part"); << " rows starting from the beginning of the part, columns: ";
for (size_t i = 0, size = columns_to_read.size(); i < size; ++i)
message << (i == 0 ? "" : ", ") << columns_to_read[i];
LOG_TRACE(log, message.rdbuf());
}
addTotalRowsApprox(data_part->rows_count); addTotalRowsApprox(data_part->rows_count);