mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
schema: Add view_info field
This patch adds a view_info optional field to the schema. It's presence indicates the schema represents a materialized view. Signed-off-by: Duarte Nunes <duarte@scylladb.com>
This commit is contained in:
11
schema.cc
11
schema.cc
@@ -348,7 +348,8 @@ bool operator==(const schema& x, const schema& y)
|
||||
&& x._raw._compaction_strategy_options == y._raw._compaction_strategy_options
|
||||
&& x._raw._caching_options == y._raw._caching_options
|
||||
&& x._raw._dropped_columns == y._raw._dropped_columns
|
||||
&& x._raw._collections == y._raw._collections;
|
||||
&& x._raw._collections == y._raw._collections
|
||||
&& x._raw._view_info == y._raw._view_info;
|
||||
#if 0
|
||||
&& Objects.equal(triggers, other.triggers)
|
||||
#endif
|
||||
@@ -463,6 +464,9 @@ std::ostream& operator<<(std::ostream& os, const schema& s) {
|
||||
os << c.first << " : " << c.second->name();
|
||||
}
|
||||
os << "}";
|
||||
if (s.is_view()) {
|
||||
os << ", viewInfo=" << *s.view_info();
|
||||
}
|
||||
os << "]";
|
||||
return os;
|
||||
}
|
||||
@@ -683,6 +687,11 @@ void schema_builder::prepare_dense_schema(schema::raw_schema& raw) {
|
||||
}
|
||||
}
|
||||
|
||||
schema_builder& schema_builder::with_view_info(utils::UUID base_id, sstring base_name, bool include_all_columns, sstring where_clause) {
|
||||
_raw._view_info = view_info(std::move(base_id), std::move(base_name), include_all_columns, std::move(where_clause));
|
||||
return *this;
|
||||
}
|
||||
|
||||
schema_ptr schema_builder::build() {
|
||||
schema::raw_schema new_raw = _raw; // Copy so that build() remains idempotent.
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "compress.hh"
|
||||
#include "compaction_strategy.hh"
|
||||
#include "caching_options.hh"
|
||||
#include "stdx.hh"
|
||||
|
||||
using column_count_type = uint32_t;
|
||||
|
||||
@@ -415,6 +416,7 @@ private:
|
||||
table_schema_version _version;
|
||||
std::unordered_map<sstring, api::timestamp_type> _dropped_columns;
|
||||
std::map<bytes, data_type> _collections;
|
||||
stdx::optional<view_info> _view_info;
|
||||
};
|
||||
raw_schema _raw;
|
||||
thrift_schema _thrift;
|
||||
@@ -623,6 +625,12 @@ public:
|
||||
const data_type& regular_column_name_type() const {
|
||||
return _raw._regular_column_name_type;
|
||||
}
|
||||
const stdx::optional<::view_info>& view_info() const {
|
||||
return _raw._view_info;
|
||||
}
|
||||
bool is_view() const {
|
||||
return bool(_raw._view_info);
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const schema& s);
|
||||
friend bool operator==(const schema&, const schema&);
|
||||
const column_mapping& get_column_mapping() const;
|
||||
|
||||
@@ -216,6 +216,11 @@ public:
|
||||
|
||||
void add_default_index_names(database&);
|
||||
|
||||
schema_builder& with_view_info(utils::UUID base_id, sstring base_name, bool include_all_columns, sstring where_clause);
|
||||
schema_builder& with_view_info(const schema& base_schema, bool include_all_columns, sstring where_clause) {
|
||||
return with_view_info(base_schema.id(), base_schema.cf_name(), include_all_columns, where_clause);
|
||||
}
|
||||
|
||||
// Equivalent to with(cp).build()
|
||||
schema_ptr build(compact_storage cp);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user