forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve PartitionPruner and trivial count opt
- Loading branch information
Showing
20 changed files
with
352 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include "BoolMask.h" | ||
|
||
|
||
/// BoolMask::can_be_X = true implies it will never change during BoolMask::combine. | ||
const BoolMask BoolMask::consider_only_can_be_true(false, true); | ||
const BoolMask BoolMask::consider_only_can_be_false(true, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,59 @@ | ||
#pragma once | ||
|
||
#include <fmt/format.h> | ||
|
||
/// Multiple Boolean values. That is, two Boolean values: can it be true, can it be false. | ||
struct BoolMask | ||
{ | ||
bool can_be_true = false; | ||
bool can_be_false = false; | ||
|
||
BoolMask() = default; | ||
BoolMask(bool can_be_true_, bool can_be_false_) : can_be_true(can_be_true_), can_be_false(can_be_false_) {} | ||
BoolMask(bool can_be_true_, bool can_be_false_) : can_be_true(can_be_true_), can_be_false(can_be_false_) { } | ||
|
||
BoolMask operator &(const BoolMask & m) const | ||
{ | ||
return {can_be_true && m.can_be_true, can_be_false || m.can_be_false}; | ||
} | ||
BoolMask operator |(const BoolMask & m) const | ||
{ | ||
return {can_be_true || m.can_be_true, can_be_false && m.can_be_false}; | ||
} | ||
BoolMask operator !() const | ||
BoolMask operator&(const BoolMask & m) const { return {can_be_true && m.can_be_true, can_be_false || m.can_be_false}; } | ||
BoolMask operator|(const BoolMask & m) const { return {can_be_true || m.can_be_true, can_be_false && m.can_be_false}; } | ||
BoolMask operator!() const { return {can_be_false, can_be_true}; } | ||
|
||
bool operator==(const BoolMask & other) const { return can_be_true == other.can_be_true && can_be_false == other.can_be_false; } | ||
|
||
/// Check if mask is no longer changeable under BoolMask::combine. | ||
/// We use this condition to early-exit KeyConditions::checkInRange methods. | ||
bool isComplete(const BoolMask & initial_mask) const | ||
{ | ||
return {can_be_false, can_be_true}; | ||
if (initial_mask == consider_only_can_be_true) | ||
return can_be_true; | ||
else if (initial_mask == consider_only_can_be_false) | ||
return can_be_false; | ||
else | ||
return can_be_true && can_be_false; | ||
} | ||
|
||
/// If mask is (true, true), then it can no longer change under operation |. | ||
/// We use this condition to early-exit KeyConditions::check{InRange,After} methods. | ||
bool isComplete() const | ||
/// Combine check result in different hyperrectangles. | ||
static BoolMask combine(const BoolMask & left, const BoolMask & right) | ||
{ | ||
return can_be_false && can_be_true; | ||
return {left.can_be_true || right.can_be_true, left.can_be_false || right.can_be_false}; | ||
} | ||
|
||
/// These special constants are used to implement KeyCondition::mayBeTrue{InRange,After} via KeyCondition::check{InRange,After}. | ||
/// When used as an initial_mask argument in KeyCondition::check{InRange,After} methods, they effectively prevent | ||
/// calculation of discarded BoolMask component as it is already set to true. | ||
/// The following two special constants are used to speed up | ||
/// KeyCondition::checkInRange. When used as an initial_mask argument, they | ||
/// effectively prevent calculation of discarded BoolMask component as it is | ||
/// no longer changeable under BoolMask::combine (isComplete). | ||
static const BoolMask consider_only_can_be_true; | ||
static const BoolMask consider_only_can_be_false; | ||
}; | ||
|
||
namespace fmt | ||
{ | ||
template <> | ||
struct formatter<BoolMask> | ||
{ | ||
static constexpr auto parse(format_parse_context & ctx) { return ctx.begin(); } | ||
|
||
template <typename FormatContext> | ||
auto format(const BoolMask & mask, FormatContext & ctx) | ||
{ | ||
return fmt::format_to(ctx.out(), "({}, {})", mask.can_be_true, mask.can_be_false); | ||
} | ||
}; | ||
} |
Oops, something went wrong.