Files
scylladb/cql3/lists.hh
Kefu Chai 372a4d1b79 treewide: do not define FMT_DEPRECATED_OSTREAM
since we do not rely on FMT_DEPRECATED_OSTREAM to define the
fmt::formatter for us anymore, let's stop defining `FMT_DEPRECATED_OSTREAM`.

in this change,

* utils: drop the range formatters in to_string.hh and to_string.c, as
  we don't use them anymore. and the tests for them in
  test/boost/string_format_test.cc are removed accordingly.
* utils: use fmt to print chunk_vector and small_vector. as
  we are not able to print the elements using operator<< anymore
  after switching to {fmt} formatters.
* test/boost: specialize fmt::details::is_std_string_like<bytes>
  due to a bug in {fmt} v9, {fmt} fails to format a range whose
  element type is `basic_sstring<uint8_t>`, as it considers it
  as a string-like type, but `basic_sstring<uint8_t>`'s char type
  is signed char, not char. this issue does not exist in {fmt} v10,
  so, in this change, we add a workaround to explicitly specialize
  the type trait to assure that {fmt} format this type using its
  `fmt::formatter` specialization instead of trying to format it
  as a string. also, {fmt}'s generic ranges formatter calls the
  pair formatter's `set_brackets()` and `set_separator()` methods
  when printing the range, but operator<< based formatter does not
  provide these method, we have to include this change in the change
  switching to {fmt}, otherwise the change specializing
  `fmt::details::is_std_string_like<bytes>` won't compile.
* test/boost: in tests, we use `BOOST_REQUIRE_EQUAL()` and its friends
  for comparing values. but without the operator<< based formatters,
  Boost.Test would not be able to print them. after removing
  the homebrew formatters, we need to use the generic
  `boost_test_print_type()` helper to do this job. so we are
  including `test_utils.hh` in tests so that we can print
  the formattable types.
* treewide: add "#include "utils/to_string.hh" where
  `fmt::formatter<optional<>>` is used.
* configure.py: do not define FMT_DEPRECATED_OSTREAM
* cmake: do not define FMT_DEPRECATED_OSTREAM

Refs #13245

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-04-19 22:57:36 +08:00

96 lines
3.6 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*
* Modified by ScyllaDB
*/
/*
* SPDX-License-Identifier: (AGPL-3.0-or-later and Apache-2.0)
*/
#pragma once
#include "operation.hh"
#include "utils/chunked_vector.hh"
namespace cql3 {
/**
* Static helper methods and classes for lists.
*/
class lists {
lists() = delete;
public:
static lw_shared_ptr<column_specification> index_spec_of(const column_specification&);
static lw_shared_ptr<column_specification> value_spec_of(const column_specification&);
static lw_shared_ptr<column_specification> uuid_index_spec_of(const column_specification&);
public:
class setter : public operation_skip_if_unset {
public:
setter(const column_definition& column, expr::expression e)
: operation_skip_if_unset(column, std::move(e)) {
}
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
static void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params, const column_definition& column, const cql3::raw_value& value);
};
class setter_by_index : public operation_skip_if_unset {
protected:
expr::expression _idx;
public:
setter_by_index(const column_definition& column, expr::expression idx, expr::expression e)
: operation_skip_if_unset(column, std::move(e)), _idx(std::move(idx)) {
}
virtual bool requires_read() const override;
virtual void fill_prepare_context(prepare_context& ctx) override;
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
};
class setter_by_uuid : public setter_by_index {
public:
setter_by_uuid(const column_definition& column, expr::expression idx, expr::expression e)
: setter_by_index(column, std::move(idx), std::move(e)) {
}
virtual bool requires_read() const override;
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
};
class appender : public operation_skip_if_unset {
public:
using operation_skip_if_unset::operation_skip_if_unset;
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
};
static void do_append(const cql3::raw_value& list_value,
mutation& m,
const clustering_key_prefix& prefix,
const column_definition& column,
const update_parameters& params);
class prepender : public operation_skip_if_unset {
public:
using operation_skip_if_unset::operation_skip_if_unset;
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
};
class discarder : public operation_skip_if_unset {
public:
discarder(const column_definition& column, expr::expression e)
: operation_skip_if_unset(column, std::move(e)) {
}
virtual bool requires_read() const override;
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
};
class discarder_by_index : public operation_skip_if_unset {
public:
discarder_by_index(const column_definition& column, expr::expression idx)
: operation_skip_if_unset(column, std::move(idx)) {
}
virtual bool requires_read() const override;
virtual void execute(mutation& m, const clustering_key_prefix& prefix, const update_parameters& params) override;
};
};
}