The write path uses a base schema at a particular version, and we want it to use the materialized views at the corresponding version. To achieve this, we need to map the state currently in db::view::view to a particular schema version, which this patch does by introducing the view_info class to hold the state previously in db::view::view, and by having a view schema directly point to it. The changes in the patch are thus: 1) Introduce view_info to hold the extra view state; 2) Point to the view_info from the schema; 3) Make the functions in the now stateless db::view::view non-member; 4) Remove the db::view::view class. All changes are structural and don't affect current behavior. Signed-off-by: Duarte Nunes <duarte@scylladb.com>
72 lines
2.3 KiB
C++
72 lines
2.3 KiB
C++
/*
|
|
* Copyright (C) 2017 ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* This file is part of Scylla.
|
|
*
|
|
* Scylla is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Scylla is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "cql3/statements/select_statement.hh"
|
|
#include "dht/i_partitioner.hh"
|
|
#include "query-request.hh"
|
|
#include "schema.hh"
|
|
|
|
class view_info final {
|
|
const schema& _schema;
|
|
raw_view_info _raw;
|
|
// The following fields are used to select base table rows.
|
|
mutable shared_ptr<cql3::statements::select_statement> _select_statement;
|
|
mutable stdx::optional<query::partition_slice> _partition_slice;
|
|
mutable stdx::optional<dht::partition_range_vector> _partition_ranges;
|
|
mutable const column_definition* _base_non_pk_column_in_view_pk;
|
|
public:
|
|
view_info(const schema& schema, const raw_view_info& raw_view_info);
|
|
|
|
const raw_view_info& raw() const {
|
|
return _raw;
|
|
}
|
|
|
|
const utils::UUID& base_id() const {
|
|
return _raw.base_id();
|
|
}
|
|
|
|
const sstring& base_name() const {
|
|
return _raw.base_name();
|
|
}
|
|
|
|
bool include_all_columns() const {
|
|
return _raw.include_all_columns();
|
|
}
|
|
|
|
const sstring& where_clause() const {
|
|
return _raw.where_clause();
|
|
}
|
|
|
|
cql3::statements::select_statement& select_statement() const;
|
|
const query::partition_slice& partition_slice() const;
|
|
const dht::partition_range_vector& partition_ranges() const;
|
|
const column_definition* view_column(const schema& base, column_id base_id) const;
|
|
const column_definition* base_non_pk_column_in_view_pk(const schema& base) const;
|
|
|
|
friend bool operator==(const view_info& x, const view_info& y) {
|
|
return x._raw == y._raw;
|
|
}
|
|
friend std::ostream& operator<<(std::ostream& os, const view_info& view) {
|
|
return os << view._raw;
|
|
}
|
|
}; |