From 60e3637efcebc285de134dd13f6b55a907d0f8e1 Mon Sep 17 00:00:00 2001 From: Gleb Natapov Date: Thu, 28 Jan 2016 11:26:00 +0200 Subject: [PATCH] Move frozen_schema to idl --- configure.py | 1 + frozen_schema.cc | 5 +++++ frozen_schema.hh | 4 ++-- idl/frozen_schema.idl.hh | 24 ++++++++++++++++++++++++ message/messaging_service.cc | 13 +++++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 idl/frozen_schema.idl.hh diff --git a/configure.py b/configure.py index 5b25de9248..0774cae1b0 100755 --- a/configure.py +++ b/configure.py @@ -471,6 +471,7 @@ idls = ['idl/gossip_digest.idl.hh', 'idl/reconcilable_result.idl.hh', 'idl/streaming.idl.hh', 'idl/paging_state.idl.hh', + 'idl/frozen_schema.idl.hh', ] scylla_tests_dependencies = scylla_core + api + idls + [ diff --git a/frozen_schema.cc b/frozen_schema.cc index f9cf6361cd..3f9a727c3b 100644 --- a/frozen_schema.cc +++ b/frozen_schema.cc @@ -46,6 +46,11 @@ frozen_schema::frozen_schema(bytes b) : _data(std::move(b)) { } +bytes_view frozen_schema::representation() const +{ + return _data; +} + template<> db::serializer::serializer(const frozen_schema& v) : _item(v) diff --git a/frozen_schema.hh b/frozen_schema.hh index 7e68f2af56..7b1d97d8c3 100644 --- a/frozen_schema.hh +++ b/frozen_schema.hh @@ -30,9 +30,8 @@ // It's safe to access from another shard by const&. class frozen_schema { bytes _data; -private: - frozen_schema(bytes); public: + explicit frozen_schema(bytes); frozen_schema(const schema_ptr&); frozen_schema(frozen_schema&&) = default; frozen_schema(const frozen_schema&) = default; @@ -40,6 +39,7 @@ public: frozen_schema& operator=(frozen_schema&&) = default; schema_ptr unfreeze() const; friend class db::serializer; + bytes_view representation() const; }; namespace db { diff --git a/idl/frozen_schema.idl.hh b/idl/frozen_schema.idl.hh new file mode 100644 index 0000000000..ab58debcf5 --- /dev/null +++ b/idl/frozen_schema.idl.hh @@ -0,0 +1,24 @@ +/* + * Copyright 2016 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 . + */ + +class frozen_schema final { + bytes representation(); +}; diff --git a/message/messaging_service.cc b/message/messaging_service.cc index 360246bb84..6ddfe21d59 100644 --- a/message/messaging_service.cc +++ b/message/messaging_service.cc @@ -41,6 +41,7 @@ #include "idl/keys.dist.hh" #include "idl/uuid.dist.hh" #include "idl/frozen_mutation.dist.hh" +#include "idl/frozen_schema.dist.hh" #include "idl/streaming.dist.hh" #include "idl/token.dist.hh" #include "idl/gossip_digest.dist.hh" @@ -53,6 +54,7 @@ #include "idl/keys.dist.impl.hh" #include "idl/uuid.dist.impl.hh" #include "idl/frozen_mutation.dist.impl.hh" +#include "idl/frozen_schema.dist.impl.hh" #include "idl/streaming.dist.impl.hh" #include "idl/token.dist.impl.hh" #include "idl/gossip_digest.dist.impl.hh" @@ -217,6 +219,17 @@ read(serializer, Input& in, boost::type type) { return ser::deserialize(in, type); } +template +void write(serializer, Output& out, const frozen_schema& data) { + ser::serialize(out, data); +} + +template +frozen_schema +read(serializer, Input& in, boost::type type) { + return ser::deserialize(in, type); +} + template void write(serializer, Output& out, const reconcilable_result& data) { ser::serialize(out, data);