diff --git a/types.cc b/types.cc index b83a906575..7d1e4daa2b 100644 --- a/types.cc +++ b/types.cc @@ -266,8 +266,6 @@ struct byte_type_impl : integer_type_impl { throw marshal_exception(format("Expected 1 byte for a tinyint ({:d})", v.size())); } } - - virtual bool is_native() const override { return true; } }; struct short_type_impl : integer_type_impl { @@ -279,22 +277,17 @@ struct short_type_impl : integer_type_impl { throw marshal_exception(format("Expected 2 bytes for a smallint ({:d})", v.size())); } } - - virtual bool is_native() const override { return true; } }; struct int32_type_impl : integer_type_impl { int32_type_impl() : integer_type_impl{kind::int32, int32_type_name, 4} { } - - virtual bool is_native() const override { return true; } }; struct long_type_impl : integer_type_impl { long_type_impl() : integer_type_impl{kind::long_kind, long_type_name, 8} { } - virtual bool is_native() const override { return true; } virtual bool is_value_compatible_with_internal(const abstract_type& other) const override { return &other == this || &other == date_type.get() || &other == timestamp_type.get(); } @@ -360,13 +353,11 @@ struct string_type_impl : public concrete_type { struct ascii_type_impl final : public string_type_impl { ascii_type_impl() : string_type_impl(kind::ascii, ascii_type_name) {} - virtual bool is_native() const override { return true; } }; struct utf8_type_impl final : public string_type_impl { static const char* name; utf8_type_impl() : string_type_impl(kind::utf8, utf8_type_name) {} - virtual bool is_native() const override { return true; } virtual bool is_compatible_with(const abstract_type& other) const override { // Anything that is ascii is also utf8, and they both use bytes // comparison @@ -425,7 +416,6 @@ struct bytes_type_impl final : public concrete_type { v.remove_prefix(2); return bytes_type->from_string(v); } - virtual bool is_native() const override { return true; } virtual bool is_value_compatible_with_internal(const abstract_type& other) const override { return true; } @@ -495,7 +485,6 @@ struct boolean_type_impl : public simple_type_impl { } return this->decompose(value.asBool()); } - virtual bool is_native() const override { return true; } }; // This is the old version of timestamp_type_impl, but has been replaced as it @@ -552,7 +541,6 @@ public: } return from_string(value.asString()); } - virtual bool is_native() const override { return true; } virtual bool is_value_compatible_with_internal(const abstract_type& other) const override { return &other == this || &other == timestamp_type.get() || &other == long_type.get(); } @@ -657,7 +645,6 @@ struct timeuuid_type_impl : public concrete_type { } return from_string(value.asString()); } - virtual bool is_native() const override { return true; } private: static int compare_bytes(bytes_view o1, bytes_view o2) { auto compare_pos = [&] (unsigned pos, int mask, int ifequal) { @@ -824,7 +811,6 @@ public: } return from_string(value.asString()); } - virtual bool is_native() const override { return true; } virtual bool is_value_compatible_with_internal(const abstract_type& other) const override { return &other == this || &other == date_type.get() || &other == long_type.get(); } @@ -925,7 +911,6 @@ struct simple_date_type_impl : public simple_type_impl { virtual bytes from_json_object(const Json::Value& value, cql_serialization_format sf) const override { return from_string(value.asString()); } - virtual bool is_native() const override { return true; } }; struct time_type_impl : public simple_type_impl { @@ -1017,7 +1002,6 @@ struct time_type_impl : public simple_type_impl { virtual bytes from_json_object(const Json::Value& value, cql_serialization_format sf) const override { return from_string(value.asString()); } - virtual bool is_native() const override { return true; } }; struct uuid_type_impl : concrete_type { @@ -1096,7 +1080,6 @@ struct uuid_type_impl : concrete_type { virtual bytes from_json_object(const Json::Value& value, cql_serialization_format sf) const override { return from_string(value.asString()); } - virtual bool is_native() const override { return true; } virtual bool is_value_compatible_with_internal(const abstract_type& other) const override { return &other == this || &other == timeuuid_type.get(); } @@ -1193,7 +1176,6 @@ struct inet_addr_type_impl : concrete_type { virtual bytes from_json_object(const Json::Value& value, cql_serialization_format sf) const override { return from_string(value.asString()); } - virtual bool is_native() const override { return true; } }; // Integer of same length of a given type. This is useful because our @@ -1346,12 +1328,10 @@ struct floating_type_impl : public simple_type_impl { struct double_type_impl : floating_type_impl { double_type_impl() : floating_type_impl{kind::double_kind, double_type_name, 8} { } - virtual bool is_native() const override { return true; } }; struct float_type_impl : floating_type_impl { float_type_impl() : floating_type_impl{kind::float_kind, float_type_name, 4} { } - virtual bool is_native() const override { return true; } }; @@ -1464,7 +1444,6 @@ public: throw marshal_exception(format("unable to make int from '{}'", text)); } } - virtual bool is_native() const override { return true; } virtual bool is_value_compatible_with_internal(const abstract_type& other) const override { return &other == this || int32_type->is_value_compatible_with(other) || long_type->is_value_compatible_with(other); } @@ -1567,7 +1546,6 @@ public: throw marshal_exception(format("unable to make BigDecimal from '{}'", text)); } } - virtual bool is_native() const override { return true; } }; class counter_type_impl : public abstract_type { @@ -1604,7 +1582,6 @@ public: virtual bytes from_string(sstring_view text) const override { fail(unimplemented::cause::COUNTERS); } - virtual bool is_native() const override { return true; } virtual size_t native_value_size() const override { fail(unimplemented::cause::COUNTERS); } @@ -1766,7 +1743,6 @@ public: virtual bool less(bytes_view v1, bytes_view v2) const override { return less_unsigned(v1, v2); } - virtual bool is_native() const override { return true; } virtual bool references_duration() const override { return true; } @@ -1816,7 +1792,6 @@ struct empty_type_impl : abstract_type { virtual bytes from_string(sstring_view text) const override { return {}; } - virtual bool is_native() const override { return true; } virtual size_t native_value_size() const override { return 0; } @@ -2182,6 +2157,8 @@ bool abstract_type::is_multi_cell() const { return visit(*this, visitor{}); } +bool abstract_type::is_native() const { return !is_collection() && !is_tuple(); } + abstract_type::cql3_kind abstract_type::get_cql3_kind_impl() const { struct visitor { cql3_kind operator()(const ascii_type_impl&) { return cql3_kind::ASCII; } diff --git a/types.hh b/types.hh index 64dd9670b5..e92b757fb7 100644 --- a/types.hh +++ b/types.hh @@ -641,7 +641,7 @@ public: bool is_reversed() const { return _kind == kind::reversed; } bool is_tuple() const; bool is_user_type() const { return _kind == kind::user; } - virtual bool is_native() const = 0; + bool is_native() const; cql3::cql3_type as_cql3_type() const; const sstring& cql3_type_name() const; cql3_kind_enum_set::prepared get_cql3_kind() const; @@ -997,10 +997,6 @@ public: return _underlying_type->from_string(s); } - virtual bool is_native() const { - return _underlying_type->is_native(); - } - virtual bool references_user_type(const sstring& keyspace, const bytes& name) const override { return _underlying_type->references_user_type(keyspace, name); } diff --git a/types/collection.hh b/types/collection.hh index d484eaa0c2..4b2471cf69 100644 --- a/types/collection.hh +++ b/types/collection.hh @@ -66,7 +66,6 @@ public: virtual bool is_value_compatible_with_internal(const abstract_type& other) const override; virtual bool is_compatible_with_frozen(const collection_type_impl& previous) const = 0; virtual bool is_value_compatible_with_frozen(const collection_type_impl& previous) const = 0; - virtual bool is_native() const override { return false; } template static bytes pack(BytesViewIterator start, BytesViewIterator finish, int elements, cql_serialization_format sf); // requires linearized collection_mutation_view, lifetime diff --git a/types/tuple.hh b/types/tuple.hh index afd60a9497..49e5259b7b 100644 --- a/types/tuple.hh +++ b/types/tuple.hh @@ -136,7 +136,6 @@ public: virtual bytes from_json_object(const Json::Value& value, cql_serialization_format sf) const override; virtual bool is_compatible_with(const abstract_type& previous) const override; virtual bool is_value_compatible_with_internal(const abstract_type& previous) const override; - virtual bool is_native() const override { return false; } virtual bool references_user_type(const sstring& keyspace, const bytes& name) const override; virtual std::optional update_user_type(const shared_ptr updated) const override; virtual bool references_duration() const override; diff --git a/types/user.hh b/types/user.hh index 9e54522d6f..6184c9f4bf 100644 --- a/types/user.hh +++ b/types/user.hh @@ -52,7 +52,6 @@ public: sstring field_name_as_string(size_t i) const { return _string_field_names[i]; } const std::vector& field_names() const { return _field_names; } sstring get_name_as_string() const; - virtual bool is_native() const override { return false; } virtual bool references_user_type(const sstring& keyspace, const bytes& name) const override; virtual std::optional update_user_type(const shared_ptr updated) const override;