diff options
author | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-06-07 17:03:03 +0300 |
---|---|---|
committer | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-06-07 17:03:03 +0300 |
commit | 5f4dfe49d5c497e5c046d29049bd102ed405ddef (patch) | |
tree | 7c1df85ab452ebf60548685fa42d0a2d8e951dc7 | |
parent | f86cc6b226195a56622fbd70e0c0c9aeefb6a46f (diff) | |
download | ydb-5f4dfe49d5c497e5c046d29049bd102ed405ddef.tar.gz |
fix stupid
5 files changed, 20 insertions, 27 deletions
diff --git a/ydb/core/tx/columnshard/engines/reader/batch.cpp b/ydb/core/tx/columnshard/engines/reader/batch.cpp index fcbcb40169d..d79bb9f7da7 100644 --- a/ydb/core/tx/columnshard/engines/reader/batch.cpp +++ b/ydb/core/tx/columnshard/engines/reader/batch.cpp @@ -172,7 +172,7 @@ ui64 TBatch::GetUsefulBytes(const ui64 bytes) const { } std::shared_ptr<TSortableBatchPosition> TBatch::GetFirstPK(const bool reverse, const TIndexInfo& indexInfo) const { - if (!FirstPK || !LastPK) { + if (!FirstPK || !ReverseFirstPK) { std::shared_ptr<TSortableBatchPosition> from; std::shared_ptr<TSortableBatchPosition> to; GetPKBorders(reverse, indexInfo, from, to); @@ -186,8 +186,8 @@ std::shared_ptr<TSortableBatchPosition> TBatch::GetFirstPK(const bool reverse, c void TBatch::GetPKBorders(const bool reverse, const TIndexInfo& indexInfo, std::shared_ptr<TSortableBatchPosition>& from, std::shared_ptr<TSortableBatchPosition>& to) const { auto indexKey = indexInfo.GetIndexKey(); + Y_VERIFY(PortionInfo->Valid()); if (!FirstPK) { - Y_VERIFY(PortionInfo->Valid()); const NArrow::TReplaceKey& minRecord = PortionInfo->IndexKeyStart(); auto batch = minRecord.ToBatch(indexKey); Y_VERIFY(batch); @@ -195,7 +195,6 @@ void TBatch::GetPKBorders(const bool reverse, const TIndexInfo& indexInfo, std:: ReverseLastPK = std::make_shared<TSortableBatchPosition>(batch, 0, indexKey->field_names(), true); } if (!LastPK) { - Y_VERIFY(PortionInfo->Valid()); const NArrow::TReplaceKey& maxRecord = PortionInfo->IndexKeyEnd(); auto batch = maxRecord.ToBatch(indexKey); Y_VERIFY(batch); diff --git a/ydb/core/tx/columnshard/engines/reader/granule.cpp b/ydb/core/tx/columnshard/engines/reader/granule.cpp index 0afae0b72b9..e970eb52677 100644 --- a/ydb/core/tx/columnshard/engines/reader/granule.cpp +++ b/ydb/core/tx/columnshard/engines/reader/granule.cpp @@ -70,29 +70,24 @@ std::deque<TGranule::TBatchForMerge> TGranule::SortBatchesByPK(const bool revers ui32 currentPoolId = 0; std::map<TSortableBatchPosition, ui32> poolIds; for (auto&& i : batches) { - if (!i.GetFrom() && !i.GetTo()) { + if (!i.GetFrom()) { continue; } - if (i.GetFrom()) { - auto it = poolIds.rbegin(); - for (; it != poolIds.rend(); ++it) { - if (it->first.Compare(*i.GetFrom()) < 0) { - break; - } - } - if (it != poolIds.rend()) { - i.SetPoolId(it->second); - if (i.GetTo()) { - poolIds.erase(it->first); - poolIds.emplace(*i.GetTo(), *i.GetPoolId()); - } else { - poolIds.erase(it->first); - } - } else if (i.GetTo()) { - i.SetPoolId(++currentPoolId); - poolIds.emplace(*i.GetTo(), *i.GetPoolId()); + auto it = poolIds.rbegin(); + for (; it != poolIds.rend(); ++it) { + if (it->first.Compare(*i.GetFrom()) < 0) { + break; } } + if (it != poolIds.rend()) { + i.SetPoolId(it->second); + poolIds.erase(it->first); + } else { + i.SetPoolId(++currentPoolId); + } + if (i.GetTo()) { + poolIds.emplace(*i.GetTo(), *i.GetPoolId()); + } } return batches; } diff --git a/ydb/core/tx/columnshard/engines/reader/granule.h b/ydb/core/tx/columnshard/engines/reader/granule.h index 4c8f12b4e73..63657a469d0 100644 --- a/ydb/core/tx/columnshard/engines/reader/granule.h +++ b/ydb/core/tx/columnshard/engines/reader/granule.h @@ -111,7 +111,7 @@ public: if (!From && !item.From) { return false; } else if (From && item.From) { - return From->Compare(*item.From) < 0; + return From->Compare(*item.From) == std::partial_ordering::less; } else if (!From) { return true; } else { diff --git a/ydb/core/tx/columnshard/engines/reader/order_control/pk_with_limit.cpp b/ydb/core/tx/columnshard/engines/reader/order_control/pk_with_limit.cpp index 36576669e8c..69c659cc86b 100644 --- a/ydb/core/tx/columnshard/engines/reader/order_control/pk_with_limit.cpp +++ b/ydb/core/tx/columnshard/engines/reader/order_control/pk_with_limit.cpp @@ -37,11 +37,10 @@ bool TPKSortingWithLimit::DoWakeup(const TGranule& granule, TGranulesFillingCont OnBatchFilterInitialized(*b, context); batches.pop_front(); if (batches.size()) { - auto nextBatchControlPoint = batches.front()->GetFirstPK(ReadMetadata->IsDescSorted(), ReadMetadata->GetIndexInfo()); - if (!nextBatchControlPoint) { + if (!batches.front().GetFrom()) { continue; } - MergeStream.PutControlPoint(nextBatchControlPoint); + MergeStream.PutControlPoint(batches.front().GetFrom()); } while (CurrentItemsLimit && MergeStream.DrainCurrent()) { --CurrentItemsLimit; diff --git a/ydb/core/tx/columnshard/engines/reader/read_filter_merger.h b/ydb/core/tx/columnshard/engines/reader/read_filter_merger.h index ef5de23549f..c76adf41169 100644 --- a/ydb/core/tx/columnshard/engines/reader/read_filter_merger.h +++ b/ydb/core/tx/columnshard/engines/reader/read_filter_merger.h @@ -121,7 +121,7 @@ private: , KeyColumns(batch, 0, keyColumns, reverseSort) , VersionColumns(batch, 0, TIndexInfo::GetSpecialColumnNames(), false) , RecordsCount(batch->num_rows()) - , ReverseSortKff(reverseSort ? 1 : -1) + , ReverseSortKff(reverseSort ? -1 : 1) , PoolId(poolId) , Filter(filter) { |