diff --git a/.github/workflows/lint_and_test_cpp.yaml b/.github/workflows/lint_and_test_cpp.yaml index 35fdecd687..ca4ae55203 100644 --- a/.github/workflows/lint_and_test_cpp.yaml +++ b/.github/workflows/lint_and_test_cpp.yaml @@ -78,7 +78,9 @@ jobs: iwyu: name: IWYU - needs: cpp_clang_format_linter + needs: + - cpp_clang_format_linter + - cpp_clang_tidy_linter runs-on: ubuntu-latest env: USE_JEMALLOC: OFF diff --git a/src/base/pegasus_utils.h b/src/base/pegasus_utils.h index a6ea381f74..adb0788884 100644 --- a/src/base/pegasus_utils.h +++ b/src/base/pegasus_utils.h @@ -28,7 +28,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "utils/flags.h" DSN_DECLARE_bool(encrypt_data_at_rest); @@ -122,9 +122,9 @@ const std::string &redact_sensitive_string(const T &src) } } -inline absl::string_view to_string_view(rocksdb::Slice s) { return {s.data(), s.size()}; } +inline std::string_view to_string_view(rocksdb::Slice s) { return {s.data(), s.size()}; } -inline rocksdb::Slice to_rocksdb_slice(absl::string_view s) { return {s.data(), s.size()}; } +inline rocksdb::Slice to_rocksdb_slice(std::string_view s) { return {s.data(), s.size()}; } } // namespace utils } // namespace pegasus diff --git a/src/base/pegasus_value_schema.h b/src/base/pegasus_value_schema.h index d8f651b163..c95ceedbd3 100644 --- a/src/base/pegasus_value_schema.h +++ b/src/base/pegasus_value_schema.h @@ -32,7 +32,7 @@ #include "utils/blob.h" #include "utils/endians.h" #include "utils/fmt_logging.h" -#include "absl/strings/string_view.h" +#include #include "value_field.h" namespace pegasus { @@ -55,7 +55,7 @@ inline uint64_t extract_timestamp_from_timetag(uint64_t timetag) /// Extracts expire_ts from rocksdb value with given version. /// The value schema must be in v0 or v1. /// \return expire_ts in host endian -inline uint32_t pegasus_extract_expire_ts(uint32_t version, absl::string_view value) +inline uint32_t pegasus_extract_expire_ts(uint32_t version, std::string_view value) { CHECK_LE(version, PEGASUS_DATA_VERSION_MAX); return dsn::data_input(value).read_u32(); @@ -76,7 +76,7 @@ pegasus_extract_user_data(uint32_t version, std::string &&raw_value, ::dsn::blob if (version == 1) { input.skip(sizeof(uint64_t)); } - absl::string_view view = input.read_str(); + std::string_view view = input.read_str(); // tricky code to avoid memory copy std::shared_ptr buf(const_cast(view.data()), [s](char *) { delete s; }); @@ -84,7 +84,7 @@ pegasus_extract_user_data(uint32_t version, std::string &&raw_value, ::dsn::blob } /// Extracts timetag from a v1 value. -inline uint64_t pegasus_extract_timetag(int version, absl::string_view value) +inline uint64_t pegasus_extract_timetag(int version, std::string_view value) { CHECK_EQ(version, 1); @@ -118,7 +118,7 @@ inline bool check_if_ts_expired(uint32_t epoch_now, uint32_t expire_ts) /// \return true if expired inline bool check_if_record_expired(uint32_t value_schema_version, uint32_t epoch_now, - absl::string_view raw_value) + std::string_view raw_value) { return check_if_ts_expired(epoch_now, pegasus_extract_expire_ts(value_schema_version, raw_value)); @@ -136,7 +136,7 @@ class pegasus_value_generator /// A higher level utility for generating value with given version. /// The value schema must be in v0 or v1. rocksdb::SliceParts generate_value(uint32_t value_schema_version, - absl::string_view user_data, + std::string_view user_data, uint32_t expire_ts, uint64_t timetag) { @@ -157,7 +157,7 @@ class pegasus_value_generator /// /// rocksdb value (ver 0) = [expire_ts(uint32_t)] [user_data(bytes)] /// \internal - rocksdb::SliceParts generate_value_v0(uint32_t expire_ts, absl::string_view user_data) + rocksdb::SliceParts generate_value_v0(uint32_t expire_ts, std::string_view user_data) { _write_buf.resize(sizeof(uint32_t)); _write_slices.clear(); @@ -210,7 +210,7 @@ class pegasus_value_generator /// /// \internal rocksdb::SliceParts - generate_value_v1(uint32_t expire_ts, uint64_t timetag, absl::string_view user_data) + generate_value_v1(uint32_t expire_ts, uint64_t timetag, std::string_view user_data) { _write_buf.resize(sizeof(uint32_t) + sizeof(uint64_t)); _write_slices.clear(); @@ -258,7 +258,7 @@ class value_schema public: virtual ~value_schema() = default; - virtual std::unique_ptr extract_field(absl::string_view value, + virtual std::unique_ptr extract_field(std::string_view value, value_field_type type) = 0; /// Extracts user value from the raw rocksdb value. /// In order to avoid data copy, the ownership of `raw_value` will be transferred diff --git a/src/base/test/value_manager_test.cpp b/src/base/test/value_manager_test.cpp index 35c1ce488c..f9e8a8dfd0 100644 --- a/src/base/test/value_manager_test.cpp +++ b/src/base/test/value_manager_test.cpp @@ -23,7 +23,7 @@ #include "base/value_schema_manager.h" #include "gtest/gtest.h" #include "pegasus_value_schema.h" -#include "absl/strings/string_view.h" +#include #include "value_field.h" using namespace pegasus; @@ -31,7 +31,7 @@ using namespace pegasus; extern std::string generate_value(value_schema *schema, uint32_t expire_ts, uint64_t time_tag, - absl::string_view user_data); + std::string_view user_data); TEST(value_schema_manager, get_latest_value_schema) { diff --git a/src/base/test/value_schema_test.cpp b/src/base/test/value_schema_test.cpp index 246eab5ef7..aa39bffccd 100644 --- a/src/base/test/value_schema_test.cpp +++ b/src/base/test/value_schema_test.cpp @@ -30,7 +30,7 @@ #include "base/value_schema_manager.h" #include "gtest/gtest.h" #include "utils/blob.h" -#include "absl/strings/string_view.h" +#include #include "value_field.h" using namespace pegasus; @@ -52,7 +52,7 @@ uint64_t extract_time_tag(value_schema *schema, const std::string &raw_value) std::string generate_value(value_schema *schema, uint32_t expire_ts, uint64_t time_tag, - absl::string_view user_data) + std::string_view user_data) { std::string write_buf; std::vector write_slices; diff --git a/src/base/value_field.h b/src/base/value_field.h index 11e99b8939..f5319a2261 100644 --- a/src/base/value_field.h +++ b/src/base/value_field.h @@ -56,9 +56,9 @@ struct time_tag_field : public value_field struct user_data_field : public value_field { - explicit user_data_field(absl::string_view data) : user_data(data) {} + explicit user_data_field(std::string_view data) : user_data(data) {} value_field_type type() { return value_field_type::USER_DATA; } - absl::string_view user_data; + std::string_view user_data; }; } // namespace pegasus diff --git a/src/base/value_schema_manager.cpp b/src/base/value_schema_manager.cpp index 2ce2f1db66..aeeafd850e 100644 --- a/src/base/value_schema_manager.cpp +++ b/src/base/value_schema_manager.cpp @@ -47,7 +47,7 @@ void value_schema_manager::register_schema(std::unique_ptr schema) } value_schema *value_schema_manager::get_value_schema(uint32_t meta_cf_data_version, - absl::string_view value) const + std::string_view value) const { dsn::data_input input(value); uint8_t first_byte = input.read_u8(); diff --git a/src/base/value_schema_manager.h b/src/base/value_schema_manager.h index 5afeef5740..86b834bfd6 100644 --- a/src/base/value_schema_manager.h +++ b/src/base/value_schema_manager.h @@ -25,7 +25,7 @@ #include "pegasus_value_schema.h" #include "utils/singleton.h" -#include "absl/strings/string_view.h" +#include namespace pegasus { @@ -35,7 +35,7 @@ class value_schema_manager : public dsn::utils::singleton void register_schema(std::unique_ptr schema); /// using the raw value in rocksdb and data version stored in meta column family to get data /// version - value_schema *get_value_schema(uint32_t meta_cf_data_version, absl::string_view value) const; + value_schema *get_value_schema(uint32_t meta_cf_data_version, std::string_view value) const; value_schema *get_value_schema(uint32_t version) const; value_schema *get_latest_value_schema() const; diff --git a/src/base/value_schema_v0.cpp b/src/base/value_schema_v0.cpp index b7cc30b5dc..2c0c4fdb5b 100644 --- a/src/base/value_schema_v0.cpp +++ b/src/base/value_schema_v0.cpp @@ -32,7 +32,7 @@ #include "utils/ports.h" namespace pegasus { -std::unique_ptr value_schema_v0::extract_field(absl::string_view value, +std::unique_ptr value_schema_v0::extract_field(std::string_view value, value_field_type type) { std::unique_ptr field = nullptr; @@ -80,14 +80,14 @@ rocksdb::SliceParts value_schema_v0::generate_value(const value_params ¶ms) params.write_slices.clear(); params.write_slices.emplace_back(params.write_buf.data(), params.write_buf.size()); - absl::string_view user_data = data_field->user_data; + std::string_view user_data = data_field->user_data; if (user_data.length() > 0) { params.write_slices.emplace_back(user_data.data(), user_data.length()); } return {¶ms.write_slices[0], static_cast(params.write_slices.size())}; } -std::unique_ptr value_schema_v0::extract_timestamp(absl::string_view value) +std::unique_ptr value_schema_v0::extract_timestamp(std::string_view value) { uint32_t expire_ts = dsn::data_input(value).read_u32(); return std::make_unique(expire_ts); diff --git a/src/base/value_schema_v0.h b/src/base/value_schema_v0.h index 683afe8f92..750136916d 100644 --- a/src/base/value_schema_v0.h +++ b/src/base/value_schema_v0.h @@ -25,7 +25,7 @@ #include "pegasus_value_schema.h" #include "utils/blob.h" -#include "absl/strings/string_view.h" +#include #include "value_field.h" namespace pegasus { @@ -37,7 +37,7 @@ class value_schema_v0 : public value_schema public: value_schema_v0() = default; - std::unique_ptr extract_field(absl::string_view value, + std::unique_ptr extract_field(std::string_view value, value_field_type type) override; dsn::blob extract_user_data(std::string &&value) override; void update_field(std::string &value, std::unique_ptr field) override; @@ -45,7 +45,7 @@ class value_schema_v0 : public value_schema data_version version() const override { return data_version::VERSION_0; } private: - std::unique_ptr extract_timestamp(absl::string_view value); + std::unique_ptr extract_timestamp(std::string_view value); void update_expire_ts(std::string &value, std::unique_ptr field); }; } // namespace pegasus diff --git a/src/base/value_schema_v1.cpp b/src/base/value_schema_v1.cpp index 9e00369176..78c45cdef3 100644 --- a/src/base/value_schema_v1.cpp +++ b/src/base/value_schema_v1.cpp @@ -32,7 +32,7 @@ #include "utils/ports.h" namespace pegasus { -std::unique_ptr value_schema_v1::extract_field(absl::string_view value, +std::unique_ptr value_schema_v1::extract_field(std::string_view value, value_field_type type) { std::unique_ptr field = nullptr; @@ -88,20 +88,20 @@ rocksdb::SliceParts value_schema_v1::generate_value(const value_params ¶ms) params.write_slices.clear(); params.write_slices.emplace_back(params.write_buf.data(), params.write_buf.size()); - absl::string_view user_data = data_field->user_data; + std::string_view user_data = data_field->user_data; if (user_data.length() > 0) { params.write_slices.emplace_back(user_data.data(), user_data.length()); } return {¶ms.write_slices[0], static_cast(params.write_slices.size())}; } -std::unique_ptr value_schema_v1::extract_timestamp(absl::string_view value) +std::unique_ptr value_schema_v1::extract_timestamp(std::string_view value) { uint32_t expire_ts = dsn::data_input(value).read_u32(); return std::make_unique(expire_ts); } -std::unique_ptr value_schema_v1::extract_time_tag(absl::string_view value) +std::unique_ptr value_schema_v1::extract_time_tag(std::string_view value) { dsn::data_input input(value); input.skip(sizeof(uint32_t)); diff --git a/src/base/value_schema_v1.h b/src/base/value_schema_v1.h index 7811b49f6b..88e8a03373 100644 --- a/src/base/value_schema_v1.h +++ b/src/base/value_schema_v1.h @@ -25,7 +25,7 @@ #include "pegasus_value_schema.h" #include "utils/blob.h" -#include "absl/strings/string_view.h" +#include #include "value_field.h" namespace pegasus { @@ -37,7 +37,7 @@ class value_schema_v1 : public value_schema public: value_schema_v1() = default; - std::unique_ptr extract_field(absl::string_view value, + std::unique_ptr extract_field(std::string_view value, value_field_type type) override; dsn::blob extract_user_data(std::string &&value) override; void update_field(std::string &value, std::unique_ptr field) override; @@ -45,8 +45,8 @@ class value_schema_v1 : public value_schema data_version version() const override { return data_version::VERSION_1; } private: - std::unique_ptr extract_timestamp(absl::string_view value); - std::unique_ptr extract_time_tag(absl::string_view value); + std::unique_ptr extract_timestamp(std::string_view value); + std::unique_ptr extract_time_tag(std::string_view value); void update_expire_ts(std::string &value, std::unique_ptr field); }; diff --git a/src/base/value_schema_v2.cpp b/src/base/value_schema_v2.cpp index 400cad75e7..f08724c3c5 100644 --- a/src/base/value_schema_v2.cpp +++ b/src/base/value_schema_v2.cpp @@ -33,7 +33,7 @@ namespace pegasus { -std::unique_ptr value_schema_v2::extract_field(absl::string_view value, +std::unique_ptr value_schema_v2::extract_field(std::string_view value, value_field_type type) { std::unique_ptr field = nullptr; @@ -91,21 +91,21 @@ rocksdb::SliceParts value_schema_v2::generate_value(const value_params ¶ms) params.write_slices.clear(); params.write_slices.emplace_back(params.write_buf.data(), params.write_buf.size()); - absl::string_view user_data = data_field->user_data; + std::string_view user_data = data_field->user_data; if (user_data.length() > 0) { params.write_slices.emplace_back(user_data.data(), user_data.length()); } return {¶ms.write_slices[0], static_cast(params.write_slices.size())}; } -std::unique_ptr value_schema_v2::extract_timestamp(absl::string_view value) +std::unique_ptr value_schema_v2::extract_timestamp(std::string_view value) { dsn::data_input input(value); input.skip(sizeof(uint8_t)); return std::make_unique(input.read_u32()); } -std::unique_ptr value_schema_v2::extract_time_tag(absl::string_view value) +std::unique_ptr value_schema_v2::extract_time_tag(std::string_view value) { dsn::data_input input(value); input.skip(sizeof(uint8_t)); diff --git a/src/base/value_schema_v2.h b/src/base/value_schema_v2.h index c3101baf3a..5415c5d648 100644 --- a/src/base/value_schema_v2.h +++ b/src/base/value_schema_v2.h @@ -25,7 +25,7 @@ #include "pegasus_value_schema.h" #include "utils/blob.h" -#include "absl/strings/string_view.h" +#include #include "value_field.h" namespace pegasus { @@ -38,7 +38,7 @@ class value_schema_v2 : public value_schema public: value_schema_v2() = default; - std::unique_ptr extract_field(absl::string_view value, + std::unique_ptr extract_field(std::string_view value, value_field_type type) override; dsn::blob extract_user_data(std::string &&value) override; void update_field(std::string &value, std::unique_ptr field) override; @@ -46,8 +46,8 @@ class value_schema_v2 : public value_schema data_version version() const override { return data_version::VERSION_2; } private: - std::unique_ptr extract_timestamp(absl::string_view value); - std::unique_ptr extract_time_tag(absl::string_view value); + std::unique_ptr extract_timestamp(std::string_view value); + std::unique_ptr extract_time_tag(std::string_view value); void update_expire_ts(std::string &value, std::unique_ptr field); }; } // namespace pegasus diff --git a/src/block_service/local/local_service.cpp b/src/block_service/local/local_service.cpp index f0dc35f141..0069a03773 100644 --- a/src/block_service/local/local_service.cpp +++ b/src/block_service/local/local_service.cpp @@ -21,7 +21,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "local_service.h" #include "nlohmann/json.hpp" #include "rocksdb/slice.h" @@ -279,7 +279,7 @@ dsn::task_ptr local_file_object::write(const write_request &req, write_future_ptr tsk(new write_future(code, cb, 0)); tsk->set_tracker(tracker); - FAIL_POINT_INJECT_F("mock_local_service_write_failed", [=](absl::string_view) { + FAIL_POINT_INJECT_F("mock_local_service_write_failed", [=](std::string_view) { auto write_failed = [=]() { write_response resp; resp.err = ERR_FS_INTERNAL; diff --git a/src/client/replication_ddl_client.cpp b/src/client/replication_ddl_client.cpp index 1844b87d94..27bfb2df0a 100644 --- a/src/client/replication_ddl_client.cpp +++ b/src/client/replication_ddl_client.cpp @@ -1457,7 +1457,7 @@ void replication_ddl_client::end_meta_request(const rpc_response_task_ptr &callb error_code err, dsn::message_ex *request, dsn::message_ex *response) mutable { FAIL_POINT_INJECT_NOT_RETURN_F( "ddl_client_request_meta", - [&err, this](absl::string_view str) { err = pop_mock_error(); }); + [&err, this](std::string_view str) { err = pop_mock_error(); }); end_meta_request(callback, attempt_count + 1, err, request, response); }); diff --git a/src/client/replication_ddl_client.h b/src/client/replication_ddl_client.h index a14b9a97d4..274605bb34 100644 --- a/src/client/replication_ddl_client.h +++ b/src/client/replication_ddl_client.h @@ -59,7 +59,7 @@ #include "utils/flags.h" #include "utils/fmt_logging.h" #include "utils/ports.h" -#include "absl/strings/string_view.h" +#include DSN_DECLARE_uint32(ddl_client_max_attempt_count); DSN_DECLARE_uint32(ddl_client_retry_interval_ms); @@ -301,7 +301,7 @@ class replication_ddl_client error_code err, dsn::message_ex *request, dsn::message_ex *response) mutable { FAIL_POINT_INJECT_NOT_RETURN_F( "ddl_client_request_meta", - [&err, this](absl::string_view str) { err = pop_mock_error(); }); + [&err, this](std::string_view str) { err = pop_mock_error(); }); end_meta_request(std::move(task), 1, err, request, response); }); @@ -342,7 +342,7 @@ class replication_ddl_client FAIL_POINT_INJECT_NOT_RETURN_F( "ddl_client_request_meta", - [&resp, this](absl::string_view str) { resp.err = pop_mock_error(); }); + [&resp, this](std::string_view str) { resp.err = pop_mock_error(); }); LOG_INFO("received response from meta server: rpc_code={}, err={}, attempt_count={}, " "max_attempt_count={}", diff --git a/src/client_lib/pegasus_client_impl.cpp b/src/client_lib/pegasus_client_impl.cpp index 2ad491c4f8..4ab09425bb 100644 --- a/src/client_lib/pegasus_client_impl.cpp +++ b/src/client_lib/pegasus_client_impl.cpp @@ -26,7 +26,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/common.h" #include "common/replication_other_types.h" #include "common/serialization_helper/dsn.layer2_types.h" diff --git a/src/common/fs_manager.cpp b/src/common/fs_manager.cpp index 4544c00985..1801d2c46b 100644 --- a/src/common/fs_manager.cpp +++ b/src/common/fs_manager.cpp @@ -31,7 +31,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/gpid.h" #include "common/replication_enums.h" #include "fmt/core.h" @@ -134,7 +134,7 @@ uint64_t dir_node::replicas_count(app_id id) const return iter->second.size(); } -std::string dir_node::replica_dir(absl::string_view app_type, const dsn::gpid &pid) const +std::string dir_node::replica_dir(std::string_view app_type, const dsn::gpid &pid) const { return utils::filesystem::path_combine(full_dir, fmt::format("{}.{}", pid, app_type)); } @@ -159,7 +159,7 @@ uint64_t dir_node::remove(const gpid &pid) void dir_node::update_disk_stat() { - FAIL_POINT_INJECT_F("update_disk_stat", [](absl::string_view) { return; }); + FAIL_POINT_INJECT_F("update_disk_stat", [](std::string_view) { return; }); dsn::utils::filesystem::disk_space_info dsi; if (!dsn::utils::filesystem::get_disk_space_info(full_dir, dsi)) { @@ -329,7 +329,7 @@ dir_node *fs_manager::find_best_dir_for_new_replica(const gpid &pid) const } void fs_manager::specify_dir_for_new_replica_for_test(dir_node *specified_dn, - absl::string_view app_type, + std::string_view app_type, const dsn::gpid &pid) const { bool dn_found = false; @@ -432,7 +432,7 @@ bool fs_manager::is_dir_node_exist(const std::string &data_dir, const std::strin return false; } -dir_node *fs_manager::find_replica_dir(absl::string_view app_type, gpid pid) +dir_node *fs_manager::find_replica_dir(std::string_view app_type, gpid pid) { std::string replica_dir; dir_node *replica_dn = nullptr; @@ -457,7 +457,7 @@ dir_node *fs_manager::find_replica_dir(absl::string_view app_type, gpid pid) return replica_dn; } -dir_node *fs_manager::create_replica_dir_if_necessary(absl::string_view app_type, gpid pid) +dir_node *fs_manager::create_replica_dir_if_necessary(std::string_view app_type, gpid pid) { // Try to find the replica directory. auto replica_dn = find_replica_dir(app_type, pid); @@ -489,7 +489,7 @@ dir_node *fs_manager::create_replica_dir_if_necessary(absl::string_view app_type return replica_dn; } -dir_node *fs_manager::create_child_replica_dir(absl::string_view app_type, +dir_node *fs_manager::create_child_replica_dir(std::string_view app_type, gpid child_pid, const std::string &parent_dir) { diff --git a/src/common/fs_manager.h b/src/common/fs_manager.h index 5820d26887..0ceecc3e43 100644 --- a/src/common/fs_manager.h +++ b/src/common/fs_manager.h @@ -31,7 +31,7 @@ #include "utils/autoref_ptr.h" #include "utils/error_code.h" #include "utils/flags.h" -#include "absl/strings/string_view.h" +#include #include "utils/metrics.h" #include "utils/ports.h" #include "utils/zlocks.h" @@ -105,7 +105,7 @@ struct dir_node uint64_t replicas_count() const; // Construct the replica dir for the given 'app_type' and 'pid'. // NOTE: Just construct the string, the directory will not be created. - std::string replica_dir(absl::string_view app_type, const dsn::gpid &pid) const; + std::string replica_dir(std::string_view app_type, const dsn::gpid &pid) const; bool has(const dsn::gpid &pid) const; uint64_t remove(const dsn::gpid &pid); void update_disk_stat(); @@ -133,18 +133,18 @@ class fs_manager // dir_nodes. // NOTE: only used in test. void specify_dir_for_new_replica_for_test(dir_node *specified_dn, - absl::string_view app_type, + std::string_view app_type, const dsn::gpid &pid) const; void add_replica(const dsn::gpid &pid, const std::string &pid_dir); // Find the replica instance directory. - dir_node *find_replica_dir(absl::string_view app_type, gpid pid); + dir_node *find_replica_dir(std::string_view app_type, gpid pid); // Similar to the above, but it will create a new directory if not found. - dir_node *create_replica_dir_if_necessary(absl::string_view app_type, gpid pid); + dir_node *create_replica_dir_if_necessary(std::string_view app_type, gpid pid); // Similar to the above, and will create a directory for the child on the same dir_node // of parent. // During partition split, we should guarantee child replica and parent replica share the // same data dir. - dir_node *create_child_replica_dir(absl::string_view app_type, + dir_node *create_child_replica_dir(std::string_view app_type, gpid child_pid, const std::string &parent_dir); void remove_replica(const dsn::gpid &pid); diff --git a/src/common/serialization_helper/thrift_helper.h b/src/common/serialization_helper/thrift_helper.h index c3e2bbfb0c..54737a30b6 100644 --- a/src/common/serialization_helper/thrift_helper.h +++ b/src/common/serialization_helper/thrift_helper.h @@ -37,7 +37,7 @@ #include #include -#include "absl/strings/string_view.h" +#include using namespace ::apache::thrift::transport; namespace dsn { @@ -498,7 +498,7 @@ inline uint32_t task_code::write(apache::thrift::protocol::TProtocol *oprot) con dynamic_cast(oprot); if (binary_proto != nullptr) { // the protocol is binary protocol - return binary_proto->writeString(absl::string_view(name)); + return binary_proto->writeString(std::string_view(name)); } else { // the protocol is json protocol uint32_t xfer = 0; @@ -566,7 +566,7 @@ inline uint32_t error_code::write(apache::thrift::protocol::TProtocol *oprot) co dynamic_cast(oprot); if (binary_proto != nullptr) { // the protocol is binary protocol - return binary_proto->writeString(absl::string_view(name)); + return binary_proto->writeString(std::string_view(name)); } else { // the protocol is json protocol uint32_t xfer = 0; diff --git a/src/failure_detector/failure_detector.cpp b/src/failure_detector/failure_detector.cpp index 62a0c7fc8a..b3d1378ebd 100644 --- a/src/failure_detector/failure_detector.cpp +++ b/src/failure_detector/failure_detector.cpp @@ -34,7 +34,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "failure_detector/fd.code.definition.h" #include "fd_types.h" #include "fmt/core.h" diff --git a/src/gutil/test/map_util_unittest.cpp b/src/gutil/test/map_util_unittest.cpp index 0c3e70011f..97132846ef 100644 --- a/src/gutil/test/map_util_unittest.cpp +++ b/src/gutil/test/map_util_unittest.cpp @@ -73,7 +73,7 @@ TEST(MapUtil, HeterogeneousLookup) // Verify that I can use a key type that's appropriate for heterogeneous // lookup, such as string_view -> string. - constexpr absl::string_view kLookupKey = "foo"; + constexpr std::string_view kLookupKey = "foo"; EXPECT_EQ(FindWithDefault(m, kLookupKey), ""); EXPECT_EQ(FindWithDefault(const_m, kLookupKey), ""); diff --git a/src/http/http_client.cpp b/src/http/http_client.cpp index 24dd575f5c..a369fe3e97 100644 --- a/src/http/http_client.cpp +++ b/src/http/http_client.cpp @@ -483,15 +483,15 @@ void http_client::free_header_list() _header_list = nullptr; } -void http_client::set_header_field(absl::string_view key, absl::string_view val) +void http_client::set_header_field(std::string_view key, std::string_view val) { _header_fields[std::string(key)] = std::string(val); _header_changed = true; } -void http_client::set_accept(absl::string_view val) { set_header_field("Accept", val); } +void http_client::set_accept(std::string_view val) { set_header_field("Accept", val); } -void http_client::set_content_type(absl::string_view val) { set_header_field("Content-Type", val); } +void http_client::set_content_type(std::string_view val) { set_header_field("Content-Type", val); } dsn::error_s http_client::process_header() { diff --git a/src/http/http_client.h b/src/http/http_client.h index 0d8b35e13c..9624f1e467 100644 --- a/src/http/http_client.h +++ b/src/http/http_client.h @@ -27,7 +27,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "http/http_method.h" #include "http/http_status_code.h" #include "utils/enum_helper.h" @@ -199,8 +199,8 @@ class http_client // Operations for the header fields. void clear_header_fields(); - void set_accept(absl::string_view val); - void set_content_type(absl::string_view val); + void set_accept(std::string_view val); + void set_content_type(std::string_view val); // Submit request to remote http service, with response processed by callback function. // @@ -235,7 +235,7 @@ class http_client dsn::error_s set_method(http_method method); void free_header_list(); - void set_header_field(absl::string_view key, absl::string_view val); + void set_header_field(std::string_view key, std::string_view val); dsn::error_s process_header(); // The size of a buffer that is used by libcurl to store human readable diff --git a/src/http/uri_decoder.cpp b/src/http/uri_decoder.cpp index d6a1a1de9f..63b784caec 100644 --- a/src/http/uri_decoder.cpp +++ b/src/http/uri_decoder.cpp @@ -40,7 +40,7 @@ error_with from_hex(const char c) } } -error_with decode_char(const absl::string_view &hex) +error_with decode_char(const std::string_view &hex) { CHECK_EQ(2, hex.size()); @@ -53,7 +53,7 @@ error_with decode_char(const absl::string_view &hex) return error_s::make(ERR_INVALID_PARAMETERS); } -error_with decode(const absl::string_view &encoded_uri) +error_with decode(const std::string_view &encoded_uri) { std::string decoded_uri; for (size_t i = 0; i < encoded_uri.size(); ++i) { @@ -64,7 +64,7 @@ error_with decode(const absl::string_view &encoded_uri) "Encountered partial escape sequence at end of string"); } - const absl::string_view encoded_char(encoded_uri.data() + i + 1, 2); + const std::string_view encoded_char(encoded_uri.data() + i + 1, 2); auto decoded_char = decode_char(encoded_char); if (!decoded_char.is_ok()) { return error_s::make( diff --git a/src/http/uri_decoder.h b/src/http/uri_decoder.h index b1d28a13ba..93266f4523 100644 --- a/src/http/uri_decoder.h +++ b/src/http/uri_decoder.h @@ -20,14 +20,14 @@ #include #include "utils/errors.h" -#include "absl/strings/string_view.h" +#include namespace dsn { namespace uri { /// \brief Decodes a sequence according to the percent decoding rules. /// \returns the decoded uri path -error_with decode(const absl::string_view &encoded_uri); +error_with decode(const std::string_view &encoded_uri); } // namespace uri } // namespace dsn diff --git a/src/meta/duplication/meta_duplication_service.cpp b/src/meta/duplication/meta_duplication_service.cpp index 4f0d7f816e..83b9638c05 100644 --- a/src/meta/duplication/meta_duplication_service.cpp +++ b/src/meta/duplication/meta_duplication_service.cpp @@ -21,7 +21,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common//duplication_common.h" #include "common/common.h" #include "common/gpid.h" @@ -490,19 +490,19 @@ void meta_duplication_service::create_follower_app_for_duplication( _meta_svc->tracker(), [=](error_code err, configuration_create_app_response &&resp) mutable { FAIL_POINT_INJECT_NOT_RETURN_F("update_app_request_ok", - [&](absl::string_view s) -> void { err = ERR_OK; }); + [&](std::string_view s) -> void { err = ERR_OK; }); error_code create_err = err == ERR_OK ? resp.err : err; error_code update_err = ERR_NO_NEED_OPERATE; FAIL_POINT_INJECT_NOT_RETURN_F( "persist_dup_status_failed", - [&](absl::string_view s) -> void { create_err = ERR_OK; }); + [&](std::string_view s) -> void { create_err = ERR_OK; }); if (create_err == ERR_OK) { update_err = dup->alter_status(duplication_status::DS_APP); } FAIL_POINT_INJECT_F("persist_dup_status_failed", - [&](absl::string_view s) -> void { return; }); + [&](std::string_view s) -> void { return; }); if (update_err == ERR_OK) { blob value = dup->to_json_blob(); // Note: this function is `async`, it may not be persisted completed @@ -539,7 +539,7 @@ void meta_duplication_service::check_follower_app_if_create_completed( msg, _meta_svc->tracker(), [=](error_code err, query_cfg_response &&resp) mutable { - FAIL_POINT_INJECT_NOT_RETURN_F("create_app_ok", [&](absl::string_view s) -> void { + FAIL_POINT_INJECT_NOT_RETURN_F("create_app_ok", [&](std::string_view s) -> void { err = ERR_OK; int count = dup->partition_count; while (count-- > 0) { @@ -588,7 +588,7 @@ void meta_duplication_service::check_follower_app_if_create_completed( } FAIL_POINT_INJECT_F("persist_dup_status_failed", - [&](absl::string_view s) -> void { return; }); + [&](std::string_view s) -> void { return; }); if (update_err == ERR_OK) { blob value = dup->to_json_blob(); // Note: this function is `async`, it may not be persisted completed diff --git a/src/meta/load_balance_policy.cpp b/src/meta/load_balance_policy.cpp index 9295796746..623e7e4fe0 100644 --- a/src/meta/load_balance_policy.cpp +++ b/src/meta/load_balance_policy.cpp @@ -29,7 +29,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "dsn.layer2_types.h" #include "meta/meta_data.h" #include "meta_admin_types.h" @@ -147,7 +147,7 @@ generate_balancer_request(const app_mapper &apps, const host_port &to) { FAIL_POINT_INJECT_F("generate_balancer_request", - [](absl::string_view name) { return nullptr; }); + [](std::string_view name) { return nullptr; }); configuration_balancer_request result; result.gpid = pc.pid; diff --git a/src/meta/meta_bulk_load_ingestion_context.cpp b/src/meta/meta_bulk_load_ingestion_context.cpp index 6921d4ea86..79d01a4f1e 100644 --- a/src/meta/meta_bulk_load_ingestion_context.cpp +++ b/src/meta/meta_bulk_load_ingestion_context.cpp @@ -26,7 +26,7 @@ #include "utils/fail_point.h" #include "utils/fmt_logging.h" #include "utils/string_conv.h" -#include "absl/strings/string_view.h" +#include DSN_DEFINE_uint32(meta_server, bulk_load_node_max_ingesting_count, @@ -73,7 +73,7 @@ uint32_t ingestion_context::node_context::get_max_disk_ingestion_count( const uint32_t max_node_ingestion_count) const { FAIL_POINT_INJECT_F("ingestion_node_context_disk_count", - [](absl::string_view count_str) -> uint32_t { + [](std::string_view count_str) -> uint32_t { uint32_t count = 0; buf2uint32(count_str, count); return count; @@ -123,7 +123,7 @@ void ingestion_context::node_context::decrease(const std::string &disk_tag) bool ingestion_context::try_partition_ingestion(const partition_configuration &pc, const config_context &cc) { - FAIL_POINT_INJECT_F("ingestion_try_partition_ingestion", [=](absl::string_view) -> bool { + FAIL_POINT_INJECT_F("ingestion_try_partition_ingestion", [=](std::string_view) -> bool { auto info = partition_node_info(); info.pid = pc.pid; _running_partitions[pc.pid] = info; @@ -158,7 +158,7 @@ void ingestion_context::add_partition(const partition_node_info &info) void ingestion_context::remove_partition(const gpid &pid) { FAIL_POINT_INJECT_F("ingestion_context_remove_partition", - [=](absl::string_view) { _running_partitions.erase(pid); }); + [=](std::string_view) { _running_partitions.erase(pid); }); if (_running_partitions.find(pid) == _running_partitions.end()) { return; diff --git a/src/meta/meta_bulk_load_service.cpp b/src/meta/meta_bulk_load_service.cpp index aa2688ce55..198fb003e7 100644 --- a/src/meta/meta_bulk_load_service.cpp +++ b/src/meta/meta_bulk_load_service.cpp @@ -26,7 +26,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "block_service/block_service.h" #include "block_service/block_service_manager.h" #include "common/replica_envs.h" @@ -101,7 +101,7 @@ void bulk_load_service::initialize_bulk_load_service() void bulk_load_service::on_start_bulk_load(start_bulk_load_rpc rpc) { FAIL_POINT_INJECT_F("meta_on_start_bulk_load", - [=](absl::string_view) { rpc.response().err = ERR_OK; }); + [=](std::string_view) { rpc.response().err = ERR_OK; }); const auto &request = rpc.request(); auto &response = rpc.response(); @@ -171,7 +171,7 @@ bulk_load_service::check_bulk_load_request_params(const start_bulk_load_request std::string &hint_msg) { FAIL_POINT_INJECT_F("meta_check_bulk_load_request_params", - [](absl::string_view) -> error_code { return ERR_OK; }); + [](std::string_view) -> error_code { return ERR_OK; }); if (!validate_ingest_behind(envs, request.ingest_behind)) { hint_msg = fmt::format("inconsistent ingestion behind option"); @@ -414,7 +414,7 @@ bool bulk_load_service::check_partition_status( // ThreadPool: THREAD_POOL_META_STATE void bulk_load_service::partition_bulk_load(const std::string &app_name, const gpid &pid) { - FAIL_POINT_INJECT_F("meta_bulk_load_partition_bulk_load", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("meta_bulk_load_partition_bulk_load", [](std::string_view) {}); partition_configuration pc; if (!check_partition_status(app_name, @@ -583,7 +583,7 @@ void bulk_load_service::on_partition_bulk_load_reply(error_code err, // ThreadPool: THREAD_POOL_META_STATE void bulk_load_service::try_resend_bulk_load_request(const std::string &app_name, const gpid &pid) { - FAIL_POINT_INJECT_F("meta_bulk_load_resend_request", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("meta_bulk_load_resend_request", [](std::string_view) {}); zauto_read_lock l(_lock); if (is_app_bulk_loading_unlocked(pid.get_app_id())) { tasking::enqueue(LPC_META_STATE_NORMAL, @@ -1091,7 +1091,7 @@ void bulk_load_service::update_app_status_on_remote_storage_unlocked( int32_t app_id, bulk_load_status::type new_status, error_code err, bool should_send_request) { FAIL_POINT_INJECT_F("meta_update_app_status_on_remote_storage_unlocked", - [](absl::string_view) {}); + [](std::string_view) {}); app_bulk_load_info ainfo = _app_bulk_load_info[app_id]; auto old_status = ainfo.status; @@ -1223,7 +1223,7 @@ bool bulk_load_service::check_ever_ingestion_succeed(const partition_configurati // ThreadPool: THREAD_POOL_META_STATE void bulk_load_service::partition_ingestion(const std::string &app_name, const gpid &pid) { - FAIL_POINT_INJECT_F("meta_bulk_load_partition_ingestion", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("meta_bulk_load_partition_ingestion", [](std::string_view) {}); auto app_status = get_app_bulk_load_status(pid.get_app_id()); if (app_status != bulk_load_status::BLS_INGESTING) { @@ -1659,7 +1659,7 @@ void bulk_load_service::on_clear_bulk_load(clear_bulk_load_rpc rpc) void bulk_load_service::do_clear_app_bulk_load_result(int32_t app_id, clear_bulk_load_rpc rpc) { FAIL_POINT_INJECT_F("meta_do_clear_app_bulk_load_result", - [rpc](absl::string_view) { rpc.response().err = ERR_OK; }); + [rpc](std::string_view) { rpc.response().err = ERR_OK; }); std::string bulk_load_path = get_app_bulk_load_path(app_id); _meta_svc->get_meta_storage()->delete_node_recursively( std::move(bulk_load_path), [this, app_id, bulk_load_path, rpc]() { @@ -1753,7 +1753,7 @@ void bulk_load_service::do_sync_partition(const gpid &pid, std::string &partitio // ThreadPool: THREAD_POOL_META_SERVER void bulk_load_service::try_to_continue_bulk_load() { - FAIL_POINT_INJECT_F("meta_try_to_continue_bulk_load", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("meta_try_to_continue_bulk_load", [](std::string_view) {}); zauto_read_lock l(_lock); for (const auto app_id : _bulk_load_app_id) { app_bulk_load_info ainfo = _app_bulk_load_info[app_id]; diff --git a/src/meta/meta_server_failure_detector.cpp b/src/meta/meta_server_failure_detector.cpp index 1d900fbcbe..9e198582cc 100644 --- a/src/meta/meta_server_failure_detector.cpp +++ b/src/meta/meta_server_failure_detector.cpp @@ -30,7 +30,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "fd_types.h" #include "meta/meta_options.h" #include "meta/meta_service.h" @@ -107,7 +107,7 @@ void meta_server_failure_detector::on_worker_connected(const host_port &node) bool meta_server_failure_detector::get_leader(host_port *leader) { - FAIL_POINT_INJECT_F("meta_server_failure_detector_get_leader", [leader](absl::string_view str) { + FAIL_POINT_INJECT_F("meta_server_failure_detector_get_leader", [leader](std::string_view str) { /// the format of str is : true#{ip}:{port} or false#{ip}:{port} auto pos = str.find("#"); // get leader host_port diff --git a/src/nfs/nfs_client_impl.cpp b/src/nfs/nfs_client_impl.cpp index 867d1891a9..5b2bcd3657 100644 --- a/src/nfs/nfs_client_impl.cpp +++ b/src/nfs/nfs_client_impl.cpp @@ -30,7 +30,7 @@ // IWYU pragma: no_include #include -#include "absl/strings/string_view.h" +#include #include "fmt/core.h" #include "nfs/nfs_code_definition.h" #include "nfs/nfs_node.h" diff --git a/src/nfs/nfs_server_impl.cpp b/src/nfs/nfs_server_impl.cpp index 001090d095..d4f8568b81 100644 --- a/src/nfs/nfs_server_impl.cpp +++ b/src/nfs/nfs_server_impl.cpp @@ -32,7 +32,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "fmt/core.h" // IWYU pragma: keep #include "gutil/map_util.h" #include "nfs/nfs_code_definition.h" diff --git a/src/redis_protocol/proxy/main.cpp b/src/redis_protocol/proxy/main.cpp index 0d3c0b9bc5..63f0855ef0 100644 --- a/src/redis_protocol/proxy/main.cpp +++ b/src/redis_protocol/proxy/main.cpp @@ -17,7 +17,7 @@ * under the License. */ -#include +#include "pegasus/version.h" #include #include #include diff --git a/src/redis_protocol/proxy_lib/redis_parser.cpp b/src/redis_protocol/proxy_lib/redis_parser.cpp index 9aea607eac..99683d902c 100644 --- a/src/redis_protocol/proxy_lib/redis_parser.cpp +++ b/src/redis_protocol/proxy_lib/redis_parser.cpp @@ -32,7 +32,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/common.h" #include "common/replication_other_types.h" #include "pegasus/client.h" @@ -207,7 +207,7 @@ void redis_parser::eat_all(char *dest, size_t length) bool redis_parser::end_array_size() { int32_t count = 0; - if (dsn_unlikely(!dsn::buf2int32(absl::string_view(_current_size), count))) { + if (dsn_unlikely(!dsn::buf2int32(std::string_view(_current_size), count))) { LOG_ERROR_PREFIX("invalid size string \"{}\"", _current_size); return false; } @@ -242,7 +242,7 @@ void redis_parser::append_current_bulk_string() bool redis_parser::end_bulk_string_size() { int32_t length = 0; - if (dsn_unlikely(!dsn::buf2int32(absl::string_view(_current_size), length))) { + if (dsn_unlikely(!dsn::buf2int32(std::string_view(_current_size), length))) { LOG_ERROR_PREFIX("invalid size string \"{}\"", _current_size); return false; } diff --git a/src/replica/bulk_load/replica_bulk_loader.cpp b/src/replica/bulk_load/replica_bulk_loader.cpp index e8eb03987e..b58afccc70 100644 --- a/src/replica/bulk_load/replica_bulk_loader.cpp +++ b/src/replica/bulk_load/replica_bulk_loader.cpp @@ -22,7 +22,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "block_service/block_service_manager.h" #include "common/bulk_load_common.h" #include "common/gpid.h" @@ -487,7 +487,7 @@ void replica_bulk_loader::download_files(const std::string &provider_name, const std::string &remote_dir, const std::string &local_dir) { - FAIL_POINT_INJECT_F("replica_bulk_loader_download_files", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_bulk_loader_download_files", [](std::string_view) {}); LOG_INFO_PREFIX("start to download files"); dist::block_service::block_filesystem *fs = diff --git a/src/replica/disk_cleaner.cpp b/src/replica/disk_cleaner.cpp index 805da23914..8a191d67fc 100644 --- a/src/replica/disk_cleaner.cpp +++ b/src/replica/disk_cleaner.cpp @@ -36,7 +36,7 @@ #include "utils/fmt_logging.h" #include "utils/macros.h" #include "utils/string_conv.h" -#include "absl/strings/string_view.h" +#include DSN_DEFINE_uint64(replication, gc_disk_error_replica_interval_seconds, @@ -148,7 +148,7 @@ bool parse_timestamp_us(const std::string &name, size_t suffix_size, uint64_t &t } const auto ok = - dsn::buf2uint64(absl::string_view(name.data() + begin_idx, length), timestamp_us); + dsn::buf2uint64(std::string_view(name.data() + begin_idx, length), timestamp_us); return ok ? timestamp_us > MIN_TIMESTAMP_US : false; } diff --git a/src/replica/duplication/duplication_pipeline.cpp b/src/replica/duplication/duplication_pipeline.cpp index 53e54ece33..83bf4608b5 100644 --- a/src/replica/duplication/duplication_pipeline.cpp +++ b/src/replica/duplication/duplication_pipeline.cpp @@ -47,7 +47,7 @@ namespace replication { // // /*static*/ std::function( - replica_base *, absl::string_view /*remote cluster*/, absl::string_view /*app*/)> + replica_base *, std::string_view /*remote cluster*/, std::string_view /*app*/)> mutation_duplicator::creator; // // diff --git a/src/replica/duplication/load_from_private_log.cpp b/src/replica/duplication/load_from_private_log.cpp index 6b0af82251..b0e501409f 100644 --- a/src/replica/duplication/load_from_private_log.cpp +++ b/src/replica/duplication/load_from_private_log.cpp @@ -20,7 +20,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/duplication_common.h" #include "duplication_types.h" #include "load_from_private_log.h" @@ -119,7 +119,7 @@ void load_from_private_log::run() repeat(1_s); FAIL_POINT_INJECT_NOT_RETURN_F( - "duplication_sync_complete", [&](absl::string_view s) -> void { + "duplication_sync_complete", [&](std::string_view s) -> void { if (_duplicator->progress().confirmed_decree == invalid_decree) { // set_confirmed_decree(9), the value must be equal (decree_start of // `test_start_duplication` in `load_from_private_log_test.cpp`) -1 diff --git a/src/replica/duplication/mutation_batch.cpp b/src/replica/duplication/mutation_batch.cpp index f50e7c113c..9a6493cb99 100644 --- a/src/replica/duplication/mutation_batch.cpp +++ b/src/replica/duplication/mutation_batch.cpp @@ -21,7 +21,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/replication.codes.h" #include "consensus_types.h" #include "metadata_types.h" diff --git a/src/replica/duplication/mutation_duplicator.h b/src/replica/duplication/mutation_duplicator.h index b1c29e00fa..cb6b3c65e2 100644 --- a/src/replica/duplication/mutation_duplicator.h +++ b/src/replica/duplication/mutation_duplicator.h @@ -68,7 +68,7 @@ class mutation_duplicator : public replica_base // Singleton creator of mutation_duplicator. static std::function( - replica_base *, absl::string_view /*remote cluster*/, absl::string_view /*app name*/)> + replica_base *, std::string_view /*remote cluster*/, std::string_view /*app name*/)> creator; explicit mutation_duplicator(replica_base *r) : replica_base(r) {} @@ -84,7 +84,7 @@ class mutation_duplicator : public replica_base }; inline std::unique_ptr new_mutation_duplicator( - replica_base *r, absl::string_view remote_cluster_address, absl::string_view app) + replica_base *r, std::string_view remote_cluster_address, std::string_view app) { return mutation_duplicator::creator(r, remote_cluster_address, app); } diff --git a/src/replica/duplication/replica_follower.cpp b/src/replica/duplication/replica_follower.cpp index 4918f60e81..3373d9a86c 100644 --- a/src/replica/duplication/replica_follower.cpp +++ b/src/replica/duplication/replica_follower.cpp @@ -42,7 +42,7 @@ #include "utils/filesystem.h" #include "utils/fmt_logging.h" #include "utils/ports.h" -#include "absl/strings/string_view.h" +#include #include "utils/strings.h" namespace dsn { @@ -132,13 +132,13 @@ void replica_follower::async_duplicate_checkpoint_from_master_replica() msg, &_tracker, [&](error_code err, query_cfg_response &&resp) mutable { - FAIL_POINT_INJECT_F("duplicate_checkpoint_ok", [&](absl::string_view s) -> void { + FAIL_POINT_INJECT_F("duplicate_checkpoint_ok", [&](std::string_view s) -> void { _tracker.set_tasks_success(); return; }); FAIL_POINT_INJECT_F("duplicate_checkpoint_failed", - [&](absl::string_view s) -> void { return; }); + [&](std::string_view s) -> void { return; }); if (update_master_replica_config(err, std::move(resp)) == ERR_OK) { copy_master_replica_checkpoint(); } @@ -260,7 +260,7 @@ void replica_follower::nfs_copy_remote_files(const host_port &remote_node, &_tracker, [&, remote_dir](error_code err, size_t size) mutable { FAIL_POINT_INJECT_NOT_RETURN_F("nfs_copy_ok", - [&](absl::string_view s) -> void { err = ERR_OK; }); + [&](std::string_view s) -> void { err = ERR_OK; }); if (dsn_unlikely(err != ERR_OK)) { LOG_ERROR_PREFIX("nfs copy master[{}] checkpoint failed: checkpoint = {}, err = {}", diff --git a/src/replica/duplication/test/duplication_test_base.h b/src/replica/duplication/test/duplication_test_base.h index cd54fe9d8c..d4dacf9b9a 100644 --- a/src/replica/duplication/test/duplication_test_base.h +++ b/src/replica/duplication/test/duplication_test_base.h @@ -34,7 +34,7 @@ class duplication_test_base : public replica_test_base public: duplication_test_base() { - mutation_duplicator::creator = [](replica_base *r, absl::string_view, absl::string_view) { + mutation_duplicator::creator = [](replica_base *r, std::string_view, std::string_view) { return std::make_unique(r); }; stub->_duplication_sync_timer = std::make_unique(stub.get()); diff --git a/src/replica/log_file_stream.h b/src/replica/log_file_stream.h index 3b901aed73..2b2567229b 100644 --- a/src/replica/log_file_stream.h +++ b/src/replica/log_file_stream.h @@ -66,7 +66,7 @@ class log_file::file_streamer fill_buffers(); } - // TODO(wutao1): use absl::string_view instead of using blob. + // TODO(wutao1): use std::string_view instead of using blob. // WARNING: the resulted blob is not guaranteed to be reference counted. // possible error_code: // ERR_OK result would always size as expected diff --git a/src/replica/mutation_log_replay.cpp b/src/replica/mutation_log_replay.cpp index 126d19cdfc..ee891bcb73 100644 --- a/src/replica/mutation_log_replay.cpp +++ b/src/replica/mutation_log_replay.cpp @@ -38,7 +38,7 @@ #include "utils/errors.h" #include "utils/fail_point.h" #include "utils/fmt_logging.h" -#include "absl/strings/string_view.h" +#include namespace dsn { namespace replication { @@ -77,7 +77,7 @@ namespace replication { size_t start_offset, int64_t &end_offset) { - FAIL_POINT_INJECT_F("mutation_log_replay_block", [](absl::string_view) -> error_s { + FAIL_POINT_INJECT_F("mutation_log_replay_block", [](std::string_view) -> error_s { return error_s::make(ERR_INCOMPLETE_DATA, "mutation_log_replay_block"); }); diff --git a/src/replica/mutation_log_utils.cpp b/src/replica/mutation_log_utils.cpp index 9fed18ab8b..668dff2361 100644 --- a/src/replica/mutation_log_utils.cpp +++ b/src/replica/mutation_log_utils.cpp @@ -37,9 +37,9 @@ namespace dsn { namespace replication { namespace log_utils { -/*extern*/ error_s open_read(absl::string_view path, /*out*/ log_file_ptr &file) +/*extern*/ error_s open_read(std::string_view path, /*out*/ log_file_ptr &file) { - FAIL_POINT_INJECT_F("open_read", [](absl::string_view) -> error_s { + FAIL_POINT_INJECT_F("open_read", [](std::string_view) -> error_s { return error_s::make(ERR_FILE_OPERATION_FAILED, "open_read"); }); @@ -53,7 +53,7 @@ namespace log_utils { /*extern*/ error_s list_all_files(const std::string &dir, /*out*/ std::vector &files) { - FAIL_POINT_INJECT_F("list_all_files", [](absl::string_view) -> error_s { + FAIL_POINT_INJECT_F("list_all_files", [](std::string_view) -> error_s { return error_s::make(ERR_FILE_OPERATION_FAILED, "list_all_files"); }); diff --git a/src/replica/mutation_log_utils.h b/src/replica/mutation_log_utils.h index fafa4fbf56..56a5405439 100644 --- a/src/replica/mutation_log_utils.h +++ b/src/replica/mutation_log_utils.h @@ -34,13 +34,13 @@ #include "replica/mutation_log.h" #include "utils/autoref_ptr.h" #include "utils/errors.h" -#include "absl/strings/string_view.h" +#include namespace dsn { namespace replication { namespace log_utils { -extern error_s open_read(absl::string_view path, /*out*/ log_file_ptr &file); +extern error_s open_read(std::string_view path, /*out*/ log_file_ptr &file); extern error_s list_all_files(const std::string &dir, /*out*/ std::vector &files); diff --git a/src/replica/replica_base.cpp b/src/replica/replica_base.cpp index ce4700abdd..bb8a9155ff 100644 --- a/src/replica/replica_base.cpp +++ b/src/replica/replica_base.cpp @@ -41,7 +41,7 @@ metric_entity_ptr instantiate_replica_metric_entity(const gpid &id) } // anonymous namespace -replica_base::replica_base(gpid id, absl::string_view name, absl::string_view app_name) +replica_base::replica_base(gpid id, std::string_view name, std::string_view app_name) : _gpid(id), _name(name), _app_name(app_name), diff --git a/src/replica/replica_base.h b/src/replica/replica_base.h index 8909197a64..79583c13f1 100644 --- a/src/replica/replica_base.h +++ b/src/replica/replica_base.h @@ -29,7 +29,7 @@ #include #include "common/gpid.h" -#include "absl/strings/string_view.h" +#include #include "utils/fmt_logging.h" #include "utils/metrics.h" @@ -39,7 +39,7 @@ namespace replication { /// Base class for types that are one-instance-per-replica. struct replica_base { - replica_base(gpid id, absl::string_view name, absl::string_view app_name); + replica_base(gpid id, std::string_view name, std::string_view app_name); explicit replica_base(replica_base *rhs) : replica_base(rhs->get_gpid(), rhs->replica_name(), rhs->_app_name) diff --git a/src/replica/replica_check.cpp b/src/replica/replica_check.cpp index adb4771b52..32cf5f70fa 100644 --- a/src/replica/replica_check.cpp +++ b/src/replica/replica_check.cpp @@ -58,7 +58,7 @@ #include "utils/fail_point.h" #include "utils/flags.h" #include "utils/fmt_logging.h" -#include "absl/strings/string_view.h" +#include #include "utils/metrics.h" #include "utils/thread_access_checker.h" @@ -82,7 +82,7 @@ namespace replication { void replica::init_group_check() { - FAIL_POINT_INJECT_F("replica_init_group_check", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_init_group_check", [](std::string_view) {}); _checker.only_one_thread_access(); @@ -102,7 +102,7 @@ void replica::init_group_check() void replica::broadcast_group_check() { - FAIL_POINT_INJECT_F("replica_broadcast_group_check", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_broadcast_group_check", [](std::string_view) {}); CHECK_NOTNULL(_primary_states.group_check_task, ""); diff --git a/src/replica/replica_config.cpp b/src/replica/replica_config.cpp index 7abeaf4549..3bcd5faaff 100644 --- a/src/replica/replica_config.cpp +++ b/src/replica/replica_config.cpp @@ -40,7 +40,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "bulk_load/replica_bulk_loader.h" #include "common/gpid.h" #include "common/replica_envs.h" @@ -694,7 +694,7 @@ bool replica::is_same_ballot_status_change_allowed(partition_status::type olds, bool replica::update_local_configuration(const replica_configuration &config, bool same_ballot /* = false*/) { - FAIL_POINT_INJECT_F("replica_update_local_configuration", [=](absl::string_view) -> bool { + FAIL_POINT_INJECT_F("replica_update_local_configuration", [=](std::string_view) -> bool { auto old_status = status(); _config = config; LOG_INFO_PREFIX( diff --git a/src/replica/replica_disk_migrator.cpp b/src/replica/replica_disk_migrator.cpp index 189c81c42b..f0ff784381 100644 --- a/src/replica/replica_disk_migrator.cpp +++ b/src/replica/replica_disk_migrator.cpp @@ -20,7 +20,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/fs_manager.h" #include "common/gpid.h" #include "common/replication.codes.h" @@ -164,7 +164,7 @@ void replica_disk_migrator::migrate_replica(const replica_disk_migrate_request & // THREAD_POOL_REPLICATION_LONG bool replica_disk_migrator::init_target_dir(const replica_disk_migrate_request &req) { - FAIL_POINT_INJECT_F("init_target_dir", [this](absl::string_view) -> bool { + FAIL_POINT_INJECT_F("init_target_dir", [this](std::string_view) -> bool { reset_status(); return false; }); @@ -210,7 +210,7 @@ bool replica_disk_migrator::init_target_dir(const replica_disk_migrate_request & // THREAD_POOL_REPLICATION_LONG bool replica_disk_migrator::migrate_replica_checkpoint(const replica_disk_migrate_request &req) { - FAIL_POINT_INJECT_F("migrate_replica_checkpoint", [this](absl::string_view) -> bool { + FAIL_POINT_INJECT_F("migrate_replica_checkpoint", [this](std::string_view) -> bool { reset_status(); return false; }); @@ -246,7 +246,7 @@ bool replica_disk_migrator::migrate_replica_checkpoint(const replica_disk_migrat // THREAD_POOL_REPLICATION_LONG bool replica_disk_migrator::migrate_replica_app_info(const replica_disk_migrate_request &req) { - FAIL_POINT_INJECT_F("migrate_replica_app_info", [this](absl::string_view) -> bool { + FAIL_POINT_INJECT_F("migrate_replica_app_info", [this](std::string_view) -> bool { reset_status(); return false; }); diff --git a/src/replica/replica_stub.cpp b/src/replica/replica_stub.cpp index 32f5141e17..3225c3cae7 100644 --- a/src/replica/replica_stub.cpp +++ b/src/replica/replica_stub.cpp @@ -43,7 +43,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "backup/replica_backup_server.h" #include "bulk_load/replica_bulk_loader.h" #include "common/backup_common.h" @@ -1810,7 +1810,7 @@ void replica_stub::open_replica( dsn::utils::filesystem::rename_path(origin_tmp_dir, origin_dir); rep = load_replica(origin_dn, origin_dir.c_str()); - FAIL_POINT_INJECT_F("mock_replica_load", [&](absl::string_view) -> void {}); + FAIL_POINT_INJECT_F("mock_replica_load", [&](std::string_view) -> void {}); } } } @@ -1999,7 +1999,7 @@ bool replica_stub::validate_replica_dir(const std::string &dir, replica *replica_stub::load_replica(dir_node *dn, const char *dir) { FAIL_POINT_INJECT_F("mock_replica_load", - [&](absl::string_view) -> replica * { return nullptr; }); + [&](std::string_view) -> replica * { return nullptr; }); app_info ai; gpid pid; @@ -2671,7 +2671,7 @@ replica_ptr replica_stub::create_child_replica_if_not_found(gpid child_pid, const std::string &parent_dir) { FAIL_POINT_INJECT_F( - "replica_stub_create_child_replica_if_not_found", [=](absl::string_view) -> replica_ptr { + "replica_stub_create_child_replica_if_not_found", [=](std::string_view) -> replica_ptr { const auto dn = _fs_manager.create_child_replica_dir(app->app_type, child_pid, parent_dir); CHECK_NOTNULL(dn, ""); @@ -2717,7 +2717,7 @@ dsn::error_code replica_stub::split_replica_exec(dsn::task_code code, gpid pid, local_execution handler) { FAIL_POINT_INJECT_F("replica_stub_split_replica_exec", - [](absl::string_view) { return ERR_OK; }); + [](std::string_view) { return ERR_OK; }); replica_ptr replica = pid.get_app_id() == 0 ? nullptr : get_replica(pid); if (replica && handler) { tasking::enqueue( diff --git a/src/replica/replication_app_base.cpp b/src/replica/replication_app_base.cpp index 0455772599..e15df7829d 100644 --- a/src/replica/replication_app_base.cpp +++ b/src/replica/replication_app_base.cpp @@ -32,7 +32,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/bulk_load_common.h" #include "common/duplication_common.h" #include "common/replica_envs.h" @@ -281,7 +281,7 @@ int replication_app_base::on_batched_write_requests(int64_t decree, error_code replication_app_base::apply_mutation(const mutation *mu) { FAIL_POINT_INJECT_F("replication_app_base_apply_mutation", - [](absl::string_view) { return ERR_OK; }); + [](std::string_view) { return ERR_OK; }); CHECK_EQ_PREFIX(mu->data.header.decree, last_committed_decree() + 1); CHECK_EQ_PREFIX(mu->data.updates.size(), mu->client_requests.size()); diff --git a/src/replica/split/replica_split_manager.cpp b/src/replica/split/replica_split_manager.cpp index e59096e4d4..371d92f092 100644 --- a/src/replica/split/replica_split_manager.cpp +++ b/src/replica/split/replica_split_manager.cpp @@ -48,7 +48,7 @@ #include "utils/filesystem.h" #include "utils/flags.h" #include "utils/fmt_logging.h" -#include "absl/strings/string_view.h" +#include #include "utils/thread_access_checker.h" METRIC_DEFINE_counter(replica, @@ -172,7 +172,7 @@ void replica_split_manager::child_init_replica(gpid parent_gpid, const host_port &primary_host_port, ballot init_ballot) // on child partition { - FAIL_POINT_INJECT_F("replica_child_init_replica", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_child_init_replica", [](std::string_view) {}); if (status() != partition_status::PS_INACTIVE) { LOG_WARNING_PREFIX("wrong status({})", enum_to_string(status())); @@ -218,7 +218,7 @@ void replica_split_manager::child_init_replica(gpid parent_gpid, // ThreadPool: THREAD_POOL_REPLICATION void replica_split_manager::child_check_split_context() // on child partition { - FAIL_POINT_INJECT_F("replica_child_check_split_context", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_child_check_split_context", [](std::string_view) {}); if (status() != partition_status::PS_PARTITION_SPLIT) { LOG_ERROR_PREFIX("wrong status({})", enum_to_string(status())); @@ -246,7 +246,7 @@ void replica_split_manager::child_check_split_context() // on child partition // ThreadPool: THREAD_POOL_REPLICATION bool replica_split_manager::parent_check_states() // on parent partition { - FAIL_POINT_INJECT_F("replica_parent_check_states", [](absl::string_view) { return true; }); + FAIL_POINT_INJECT_F("replica_parent_check_states", [](std::string_view) { return true; }); if (_split_status != split_status::SPLITTING || _child_init_ballot != get_ballot() || _child_gpid.get_app_id() == 0 || @@ -387,7 +387,7 @@ void replica_split_manager::child_learn_states(learn_state lstate, uint64_t total_file_size, decree last_committed_decree) // on child partition { - FAIL_POINT_INJECT_F("replica_child_learn_states", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_child_learn_states", [](std::string_view) {}); if (status() != partition_status::PS_PARTITION_SPLIT) { LOG_ERROR_PREFIX("wrong status({})", enum_to_string(status())); @@ -455,7 +455,7 @@ replica_split_manager::child_apply_private_logs(std::vector plog_fi uint64_t total_file_size, decree last_committed_decree) // on child partition { - FAIL_POINT_INJECT_F("replica_child_apply_private_logs", [](absl::string_view arg) { + FAIL_POINT_INJECT_F("replica_child_apply_private_logs", [](std::string_view arg) { return error_code::try_get(arg.data(), ERR_OK); }); @@ -547,7 +547,7 @@ replica_split_manager::child_apply_private_logs(std::vector plog_fi // ThreadPool: THREAD_POOL_REPLICATION void replica_split_manager::child_catch_up_states() // on child partition { - FAIL_POINT_INJECT_F("replica_child_catch_up_states", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_child_catch_up_states", [](std::string_view) {}); if (status() != partition_status::PS_PARTITION_SPLIT) { LOG_ERROR_PREFIX("wrong status, status is {}", enum_to_string(status())); @@ -612,7 +612,7 @@ void replica_split_manager::child_catch_up_states() // on child partition // ThreadPool: THREAD_POOL_REPLICATION void replica_split_manager::child_notify_catch_up() // on child partition { - FAIL_POINT_INJECT_F("replica_child_notify_catch_up", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_child_notify_catch_up", [](std::string_view) {}); std::unique_ptr request = std::make_unique(); request->parent_gpid = _replica->_split_states.parent_gpid; @@ -737,7 +737,7 @@ void replica_split_manager::parent_handle_child_catch_up( // ThreadPool: THREAD_POOL_REPLICATION void replica_split_manager::parent_check_sync_point_commit(decree sync_point) // on primary parent { - FAIL_POINT_INJECT_F("replica_parent_check_sync_point_commit", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_parent_check_sync_point_commit", [](std::string_view) {}); if (status() != partition_status::PS_PRIMARY) { LOG_ERROR_PREFIX("wrong status({})", enum_to_string(status())); parent_handle_split_error("check_sync_point_commit failed, primary changed", false); @@ -803,7 +803,7 @@ void replica_split_manager::parent_send_update_partition_count_request( int32_t new_partition_count, std::shared_ptr> ¬_replied_addresses) // on primary parent { - FAIL_POINT_INJECT_F("replica_parent_update_partition_count_request", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_parent_update_partition_count_request", [](std::string_view) {}); CHECK_EQ_PREFIX(status(), partition_status::PS_PRIMARY); @@ -964,7 +964,7 @@ void replica_split_manager::on_update_child_group_partition_count_reply( // ThreadPool: THREAD_POOL_REPLICATION void replica_split_manager::register_child_on_meta(ballot b) // on primary parent { - FAIL_POINT_INJECT_F("replica_register_child_on_meta", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_register_child_on_meta", [](std::string_view) {}); if (status() != partition_status::PS_PRIMARY || _split_status != split_status::SPLITTING) { LOG_ERROR_PREFIX( @@ -1013,7 +1013,7 @@ void replica_split_manager::register_child_on_meta(ballot b) // on primary paren void replica_split_manager::parent_send_register_request( const register_child_request &request) // on primary parent { - FAIL_POINT_INJECT_F("replica_parent_send_register_request", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_parent_send_register_request", [](std::string_view) {}); CHECK_EQ_PREFIX(status(), partition_status::PS_INACTIVE); LOG_INFO_PREFIX( @@ -1043,7 +1043,7 @@ void replica_split_manager::on_register_child_on_meta_reply( const register_child_request &request, const register_child_response &response) // on primary parent { - FAIL_POINT_INJECT_F("replica_on_register_child_on_meta_reply", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_on_register_child_on_meta_reply", [](std::string_view) {}); _replica->_checker.only_one_thread_access(); @@ -1517,7 +1517,7 @@ void replica_split_manager::primary_parent_handle_stop_split( void replica_split_manager::parent_send_notify_stop_request( split_status::type meta_split_status) // on primary parent { - FAIL_POINT_INJECT_F("replica_parent_send_notify_stop_request", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("replica_parent_send_notify_stop_request", [](std::string_view) {}); auto meta_address = dsn::dns_resolver::instance().resolve_address(_stub->_failure_detector->get_servers()); std::unique_ptr req = std::make_unique(); diff --git a/src/runtime/profiler.cpp b/src/runtime/profiler.cpp index 7852f1fcb1..2228cc35b3 100644 --- a/src/runtime/profiler.cpp +++ b/src/runtime/profiler.cpp @@ -57,7 +57,7 @@ START<== queue(server) == ENQUEUE <===== net(reply) ======= REPLY <============= #include #include -#include "absl/strings/string_view.h" +#include #include "aio/aio_task.h" #include "fmt/core.h" #include "profiler_header.h" diff --git a/src/runtime/rpc/dns_resolver.cpp b/src/runtime/rpc/dns_resolver.cpp index 2eab9d8327..bfd7f5206d 100644 --- a/src/runtime/rpc/dns_resolver.cpp +++ b/src/runtime/rpc/dns_resolver.cpp @@ -22,7 +22,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "fmt/core.h" #include "fmt/format.h" #include "runtime/rpc/dns_resolver.h" diff --git a/src/runtime/rpc/network.cpp b/src/runtime/rpc/network.cpp index 2c506fd720..c572b19a8d 100644 --- a/src/runtime/rpc/network.cpp +++ b/src/runtime/rpc/network.cpp @@ -32,7 +32,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "message_parser_manager.h" #include "runtime/api_task.h" #include "runtime/rpc/rpc_address.h" diff --git a/src/runtime/rpc/rpc_address.cpp b/src/runtime/rpc/rpc_address.cpp index f8d02d7c66..064dd458d5 100644 --- a/src/runtime/rpc/rpc_address.cpp +++ b/src/runtime/rpc/rpc_address.cpp @@ -35,7 +35,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "runtime/rpc/group_address.h" #include "utils/error_code.h" #include "utils/fixed_size_buffer_pool.h" @@ -143,7 +143,7 @@ bool rpc_address::is_site_local_address(uint32_t ip_net) /*static*/ bool rpc_address::is_docker_netcard(const char *netcard_interface, uint32_t ip_net) { - if (absl::string_view(netcard_interface).find("docker") != absl::string_view::npos) { + if (std::string_view(netcard_interface).find("docker") != std::string_view::npos) { return true; } uint32_t iphost = ntohl(ip_net); diff --git a/src/runtime/rpc/thrift_message_parser.cpp b/src/runtime/rpc/thrift_message_parser.cpp index 08bbfcb872..d547075025 100644 --- a/src/runtime/rpc/thrift_message_parser.cpp +++ b/src/runtime/rpc/thrift_message_parser.cpp @@ -46,7 +46,7 @@ #include "utils/endians.h" #include "utils/fmt_logging.h" #include "utils/fmt_utils.h" -#include "absl/strings/string_view.h" +#include #include "utils/strings.h" namespace dsn { @@ -340,7 +340,7 @@ void thrift_message_parser::prepare_on_send(message_ex *msg) // first total length, but we don't know the length, so firstly we put a placeholder header_proto.writeI32(0); // then the error_message - header_proto.writeString(absl::string_view(header->server.error_name)); + header_proto.writeString(std::string_view(header->server.error_name)); // then the thrift message begin header_proto.writeMessageBegin( header->rpc_name, ::apache::thrift::protocol::T_REPLY, header->id); diff --git a/src/runtime/task/task_queue.cpp b/src/runtime/task/task_queue.cpp index 8b0de42b34..b22e01bdb8 100644 --- a/src/runtime/task/task_queue.cpp +++ b/src/runtime/task/task_queue.cpp @@ -26,7 +26,7 @@ #include "task_queue.h" -#include "absl/strings/string_view.h" +#include #include "fmt/core.h" #include "runtime/rpc/network.h" #include "runtime/rpc/rpc_engine.h" diff --git a/src/security/sasl_client_wrapper.cpp b/src/security/sasl_client_wrapper.cpp index 50296826da..acdce301e0 100644 --- a/src/security/sasl_client_wrapper.cpp +++ b/src/security/sasl_client_wrapper.cpp @@ -23,7 +23,7 @@ #include "utils/error_code.h" #include "utils/fail_point.h" #include "utils/flags.h" -#include "absl/strings/string_view.h" +#include DSN_DECLARE_string(service_fqdn); DSN_DECLARE_string(service_name); @@ -33,7 +33,7 @@ namespace security { error_s sasl_client_wrapper::init() { - FAIL_POINT_INJECT_F("sasl_client_wrapper_init", [](absl::string_view str) { + FAIL_POINT_INJECT_F("sasl_client_wrapper_init", [](std::string_view str) { error_code err = error_code::try_get(str.data(), ERR_UNKNOWN); return error_s::make(err); }); @@ -45,7 +45,7 @@ error_s sasl_client_wrapper::init() error_s sasl_client_wrapper::start(const std::string &mechanism, const blob &input, blob &output) { - FAIL_POINT_INJECT_F("sasl_client_wrapper_start", [](absl::string_view str) { + FAIL_POINT_INJECT_F("sasl_client_wrapper_start", [](std::string_view str) { error_code err = error_code::try_get(str.data(), ERR_UNKNOWN); return error_s::make(err); }); @@ -62,7 +62,7 @@ error_s sasl_client_wrapper::start(const std::string &mechanism, const blob &inp error_s sasl_client_wrapper::step(const blob &input, blob &output) { - FAIL_POINT_INJECT_F("sasl_client_wrapper_step", [](absl::string_view str) { + FAIL_POINT_INJECT_F("sasl_client_wrapper_step", [](std::string_view str) { error_code err = error_code::try_get(str.data(), ERR_UNKNOWN); return error_s::make(err); }); diff --git a/src/security/sasl_server_wrapper.cpp b/src/security/sasl_server_wrapper.cpp index 4cda84241b..67498926ff 100644 --- a/src/security/sasl_server_wrapper.cpp +++ b/src/security/sasl_server_wrapper.cpp @@ -23,7 +23,7 @@ #include "utils/error_code.h" #include "utils/fail_point.h" #include "utils/flags.h" -#include "absl/strings/string_view.h" +#include DSN_DECLARE_string(service_fqdn); DSN_DECLARE_string(service_name); @@ -33,7 +33,7 @@ namespace security { error_s sasl_server_wrapper::init() { - FAIL_POINT_INJECT_F("sasl_server_wrapper_init", [](absl::string_view str) { + FAIL_POINT_INJECT_F("sasl_server_wrapper_init", [](std::string_view str) { error_code err = error_code::try_get(str.data(), ERR_UNKNOWN); return error_s::make(err); }); @@ -45,7 +45,7 @@ error_s sasl_server_wrapper::init() error_s sasl_server_wrapper::start(const std::string &mechanism, const blob &input, blob &output) { - FAIL_POINT_INJECT_F("sasl_server_wrapper_start", [](absl::string_view str) { + FAIL_POINT_INJECT_F("sasl_server_wrapper_start", [](std::string_view str) { error_code err = error_code::try_get(str.data(), ERR_UNKNOWN); return error_s::make(err); }); @@ -61,7 +61,7 @@ error_s sasl_server_wrapper::start(const std::string &mechanism, const blob &inp error_s sasl_server_wrapper::step(const blob &input, blob &output) { - FAIL_POINT_INJECT_F("sasl_server_wrapper_step", [](absl::string_view str) { + FAIL_POINT_INJECT_F("sasl_server_wrapper_step", [](std::string_view str) { error_code err = error_code::try_get(str.data(), ERR_UNKNOWN); return error_s::make(err); }); diff --git a/src/security/sasl_wrapper.cpp b/src/security/sasl_wrapper.cpp index 14c28f7b95..7d7d222c51 100644 --- a/src/security/sasl_wrapper.cpp +++ b/src/security/sasl_wrapper.cpp @@ -23,7 +23,7 @@ #include "sasl_server_wrapper.h" #include "utils/error_code.h" #include "utils/fail_point.h" -#include "absl/strings/string_view.h" +#include namespace dsn { namespace security { @@ -44,7 +44,7 @@ sasl_wrapper::~sasl_wrapper() error_s sasl_wrapper::retrieve_username(std::string &output) { - FAIL_POINT_INJECT_F("sasl_wrapper_retrieve_username", [](absl::string_view str) { + FAIL_POINT_INJECT_F("sasl_wrapper_retrieve_username", [](std::string_view str) { error_code err = error_code::try_get(str.data(), ERR_UNKNOWN); return error_s::make(err); }); diff --git a/src/server/collector/main.cpp b/src/server/collector/main.cpp index 718937ba24..225c922e81 100644 --- a/src/server/collector/main.cpp +++ b/src/server/collector/main.cpp @@ -21,7 +21,7 @@ #include #include "info_collector_app.h" -#include "pegasus_service_app.h" +#include "server/pegasus_service_app.h" #include "runtime/app_model.h" #include "runtime/service_app.h" #include "server/server_utils.h" diff --git a/src/server/compaction_filter_rule.cpp b/src/server/compaction_filter_rule.cpp index cf369da96b..d04b67e70b 100644 --- a/src/server/compaction_filter_rule.cpp +++ b/src/server/compaction_filter_rule.cpp @@ -22,14 +22,14 @@ #include "base/pegasus_utils.h" #include "base/pegasus_value_schema.h" #include "utils/fmt_logging.h" -#include "absl/strings/string_view.h" +#include #include "utils/strings.h" namespace pegasus { namespace server { -bool string_pattern_match(absl::string_view value, +bool string_pattern_match(std::string_view value, string_match_type type, - absl::string_view filter_pattern) + std::string_view filter_pattern) { if (filter_pattern.empty()) return false; @@ -38,7 +38,7 @@ bool string_pattern_match(absl::string_view value, switch (type) { case string_match_type::SMT_MATCH_ANYWHERE: - return value.find(filter_pattern) != absl::string_view::npos; + return value.find(filter_pattern) != std::string_view::npos; case string_match_type::SMT_MATCH_PREFIX: return dsn::utils::mequals(value.data(), filter_pattern.data(), filter_pattern.length()); case string_match_type::SMT_MATCH_POSTFIX: @@ -53,27 +53,27 @@ bool string_pattern_match(absl::string_view value, hashkey_pattern_rule::hashkey_pattern_rule(uint32_t data_version) {} -bool hashkey_pattern_rule::match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const +bool hashkey_pattern_rule::match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const { return string_pattern_match(hash_key, match_type, pattern); } sortkey_pattern_rule::sortkey_pattern_rule(uint32_t data_version) {} -bool sortkey_pattern_rule::match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const +bool sortkey_pattern_rule::match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const { return string_pattern_match(sort_key, match_type, pattern); } ttl_range_rule::ttl_range_rule(uint32_t data_version) : data_version(data_version) {} -bool ttl_range_rule::match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const +bool ttl_range_rule::match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const { uint32_t expire_ts = pegasus_extract_expire_ts(data_version, existing_value); // if start_ttl and stop_ttl = 0, it means we want to delete keys which have no ttl diff --git a/src/server/compaction_filter_rule.h b/src/server/compaction_filter_rule.h index be211ba6b0..e471a759fd 100644 --- a/src/server/compaction_filter_rule.h +++ b/src/server/compaction_filter_rule.h @@ -30,7 +30,7 @@ #include "utils/enum_helper.h" #include "utils/factory_store.h" #include "utils/fmt_utils.h" -#include "absl/strings/string_view.h" +#include namespace pegasus { namespace server { @@ -76,9 +76,9 @@ class compaction_filter_rule // TODO(zhaoliwei): we can use `value_filed` to replace existing_value in the later, // after the refactor of value schema - virtual bool match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const = 0; + virtual bool match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const = 0; }; enum string_match_type @@ -102,9 +102,9 @@ class hashkey_pattern_rule : public compaction_filter_rule public: hashkey_pattern_rule(uint32_t data_version = VERSION_MAX); - bool match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const; + bool match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const; DEFINE_JSON_SERIALIZATION(pattern, match_type) private: @@ -124,9 +124,9 @@ class sortkey_pattern_rule : public compaction_filter_rule public: sortkey_pattern_rule(uint32_t data_version = VERSION_MAX); - bool match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const; + bool match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const; DEFINE_JSON_SERIALIZATION(pattern, match_type) private: @@ -144,9 +144,9 @@ class ttl_range_rule : public compaction_filter_rule public: explicit ttl_range_rule(uint32_t data_version); - bool match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const; + bool match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const; DEFINE_JSON_SERIALIZATION(start_ttl, stop_ttl) private: diff --git a/src/server/compaction_operation.cpp b/src/server/compaction_operation.cpp index 5c139073c1..605501dd57 100644 --- a/src/server/compaction_operation.cpp +++ b/src/server/compaction_operation.cpp @@ -30,9 +30,9 @@ namespace pegasus { namespace server { compaction_operation::~compaction_operation() = default; -bool compaction_operation::all_rules_match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const +bool compaction_operation::all_rules_match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const { if (rules.empty()) { return false; @@ -55,9 +55,9 @@ delete_key::delete_key(filter_rules &&rules, uint32_t data_version) delete_key::delete_key(uint32_t data_version) : compaction_operation(data_version) {} -bool delete_key::filter(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value, +bool delete_key::filter(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value, std::string *new_value, bool *value_changed) const { @@ -74,9 +74,9 @@ update_ttl::update_ttl(filter_rules &&rules, uint32_t data_version) update_ttl::update_ttl(uint32_t data_version) : compaction_operation(data_version) {} -bool update_ttl::filter(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value, +bool update_ttl::filter(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value, std::string *new_value, bool *value_changed) const { diff --git a/src/server/compaction_operation.h b/src/server/compaction_operation.h index d7c9d811eb..882e27ba49 100644 --- a/src/server/compaction_operation.h +++ b/src/server/compaction_operation.h @@ -27,7 +27,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/json_helper.h" #include "compaction_filter_rule.h" #include "utils/blob.h" @@ -75,18 +75,18 @@ class compaction_operation explicit compaction_operation(uint32_t data_version) : data_version(data_version) {} virtual ~compaction_operation() = 0; - bool all_rules_match(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value) const; + bool all_rules_match(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value) const; void set_rules(filter_rules &&rules); /** * @return false indicates that this key-value should be removed * If you want to modify the existing_value, you can pass it back through new_value and * value_changed needs to be set to true in this case. */ - virtual bool filter(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value, + virtual bool filter(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value, std::string *new_value, bool *value_changed) const = 0; @@ -106,9 +106,9 @@ class delete_key : public compaction_operation delete_key(filter_rules &&rules, uint32_t data_version); explicit delete_key(uint32_t data_version); - bool filter(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value, + bool filter(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value, std::string *new_value, bool *value_changed) const; @@ -154,9 +154,9 @@ class update_ttl : public compaction_operation update_ttl(filter_rules &&rules, uint32_t data_version); explicit update_ttl(uint32_t data_version); - bool filter(absl::string_view hash_key, - absl::string_view sort_key, - absl::string_view existing_value, + bool filter(std::string_view hash_key, + std::string_view sort_key, + std::string_view existing_value, std::string *new_value, bool *value_changed) const; DEFINE_JSON_SERIALIZATION(type, value) diff --git a/src/server/hotkey_collector.cpp b/src/server/hotkey_collector.cpp index a05c3012d8..aca5231342 100644 --- a/src/server/hotkey_collector.cpp +++ b/src/server/hotkey_collector.cpp @@ -129,7 +129,7 @@ find_outlier_index(const std::vector &captured_keys, int threshold, in // TODO: (Tangyanzhao) replace it to xxhash -/*extern*/ int get_bucket_id(absl::string_view data, int bucket_num) +/*extern*/ int get_bucket_id(std::string_view data, int bucket_num) { return static_cast(boost::hash_range(data.begin(), data.end()) % bucket_num); } @@ -398,7 +398,7 @@ struct blob_hash { std::size_t operator()(const dsn::blob &str) const { - absl::string_view cp = str.to_string_view(); + std::string_view cp = str.to_string_view(); return boost::hash_range(cp.begin(), cp.end()); } }; @@ -429,7 +429,7 @@ void hotkey_fine_data_collector::analyse_data(detect_hotkey_result &result) // the weight of all the collected hash keys std::vector weights; weights.reserve(hash_keys_weight.size()); - absl::string_view weight_max_key; // the hashkey with the max weight + std::string_view weight_max_key; // the hashkey with the max weight uint64_t weight_max = 0; // the max weight by far for (const auto &iter : hash_keys_weight) { weights.push_back(iter.second); diff --git a/src/server/hotkey_collector.h b/src/server/hotkey_collector.h index 826bf157b8..b8b74ccf51 100644 --- a/src/server/hotkey_collector.h +++ b/src/server/hotkey_collector.h @@ -29,7 +29,7 @@ #include "replica/replica_base.h" #include "replica_admin_types.h" #include "utils/blob.h" -#include "absl/strings/string_view.h" +#include namespace pegasus { namespace server { @@ -50,7 +50,7 @@ struct detect_hotkey_result } }; -extern int get_bucket_id(absl::string_view data, int bucket_num); +extern int get_bucket_id(std::string_view data, int bucket_num); extern bool find_outlier_index(const std::vector &captured_keys, int threshold, int &hot_index); diff --git a/src/server/hotspot_partition_calculator.cpp b/src/server/hotspot_partition_calculator.cpp index b2b71e6987..9b99abfabb 100644 --- a/src/server/hotspot_partition_calculator.cpp +++ b/src/server/hotspot_partition_calculator.cpp @@ -22,7 +22,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "client/replication_ddl_client.h" #include "common/gpid.h" #include "common/serialization_helper/dsn.layer2_types.h" @@ -212,7 +212,7 @@ void hotspot_partition_calculator::send_detect_hotkey_request( const dsn::replication::hotkey_type::type hotkey_type, const dsn::replication::detect_action::type action) { - FAIL_POINT_INJECT_F("send_detect_hotkey_request", [](absl::string_view) {}); + FAIL_POINT_INJECT_F("send_detect_hotkey_request", [](std::string_view) {}); int app_id = -1; int partition_count = -1; diff --git a/src/server/key_ttl_compaction_filter.h b/src/server/key_ttl_compaction_filter.h index 8df418de9d..6f4f07f05c 100644 --- a/src/server/key_ttl_compaction_filter.h +++ b/src/server/key_ttl_compaction_filter.h @@ -79,7 +79,7 @@ class KeyWithTTLCompactionFilter : public rocksdb::CompactionFilter } if (!_user_specified_operations.empty()) { - absl::string_view value_view = utils::to_string_view(existing_value); + std::string_view value_view = utils::to_string_view(existing_value); if (*value_changed) { value_view = *new_value; } @@ -92,7 +92,7 @@ class KeyWithTTLCompactionFilter : public rocksdb::CompactionFilter } bool user_specified_operation_filter(const rocksdb::Slice &key, - absl::string_view existing_value, + std::string_view existing_value, std::string *new_value, bool *value_changed) const { diff --git a/src/server/main.cpp b/src/server/main.cpp index aa9d1128e0..8c30f0d475 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -25,7 +25,7 @@ #include "info_collector_app.h" #include "meta/meta_service_app.h" #include "pegasus_server_impl.h" -#include "pegasus_service_app.h" +#include "server/pegasus_service_app.h" #include "runtime/app_model.h" #include "runtime/service_app.h" #include "server/server_utils.h" diff --git a/src/server/meta_server/main.cpp b/src/server/meta_server/main.cpp index 92cfb5f5df..efe1275b8b 100644 --- a/src/server/meta_server/main.cpp +++ b/src/server/meta_server/main.cpp @@ -21,7 +21,7 @@ #include #include "meta/meta_service_app.h" -#include "pegasus_service_app.h" +#include "server/pegasus_service_app.h" #include "runtime/app_model.h" #include "runtime/service_app.h" #include "server/server_utils.h" diff --git a/src/server/pegasus_mutation_duplicator.cpp b/src/server/pegasus_mutation_duplicator.cpp index 6b29e4e3ec..76675a17b1 100644 --- a/src/server/pegasus_mutation_duplicator.cpp +++ b/src/server/pegasus_mutation_duplicator.cpp @@ -75,9 +75,9 @@ DSN_TAG_VARIABLE(dup_max_allowed_write_size, FT_MUTABLE); /// static definition of mutation_duplicator::creator. /*static*/ std::function( - replica_base *, absl::string_view, absl::string_view)> + replica_base *, std::string_view, std::string_view)> mutation_duplicator::creator = - [](replica_base *r, absl::string_view remote, absl::string_view app) { + [](replica_base *r, std::string_view remote, std::string_view app) { return std::make_unique(r, remote, app); }; @@ -116,8 +116,8 @@ using namespace dsn::literals::chrono_literals; } pegasus_mutation_duplicator::pegasus_mutation_duplicator(dsn::replication::replica_base *r, - absl::string_view remote_cluster, - absl::string_view app) + std::string_view remote_cluster, + std::string_view app) : mutation_duplicator(r), _remote_cluster(remote_cluster), METRIC_VAR_INIT_replica(dup_shipped_successful_requests), diff --git a/src/server/pegasus_mutation_duplicator.h b/src/server/pegasus_mutation_duplicator.h index 2d81a6a37c..0ac19c68df 100644 --- a/src/server/pegasus_mutation_duplicator.h +++ b/src/server/pegasus_mutation_duplicator.h @@ -31,7 +31,7 @@ #include "runtime/task/task_code.h" #include "runtime/task/task_tracker.h" #include "utils/chrono_literals.h" -#include "absl/strings/string_view.h" +#include #include "utils/metrics.h" #include "utils/zlocks.h" @@ -61,8 +61,8 @@ class pegasus_mutation_duplicator : public dsn::replication::mutation_duplicator public: pegasus_mutation_duplicator(dsn::replication::replica_base *r, - absl::string_view remote_cluster, - absl::string_view app); + std::string_view remote_cluster, + std::string_view app); void duplicate(mutation_tuple_set muts, callback cb) override; diff --git a/src/server/pegasus_server_impl.cpp b/src/server/pegasus_server_impl.cpp index e3a75c2fef..ffb4b8c1c9 100644 --- a/src/server/pegasus_server_impl.cpp +++ b/src/server/pegasus_server_impl.cpp @@ -44,7 +44,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "base/idl_utils.h" // IWYU pragma: keep #include "base/meta_store.h" #include "base/pegasus_key_schema.h" @@ -2354,7 +2354,7 @@ bool pegasus_server_impl::validate_filter(::dsn::apps::filter_type::type filter_ return false; if (filter_type == ::dsn::apps::filter_type::FT_MATCH_ANYWHERE) { return value.to_string_view().find(filter_pattern.to_string_view()) != - absl::string_view::npos; + std::string_view::npos; } else if (filter_type == ::dsn::apps::filter_type::FT_MATCH_PREFIX) { return dsn::utils::mequals( value.data(), filter_pattern.data(), filter_pattern.length()); diff --git a/src/server/pegasus_service_app.h b/src/server/pegasus_service_app.h index 6d5eda6ac0..787a62dd43 100644 --- a/src/server/pegasus_service_app.h +++ b/src/server/pegasus_service_app.h @@ -21,8 +21,8 @@ #include "meta/meta_service_app.h" #include "replica/replication_service_app.h" -#include -#include +#include "pegasus/version.h" +#include "pegasus/git_commit.h" #include "utils/builtin_metrics.h" namespace pegasus { diff --git a/src/server/pegasus_write_service_impl.h b/src/server/pegasus_write_service_impl.h index 2169b273e2..35a9c6399d 100644 --- a/src/server/pegasus_write_service_impl.h +++ b/src/server/pegasus_write_service_impl.h @@ -90,7 +90,7 @@ class pegasus_write_service::impl : public dsn::replication::replica_base int empty_put(int64_t decree) { int err = - _rocksdb_wrapper->write_batch_put(decree, absl::string_view(), absl::string_view(), 0); + _rocksdb_wrapper->write_batch_put(decree, std::string_view(), std::string_view(), 0); auto cleanup = dsn::defer([this]() { _rocksdb_wrapper->clear_up_write_batch(); }); if (err != rocksdb::Status::kOk) { return err; @@ -178,7 +178,7 @@ class pegasus_write_service::impl : public dsn::replication::replica_base resp.decree = decree; resp.server = _primary_host_port; - absl::string_view raw_key = update.key.to_string_view(); + std::string_view raw_key = update.key.to_string_view(); int64_t new_value = 0; uint32_t new_expire_ts = 0; db_get_context get_ctx; @@ -275,7 +275,7 @@ class pegasus_write_service::impl : public dsn::replication::replica_base pegasus_generate_key(check_key, update.hash_key, update.check_sort_key); db_get_context get_context; - absl::string_view check_raw_key = check_key.to_string_view(); + std::string_view check_raw_key = check_key.to_string_view(); int err = _rocksdb_wrapper->get(check_raw_key, &get_context); if (err != rocksdb::Status::kOk) { // read check value failed @@ -327,7 +327,7 @@ class pegasus_write_service::impl : public dsn::replication::replica_base } else { // check not passed, write empty record to update rocksdb's last flushed decree resp.error = _rocksdb_wrapper->write_batch_put( - decree, absl::string_view(), absl::string_view(), 0); + decree, std::string_view(), std::string_view(), 0); } auto cleanup = dsn::defer([this]() { _rocksdb_wrapper->clear_up_write_batch(); }); @@ -395,7 +395,7 @@ class pegasus_write_service::impl : public dsn::replication::replica_base pegasus_generate_key(check_key, update.hash_key, update.check_sort_key); db_get_context get_context; - absl::string_view check_raw_key = check_key.to_string_view(); + std::string_view check_raw_key = check_key.to_string_view(); int err = _rocksdb_wrapper->get(check_raw_key, &get_context); if (err != rocksdb::Status::kOk) { // read check value failed @@ -453,7 +453,7 @@ class pegasus_write_service::impl : public dsn::replication::replica_base } else { // check not passed, write empty record to update rocksdb's last flushed decree resp.error = _rocksdb_wrapper->write_batch_put( - decree, absl::string_view(), absl::string_view(), 0); + decree, std::string_view(), std::string_view(), 0); } auto cleanup = dsn::defer([this]() { _rocksdb_wrapper->clear_up_write_batch(); }); @@ -562,7 +562,7 @@ class pegasus_write_service::impl : public dsn::replication::replica_base _rocksdb_wrapper->clear_up_write_batch(); } - static dsn::blob composite_raw_key(absl::string_view hash_key, absl::string_view sort_key) + static dsn::blob composite_raw_key(std::string_view hash_key, std::string_view sort_key) { dsn::blob raw_key; pegasus_generate_key(raw_key, hash_key, sort_key); @@ -609,7 +609,7 @@ class pegasus_write_service::impl : public dsn::replication::replica_base return false; if (check_type == ::dsn::apps::cas_check_type::CT_VALUE_MATCH_ANYWHERE) { return value.to_string_view().find(check_operand.to_string_view()) != - absl::string_view::npos; + std::string_view::npos; } else if (check_type == ::dsn::apps::cas_check_type::CT_VALUE_MATCH_PREFIX) { return dsn::utils::mequals( value.data(), check_operand.data(), check_operand.length()); diff --git a/src/server/replica_server/main.cpp b/src/server/replica_server/main.cpp index ad355692e4..b1d9a480f8 100644 --- a/src/server/replica_server/main.cpp +++ b/src/server/replica_server/main.cpp @@ -24,7 +24,7 @@ #include "common/replication_common.h" #include "compaction_operation.h" #include "pegasus_server_impl.h" -#include "pegasus_service_app.h" +#include "server/pegasus_service_app.h" #include "runtime/app_model.h" #include "runtime/service_app.h" #include "server/server_utils.h" diff --git a/src/server/rocksdb_wrapper.cpp b/src/server/rocksdb_wrapper.cpp index 59203836be..016adaade8 100644 --- a/src/server/rocksdb_wrapper.cpp +++ b/src/server/rocksdb_wrapper.cpp @@ -74,9 +74,9 @@ rocksdb_wrapper::rocksdb_wrapper(pegasus_server_impl *server) _wt_opts->disableWAL = true; } -int rocksdb_wrapper::get(absl::string_view raw_key, /*out*/ db_get_context *ctx) +int rocksdb_wrapper::get(std::string_view raw_key, /*out*/ db_get_context *ctx) { - FAIL_POINT_INJECT_F("db_get", [](absl::string_view) -> int { return FAIL_DB_GET; }); + FAIL_POINT_INJECT_F("db_get", [](std::string_view) -> int { return FAIL_DB_GET; }); rocksdb::Status s = _db->Get(_rd_opts, utils::to_rocksdb_slice(raw_key), &(ctx->raw_value)); if (dsn_likely(s.ok())) { @@ -105,20 +105,20 @@ int rocksdb_wrapper::get(absl::string_view raw_key, /*out*/ db_get_context *ctx) } int rocksdb_wrapper::write_batch_put(int64_t decree, - absl::string_view raw_key, - absl::string_view value, + std::string_view raw_key, + std::string_view value, uint32_t expire_sec) { return write_batch_put_ctx(db_write_context::empty(decree), raw_key, value, expire_sec); } int rocksdb_wrapper::write_batch_put_ctx(const db_write_context &ctx, - absl::string_view raw_key, - absl::string_view value, + std::string_view raw_key, + std::string_view value, uint32_t expire_sec) { FAIL_POINT_INJECT_F("db_write_batch_put", - [](absl::string_view) -> int { return FAIL_DB_WRITE_BATCH_PUT; }); + [](std::string_view) -> int { return FAIL_DB_WRITE_BATCH_PUT; }); uint64_t new_timetag = ctx.remote_timetag; if (!ctx.is_duplicated_write()) { // local write @@ -143,7 +143,7 @@ int rocksdb_wrapper::write_batch_put_ctx(const db_write_context &ctx, if (local_timetag >= new_timetag) { // ignore this stale update with lower timetag, // and write an empty record instead - raw_key = value = absl::string_view(); + raw_key = value = std::string_view(); } } } @@ -175,7 +175,7 @@ int rocksdb_wrapper::write(int64_t decree) return FLAGS_inject_write_error_for_test; } - FAIL_POINT_INJECT_F("db_write", [](absl::string_view) -> int { return FAIL_DB_WRITE; }); + FAIL_POINT_INJECT_F("db_write", [](std::string_view) -> int { return FAIL_DB_WRITE; }); rocksdb::Status status = _write_batch->Put(_meta_cf, meta_store::LAST_FLUSHED_DECREE, std::to_string(decree)); @@ -194,10 +194,10 @@ int rocksdb_wrapper::write(int64_t decree) return status.code(); } -int rocksdb_wrapper::write_batch_delete(int64_t decree, absl::string_view raw_key) +int rocksdb_wrapper::write_batch_delete(int64_t decree, std::string_view raw_key) { FAIL_POINT_INJECT_F("db_write_batch_delete", - [](absl::string_view) -> int { return FAIL_DB_WRITE_BATCH_DELETE; }); + [](std::string_view) -> int { return FAIL_DB_WRITE_BATCH_DELETE; }); rocksdb::Status s = _write_batch->Delete(utils::to_rocksdb_slice(raw_key)); if (dsn_unlikely(!s.ok())) { diff --git a/src/server/rocksdb_wrapper.h b/src/server/rocksdb_wrapper.h index 00a682a540..c73f5cb918 100644 --- a/src/server/rocksdb_wrapper.h +++ b/src/server/rocksdb_wrapper.h @@ -29,7 +29,7 @@ #include "pegasus_value_schema.h" #include "replica/replica_base.h" -#include "absl/strings/string_view.h" +#include #include "utils/metrics.h" namespace rocksdb { @@ -54,18 +54,18 @@ class rocksdb_wrapper : public dsn::replication::replica_base /// is returned. /// \result ctx.expired=true if record expired. Still rocksdb::Status::kOk is returned. /// \result ctx.found=false if record is not found. Still rocksdb::Status::kOk is returned. - int get(absl::string_view raw_key, /*out*/ db_get_context *ctx); + int get(std::string_view raw_key, /*out*/ db_get_context *ctx); int write_batch_put(int64_t decree, - absl::string_view raw_key, - absl::string_view value, + std::string_view raw_key, + std::string_view value, uint32_t expire_sec); int write_batch_put_ctx(const db_write_context &ctx, - absl::string_view raw_key, - absl::string_view value, + std::string_view raw_key, + std::string_view value, uint32_t expire_sec); int write(int64_t decree); - int write_batch_delete(int64_t decree, absl::string_view raw_key); + int write_batch_delete(int64_t decree, std::string_view raw_key); void clear_up_write_batch(); int ingest_files(int64_t decree, const std::vector &sst_file_list, diff --git a/src/server/test/hotkey_collector_test.cpp b/src/server/test/hotkey_collector_test.cpp index c8eb49cadb..1c6e72b560 100644 --- a/src/server/test/hotkey_collector_test.cpp +++ b/src/server/test/hotkey_collector_test.cpp @@ -70,7 +70,7 @@ TEST(hotkey_collector_public_func_test, get_bucket_id_test) { int bucket_id = -1; for (int i = 0; i < 1000000; i++) { - bucket_id = get_bucket_id(absl::string_view(generate_hash_key_by_random(false)), + bucket_id = get_bucket_id(std::string_view(generate_hash_key_by_random(false)), FLAGS_hotkey_buckets_num); ASSERT_GE(bucket_id, 0); ASSERT_LT(bucket_id, FLAGS_hotkey_buckets_num); diff --git a/src/server/test/pegasus_write_service_impl_test.cpp b/src/server/test/pegasus_write_service_impl_test.cpp index a076699ef1..0ac33faa40 100644 --- a/src/server/test/pegasus_write_service_impl_test.cpp +++ b/src/server/test/pegasus_write_service_impl_test.cpp @@ -34,7 +34,7 @@ #include "server/rocksdb_wrapper.h" #include "utils/blob.h" #include "utils/fail_point.h" -#include "absl/strings/string_view.h" +#include namespace pegasus { namespace server { @@ -55,7 +55,7 @@ class pegasus_write_service_impl_test : public pegasus_server_test_base _rocksdb_wrapper = _write_impl->_rocksdb_wrapper.get(); } - int db_get(absl::string_view raw_key, db_get_context *get_ctx) + int db_get(std::string_view raw_key, db_get_context *get_ctx) { return _rocksdb_wrapper->get(raw_key, get_ctx); } @@ -79,7 +79,7 @@ class incr_test : public pegasus_write_service_impl_test { pegasus_write_service_impl_test::SetUp(); pegasus::pegasus_generate_key( - req.key, absl::string_view("hash_key"), absl::string_view("sort_key")); + req.key, std::string_view("hash_key"), std::string_view("sort_key")); } dsn::apps::incr_request req; diff --git a/src/server/test/rocksdb_wrapper_test.cpp b/src/server/test/rocksdb_wrapper_test.cpp index e7f4b0006c..7831afc713 100644 --- a/src/server/test/rocksdb_wrapper_test.cpp +++ b/src/server/test/rocksdb_wrapper_test.cpp @@ -39,7 +39,7 @@ #include "utils/blob.h" #include "utils/error_code.h" #include "utils/fmt_logging.h" -#include "absl/strings/string_view.h" +#include namespace pegasus { namespace server { @@ -60,12 +60,12 @@ class rocksdb_wrapper_test : public pegasus_server_test_base _rocksdb_wrapper = _server_write->_write_svc->_impl->_rocksdb_wrapper.get(); pegasus::pegasus_generate_key( - _raw_key, absl::string_view("hash_key"), absl::string_view("sort_key")); + _raw_key, std::string_view("hash_key"), std::string_view("sort_key")); } void single_set(db_write_context write_ctx, dsn::blob raw_key, - absl::string_view user_value, + std::string_view user_value, int32_t expire_ts_seconds) { ASSERT_EQ(_rocksdb_wrapper->write_batch_put_ctx( @@ -93,7 +93,7 @@ class rocksdb_wrapper_test : public pegasus_server_test_base SetUp(); } - uint64_t read_timestamp_from(absl::string_view raw_value) + uint64_t read_timestamp_from(std::string_view raw_value) { uint64_t local_timetag = pegasus_extract_timetag(_rocksdb_wrapper->_pegasus_data_version, raw_value); diff --git a/src/shell/command_helper.h b/src/shell/command_helper.h index 0a5440b400..ebc48c2fd1 100644 --- a/src/shell/command_helper.h +++ b/src/shell/command_helper.h @@ -38,8 +38,8 @@ #include #include -#include -#include +#include "pegasus/git_commit.h" +#include "pegasus/version.h" #include #include @@ -56,7 +56,7 @@ #include "runtime/task/async_calls.h" #include "tools/mutation_log_tool.h" #include "utils/fmt_utils.h" -#include "absl/strings/string_view.h" +#include #include "utils/errors.h" #include "utils/metrics.h" #include "utils/ports.h" @@ -286,7 +286,7 @@ inline bool validate_filter(pegasus::pegasus_client::filter_type filter_type, if (value.length() < filter_pattern.length()) return false; if (filter_type == pegasus::pegasus_client::FT_MATCH_ANYWHERE) { - return absl::string_view(value).find(filter_pattern) != absl::string_view::npos; + return std::string_view(value).find(filter_pattern) != std::string_view::npos; } else if (filter_type == pegasus::pegasus_client::FT_MATCH_PREFIX) { return dsn::utils::mequals( value.data(), filter_pattern.data(), filter_pattern.length()); diff --git a/src/shell/commands.h b/src/shell/commands.h index 3ea3c132c0..d2dd734f40 100644 --- a/src/shell/commands.h +++ b/src/shell/commands.h @@ -29,14 +29,14 @@ #include "utils/filesystem.h" #include "utils/output_utils.h" #include "utils/string_conv.h" -#include "absl/strings/string_view.h" +#include #include "client/replication_ddl_client.h" #include "tools/mutation_log_tool.h" #include #include -#include -#include +#include "pegasus/version.h" +#include "pegasus/git_commit.h" #include #include "command_executor.h" diff --git a/src/shell/main.cpp b/src/shell/main.cpp index a6df779fe9..b044a749b7 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -18,7 +18,7 @@ */ #include -#include +#include "pegasus/version.h" #include #include #include diff --git a/src/utils/blob.h b/src/utils/blob.h index fea1a7a0e0..3cdbce320a 100644 --- a/src/utils/blob.h +++ b/src/utils/blob.h @@ -29,7 +29,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include #include @@ -59,7 +59,7 @@ class blob { } - /// NOTE: Use absl::string_view whenever possible. + /// NOTE: Use std::string_view whenever possible. /// blob is designed for shared buffer, never use it as constant view. /// Maybe we could deprecate this function in the future. blob(const char *buffer, int offset, unsigned int length) @@ -100,7 +100,7 @@ class blob _length = length; } - /// Deprecated. Use absl::string_view whenever possible. + /// Deprecated. Use std::string_view whenever possible. void assign(const char *buffer, int offset, unsigned int length) { _holder = nullptr; @@ -165,7 +165,7 @@ class blob return os << bb.to_string(); } - absl::string_view to_string_view() const { return absl::string_view(_data, _length); } + std::string_view to_string_view() const { return std::string_view(_data, _length); } uint32_t read(::apache::thrift::protocol::TProtocol *iprot); uint32_t write(::apache::thrift::protocol::TProtocol *oprot) const; diff --git a/src/utils/endians.h b/src/utils/endians.h index f41a4b7759..1d0739b4ea 100644 --- a/src/utils/endians.h +++ b/src/utils/endians.h @@ -23,7 +23,7 @@ #include "api_utilities.h" #include "fmt_logging.h" #include "ports.h" -#include "absl/strings/string_view.h" +#include namespace dsn { @@ -108,7 +108,7 @@ class data_output class data_input { public: - explicit data_input(absl::string_view s) : _p(s.data()), _size(s.size()) {} + explicit data_input(std::string_view s) : _p(s.data()), _size(s.size()) {} uint8_t read_u8() { return read_unsigned(); } @@ -118,7 +118,7 @@ class data_input uint64_t read_u64() { return read_unsigned(); } - absl::string_view read_str() { return {_p, _size}; } + std::string_view read_str() { return {_p, _size}; } void skip(size_t sz) { diff --git a/src/utils/errors.h b/src/utils/errors.h index 8d5806efa5..587ef8d976 100644 --- a/src/utils/errors.h +++ b/src/utils/errors.h @@ -33,7 +33,7 @@ #include "utils/fmt_logging.h" #include "utils/fmt_utils.h" #include "utils/ports.h" -#include "absl/strings/string_view.h" +#include namespace dsn { @@ -72,7 +72,7 @@ class error_s error_s(error_s &&rhs) noexcept = default; error_s &operator=(error_s &&) noexcept = default; - static error_s make(error_code code, absl::string_view reason) { return error_s(code, reason); } + static error_s make(error_code code, std::string_view reason) { return error_s(code, reason); } // NOLINT static error_s make(error_code code) { @@ -145,14 +145,14 @@ class error_s } private: - error_s(error_code code, absl::string_view msg) noexcept : _info(new error_info(code, msg)) {} + error_s(error_code code, std::string_view msg) noexcept : _info(new error_info(code, msg)) {} struct error_info { error_code code; std::string msg; // TODO(wutao1): use raw char* to improve performance? - error_info(error_code c, absl::string_view s) : code(c), msg(s) {} + error_info(error_code c, std::string_view s) : code(c), msg(s) {} }; void copy(const error_s &rhs) diff --git a/src/utils/fail_point.cpp b/src/utils/fail_point.cpp index 45c809c020..49790832c8 100644 --- a/src/utils/fail_point.cpp +++ b/src/utils/fail_point.cpp @@ -34,7 +34,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "fail_point_impl.h" #include "utils/fail_point.h" #include "utils/fmt_logging.h" @@ -45,7 +45,7 @@ namespace fail { static fail_point_registry REGISTRY; -/*extern*/ const std::string *eval(absl::string_view name) +/*extern*/ const std::string *eval(std::string_view name) { fail_point *p = REGISTRY.try_get(name); if (!p) { @@ -71,7 +71,7 @@ inline const char *task_type_to_string(fail_point::task_type t) } } -/*extern*/ void cfg(absl::string_view name, absl::string_view action) +/*extern*/ void cfg(std::string_view name, std::string_view action) { fail_point &p = REGISTRY.create_if_not_exists(name); p.set_action(action); @@ -93,14 +93,14 @@ inline const char *task_type_to_string(fail_point::task_type t) _S_FAIL_POINT_ENABLED = false; } -void fail_point::set_action(absl::string_view action) +void fail_point::set_action(std::string_view action) { if (!parse_from_string(action)) { LOG_FATAL("unrecognized command: {}", action); } } -bool fail_point::parse_from_string(absl::string_view action) +bool fail_point::parse_from_string(std::string_view action) { _max_cnt = -1; _freq = 100; diff --git a/src/utils/fail_point.h b/src/utils/fail_point.h index 663dcbd5a3..2c0e4111bf 100644 --- a/src/utils/fail_point.h +++ b/src/utils/fail_point.h @@ -36,7 +36,7 @@ #include #include "utils/ports.h" -#include "absl/strings/string_view.h" +#include // The only entry to define a fail point with `return` function: lambda function must be // return non-void type. When a fail point is defined, it's referenced via the name. @@ -75,14 +75,14 @@ namespace dsn { namespace fail { -extern const std::string *eval(absl::string_view name); +extern const std::string *eval(std::string_view name); /// Set new actions to a fail point at runtime. /// The format of an action is `[p%][cnt*]task[(arg)]`. `p%` is the expected probability that /// the action is triggered, and `cnt*` is the max times the action can be triggered. /// For example, `20%3*print(still alive!)` means the fail point has 20% chance to print a /// message "still alive!". And the message will be printed at most 3 times. -extern void cfg(absl::string_view name, absl::string_view action); +extern void cfg(std::string_view name, std::string_view action); extern void setup(); diff --git a/src/utils/fail_point_impl.h b/src/utils/fail_point_impl.h index 75ad2ef399..449d8fd534 100644 --- a/src/utils/fail_point_impl.h +++ b/src/utils/fail_point_impl.h @@ -61,11 +61,11 @@ struct fail_point Void, }; - void set_action(absl::string_view action); + void set_action(std::string_view action); const std::string *eval(); - explicit fail_point(absl::string_view name) : _name(name) {} + explicit fail_point(std::string_view name) : _name(name) {} /// for test only fail_point(task_type t, std::string arg, int freq, int max_cnt) @@ -76,7 +76,7 @@ struct fail_point /// for test only fail_point() = default; - bool parse_from_string(absl::string_view action); + bool parse_from_string(std::string_view action); friend inline bool operator==(const fail_point &p1, const fail_point &p2) { @@ -103,7 +103,7 @@ USER_DEFINED_ENUM_FORMATTER(fail_point::task_type) struct fail_point_registry { - fail_point &create_if_not_exists(absl::string_view name) + fail_point &create_if_not_exists(std::string_view name) { std::lock_guard guard(_mu); @@ -111,7 +111,7 @@ struct fail_point_registry return it->second; } - fail_point *try_get(absl::string_view name) + fail_point *try_get(std::string_view name) { std::lock_guard guard(_mu); diff --git a/src/utils/filesystem.cpp b/src/utils/filesystem.cpp index 1a7b3dd214..75ad72f5a1 100644 --- a/src/utils/filesystem.cpp +++ b/src/utils/filesystem.cpp @@ -43,7 +43,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "errors.h" #include "utils/defer.h" #include "utils/env.h" @@ -648,9 +648,9 @@ error_code get_process_image_path(int pid, std::string &path) bool get_disk_space_info(const std::string &path, disk_space_info &info) { - FAIL_POINT_INJECT_F("filesystem_get_disk_space_info", [&info](absl::string_view str) { + FAIL_POINT_INJECT_F("filesystem_get_disk_space_info", [&info](std::string_view str) { info.capacity = 100 * 1024 * 1024; - if (str.find("insufficient") != absl::string_view::npos) { + if (str.find("insufficient") != std::string_view::npos) { info.available = 512 * 1024; } else { info.available = 50 * 1024 * 1024; @@ -850,11 +850,11 @@ bool verify_file_size(const std::string &fname, FileDataType type, const int64_t bool create_directory(const std::string &path, std::string &absolute_path, std::string &err_msg) { - FAIL_POINT_INJECT_F("filesystem_create_directory", [path](absl::string_view str) { + FAIL_POINT_INJECT_F("filesystem_create_directory", [path](std::string_view str) { // when str contains 'false', and path contains broken_disk_dir, mock create fail(return // false) std::string broken_disk_dir = "disk1"; - return str.find("false") == absl::string_view::npos || + return str.find("false") == std::string_view::npos || path.find(broken_disk_dir) == std::string::npos; }); @@ -871,11 +871,11 @@ bool create_directory(const std::string &path, std::string &absolute_path, std:: bool check_dir_rw(const std::string &path, std::string &err_msg) { - FAIL_POINT_INJECT_F("filesystem_check_dir_rw", [path](absl::string_view str) { + FAIL_POINT_INJECT_F("filesystem_check_dir_rw", [path](std::string_view str) { // when str contains 'false', and path contains broken_disk_dir, mock check fail(return // false) std::string broken_disk_dir = "disk1"; - return str.find("false") == absl::string_view::npos || + return str.find("false") == std::string_view::npos || path.find(broken_disk_dir) == std::string::npos; }); diff --git a/src/utils/fmt_logging.h b/src/utils/fmt_logging.h index 97e751a48c..a7b41c68c8 100644 --- a/src/utils/fmt_logging.h +++ b/src/utils/fmt_logging.h @@ -33,7 +33,7 @@ do { \ if (level >= log_start_level) \ global_log( \ - __FILENAME__, __FUNCTION__, __LINE__, level, fmt::format(__VA_ARGS__).c_str()); \ + __FILE_NAME__, __FUNCTION__, __LINE__, level, fmt::format(__VA_ARGS__).c_str()); \ } while (false) #define LOG_DEBUG(...) LOG(LOG_LEVEL_DEBUG, __VA_ARGS__) diff --git a/src/utils/metrics.h b/src/utils/metrics.h index 199d11d483..9d9b0671d3 100644 --- a/src/utils/metrics.h +++ b/src/utils/metrics.h @@ -40,7 +40,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/json_helper.h" #include "http/http_server.h" #include "utils/alloc.h" @@ -853,22 +853,22 @@ class metric_prototype public: struct ctor_args { - const absl::string_view entity_type; + const std::string_view entity_type; const metric_type type; - const absl::string_view name; + const std::string_view name; const metric_unit unit; - const absl::string_view desc; + const std::string_view desc; }; - absl::string_view entity_type() const { return _args.entity_type; } + std::string_view entity_type() const { return _args.entity_type; } metric_type type() const { return _args.type; } - absl::string_view name() const { return _args.name; } + std::string_view name() const { return _args.name; } metric_unit unit() const { return _args.unit; } - absl::string_view description() const { return _args.desc; } + std::string_view description() const { return _args.desc; } protected: explicit metric_prototype(const ctor_args &args); diff --git a/src/utils/simple_logger.cpp b/src/utils/simple_logger.cpp index 6e56cbbca9..e437afac2d 100644 --- a/src/utils/simple_logger.cpp +++ b/src/utils/simple_logger.cpp @@ -41,7 +41,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "runtime/api_layer1.h" #include "utils/command_manager.h" #include "utils/errors.h" @@ -165,7 +165,7 @@ inline void process_fatal_log(log_level_t log_level) } bool coredump = true; - FAIL_POINT_INJECT_NOT_RETURN_F("coredump_for_fatal_log", [&coredump](absl::string_view str) { + FAIL_POINT_INJECT_NOT_RETURN_F("coredump_for_fatal_log", [&coredump](std::string_view str) { CHECK(buf2bool(str, coredump), "invalid coredump toggle for fatal log, should be true or false: {}", str); diff --git a/src/utils/string_conv.h b/src/utils/string_conv.h index a92b1e6bb3..94fc563752 100644 --- a/src/utils/string_conv.h +++ b/src/utils/string_conv.h @@ -27,14 +27,14 @@ #include #include -#include "absl/strings/string_view.h" +#include namespace dsn { namespace internal { template -bool buf2signed(absl::string_view buf, T &result) +bool buf2signed(std::string_view buf, T &result) { static_assert(std::is_signed::value, "buf2signed works only with signed integer"); @@ -65,7 +65,7 @@ bool buf2signed(absl::string_view buf, T &result) } template -bool buf2unsigned(absl::string_view buf, T &result) +bool buf2unsigned(std::string_view buf, T &result) { static_assert(std::is_unsigned::value, "buf2unsigned works only with unsigned integer"); @@ -104,32 +104,32 @@ bool buf2unsigned(absl::string_view buf, T &result) /// buf2*: `result` will keep unmodified if false is returned. -inline bool buf2int32(absl::string_view buf, int32_t &result) +inline bool buf2int32(std::string_view buf, int32_t &result) { return internal::buf2signed(buf, result); } -inline bool buf2int64(absl::string_view buf, int64_t &result) +inline bool buf2int64(std::string_view buf, int64_t &result) { return internal::buf2signed(buf, result); } -inline bool buf2uint32(absl::string_view buf, uint32_t &result) +inline bool buf2uint32(std::string_view buf, uint32_t &result) { return internal::buf2unsigned(buf, result); } -inline bool buf2uint64(absl::string_view buf, uint64_t &result) +inline bool buf2uint64(std::string_view buf, uint64_t &result) { return internal::buf2unsigned(buf, result); } -inline bool buf2uint16(absl::string_view buf, uint16_t &result) +inline bool buf2uint16(std::string_view buf, uint16_t &result) { return internal::buf2unsigned(buf, result); } -inline bool buf2bool(absl::string_view buf, bool &result, bool ignore_case = true) +inline bool buf2bool(std::string_view buf, bool &result, bool ignore_case = true) { std::string data(buf.data(), buf.length()); if (ignore_case) { @@ -146,7 +146,7 @@ inline bool buf2bool(absl::string_view buf, bool &result, bool ignore_case = tru return false; } -inline bool buf2double(absl::string_view buf, double &result) +inline bool buf2double(std::string_view buf, double &result) { if (buf.empty()) { return false; @@ -175,7 +175,7 @@ inline bool buf2double(absl::string_view buf, double &result) } #define DEF_BUF2NUMERIC_FUNC(type, postfix) \ - inline bool buf2numeric(absl::string_view buf, type &result) \ + inline bool buf2numeric(std::string_view buf, type &result) \ { \ return buf2##postfix(buf, result); \ } diff --git a/src/utils/test/fail_point_test.cpp b/src/utils/test/fail_point_test.cpp index 62b1c0c507..e04d39f54c 100644 --- a/src/utils/test/fail_point_test.cpp +++ b/src/utils/test/fail_point_test.cpp @@ -33,7 +33,7 @@ #include "gtest/gtest.h" #include "utils/fail_point.h" #include "utils/fail_point_impl.h" -#include "absl/strings/string_view.h" +#include namespace dsn { namespace fail { @@ -119,12 +119,12 @@ TEST(fail_point, parse) int test_func() { - FAIL_POINT_INJECT_F("test_1", [](absl::string_view str) -> int { + FAIL_POINT_INJECT_F("test_1", [](std::string_view str) -> int { EXPECT_EQ(str, "1"); return 1; }); - FAIL_POINT_INJECT_F("test_2", [](absl::string_view str) -> int { + FAIL_POINT_INJECT_F("test_2", [](std::string_view str) -> int { EXPECT_EQ(str, "2"); return 2; }); @@ -148,7 +148,7 @@ TEST(fail_point, macro_use) void test_func_return_void(int &a) { - FAIL_POINT_INJECT_F("test_1", [](absl::string_view str) {}); + FAIL_POINT_INJECT_F("test_1", [](std::string_view str) {}); a++; } TEST(fail_point, return_void) diff --git a/src/utils/test/fmt_logging_test.cpp b/src/utils/test/fmt_logging_test.cpp index 20017ddecd..c19126c7c5 100644 --- a/src/utils/test/fmt_logging_test.cpp +++ b/src/utils/test/fmt_logging_test.cpp @@ -27,7 +27,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "common/gpid.h" #include "common/replication.codes.h" #include "gtest/gtest.h" @@ -46,8 +46,8 @@ TEST(fmt_logging, basic) ASSERT_EQ(fmt::format("{}", error_s::make(ERR_TIMEOUT, "yes")), "ERR_TIMEOUT: yes"); ASSERT_EQ(fmt::format("{}", ERR_OK), "ERR_OK"); ASSERT_EQ(fmt::format("{}", LPC_REPLICATION_LOW), "LPC_REPLICATION_LOW"); - ASSERT_EQ(absl::string_view("yes"), "yes"); - ASSERT_EQ(fmt::format("{}", absl::string_view("yes\0yes")), "yes\0yes"); + ASSERT_EQ(std::string_view("yes"), "yes"); + ASSERT_EQ(fmt::format("{}", std::string_view("yes\0yes")), "yes\0yes"); ASSERT_DEATH(CHECK(false, "CHECK false in test"), "CHECK false in test"); } diff --git a/src/utils/test/string_conv_test.cpp b/src/utils/test/string_conv_test.cpp index c9fd5fc2d7..5e564b0d2b 100644 --- a/src/utils/test/string_conv_test.cpp +++ b/src/utils/test/string_conv_test.cpp @@ -27,7 +27,7 @@ #include "utils/string_conv.h" #include "gtest/gtest.h" -#include "absl/strings/string_view.h" +#include TEST(string_conv, buf2bool) { @@ -50,13 +50,13 @@ TEST(string_conv, buf2bool) ASSERT_FALSE(dsn::buf2bool("TrUe", result, false)); std::string str("true\0false", 10); - ASSERT_FALSE(dsn::buf2bool(absl::string_view(str.data(), 3), result)); - ASSERT_TRUE(dsn::buf2bool(absl::string_view(str.data(), 4), result)); + ASSERT_FALSE(dsn::buf2bool(std::string_view(str.data(), 3), result)); + ASSERT_TRUE(dsn::buf2bool(std::string_view(str.data(), 4), result)); ASSERT_EQ(result, true); - ASSERT_FALSE(dsn::buf2bool(absl::string_view(str.data(), 5), result)); - ASSERT_FALSE(dsn::buf2bool(absl::string_view(str.data(), 6), result)); - ASSERT_FALSE(dsn::buf2bool(absl::string_view(str.data() + 5, 4), result)); - ASSERT_TRUE(dsn::buf2bool(absl::string_view(str.data() + 5, 5), result)); + ASSERT_FALSE(dsn::buf2bool(std::string_view(str.data(), 5), result)); + ASSERT_FALSE(dsn::buf2bool(std::string_view(str.data(), 6), result)); + ASSERT_FALSE(dsn::buf2bool(std::string_view(str.data() + 5, 4), result)); + ASSERT_TRUE(dsn::buf2bool(std::string_view(str.data() + 5, 5), result)); ASSERT_EQ(result, false); } @@ -92,12 +92,12 @@ TEST(string_conv, buf2int32) // "\045" is "%", so the string length=5, otherwise(2th argument > 5) it will be reported // "global-buffer-overflow" error under AddressSanitizer check std::string str("123\0456", 5); - ASSERT_TRUE(dsn::buf2int32(absl::string_view(str.data(), 2), result)); + ASSERT_TRUE(dsn::buf2int32(std::string_view(str.data(), 2), result)); ASSERT_EQ(result, 12); - ASSERT_TRUE(dsn::buf2int32(absl::string_view(str.data(), 3), result)); + ASSERT_TRUE(dsn::buf2int32(std::string_view(str.data(), 3), result)); ASSERT_EQ(result, 123); - ASSERT_FALSE(dsn::buf2int32(absl::string_view(str.data(), 4), result)); - ASSERT_FALSE(dsn::buf2int32(absl::string_view(str.data(), 5), result)); + ASSERT_FALSE(dsn::buf2int32(std::string_view(str.data(), 4), result)); + ASSERT_FALSE(dsn::buf2int32(std::string_view(str.data(), 5), result)); } TEST(string_conv, buf2int64) @@ -139,12 +139,12 @@ TEST(string_conv, buf2int64) // "\045" is "%", so the string length=5, otherwise(2th argument > 5) it will be reported // "global-buffer-overflow" error under AddressSanitizer check std::string str("123\0456", 5); - ASSERT_TRUE(dsn::buf2int64(absl::string_view(str.data(), 2), result)); + ASSERT_TRUE(dsn::buf2int64(std::string_view(str.data(), 2), result)); ASSERT_EQ(result, 12); - ASSERT_TRUE(dsn::buf2int64(absl::string_view(str.data(), 3), result)); + ASSERT_TRUE(dsn::buf2int64(std::string_view(str.data(), 3), result)); ASSERT_EQ(result, 123); - ASSERT_FALSE(dsn::buf2int64(absl::string_view(str.data(), 4), result)); - ASSERT_FALSE(dsn::buf2int64(absl::string_view(str.data(), 5), result)); + ASSERT_FALSE(dsn::buf2int64(std::string_view(str.data(), 4), result)); + ASSERT_FALSE(dsn::buf2int64(std::string_view(str.data(), 5), result)); } TEST(string_conv, buf2uint64) @@ -183,12 +183,12 @@ TEST(string_conv, buf2uint64) // "\045" is "%", so the string length=5, otherwise(2th argument > 5) it will be reported // "global-buffer-overflow" error under AddressSanitizer check std::string str("123\0456", 5); - ASSERT_TRUE(dsn::buf2uint64(absl::string_view(str.data(), 2), result)); + ASSERT_TRUE(dsn::buf2uint64(std::string_view(str.data(), 2), result)); ASSERT_EQ(result, 12); - ASSERT_TRUE(dsn::buf2uint64(absl::string_view(str.data(), 3), result)); + ASSERT_TRUE(dsn::buf2uint64(std::string_view(str.data(), 3), result)); ASSERT_EQ(result, 123); - ASSERT_FALSE(dsn::buf2uint64(absl::string_view(str.data(), 4), result)); - ASSERT_FALSE(dsn::buf2uint64(absl::string_view(str.data(), 5), result)); + ASSERT_FALSE(dsn::buf2uint64(std::string_view(str.data(), 4), result)); + ASSERT_FALSE(dsn::buf2uint64(std::string_view(str.data(), 5), result)); } TEST(string_conv, buf2uint32) @@ -229,12 +229,12 @@ TEST(string_conv, buf2uint32) // "\045" is "%", so the string length=5, otherwise(2th argument > 5) it will be reported // "global-buffer-overflow" error under AddressSanitizer check std::string str("123\0456", 5); - ASSERT_TRUE(dsn::buf2uint32(absl::string_view(str.data(), 2), result)); + ASSERT_TRUE(dsn::buf2uint32(std::string_view(str.data(), 2), result)); ASSERT_EQ(result, 12); - ASSERT_TRUE(dsn::buf2uint32(absl::string_view(str.data(), 3), result)); + ASSERT_TRUE(dsn::buf2uint32(std::string_view(str.data(), 3), result)); ASSERT_EQ(result, 123); - ASSERT_FALSE(dsn::buf2uint32(absl::string_view(str.data(), 4), result)); - ASSERT_FALSE(dsn::buf2uint32(absl::string_view(str.data(), 5), result)); + ASSERT_FALSE(dsn::buf2uint32(std::string_view(str.data(), 4), result)); + ASSERT_FALSE(dsn::buf2uint32(std::string_view(str.data(), 5), result)); } TEST(string_conv, int64_partial) diff --git a/src/utils/time_utils.h b/src/utils/time_utils.h index 546bea0ef2..d36aa98640 100644 --- a/src/utils/time_utils.h +++ b/src/utils/time_utils.h @@ -33,7 +33,7 @@ #include #include -#include "absl/strings/string_view.h" +#include #include "runtime/api_layer1.h" #include "utils/fmt_logging.h" #include "utils/ports.h" @@ -115,7 +115,7 @@ inline int64_t get_unix_sec_today_midnight() // `hh:mm` (range in [00:00, 23:59]) to seconds since 00:00:00 // eg. `01:00` => `3600` // Return: -1 when invalid -inline int hh_mm_to_seconds(absl::string_view hhmm) +inline int hh_mm_to_seconds(std::string_view hhmm) { int hour = 0, min = 0, sec = -1; if (::sscanf(hhmm.data(), "%d:%d", &hour, &min) == 2 && (0 <= hour && hour <= 23) && @@ -128,7 +128,7 @@ inline int hh_mm_to_seconds(absl::string_view hhmm) // local time `hh:mm` to unix timestamp. // eg. `18:10` => `1525947000` when called on May 10, 2018, CST // Return: -1 when invalid -inline int64_t hh_mm_today_to_unix_sec(absl::string_view hhmm_of_day) +inline int64_t hh_mm_today_to_unix_sec(std::string_view hhmm_of_day) { int sec_of_day = hh_mm_to_seconds(hhmm_of_day); if (sec_of_day == -1) {