/* */ /* * Copyright (C) 2015-present ScyllaDB * * Modified by ScyllaDB */ /* * SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0) */ #pragma once #include #include #include "to_string.hh" #include "relation.hh" #include "column_identifier.hh" #include "restrictions/restriction.hh" #include "expr/expression.hh" namespace cql3 { /** * A relation using the token function. * Examples: * */ class token_relation : public relation { private: std::vector<::shared_ptr> _entities; expr::expression _value; /** * Returns the definition of the columns to which apply the token restriction. * * @param cfm the column family metadata * @return the definition of the columns to which apply the token restriction. * @throws InvalidRequestException if the entity cannot be resolved */ std::vector get_column_definitions(const schema& s); /** * Returns the receivers for this relation. * * @param cfm the Column Family meta data * @param columnDefs the column definitions * @return the receivers for the specified relation. * @throws InvalidRequestException if the relation is invalid */ std::vector> to_receivers(const schema& schema, const std::vector& column_defs) const; public: token_relation(std::vector<::shared_ptr> entities, expr::oper_t type, expr::expression value) : relation(type), _entities(std::move(entities)), _value( std::move(value)) { } bool on_token() const override { return true; } ::shared_ptr new_EQ_restriction(data_dictionary::database db, schema_ptr schema, prepare_context& ctx) override; ::shared_ptr new_IN_restriction(data_dictionary::database db, schema_ptr schema, prepare_context& ctx) override; ::shared_ptr new_slice_restriction(data_dictionary::database db, schema_ptr schema, prepare_context& ctx, statements::bound bound, bool inclusive) override; ::shared_ptr new_contains_restriction( data_dictionary::database db, schema_ptr schema, prepare_context& ctx, bool isKey) override; ::shared_ptr new_LIKE_restriction(data_dictionary::database db, schema_ptr schema, prepare_context& ctx) override; ::shared_ptr maybe_rename_identifier(const column_identifier::raw& from, column_identifier::raw to) override; sstring to_string() const override; protected: expr::expression to_expression(const std::vector>& receivers, const expr::expression& raw, data_dictionary::database db, const sstring& keyspace, prepare_context& ctx) const override; }; }