Skip to content

Commit

Permalink
helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 committed Aug 18, 2024
1 parent c08de1f commit 80c3945
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ydb/core/tx/columnshard/engines/predicate/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ bool TPKRangesFilter::IsPortionInUsage(const TPortionInfo& info) const {
return SortedRanges.empty();
}

bool TPKRangesFilter::CheckPoint(const NArrow::TReplaceKey& point) const {
for (auto&& i : SortedRanges) {
if (i.CheckPoint(point)) {
return true;
}
}
return SortedRanges.empty();
}

TPKRangeFilter::EUsageClass TPKRangesFilter::IsPortionInPartialUsage(const NArrow::TReplaceKey& start, const NArrow::TReplaceKey& end) const {
for (auto&& i : SortedRanges) {
switch (i.IsPortionInPartialUsage(start, end)) {
Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/columnshard/engines/predicate/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TPKRangesFilter {

bool IsPortionInUsage(const TPortionInfo& info) const;
TPKRangeFilter::EUsageClass IsPortionInPartialUsage(const NArrow::TReplaceKey& start, const NArrow::TReplaceKey& end) const;
bool CheckPoint(const NArrow::TReplaceKey& point) const;

NArrow::TColumnFilter BuildFilter(const arrow::Datum& data) const;

Expand Down
16 changes: 16 additions & 0 deletions ydb/core/tx/columnshard/engines/predicate/range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,20 @@ TConclusion<TPKRangeFilter> TPKRangeFilter::Build(TPredicateContainer&& from, TP
return TPKRangeFilter(std::move(from), std::move(to));
}

bool TPKRangeFilter::CheckPoint(const NArrow::TReplaceKey& point) const {
std::partial_ordering equalityWithFrom = std::partial_ordering::greater;
if (const auto& from = PredicateFrom.GetReplaceKey()) {
equalityWithFrom = point.ComparePartNotNull(*from, from->Size());
}
std::partial_ordering equalityWithTo = std::partial_ordering::less;
if (const auto& to = PredicateTo.GetReplaceKey()) {
equalityWithTo = point.ComparePartNotNull(*to, to->Size());
}
const bool startInternal = (equalityWithFrom == std::partial_ordering::equivalent && PredicateFrom.IsInclude()) ||
(equalityWithFrom == std::partial_ordering::greater);
const bool endInternal = (equalityWithTo == std::partial_ordering::equivalent && PredicateTo.IsInclude()) ||
(equalityWithTo == std::partial_ordering::less);
return startInternal && endInternal;
}

}
1 change: 1 addition & 0 deletions ydb/core/tx/columnshard/engines/predicate/range.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class TPKRangeFilter {
NArrow::TColumnFilter BuildFilter(const arrow::Datum& data) const;

bool IsPortionInUsage(const TPortionInfo& info) const;
bool CheckPoint(const NArrow::TReplaceKey& point) const;

enum class EUsageClass {
DontUsage,
Expand Down

0 comments on commit 80c3945

Please sign in to comment.