Skip to content

Commit

Permalink
data_dictionary: move user_types_metadata to new module data_dictionary
Browse files Browse the repository at this point in the history
The new module will contain all schema related metadata, detached from
actual data access (provided by the database class). User types is the
first contents to be moved to the new module.
  • Loading branch information
avikivity committed Dec 15, 2021
1 parent 3ac622b commit 021c759
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 16 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ set(scylla_sources
cql3/util.cc
cql3/ut_name.cc
cql3/values.cc
data_dictionary/data_dictionary.cc
database.cc
db/batchlog_manager.cc
db/commitlog/commitlog.cc
Expand Down
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ def find_headers(repodir, excluded_dirs):
'cql3/util.cc',
'cql3/ut_name.cc',
'cql3/role_name.cc',
'data_dictionary/data_dictionary.cc',
'thrift/handler.cc',
'thrift/server.cc',
'thrift/controller.cc',
Expand Down
2 changes: 1 addition & 1 deletion cql3/cql3_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "cql3/util.hh"
#include "ut_name.hh"
#include "database.hh"
#include "user_types_metadata.hh"
#include "data_dictionary/user_types_metadata.hh"
#include "types/map.hh"
#include "types/set.hh"
#include "types/list.hh"
Expand Down
5 changes: 4 additions & 1 deletion cql3/cql3_type.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
#include "enum_set.hh"

class database;

namespace data_dictionary {
class user_types_metadata;
}

namespace cql3 {

Expand Down Expand Up @@ -81,7 +84,7 @@ public:
virtual bool references_user_type(const sstring&) const;
virtual std::optional<sstring> keyspace() const;
virtual void freeze();
virtual cql3_type prepare_internal(const sstring& keyspace, const user_types_metadata&) = 0;
virtual cql3_type prepare_internal(const sstring& keyspace, const data_dictionary::user_types_metadata&) = 0;
virtual cql3_type prepare(database& db, const sstring& keyspace);
static shared_ptr<raw> from(cql3_type type);
static shared_ptr<raw> user_type(ut_name name);
Expand Down
2 changes: 1 addition & 1 deletion cql3/statements/alter_type_statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "service/storage_proxy.hh"
#include "database.hh"
#include "boost/range/adaptor/map.hpp"
#include "user_types_metadata.hh"
#include "data_dictionary/user_types_metadata.hh"

namespace cql3 {

Expand Down
2 changes: 1 addition & 1 deletion cql3/statements/create_type_statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "database.hh"
#include "service/migration_manager.hh"
#include "service/storage_proxy.hh"
#include "user_types_metadata.hh"
#include "data_dictionary/user_types_metadata.hh"
#include "cql3/query_processor.hh"
#include "cql3/column_identifier.hh"

Expand Down
2 changes: 1 addition & 1 deletion cql3/statements/drop_type_statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "service/migration_manager.hh"
#include "service/storage_proxy.hh"
#include "database.hh"
#include "user_types_metadata.hh"
#include "data_dictionary/user_types_metadata.hh"

namespace cql3 {

Expand Down
32 changes: 32 additions & 0 deletions data_dictionary/data_dictionary.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2021-present 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/>.
*/

#include "user_types_metadata.hh"
#include <ostream>

namespace data_dictionary {

std::ostream& operator<<(std::ostream& os, const user_types_metadata& m) {
os << "org.apache.cassandra.config.UTMetaData@" << &m;
return os;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "bytes.hh"
#include "types/user.hh"

namespace data_dictionary {

class user_types_metadata {
std::unordered_map<bytes, user_type> _user_types;
public:
Expand All @@ -46,3 +48,5 @@ public:
}
friend std::ostream& operator<<(std::ostream& os, const user_types_metadata& m);
};

}
7 changes: 1 addition & 6 deletions database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#include "db/large_data_handler.hh"
#include "db/data_listeners.hh"

#include "user_types_metadata.hh"
#include "data_dictionary/user_types_metadata.hh"
#include <seastar/core/shared_ptr_incomplete.hh>
#include <seastar/util/memory_diagnostics.hh>

Expand Down Expand Up @@ -2336,11 +2336,6 @@ future<> database::drain() {
co_await _commitlog->shutdown();
}

std::ostream& operator<<(std::ostream& os, const user_types_metadata& m) {
os << "org.apache.cassandra.config.UTMetaData@" << &m;
return os;
}

std::ostream& operator<<(std::ostream& os, const keyspace_metadata& m) {
os << "KSMetaData{";
os << "name=" << m._name;
Expand Down
4 changes: 2 additions & 2 deletions database.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#include <unordered_set>
#include "utils/disk-error-handler.hh"
#include "utils/updateable_value.hh"
#include "user_types_metadata.hh"
#include "data_dictionary/user_types_metadata.hh"
#include "query_class_config.hh"
#include "absl-flat_hash_map.hh"
#include "utils/cross-shard-barrier.hh"
Expand Down Expand Up @@ -1091,7 +1091,7 @@ public:
compaction::table_state& as_table_state() const noexcept;
};

class user_types_metadata;
using user_types_metadata = data_dictionary::user_types_metadata;

class keyspace_metadata final {
sstring _name;
Expand Down
2 changes: 1 addition & 1 deletion db/cql_type_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "cql3/util.hh"
#include "cql_type_parser.hh"
#include "types.hh"
#include "user_types_metadata.hh"
#include "data_dictionary/user_types_metadata.hh"

static ::shared_ptr<cql3::cql3_type::raw> parse_raw(const sstring& str) {
return cql3::util::do_with_parser(str,
Expand Down
1 change: 0 additions & 1 deletion db/cql_type_parser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@

#include "seastarx.hh"

class user_types_metadata;
class types_metadata;
class keyspace_metadata;

Expand Down
2 changes: 1 addition & 1 deletion db/schema_tables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#include "cql_type_parser.hh"
#include "db/timeout_clock.hh"
#include "database.hh"
#include "user_types_metadata.hh"
#include "data_dictionary/user_types_metadata.hh"

#include "index/target_parser.hh"
#include "lang/lua.hh"
Expand Down

0 comments on commit 021c759

Please sign in to comment.