test: change sstring_view to std::string_view

Our "sstring_view" is an historic alias for the standard std::string_view.
The test/ directory used this old alias in a few of random places, let's
change them to use the standard type name.

Refs #4062.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This commit is contained in:
Nadav Har'El
2024-11-18 16:26:20 +02:00
parent b778ce08a9
commit e72aabae7f
13 changed files with 32 additions and 32 deletions

View File

@@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE(test_UUID_comparison) {
}
BOOST_AUTO_TEST_CASE(test_from_string) {
auto check = [] (sstring_view sv) {
auto check = [] (std::string_view sv) {
auto uuid = UUID(sv);
BOOST_CHECK_EQUAL(uuid.version(), 4);
BOOST_CHECK_EQUAL(fmt::to_string(uuid), sv);

View File

@@ -58,7 +58,7 @@ std::ostream& operator<<(std::ostream& out, const sync_point& sp) {
static constexpr size_t version_size = sizeof(uint8_t);
static constexpr size_t checksum_size = sizeof(uint64_t);
static uint64_t calculate_checksum(const sstring_view s) {
static uint64_t calculate_checksum(const std::string_view s) {
xx_hasher h;
h.update(s.data(), s.size());
return h.finalize_uint64();
@@ -121,7 +121,7 @@ sstring encode_v1_or_v2(const sync_point& sp, encode_version v) {
ser::serializer<sync_point_v1_or_v2>::write(out, v2);
if (v == encode_version::v2) {
sstring_view serialized_s(reinterpret_cast<const char*>(serialized.data()), version_size + measure.size());
std::string_view serialized_s(reinterpret_cast<const char*>(serialized.data()), version_size + measure.size());
uint64_t checksum = calculate_checksum(serialized_s);
ser::serializer<uint64_t>::write(out, checksum);
}

View File

@@ -218,7 +218,7 @@ SEASTAR_TEST_CASE(test_query_counters) {
};
// Executes a batch of (modifying) statements and waits for it to complete.
auto process_batch = [&e](const std::vector<sstring_view>& queries, clevel cl) mutable {
auto process_batch = [&e](const std::vector<std::string_view>& queries, clevel cl) mutable {
e.execute_batch(queries, make_options(cl)).get();
};

View File

@@ -28,7 +28,7 @@ using boost::adaptors::transformed;
std::unique_ptr<cql3::query_options> to_options(
const cql3::cql_config& cfg,
std::optional<std::vector<sstring_view>> names,
std::optional<std::vector<std::string_view>> names,
std::vector<cql3::raw_value> values) {
static auto& d = cql3::query_options::DEFAULT;
return std::make_unique<cql3::query_options>(
@@ -40,7 +40,7 @@ std::unique_ptr<cql3::query_options> to_options(
/// Asserts that e.execute_prepared(id, values) contains expected rows, in any order.
void require_rows(cql_test_env& e,
cql3::prepared_cache_key_type id,
std::optional<std::vector<sstring_view>> names,
std::optional<std::vector<std::string_view>> names,
const std::vector<bytes_opt>& values,
const std::vector<std::vector<bytes_opt>>& expected,
const seastar::compat::source_location& loc = source_location::current()) {

View File

@@ -1308,7 +1308,7 @@ SEASTAR_TEST_CASE(test_uncompressed_compound_static_row_read) {
auto val_cdef = UNCOMPRESSED_COMPOUND_STATIC_ROW_SCHEMA->get_column_definition(to_bytes("val"));
BOOST_REQUIRE(val_cdef);
auto generate = [&] (int int_val, sstring_view text_val, sstring_view inet_val) {
auto generate = [&] (int int_val, std::string_view text_val, std::string_view inet_val) {
std::vector<flat_reader_assertions_v2::expected_column> columns;
columns.push_back({s_int_cdef, int32_type->decompose(int_val)});
@@ -1669,8 +1669,8 @@ static future<> test_partition_key_with_values_of_different_types_read(const sst
BOOST_REQUIRE(text_cdef);
auto generate = [&] (bool bool_val, double double_val, float float_val, int int_val, long long_val,
sstring_view timestamp_val, sstring_view timeuuid_val, sstring_view uuid_val,
sstring_view text_val) {
std::string_view timestamp_val, std::string_view timeuuid_val, std::string_view uuid_val,
std::string_view text_val) {
std::vector<flat_reader_assertions_v2::expected_column> columns;
columns.push_back({bool_cdef, boolean_type->decompose(bool_val)});
@@ -1906,8 +1906,8 @@ SEASTAR_TEST_CASE(test_uncompressed_subset_of_columns_read) {
auto generate = [&] (std::optional<bool> bool_val, std::optional<double> double_val,
std::optional<float> float_val, std::optional<int> int_val, std::optional<long> long_val,
std::optional<sstring_view> timestamp_val, std::optional<sstring_view> timeuuid_val,
std::optional<sstring_view> uuid_val, std::optional<sstring_view> text_val) {
std::optional<std::string_view> timestamp_val, std::optional<std::string_view> timeuuid_val,
std::optional<std::string_view> uuid_val, std::optional<std::string_view> text_val) {
std::vector<flat_reader_assertions_v2::expected_column> columns;
if (bool_val) {

View File

@@ -46,7 +46,7 @@ query::clustering_row_ranges slice(
/// Overload that parses the WHERE clause from string. Named differently to disambiguate when where_clause is
/// brace-initialized.
query::clustering_row_ranges slice_parse(
sstring_view where_clause, cql_test_env& env,
std::string_view where_clause, cql_test_env& env,
const sstring& table_name = "t", const sstring& keyspace_name = "ks") {
return slice(boolean_factors(cql3::util::where_clause_to_relations(where_clause, cql3::dialect{})), env, table_name, keyspace_name);
}

View File

@@ -121,13 +121,13 @@ SEASTAR_THREAD_TEST_CASE(test_response_request_reader) {
BOOST_CHECK(v2.unset);
BOOST_CHECK_EQUAL(to_bytes(req.read_value_view(version).value), value);
std::vector<sstring_view> names;
std::vector<std::string_view> names;
std::vector<cql3::raw_value_view> values;
cql3::unset_bind_variable_vector unset;
req.read_name_and_value_list(version, names, values, unset);
BOOST_CHECK(std::none_of(unset.begin(), unset.end(), std::identity()));
BOOST_CHECK_EQUAL(names, names_and_values | boost::adaptors::transformed([] (auto& name_and_value) {
return sstring_view(name_and_value.first);
return std::string_view(name_and_value.first);
}));
BOOST_CHECK_EQUAL(values, names_and_values | boost::adaptors::transformed([] (auto& name_and_value) {
if (!name_and_value.second) {

View File

@@ -191,7 +191,7 @@ rows_assertions rows_assertions::with_serialized_columns_count(size_t columns_co
}
shared_ptr<cql_transport::messages::result_message> cquery_nofail(
cql_test_env& env, sstring_view query, std::unique_ptr<cql3::query_options>&& qo, const seastar::compat::source_location& loc) {
cql_test_env& env, std::string_view query, std::unique_ptr<cql3::query_options>&& qo, const seastar::compat::source_location& loc) {
try {
if (qo) {
return env.execute_cql(query, std::move(qo)).get();
@@ -206,7 +206,7 @@ shared_ptr<cql_transport::messages::result_message> cquery_nofail(
}
void require_rows(cql_test_env& e,
sstring_view qstr,
std::string_view qstr,
const std::vector<std::vector<bytes_opt>>& expected,
const seastar::compat::source_location& loc) {
try {
@@ -218,7 +218,7 @@ void require_rows(cql_test_env& e,
}
}
void eventually_require_rows(cql_test_env& e, sstring_view qstr, const std::vector<std::vector<bytes_opt>>& expected,
void eventually_require_rows(cql_test_env& e, std::string_view qstr, const std::vector<std::vector<bytes_opt>>& expected,
const seastar::compat::source_location& loc) {
try {
eventually([&] {

View File

@@ -74,19 +74,19 @@ void assert_that_failed(future<T>&& f)
/// \note Should be called from a seastar::thread context, as it awaits the CQL result.
shared_ptr<cql_transport::messages::result_message> cquery_nofail(
cql_test_env& env,
sstring_view query,
std::string_view query,
std::unique_ptr<cql3::query_options>&& qo = nullptr,
const seastar::compat::source_location& loc = seastar::compat::source_location::current());
/// Asserts that cquery_nofail(e, qstr) contains expected rows, in any order.
void require_rows(cql_test_env& e,
sstring_view qstr,
std::string_view qstr,
const std::vector<std::vector<bytes_opt>>& expected,
const seastar::compat::source_location& loc = seastar::compat::source_location::current());
/// Like require_rows, but wraps assertions in \c eventually.
void eventually_require_rows(
cql_test_env& e, sstring_view qstr, const std::vector<std::vector<bytes_opt>>& expected,
cql_test_env& e, std::string_view qstr, const std::vector<std::vector<bytes_opt>>& expected,
const seastar::compat::source_location& loc = seastar::compat::source_location::current());
/// Asserts that e.execute_prepared(id, values) contains expected rows, in any order.

View File

@@ -220,7 +220,7 @@ public:
adjust_rlimit();
}
virtual future<::shared_ptr<cql_transport::messages::result_message>> execute_cql(sstring_view text) override {
virtual future<::shared_ptr<cql_transport::messages::result_message>> execute_cql(std::string_view text) override {
testlog.trace("{}(\"{}\")", __FUNCTION__, text);
auto qs = make_query_state();
auto qo = make_shared<cql3::query_options>(cql3::query_options::DEFAULT);
@@ -230,7 +230,7 @@ public:
}
virtual future<::shared_ptr<cql_transport::messages::result_message>> execute_cql(
sstring_view text,
std::string_view text,
std::unique_ptr<cql3::query_options> qo) override
{
testlog.trace("{}(\"{}\")", __FUNCTION__, text);
@@ -1067,7 +1067,7 @@ private:
public:
future<::shared_ptr<cql_transport::messages::result_message>> execute_batch(
const std::vector<sstring_view>& queries, std::unique_ptr<cql3::query_options> qo) override {
const std::vector<std::string_view>& queries, std::unique_ptr<cql3::query_options> qo) override {
using cql3::statements::batch_statement;
using cql3::statements::modification_statement;
std::vector<batch_statement::single_statement> modifications;

View File

@@ -111,14 +111,14 @@ class cql_test_env {
public:
virtual ~cql_test_env() {};
virtual future<::shared_ptr<cql_transport::messages::result_message>> execute_cql(sstring_view text) = 0;
virtual future<::shared_ptr<cql_transport::messages::result_message>> execute_cql(std::string_view text) = 0;
virtual future<::shared_ptr<cql_transport::messages::result_message>> execute_cql(
sstring_view text, std::unique_ptr<cql3::query_options> qo) = 0;
std::string_view text, std::unique_ptr<cql3::query_options> qo) = 0;
/// Processes queries (which must be modifying queries) as a batch.
virtual future<::shared_ptr<cql_transport::messages::result_message>> execute_batch(
const std::vector<sstring_view>& queries, std::unique_ptr<cql3::query_options> qo) = 0;
const std::vector<std::string_view>& queries, std::unique_ptr<cql3::query_options> qo) = 0;
virtual future<cql3::prepared_cache_key_type> prepare(sstring query) = 0;

View File

@@ -53,7 +53,7 @@ raw_value make_bigint_raw(int64_t val) {
return make_raw(val);
}
raw_value make_text_raw(const sstring_view& text) {
raw_value make_text_raw(const std::string_view& text) {
return raw_value::make_value(utf8_type->decompose(text));
}
@@ -95,7 +95,7 @@ constant make_bigint_const(int64_t val) {
return make_const(val);
}
constant make_text_const(const sstring_view& text) {
constant make_text_const(const std::string_view& text) {
return constant(make_text_raw(text), utf8_type);
}
@@ -353,7 +353,7 @@ tuple_constructor make_tuple_constructor(std::vector<expression> elements, std::
.type = tuple_type_impl::get_instance(std::move(element_types))};
}
usertype_constructor make_usertype_constructor(std::vector<std::pair<sstring_view, constant>> field_values) {
usertype_constructor make_usertype_constructor(std::vector<std::pair<std::string_view, constant>> field_values) {
usertype_constructor::elements_map_type elements_map;
std::vector<bytes> field_names;
std::vector<data_type> field_types;

View File

@@ -30,7 +30,7 @@ raw_value make_tinyint_raw(int8_t val);
raw_value make_smallint_raw(int16_t val);
raw_value make_int_raw(int32_t val);
raw_value make_bigint_raw(int64_t val);
raw_value make_text_raw(const sstring_view& text);
raw_value make_text_raw(const std::string_view& text);
raw_value make_float_raw(float val);
raw_value make_double_raw(double val);
@@ -40,7 +40,7 @@ constant make_tinyint_const(int8_t val);
constant make_smallint_const(int16_t val);
constant make_int_const(int32_t val);
constant make_bigint_const(int64_t val);
constant make_text_const(const sstring_view& text);
constant make_text_const(const std::string_view& text);
constant make_float_const(float val);
constant make_double_const(double val);
@@ -102,7 +102,7 @@ collection_constructor make_map_constructor(const std::vector<std::pair<expressi
data_type key_type,
data_type element_type);
tuple_constructor make_tuple_constructor(std::vector<expression> elements, std::vector<data_type> element_types);
usertype_constructor make_usertype_constructor(std::vector<std::pair<sstring_view, constant>> field_values);
usertype_constructor make_usertype_constructor(std::vector<std::pair<std::string_view, constant>> field_values);
::lw_shared_ptr<column_specification> make_receiver(data_type receiver_type, sstring name = "receiver_name");