mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-06 06:53:12 +00:00
Previous assumption was that there can only be one regular base column in the view key. The assumption is still correct for tables created via CQL, but it's internally possible to create a view with multiple such columns - the new assumption is that if there are multiple columns, they share their liveness. This patch is vital for indexing to work properly on alternator, so it would be best to solve the issue upstream. I strived to leave the existing semantics intact as long as only up to one regular column is part of the materialized view primary key, which is the case for Scylla's materialized views. For alternator it may not be true, but all regular columns in alternator share liveness info (since alternator does not support per-column TTL), which is sufficient to compute view updates in a consistent way. Fixes #5006 Tests: unit(dev), alternator(test_gsi_update_second_regular_base_column, tic-tac-toe demo) Message-Id: <c9dec243ce903d3a922ce077dc274f988bcf5d57.1567604945.git.sarna@scylladb.com>
77 lines
2.6 KiB
C++
77 lines
2.6 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 std::optional<query::partition_slice> _partition_slice;
|
|
mutable std::optional<dht::partition_range_vector> _partition_ranges;
|
|
// Id of a regular base table column included in the view's PK, if any.
|
|
// Scylla views only allow one such column, alternator can have up to two.
|
|
mutable std::vector<column_id> _base_non_pk_columns_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* view_column(const column_definition& base_def) const;
|
|
const std::vector<column_id>& base_non_pk_columns_in_view_pk() const;
|
|
void initialize_base_dependent_fields(const schema& base);
|
|
|
|
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;
|
|
}
|
|
};
|