updated MergeTreePrewhereRangeReader; renamed MergeTreePrewhereRangeReader to MergeTreeRangeReader

This commit is contained in:
Nikolai Kochetov 2018-02-20 16:37:04 +03:00
parent dcd99860fe
commit 2bf1931d86
2 changed files with 5 additions and 12 deletions

View File

@ -187,8 +187,10 @@ void MergeTreeRangeReader::ReadResult::addGranule(size_t num_rows)
num_read_rows += num_rows; num_read_rows += num_rows;
} }
void MergeTreeRangeReader::ReadResult::adjustLastGranule(size_t num_rows_to_subtract) void MergeTreeRangeReader::ReadResult::adjustLastGranule()
{ {
size_t num_rows_to_subtract = num_read_rows - num_added_rows;
if (rows_per_granule.empty()) if (rows_per_granule.empty())
throw Exception("Can't adjust last granule because no granules were added.", ErrorCodes::LOGICAL_ERROR); throw Exception("Can't adjust last granule because no granules were added.", ErrorCodes::LOGICAL_ERROR);
@ -448,17 +450,8 @@ MergeTreeRangeReader::ReadResult MergeTreeRangeReader::startReadingChain(size_t
result.addRows(stream.finalize(result.block)); result.addRows(stream.finalize(result.block));
auto last_granule = result.rowsPerGranule().back();
auto added_rows = result.numAddedRows();
auto num_read_rows = result.numReadRows();
if (num_read_rows - last_granule > added_rows)
throw Exception("RangeReader expected reading of at least " + toString(num_read_rows - last_granule) +
" rows, but only " + toString(added_rows) + " was read.", ErrorCodes::LOGICAL_ERROR);
/// Last granule may be incomplete. /// Last granule may be incomplete.
size_t adjustment = max_rows - added_rows; result.adjustLastGranule();
result.adjustLastGranule(adjustment);
return result; return result;
} }

View File

@ -114,7 +114,7 @@ public:
const ColumnPtr & getFilter() const { return filter; } const ColumnPtr & getFilter() const { return filter; }
void addGranule(size_t num_rows); void addGranule(size_t num_rows);
void adjustLastGranule(size_t num_rows_to_subtract); void adjustLastGranule();
void addRows(size_t rows) { num_added_rows += rows; } void addRows(size_t rows) { num_added_rows += rows; }
void addRange(const MarkRange & range) { started_ranges.push_back({rows_per_granule.size(), range}); } void addRange(const MarkRange & range) { started_ranges.push_back({rows_per_granule.size(), range}); }