schema_extensions: Add an option to string method
Allow an extension to describe itself as the CQL property string that created it (and is serialized to schema tables) Only paxos extension requires override.
This commit is contained in:
@@ -55,6 +55,10 @@ public:
|
||||
return ser::serialize_to_buffer<bytes>(_paxos_gc_sec);
|
||||
}
|
||||
|
||||
std::string options_to_string() const override {
|
||||
return std::to_string(_paxos_gc_sec);
|
||||
}
|
||||
|
||||
static int32_t deserialize(const bytes_view& buffer) {
|
||||
return ser::deserialize_from_buffer(buffer, boost::type<int32_t>());
|
||||
}
|
||||
|
||||
@@ -801,6 +801,16 @@ std::ostream& operator<<(std::ostream& os, const schema& s) {
|
||||
return os;
|
||||
}
|
||||
|
||||
// default impl assumes options are in a map.
|
||||
// implementations should override if not
|
||||
std::string schema_extension::options_to_string() const {
|
||||
std::ostringstream ss;
|
||||
ss << '{';
|
||||
map_as_cql_param(ss, ser::deserialize_from_buffer(serialize(), boost::type<default_map_type>(), 0));
|
||||
ss << '}';
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static std::ostream& column_definition_as_cql_key(std::ostream& os, const column_definition & cd) {
|
||||
os << cd.name_as_cql_string();
|
||||
os << " " << cd.type->cql3_type_name();
|
||||
|
||||
@@ -534,6 +534,10 @@ public:
|
||||
virtual bool is_placeholder() const {
|
||||
return false;
|
||||
}
|
||||
using default_map_type = std::map<sstring, sstring>;
|
||||
// default impl assumes options are in a map.
|
||||
// implementations should override if not
|
||||
virtual std::string options_to_string() const;
|
||||
};
|
||||
|
||||
struct schema_static_props {
|
||||
|
||||
Reference in New Issue
Block a user