wide parts validation with file opening via disk

This commit is contained in:
Alexandra 2021-05-18 20:06:09 +00:00
parent e3a91f568e
commit 3f00f064af

View File

@ -395,10 +395,10 @@ void MergeTreeDataPartWriterWide::validateColumnOfFixedSize(const String & name,
auto disk = data_part->volume->getDisk();
String escaped_name = escapeForFileName(name);
String mrk_path = fullPath(disk, part_path + escaped_name + marks_file_extension);
String bin_path = fullPath(disk, part_path + escaped_name + DATA_FILE_EXTENSION);
DB::ReadBufferFromFile mrk_in(mrk_path);
DB::CompressedReadBufferFromFile bin_in(bin_path, 0, 0, 0, nullptr);
String mrk_path = part_path + escaped_name + marks_file_extension;
String bin_path = part_path + escaped_name + DATA_FILE_EXTENSION;
auto mrk_in = disk->readFile(mrk_path);
DB::CompressedReadBufferFromFile bin_in(disk->readFile(bin_path));
bool must_be_last = false;
UInt64 offset_in_compressed_file = 0;
UInt64 offset_in_decompressed_block = 0;
@ -407,15 +407,15 @@ void MergeTreeDataPartWriterWide::validateColumnOfFixedSize(const String & name,
size_t mark_num;
const auto & serialization = serializations[name];
for (mark_num = 0; !mrk_in.eof(); ++mark_num)
for (mark_num = 0; !mrk_in->eof(); ++mark_num)
{
if (mark_num > index_granularity.getMarksCount())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Incorrect number of marks in memory {}, on disk (at least) {}", index_granularity.getMarksCount(), mark_num + 1);
DB::readBinary(offset_in_compressed_file, mrk_in);
DB::readBinary(offset_in_decompressed_block, mrk_in);
DB::readBinary(offset_in_compressed_file, *mrk_in);
DB::readBinary(offset_in_decompressed_block, *mrk_in);
if (settings.can_use_adaptive_granularity)
DB::readBinary(index_granularity_rows, mrk_in);
DB::readBinary(index_granularity_rows, *mrk_in);
else
index_granularity_rows = data_part->index_granularity_info.fixed_index_granularity;
@ -424,7 +424,7 @@ void MergeTreeDataPartWriterWide::validateColumnOfFixedSize(const String & name,
if (index_granularity_rows != 0)
throw Exception(ErrorCodes::LOGICAL_ERROR, "We ran out of binary data but still have non empty mark #{} with rows number {}", mark_num, index_granularity_rows);
if (!mrk_in.eof())
if (!mrk_in->eof())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Mark #{} must be last, but we still have some to read", mark_num);
break;
@ -486,7 +486,7 @@ void MergeTreeDataPartWriterWide::validateColumnOfFixedSize(const String & name,
}
}
if (!mrk_in.eof())
if (!mrk_in->eof())
throw Exception(ErrorCodes::LOGICAL_ERROR,
"Still have something in marks stream, last mark #{} index granularity size {}, last rows {}", mark_num, index_granularity.getMarksCount(), index_granularity_rows);
if (!bin_in.eof())