From 0c0cc66ee7b9c19b46c930fc5cc411cdeff2775e Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 28 Dec 2018 23:57:36 +0200 Subject: [PATCH] system_keyspace, view: reduce interdependencies system_keyspace is an implementation detail for most of its users, not part of the interface, as it's only used to store internal data. Therefore, including it in a header file causes unneeded dependencies. This patch removes a dependency between views and system_keyspace.hh by moving view_name and view_build_progress into a separate header file, and using forward declarations where possible. This allows us to remove an inclusion of system_keyspace.hh from a header file (the last one), so that further changes to system_keyspace.hh will cause fewer recompilations. Message-Id: <20181228215736.11493-1-avi@scylladb.com> --- db/system_keyspace.cc | 1 + db/system_keyspace.hh | 7 +---- db/system_keyspace_view_types.hh | 47 ++++++++++++++++++++++++++++++++ db/view/view.cc | 2 ++ db/view/view_builder.hh | 9 +++++- 5 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 db/system_keyspace_view_types.hh diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index be71e67dff..53fe87c163 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -62,6 +62,7 @@ #include "query_context.hh" #include "partition_slice_builder.hh" #include "db/config.hh" +#include "system_keyspace_view_types.hh" #include "schema_builder.hh" #include "md5_hasher.hh" #include "release.hh" diff --git a/db/system_keyspace.hh b/db/system_keyspace.hh index 0104b68f6e..2844b7b7b9 100644 --- a/db/system_keyspace.hh +++ b/db/system_keyspace.hh @@ -127,12 +127,7 @@ struct range_estimates { }; using view_name = std::pair; -struct view_build_progress { - view_name view; - dht::token first_token; - std::optional next_token; - shard_id cpu_id; -}; +struct view_build_progress; extern schema_ptr hints(); extern schema_ptr batchlog(); diff --git a/db/system_keyspace_view_types.hh b/db/system_keyspace_view_types.hh new file mode 100644 index 0000000000..60e7fde4dd --- /dev/null +++ b/db/system_keyspace_view_types.hh @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2018 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 . + */ + +#pragma once + +#include +#include +#include +#include +#include "seastarx.hh" + +namespace dht { + +class token; + +} + +namespace db::system_keyspace { + +using view_name = std::pair; + +struct view_build_progress { + view_name view; + dht::token first_token; + std::optional next_token; + shard_id cpu_id; +}; + +} diff --git a/db/view/view.cc b/db/view/view.cc index ddf296ba8b..0ecf6cb8a1 100644 --- a/db/view/view.cc +++ b/db/view/view.cc @@ -58,6 +58,8 @@ #include "cql3/util.hh" #include "db/view/view.hh" #include "db/view/view_builder.hh" +#include "db/system_keyspace_view_types.hh" +#include "db/system_keyspace.hh" #include "frozen_mutation.hh" #include "gms/inet_address.hh" #include "keys.hh" diff --git a/db/view/view_builder.hh b/db/view/view_builder.hh index 3a262da853..5ded1ea09f 100644 --- a/db/view/view_builder.hh +++ b/db/view/view_builder.hh @@ -22,7 +22,6 @@ #pragma once #include "database_fwd.hh" -#include "db/system_keyspace.hh" #include "db/system_distributed_keyspace.hh" #include "dht/i_partitioner.hh" #include "keys.hh" @@ -46,6 +45,14 @@ #include #include +namespace db::system_keyspace { + +using view_name = std::pair; +class view_build_progress; + +} + + namespace db::view { /**