mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-29 19:21:01 +00:00
cql3: expression: use nested_expression in binary_operator
binary_operator::lhs is implementing the pattern in nested_expression. Use nested_expression instead to reduce code size.
This commit is contained in:
@@ -70,24 +70,12 @@ nested_expression::operator=(const nested_expression& o) {
|
||||
}
|
||||
|
||||
binary_operator::binary_operator(expression lhs, oper_t op, ::shared_ptr<term> rhs, comparison_order order)
|
||||
: lhs(std::make_unique<expression>(std::move(lhs)))
|
||||
: lhs(std::move(lhs))
|
||||
, op(op)
|
||||
, rhs(std::move(rhs))
|
||||
, order(order) {
|
||||
}
|
||||
|
||||
binary_operator::binary_operator(const binary_operator& x) : binary_operator(*x.lhs, x.op, x.rhs, x.order) {
|
||||
}
|
||||
|
||||
binary_operator&
|
||||
binary_operator::operator=(const binary_operator& x) {
|
||||
*lhs = *x.lhs;
|
||||
op = x.op;
|
||||
rhs = x.rhs;
|
||||
order = x.order;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Since column_identifier_raw is forward-declared in expression.hh, delay destructor instantiation here
|
||||
unresolved_identifier::~unresolved_identifier() = default;
|
||||
|
||||
@@ -913,7 +901,7 @@ bool is_on_collection(const binary_operator& b) {
|
||||
if (b.op == oper_t::CONTAINS || b.op == oper_t::CONTAINS_KEY) {
|
||||
return true;
|
||||
}
|
||||
if (auto tuple = std::get_if<column_value_tuple>(b.lhs.get())) {
|
||||
if (auto tuple = std::get_if<column_value_tuple>(&*b.lhs)) {
|
||||
return boost::algorithm::any_of(tuple->elements, [] (const column_value& v) { return v.sub; });
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -127,17 +127,12 @@ enum class comparison_order : char {
|
||||
|
||||
/// Operator restriction: LHS op RHS.
|
||||
struct binary_operator {
|
||||
std::unique_ptr<expression> lhs;
|
||||
nested_expression lhs;
|
||||
oper_t op;
|
||||
::shared_ptr<term> rhs;
|
||||
comparison_order order;
|
||||
|
||||
binary_operator(expression lhs, oper_t op, ::shared_ptr<term> rhs, comparison_order order = comparison_order::cql);
|
||||
|
||||
binary_operator(const binary_operator& x);
|
||||
binary_operator& operator=(const binary_operator&);
|
||||
binary_operator(binary_operator&& x) = default;
|
||||
binary_operator& operator=(binary_operator&& x) = default;
|
||||
};
|
||||
|
||||
/// A conjunction of restrictions.
|
||||
|
||||
@@ -690,7 +690,7 @@ dht::partition_range_vector partition_ranges_from_singles(
|
||||
size_t product_size = 1;
|
||||
for (const auto& e : expressions) {
|
||||
if (const auto arbitrary_binop = find_atom(e, [] (const binary_operator&) { return true; })) {
|
||||
if (auto cv = std::get_if<expr::column_value>(arbitrary_binop->lhs.get())) {
|
||||
if (auto cv = std::get_if<expr::column_value>(&*arbitrary_binop->lhs)) {
|
||||
const value_set vals = possible_lhs_values(cv->col, e, options);
|
||||
if (auto lst = std::get_if<value_list>(&vals)) {
|
||||
if (lst->empty()) {
|
||||
|
||||
Reference in New Issue
Block a user