mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
types: Devirtualize abstract_type::references_duration
Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
This commit is contained in:
34
types.cc
34
types.cc
@@ -1743,9 +1743,6 @@ public:
|
||||
virtual bool less(bytes_view v1, bytes_view v2) const override {
|
||||
return less_unsigned(v1, v2);
|
||||
}
|
||||
virtual bool references_duration() const override {
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
using counter_type = cql_duration::common_counter_type;
|
||||
|
||||
@@ -2159,6 +2156,21 @@ bool abstract_type::is_multi_cell() const {
|
||||
|
||||
bool abstract_type::is_native() const { return !is_collection() && !is_tuple(); }
|
||||
|
||||
bool abstract_type::references_duration() const {
|
||||
struct visitor {
|
||||
bool operator()(const abstract_type&) { return false; }
|
||||
bool operator()(const duration_type_impl&) { return true; }
|
||||
bool operator()(const tuple_type_impl& t) {
|
||||
return boost::algorithm::any_of(t.all_types(), std::mem_fn(&abstract_type::references_duration));
|
||||
}
|
||||
bool operator()(const map_type_impl& m) {
|
||||
return m.get_keys_type()->references_duration() || m.get_values_type()->references_duration();
|
||||
}
|
||||
bool operator()(const listlike_collection_type_impl& l) { return l.get_elements_type()->references_duration(); }
|
||||
};
|
||||
return visit(*this, visitor{});
|
||||
}
|
||||
|
||||
abstract_type::cql3_kind abstract_type::get_cql3_kind_impl() const {
|
||||
struct visitor {
|
||||
cql3_kind operator()(const ascii_type_impl&) { return cql3_kind::ASCII; }
|
||||
@@ -2558,10 +2570,6 @@ map_type_impl::update_user_type(const shared_ptr<const user_type_impl> updated)
|
||||
get_instance(k ? *k : _keys, v ? *v : _values, _is_multi_cell)));
|
||||
}
|
||||
|
||||
bool map_type_impl::references_duration() const {
|
||||
return _keys->references_duration() || _values->references_duration();
|
||||
}
|
||||
|
||||
auto collection_type_impl::deserialize_mutation_form(bytes_view in) const -> mutation_view {
|
||||
mutation_view ret;
|
||||
auto has_tomb = read_simple<bool>(in);
|
||||
@@ -3019,10 +3027,6 @@ set_type_impl::update_user_type(const shared_ptr<const user_type_impl> updated)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool set_type_impl::references_duration() const {
|
||||
return _elements->references_duration();
|
||||
}
|
||||
|
||||
list_type
|
||||
list_type_impl::get_instance(data_type elements, bool is_multi_cell) {
|
||||
return intern::get_instance(elements, is_multi_cell);
|
||||
@@ -3235,10 +3239,6 @@ list_type_impl::update_user_type(const shared_ptr<const user_type_impl> updated)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool list_type_impl::references_duration() const {
|
||||
return _elements->references_duration();
|
||||
}
|
||||
|
||||
tuple_type_impl::tuple_type_impl(kind k, sstring name, std::vector<data_type> types)
|
||||
: concrete_type(k, std::move(name), { }, data::type_info::make_variable_size()), _types(std::move(types)) {
|
||||
for (auto& t : _types) {
|
||||
@@ -3705,10 +3705,6 @@ tuple_type_impl::update_user_type(const shared_ptr<const user_type_impl> updated
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool tuple_type_impl::references_duration() const {
|
||||
return boost::algorithm::any_of(_types, std::mem_fn(&abstract_type::references_duration));
|
||||
}
|
||||
|
||||
sstring
|
||||
user_type_impl::get_name_as_string() const {
|
||||
auto real_utf8_type = static_cast<const utf8_type_impl*>(utf8_type.get());
|
||||
|
||||
4
types.hh
4
types.hh
@@ -568,9 +568,7 @@ public:
|
||||
}
|
||||
virtual bool references_user_type(const sstring& keyspace, const bytes& name) const = 0;
|
||||
virtual std::optional<data_type> update_user_type(const shared_ptr<const user_type_impl> updated) const = 0;
|
||||
virtual bool references_duration() const {
|
||||
return false;
|
||||
}
|
||||
bool references_duration() const;
|
||||
std::optional<uint32_t> value_length_if_fixed() const {
|
||||
return _value_length_if_fixed;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public:
|
||||
virtual bytes to_value(mutation_view mut, cql_serialization_format sf) const override;
|
||||
virtual bool references_user_type(const sstring& keyspace, const bytes& name) const override;
|
||||
virtual std::optional<data_type> update_user_type(const shared_ptr<const user_type_impl> updated) const override;
|
||||
virtual bool references_duration() const override;
|
||||
};
|
||||
|
||||
data_value make_list_value(data_type type, list_type_impl::native_type value);
|
||||
|
||||
@@ -72,7 +72,6 @@ public:
|
||||
virtual bytes to_value(mutation_view mut, cql_serialization_format sf) const override;
|
||||
virtual bool references_user_type(const sstring& keyspace, const bytes& name) const override;
|
||||
virtual std::optional<data_type> update_user_type(const shared_ptr<const user_type_impl> updated) const override;
|
||||
virtual bool references_duration() const override;
|
||||
};
|
||||
|
||||
data_value make_map_value(data_type tuple_type, map_type_impl::native_type value);
|
||||
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
const std::vector<bytes_view>& v, cql_serialization_format sf) const;
|
||||
virtual bool references_user_type(const sstring& keyspace, const bytes& name) const override;
|
||||
virtual std::optional<data_type> update_user_type(const shared_ptr<const user_type_impl> updated) const override;
|
||||
virtual bool references_duration() const override;
|
||||
};
|
||||
|
||||
data_value make_set_value(data_type tuple_type, set_type_impl::native_type value);
|
||||
|
||||
@@ -138,7 +138,6 @@ public:
|
||||
virtual bool is_value_compatible_with_internal(const abstract_type& previous) const override;
|
||||
virtual bool references_user_type(const sstring& keyspace, const bytes& name) const override;
|
||||
virtual std::optional<data_type> update_user_type(const shared_ptr<const user_type_impl> updated) const override;
|
||||
virtual bool references_duration() const override;
|
||||
private:
|
||||
bool check_compatibility(const abstract_type& previous, bool (abstract_type::*predicate)(const abstract_type&) const) const;
|
||||
static sstring make_name(const std::vector<data_type>& types);
|
||||
|
||||
Reference in New Issue
Block a user