Everywhere: Explicitly instantiate make_shared

seastar::make_shared has a constructor taking a T&&. There is no such
constructor in std::make_shared:

https://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared

This means that we have to move from

    make_shared(T(...)

to

    make_shared<T>(...)

If we don't want to depend on the idiosyncrasies of
seastar::make_shared.

Signed-off-by: Rafael Ávila de Espíndola <espindola@scylladb.com>
This commit is contained in:
Rafael Ávila de Espíndola
2020-07-20 11:57:36 -07:00
parent abba521199
commit ad6d65dbbd
16 changed files with 39 additions and 40 deletions

View File

@@ -1332,7 +1332,7 @@ setOrMapLiteral[shared_ptr<cql3::term::raw> t] returns [shared_ptr<cql3::term::r
{ $value = ::make_shared<cql3::maps::literal>(std::move(m)); }
| { s.push_back(t); }
( ',' tn=term { s.push_back(tn); } )*
{ $value = make_shared(cql3::sets::literal(std::move(s))); }
{ $value = ::make_shared<cql3::sets::literal>(std::move(s)); }
;
collectionLiteral returns [shared_ptr<cql3::term::raw> value]
@@ -1343,7 +1343,7 @@ collectionLiteral returns [shared_ptr<cql3::term::raw> value]
| '{' t=term v=setOrMapLiteral[t] { $value = v; } '}'
// Note that we have an ambiguity between maps and set for "{}". So we force it to a set literal,
// and deal with it later based on the type of the column (SetLiteral.java).
| '{' '}' { $value = make_shared(cql3::sets::literal({})); }
| '{' '}' { $value = ::make_shared<cql3::sets::literal>(std::vector<shared_ptr<cql3::term::raw>>()); }
;
usertypeLiteral returns [shared_ptr<cql3::user_types::literal> ut]

View File

@@ -348,22 +348,22 @@ cql3_type::raw::user_type(ut_name name) {
shared_ptr<cql3_type::raw>
cql3_type::raw::map(shared_ptr<raw> t1, shared_ptr<raw> t2) {
return make_shared(raw_collection(abstract_type::kind::map, std::move(t1), std::move(t2)));
return ::make_shared<raw_collection>(abstract_type::kind::map, std::move(t1), std::move(t2));
}
shared_ptr<cql3_type::raw>
cql3_type::raw::list(shared_ptr<raw> t) {
return make_shared(raw_collection(abstract_type::kind::list, {}, std::move(t)));
return ::make_shared<raw_collection>(abstract_type::kind::list, nullptr, std::move(t));
}
shared_ptr<cql3_type::raw>
cql3_type::raw::set(shared_ptr<raw> t) {
return make_shared(raw_collection(abstract_type::kind::set, {}, std::move(t)));
return ::make_shared<raw_collection>(abstract_type::kind::set, nullptr, std::move(t));
}
shared_ptr<cql3_type::raw>
cql3_type::raw::tuple(std::vector<shared_ptr<raw>> ts) {
return make_shared(raw_tuple(std::move(ts)));
return ::make_shared<raw_tuple>(std::move(ts));
}
shared_ptr<cql3_type::raw>

View File

@@ -486,17 +486,17 @@ function_call::make_terminal(shared_ptr<function> fun, cql3::raw_value result, c
return visit(*fun->return_type(), make_visitor(
[&] (const list_type_impl& ltype) -> shared_ptr<terminal> {
return make_shared(lists::value::from_serialized(to_buffer(result), ltype, sf));
return make_shared<lists::value>(lists::value::from_serialized(to_buffer(result), ltype, sf));
},
[&] (const set_type_impl& stype) -> shared_ptr<terminal> {
return make_shared(sets::value::from_serialized(to_buffer(result), stype, sf));
return make_shared<sets::value>(sets::value::from_serialized(to_buffer(result), stype, sf));
},
[&] (const map_type_impl& mtype) -> shared_ptr<terminal> {
return make_shared(maps::value::from_serialized(to_buffer(result), mtype, sf));
return make_shared<maps::value>(maps::value::from_serialized(to_buffer(result), mtype, sf));
},
[&] (const user_type_impl& utype) -> shared_ptr<terminal> {
// TODO (kbraun): write a test for this case when User Defined Functions are implemented
return make_shared(user_types::value::from_serialized(to_buffer(result), utype));
return make_shared<user_types::value>(user_types::value::from_serialized(to_buffer(result), utype));
},
[&] (const abstract_type& type) -> shared_ptr<terminal> {
if (type.is_collection()) {

View File

@@ -81,7 +81,7 @@ lists::literal::prepare(database& db, const sstring& keyspace, lw_shared_ptr<col
if (all_terminal) {
return value.bind(query_options::DEFAULT);
} else {
return make_shared(std::move(value));
return make_shared<delayed_value>(std::move(value));
}
}
@@ -236,7 +236,7 @@ lists::marker::bind(const query_options& options) {
try {
return with_linearized(*value, [&] (bytes_view v) {
ltype.validate(v, options.get_cql_serialization_format());
return make_shared(value::from_serialized(v, ltype, options.get_cql_serialization_format()));
return make_shared<lists::value>(value::from_serialized(v, ltype, options.get_cql_serialization_format()));
});
} catch (marshal_exception& e) {
throw exceptions::invalid_request_exception(e.what());

View File

@@ -92,7 +92,7 @@ maps::literal::prepare(database& db, const sstring& keyspace, lw_shared_ptr<colu
if (all_terminal) {
return value.bind(query_options::DEFAULT);
} else {
return make_shared(std::move(value));
return make_shared<delayed_value>(std::move(value));
}
}
@@ -269,7 +269,7 @@ maps::marker::bind(const query_options& options) {
} catch (marshal_exception& e) {
throw exceptions::invalid_request_exception(e.what());
}
return ::make_shared(maps::value::from_serialized(*val, static_cast<const map_type_impl&>(*_receiver->type), options.get_cql_serialization_format()));
return ::make_shared<maps::value>(maps::value::from_serialized(*val, static_cast<const map_type_impl&>(*_receiver->type), options.get_cql_serialization_format()));
}
void

View File

@@ -64,6 +64,8 @@ private:
std::vector<shared_ptr<term::multi_column_raw>> _in_values;
shared_ptr<tuples::in_raw> _in_marker;
public:
multi_column_relation(std::vector<shared_ptr<column_identifier::raw>> entities,
const operator_type& relation_type, shared_ptr<term::multi_column_raw> values_or_marker,
std::vector<shared_ptr<term::multi_column_raw>> in_values, shared_ptr<tuples::in_raw> in_marker)
@@ -78,11 +80,10 @@ private:
std::vector<shared_ptr<column_identifier::raw>> entities, const operator_type& relation_type,
shared_ptr<term::multi_column_raw> values_or_marker, std::vector<shared_ptr<term::multi_column_raw>> in_values,
shared_ptr<tuples::in_raw> in_marker) {
return ::make_shared(multi_column_relation(std::move(entities), relation_type, std::move(values_or_marker),
std::move(in_values), std::move(in_marker)));
return ::make_shared<multi_column_relation>(std::move(entities), relation_type, std::move(values_or_marker),
std::move(in_values), std::move(in_marker));
}
public:
/**
* Creates a multi-column EQ, LT, LTE, GT, or GTE relation.
* For example: "SELECT ... WHERE (a, b) > (0, 1)"

View File

@@ -245,7 +245,7 @@ sets::marker::bind(const query_options& options) {
} catch (marshal_exception& e) {
throw exceptions::invalid_request_exception(e.what());
}
return make_shared(value::from_serialized(*value, type, options.get_cql_serialization_format()));
return make_shared<cql3::sets::value>(value::from_serialized(*value, type, options.get_cql_serialization_format()));
}
}

View File

@@ -66,7 +66,7 @@ private:
::shared_ptr<term::raw> _map_key;
::shared_ptr<term::raw> _value;
std::vector<::shared_ptr<term::raw>> _in_values;
private:
public:
single_column_relation(::shared_ptr<column_identifier::raw> entity, ::shared_ptr<term::raw> map_key,
const operator_type& type, ::shared_ptr<term::raw> value, std::vector<::shared_ptr<term::raw>> in_values)
: relation(type)
@@ -75,7 +75,7 @@ private:
, _value(std::move(value))
, _in_values(std::move(in_values))
{ }
public:
/**
* Creates a new relation.
*
@@ -102,7 +102,7 @@ public:
static ::shared_ptr<single_column_relation> create_in_relation(::shared_ptr<column_identifier::raw> entity,
std::vector<::shared_ptr<term::raw>> in_values) {
return ::make_shared(single_column_relation(std::move(entity), {}, operator_type::IN, {}, std::move(in_values)));
return ::make_shared<single_column_relation>(std::move(entity), nullptr, operator_type::IN, nullptr, std::move(in_values));
}
::shared_ptr<column_identifier::raw> get_entity() {
@@ -190,8 +190,8 @@ protected:
virtual ::shared_ptr<relation> maybe_rename_identifier(const column_identifier::raw& from, column_identifier::raw to) override {
return *_entity == from
? ::make_shared(single_column_relation(
::make_shared<column_identifier::raw>(std::move(to)), _map_key, _relation_type, _value, _in_values))
? ::make_shared<single_column_relation>(
::make_shared<column_identifier::raw>(std::move(to)), _map_key, _relation_type, _value, _in_values)
: static_pointer_cast<single_column_relation>(shared_from_this());
}

View File

@@ -454,7 +454,7 @@ batch_statement::prepare(database& db, cql_stats& stats) {
if (!have_multiple_cfs && batch_statement_.get_statements().size() > 0) {
partition_key_bind_indices = bound_names.get_partition_key_bind_indexes(*batch_statement_.get_statements()[0].statement->s);
}
return std::make_unique<prepared_statement>(make_shared(std::move(batch_statement_)),
return std::make_unique<prepared_statement>(make_shared<cql3::statements::batch_statement>(std::move(batch_statement_)),
bound_names.get_specifications(),
std::move(partition_key_bind_indices));
}

View File

@@ -139,7 +139,7 @@ void update_statement::add_update_for_key(mutation& m, const query::clustering_r
if (rb->name().empty() || rb->type == empty_type) {
// There is no column outside the PK. So no operation could have passed through validation
assert(_column_operations.empty());
constants::setter(*s->regular_begin(), make_shared(constants::value(cql3::raw_value::make_value(bytes())))).execute(m, prefix, params);
constants::setter(*s->regular_begin(), make_shared<constants::value>(cql3::raw_value::make_value(bytes()))).execute(m, prefix, params);
} else {
// dense means we don't have a row marker, so don't accept to set only the PK. See CASSANDRA-5648.
if (_column_operations.empty()) {
@@ -217,19 +217,19 @@ insert_prepared_json_statement::execute_set_value(mutation& m, const clustering_
visit(*column.type, make_visitor(
[&] (const list_type_impl& ltype) {
lists::setter::execute(m, prefix, params, column,
::make_shared(lists::value::from_serialized(fragmented_temporary_buffer::view(*value), ltype, sf)));
::make_shared<lists::value>(lists::value::from_serialized(fragmented_temporary_buffer::view(*value), ltype, sf)));
},
[&] (const set_type_impl& stype) {
sets::setter::execute(m, prefix, params, column,
::make_shared(sets::value::from_serialized(fragmented_temporary_buffer::view(*value), stype, sf)));
::make_shared<sets::value>(sets::value::from_serialized(fragmented_temporary_buffer::view(*value), stype, sf)));
},
[&] (const map_type_impl& mtype) {
maps::setter::execute(m, prefix, params, column,
::make_shared(maps::value::from_serialized(fragmented_temporary_buffer::view(*value), mtype, sf)));
::make_shared<maps::value>(maps::value::from_serialized(fragmented_temporary_buffer::view(*value), mtype, sf)));
},
[&] (const user_type_impl& utype) {
user_types::setter::execute(m, prefix, params, column,
::make_shared(user_types::value::from_serialized(fragmented_temporary_buffer::view(*value), utype)));
::make_shared<user_types::value>(user_types::value::from_serialized(fragmented_temporary_buffer::view(*value), utype)));
},
[&] (const abstract_type& type) {
if (type.is_collection()) {

View File

@@ -51,7 +51,7 @@ tuples::literal::prepare(database& db, const sstring& keyspace, lw_shared_ptr<co
if (all_terminal) {
return value.bind(query_options::DEFAULT);
} else {
return make_shared(std::move(value));
return make_shared<delayed_value>(std::move(value));
}
}
@@ -76,7 +76,7 @@ tuples::literal::prepare(database& db, const sstring& keyspace, const std::vecto
if (all_terminal) {
return value.bind(query_options::DEFAULT);
} else {
return make_shared(std::move(value));
return make_shared<delayed_value>(std::move(value));
}
}
@@ -153,7 +153,7 @@ shared_ptr<terminal> tuples::in_marker::bind(const query_options& options) {
} catch (marshal_exception& e) {
throw exceptions::invalid_request_exception(e.what());
}
return make_shared(tuples::in_value::from_serialized(*value, type, options));
return make_shared<tuples::in_value>(tuples::in_value::from_serialized(*value, type, options));
}
}

View File

@@ -323,7 +323,7 @@ public:
} catch (marshal_exception& e) {
throw exceptions::invalid_request_exception(e.what());
}
return make_shared(value::from_serialized(*value, type));
return make_shared<tuples::value>(value::from_serialized(*value, type));
}
}
};

View File

@@ -105,7 +105,7 @@ shared_ptr<term> user_types::literal::prepare(database& db, const sstring& keysp
if (all_terminal) {
return value.bind(query_options::DEFAULT);
} else {
return make_shared(std::move(value));
return make_shared<delayed_value>(std::move(value));
}
}
@@ -238,7 +238,7 @@ shared_ptr<terminal> user_types::marker::bind(const query_options& options) {
if (value.is_unset_value()) {
return constants::UNSET_VALUE;
}
return make_shared(value::from_serialized(*value, static_cast<const user_type_impl&>(*_receiver->type)));
return make_shared<user_types::value>(value::from_serialized(*value, static_cast<const user_type_impl&>(*_receiver->type)));
}
void user_types::setter::execute(mutation& m, const clustering_key_prefix& row_key, const update_parameters& params) {

View File

@@ -413,7 +413,8 @@ static auto defer_verbose_shutdown(const char* what, Func&& func) {
startlog.info("Shutting down {} was successful", what);
};
return ::make_shared(deferred_action(std::move(vfunc)));
auto ret = deferred_action(std::move(vfunc));
return ::make_shared<decltype(ret)>(std::move(ret));
}
int main(int ac, char** av) {

View File

@@ -286,7 +286,7 @@ void schema::rebuild() {
}
_v3_columns = v3_columns::from_v2_schema(*this);
_full_slice = make_shared(partition_slice_builder(*this).build());
_full_slice = make_shared<query::partition_slice>(partition_slice_builder(*this).build());
}
const column_mapping& schema::get_column_mapping() const {

View File

@@ -28,9 +28,6 @@ namespace seastar {
template <typename T>
class shared_ptr;
template <typename T>
shared_ptr<T> make_shared(T&&);
template <typename T, typename... A>
shared_ptr<T> make_shared(A&&... a);