From 5b5d14d1e9988b5a497e24d64ce73d4ca8bf98d7 Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Mon, 8 Jan 2024 15:55:55 +0800 Subject: [PATCH] Refactor modules (#430) * Refactor third_party module Signed-off-by: jinhai * Refactor third_party module Signed-off-by: jinhai * Refactor stl: std::move and std::forward Signed-off-by: jinhai * Refactor min/max Signed-off-by: jinhai * Refactor fill/copy/str related Signed-off-by: jinhai * More std migrated Signed-off-by: jinhai * std::numeric_limits Signed-off-by: jinhai * std::numeric_limits part2 Signed-off-by: jinhai * Refactor from_chars and memory order Signed-off-by: jinhai * Refactor boost wrapper Signed-off-by: jinhai * Remove unused declaration Signed-off-by: jinhai * Update benchmark check Signed-off-by: jinhai --------- Signed-off-by: jinhai --- .../fulltext/fulltext_query_benchmark.cpp | 2 +- .../local_infinity/infinity_benchmark.cpp | 40 ++-- .../knn/knn_query_benchmark.cpp | 8 +- .../remote_query_benchmark.cpp | 8 +- src/bin/infinity_main.cpp | 67 +++--- src/common/analyzer/analyzer_pool.cpp | 8 +- src/common/analyzer/chinese_analyzer.cpp | 10 +- src/common/blocking_queue.cppm | 30 +-- src/common/boost.cppm | 26 +-- src/common/default_values.cppm | 14 +- src/common/memory/memory_chunk.cppm | 2 +- src/common/specific_concurrent_queue.cpp | 6 +- src/common/specific_concurrent_queue.cppm | 2 +- src/common/status.cpp | 4 +- src/common/status.cppm | 2 +- src/common/status_check.h | 26 --- src/common/stl.cppm | 195 +++------------- src/common/third_party.cppm | 128 ++++------ src/common/utility/defer_op.cppm | 2 +- src/common/utility/exception.cpp | 10 +- src/common/utility/exception.cppm | 6 +- src/common/utility/serialize.cppm | 4 +- src/common/utility/spinlock.cppm | 26 +-- src/common/utility/utility.cpp | 2 +- src/executor/explain_fragment.cpp | 4 +- src/executor/explain_physical_plan.cpp | 120 +++++----- .../expression/expression_selector.cpp | 2 +- src/executor/fragment/plan_fragment.cppm | 4 +- src/executor/fragment_builder.cpp | 36 +-- src/executor/hash_table.cpp | 8 +- src/executor/operator/physcial_drop_view.cppm | 4 +- src/executor/operator/physical_aggregate.cpp | 14 +- src/executor/operator/physical_aggregate.cppm | 4 +- src/executor/operator/physical_alter.cppm | 2 +- src/executor/operator/physical_command.cpp | 20 +- src/executor/operator/physical_command.cppm | 4 +- .../operator/physical_create_collection.cpp | 6 +- .../operator/physical_create_index.cpp | 2 +- .../operator/physical_create_index_do.cpp | 4 +- .../operator/physical_create_index_finish.cpp | 2 +- .../physical_create_index_prepare.cpp | 2 +- .../operator/physical_create_schema.cpp | 2 +- .../operator/physical_create_schema.cppm | 4 +- .../operator/physical_create_table.cpp | 12 +- .../operator/physical_create_view.cppm | 4 +- .../operator/physical_cross_product.cppm | 2 +- src/executor/operator/physical_delete.cpp | 2 +- src/executor/operator/physical_delete.cppm | 2 +- .../operator/physical_drop_collection.cppm | 4 +- src/executor/operator/physical_drop_index.cpp | 2 +- .../operator/physical_drop_index.cppm | 6 +- .../operator/physical_drop_schema.cpp | 2 +- .../operator/physical_drop_schema.cppm | 4 +- src/executor/operator/physical_drop_table.cpp | 2 +- .../operator/physical_drop_table.cppm | 6 +- src/executor/operator/physical_except.cppm | 4 +- src/executor/operator/physical_explain.cpp | 2 +- src/executor/operator/physical_explain.cppm | 6 +- src/executor/operator/physical_export.cppm | 4 +- src/executor/operator/physical_filter.cpp | 4 +- src/executor/operator/physical_filter.cppm | 2 +- src/executor/operator/physical_fusion.cpp | 22 +- src/executor/operator/physical_hash.cppm | 4 +- src/executor/operator/physical_import.cpp | 40 ++-- src/executor/operator/physical_import.cppm | 4 +- src/executor/operator/physical_insert.cpp | 8 +- src/executor/operator/physical_insert.cppm | 2 +- src/executor/operator/physical_intersect.cppm | 4 +- src/executor/operator/physical_knn_scan.cpp | 22 +- src/executor/operator/physical_knn_scan.cppm | 6 +- src/executor/operator/physical_limit.cpp | 6 +- src/executor/operator/physical_limit.cppm | 36 +-- src/executor/operator/physical_match.cpp | 8 +- .../operator/physical_merge_aggregate.cpp | 4 +- .../operator/physical_merge_aggregate.cppm | 4 +- .../operator/physical_merge_hash.cppm | 4 +- src/executor/operator/physical_merge_knn.cpp | 8 +- src/executor/operator/physical_merge_knn.cppm | 4 +- .../operator/physical_merge_limit.cpp | 4 +- .../physical_merge_parallel_aggregate.cppm | 4 +- .../operator/physical_merge_sort.cppm | 4 +- src/executor/operator/physical_merge_top.cppm | 4 +- .../operator/physical_nested_loop_join.cppm | 4 +- src/executor/operator/physical_optimize.cpp | 8 +- src/executor/operator/physical_optimize.cppm | 4 +- .../operator/physical_parallel_aggregate.cppm | 4 +- src/executor/operator/physical_project.cppm | 2 +- src/executor/operator/physical_show.cpp | 52 ++--- src/executor/operator/physical_show.cppm | 4 +- src/executor/operator/physical_sink.cpp | 54 ++--- src/executor/operator/physical_sink.cppm | 2 +- src/executor/operator/physical_sort.cpp | 8 +- src/executor/operator/physical_sort.cppm | 4 +- src/executor/operator/physical_source.cppm | 2 +- src/executor/operator/physical_table_scan.cpp | 2 +- .../operator/physical_table_scan.cppm | 2 +- src/executor/operator/physical_update.cpp | 2 +- src/executor/operator/physical_update.cppm | 2 +- src/executor/operator_state.cpp | 12 +- src/executor/operator_state.cppm | 2 +- src/executor/physical_operator.cppm | 2 +- src/executor/physical_planner.cpp | 40 ++-- src/expression/aggregate_expression.cpp | 2 +- src/expression/base_expression.cppm | 6 +- src/expression/case_expression.cppm | 2 +- src/expression/cast_expression.cpp | 4 +- src/expression/cast_expression.cppm | 2 +- src/expression/column_expression.cpp | 6 +- src/expression/column_expression.cppm | 2 +- .../correlated_column_expression.cpp | 2 +- src/expression/expression_transformer.cpp | 2 +- src/expression/function_expression.cpp | 2 +- src/expression/fusion_expression.cpp | 2 +- src/expression/in_expression.cpp | 2 +- src/expression/knn_expression.cpp | 6 +- src/expression/match_expression.cpp | 2 +- src/expression/reference_expression.cpp | 2 +- src/expression/reference_expression.cppm | 6 +- src/expression/subquery_expression.cpp | 2 +- src/expression/value_expression.cppm | 2 +- src/function/aggregate/avg.cpp | 26 +-- src/function/aggregate/max.cpp | 16 +- src/function/aggregate/min.cpp | 16 +- src/function/aggregate_function.cppm | 4 +- src/function/aggregate_function_set.cpp | 2 +- src/function/aggregate_function_set.cppm | 2 +- src/function/cast/bitmap_cast.cppm | 2 +- src/function/cast/blob_cast.cppm | 12 +- src/function/cast/bool_cast.cppm | 14 +- src/function/cast/cast_function.cpp | 62 ++--- src/function/cast/column_vector_cast.cppm | 4 +- src/function/cast/date_cast.cppm | 6 +- src/function/cast/datetime_cast.cppm | 6 +- src/function/cast/decimal_cast.cppm | 6 +- src/function/cast/embedding_cast.cppm | 34 ++- src/function/cast/float_cast.cppm | 20 +- src/function/cast/geography_cast.cppm | 4 +- src/function/cast/integer_cast.cppm | 38 +-- src/function/cast/interval_cast.cppm | 4 +- src/function/cast/time_cast.cppm | 4 +- src/function/cast/timestamp_cast.cppm | 6 +- src/function/cast/uuid_cast.cppm | 8 +- src/function/cast/varchar_cast.cppm | 24 +- src/function/function.cppm | 2 +- src/function/function_set.cppm | 2 +- src/function/scalar/equals.cpp | 6 +- src/function/scalar/greater.cpp | 8 +- src/function/scalar/greater_equals.cpp | 8 +- src/function/scalar/inequals.cpp | 6 +- src/function/scalar/less.cpp | 8 +- src/function/scalar/less_equals.cpp | 8 +- src/function/scalar/substring.cpp | 10 +- src/function/scalar_function.cpp | 6 +- src/function/scalar_function_set.cpp | 2 +- src/function/scalar_function_set.cppm | 2 +- src/function/special_function.cppm | 2 +- src/function/table/knn_scan.cpp | 6 +- src/function/table/knn_scan.cppm | 2 +- src/function/table/knn_scan_data.cpp | 4 +- src/function/table/knn_scan_data.cppm | 4 +- src/function/table/merge_knn_data.cpp | 4 +- src/function/table/table_scan.cpp | 2 +- src/function/table/table_scan.cppm | 2 +- src/function/table_function.cpp | 2 +- src/function/table_function_set.cppm | 2 +- src/main/config.cpp | 105 +++++---- src/main/database.cpp | 6 +- src/main/database.cppm | 2 +- src/main/infinity.cpp | 4 +- src/main/logger.cpp | 18 +- src/main/logger.cppm | 10 +- src/main/profiler.cpp | 46 ++-- src/main/profiler.cppm | 18 +- src/main/query_context.cpp | 2 +- src/main/query_context.cppm | 2 +- src/main/query_result.cppm | 4 +- src/main/session_manager.cppm | 12 +- src/main/table.cppm | 2 +- src/network/buffer_reader.cpp | 4 +- src/network/buffer_reader.cppm | 4 +- src/network/buffer_writer.cpp | 4 +- src/network/buffer_writer.cppm | 4 +- src/network/connection.cpp | 8 +- src/network/connection.cppm | 6 +- src/network/db_server.cpp | 14 +- src/network/db_server.cppm | 4 +- src/network/pg_protocol_handler.cpp | 2 +- src/network/pg_protocol_handler.cppm | 2 +- src/network/thrift_server.cpp | 62 ++--- src/parser/query_parser.h | 10 +- src/parser/type/complex/blob_type.cpp | 6 +- src/parser/type/complex/blob_type.h | 2 +- src/parser/type/complex/varchar.cpp | 4 +- src/planner/bind_context.cpp | 26 +-- src/planner/bind_context.cppm | 2 +- src/planner/binder/bind_alias_proxy.cpp | 2 +- src/planner/binder/group_binder.cpp | 4 +- src/planner/binder/having_binder.cpp | 8 +- src/planner/binder/order_binder.cpp | 8 +- src/planner/binder/project_binder.cpp | 4 +- src/planner/binder/where_binder.cpp | 2 +- src/planner/binding.cpp | 10 +- src/planner/bound/base_table_ref.cppm | 4 +- src/planner/bound/join_table_ref.cppm | 2 +- src/planner/bound/subquery_table_ref.cppm | 2 +- src/planner/bound/table_ref.cppm | 2 +- src/planner/bound_delete_statement.cppm | 4 +- src/planner/bound_select_statement.cpp | 6 +- src/planner/bound_select_statement.cppm | 4 +- src/planner/bound_update_statement.cppm | 4 +- src/planner/column_identifier.cpp | 6 +- src/planner/explain_logical_plan.cpp | 220 +++++++++--------- src/planner/expression_binder.cpp | 14 +- src/planner/logical_node_visitor.cpp | 4 +- src/planner/logical_planner.cpp | 12 +- src/planner/logical_planner.cppm | 4 +- src/planner/node/logical_aggregate.cppm | 4 +- src/planner/node/logical_command.cppm | 2 +- .../node/logical_create_collection.cppm | 4 +- src/planner/node/logical_create_schema.cppm | 2 +- src/planner/node/logical_create_table.cppm | 2 +- src/planner/node/logical_create_view.cppm | 4 +- src/planner/node/logical_cross_product.cpp | 2 +- src/planner/node/logical_drop_collection.cppm | 2 +- src/planner/node/logical_drop_index.cppm | 4 +- src/planner/node/logical_drop_schema.cppm | 2 +- src/planner/node/logical_drop_table.cppm | 2 +- src/planner/node/logical_drop_view.cppm | 2 +- src/planner/node/logical_dummy_scan.cppm | 2 +- src/planner/node/logical_export.cppm | 4 +- src/planner/node/logical_filter.cppm | 2 +- src/planner/node/logical_import.cppm | 2 +- src/planner/node/logical_insert.cppm | 2 +- src/planner/node/logical_join.cpp | 2 +- src/planner/node/logical_knn_scan.cpp | 2 +- src/planner/node/logical_limit.cppm | 4 +- src/planner/node/logical_match.cpp | 6 +- src/planner/node/logical_optimize.cppm | 2 +- src/planner/node/logical_project.cppm | 4 +- src/planner/node/logical_show.cppm | 2 +- src/planner/node/logical_sort.cppm | 2 +- src/planner/node/logical_table_scan.cpp | 2 +- src/planner/node/logical_view_scan.cppm | 2 +- src/planner/optimizer.cpp | 2 +- src/planner/optimizer/column_pruner.cpp | 8 +- src/planner/optimizer/column_remapper.cpp | 4 +- src/planner/optimizer/lazy_load.cpp | 6 +- src/planner/query_binder.cpp | 30 +-- src/planner/query_binder.cppm | 2 +- .../subquery/dependent_join_flattener.cpp | 12 +- src/planner/subquery/subquery_unnest.cpp | 14 +- src/scheduler/fragment_context.cpp | 124 +++++----- src/scheduler/fragment_context.cppm | 10 +- src/scheduler/fragment_data.cppm | 8 +- src/scheduler/fragment_task.cpp | 6 +- src/scheduler/task_scheduler.cpp | 14 +- src/scheduler/task_scheduler.cppm | 2 +- src/storage/background_process.cpp | 2 +- src/storage/base_table.cppm | 2 +- src/storage/bg_task.cppm | 8 +- src/storage/buffer/buffer_manager.cpp | 14 +- src/storage/buffer/buffer_manager.cppm | 2 +- src/storage/buffer/buffer_obj.cpp | 10 +- src/storage/buffer/buffer_obj.cppm | 2 +- src/storage/buffer/column_buffer.cpp | 4 +- src/storage/buffer/column_buffer.cppm | 2 +- .../buffer/file_worker/data_file_worker.cpp | 24 +- .../buffer/file_worker/file_worker.cpp | 16 +- .../buffer/file_worker/file_worker.cppm | 14 +- .../buffer/file_worker/hnsw_file_worker.cpp | 2 +- .../buffer/file_worker/index_file_worker.cppm | 4 +- src/storage/column_vector/bitmask.cpp | 8 +- src/storage/column_vector/bitmask_buffer.cpp | 2 +- src/storage/column_vector/bitmask_buffer.cppm | 2 +- src/storage/column_vector/column_vector.cpp | 92 ++++---- src/storage/column_vector/column_vector.cppm | 52 ++--- src/storage/column_vector/fix_heap.cpp | 16 +- src/storage/column_vector/fix_heap.cppm | 2 +- src/storage/column_vector/heap_chunk.cpp | 2 +- src/storage/column_vector/heap_chunk.cppm | 2 +- src/storage/column_vector/null_value.cppm | 69 +++--- .../operator/binary_operator.cppm | 21 +- .../operator/embedding_unary_operator.cppm | 4 + .../operator/unary_operator.cppm | 2 +- src/storage/column_vector/selection.cppm | 2 +- src/storage/column_vector/value.cpp | 78 +++---- src/storage/column_vector/value.cppm | 4 +- src/storage/column_vector/var_heap.cpp | 14 +- src/storage/column_vector/var_heap.cppm | 2 +- src/storage/column_vector/vector_buffer.cpp | 10 +- src/storage/data_block.cpp | 14 +- src/storage/data_table.cpp | 8 +- src/storage/data_table.cppm | 4 +- src/storage/definition/index_base.cpp | 12 +- src/storage/definition/index_base.cppm | 6 +- src/storage/definition/index_def.cpp | 8 +- src/storage/definition/index_def.cppm | 6 +- src/storage/definition/index_full_text.cpp | 8 +- src/storage/definition/index_full_text.cppm | 6 +- src/storage/definition/index_hnsw.cpp | 6 +- src/storage/definition/index_hnsw.cppm | 4 +- src/storage/definition/index_ivfflat.cpp | 8 +- src/storage/definition/index_ivfflat.cppm | 6 +- src/storage/definition/table_def.cppm | 4 +- src/storage/invertedindex/codec.cpp | 8 +- src/storage/invertedindex/common/bitmap.cpp | 14 +- .../invertedindex/common/dynamic_bitmap.cpp | 8 +- .../format/buffered_byte_slice_reader.cppm | 2 +- .../invertedindex/format/short_buffer.cpp | 2 +- src/storage/invertedindex/index_defines.cppm | 2 +- src/storage/invertedindex/indexer.cpp | 2 +- .../invertedindex/iresearch/analyzer.cpp | 8 +- .../invertedindex/iresearch/datastore.cpp | 72 +++--- .../invertedindex/iresearch/datastore.cppm | 6 +- .../invertedindex/iresearch/document.cppm | 2 +- .../invertedindex/multi_posting_decoder.cpp | 2 +- .../invertedindex/posting_iterator.cpp | 2 +- src/storage/io/byte_slice_reader.cpp | 6 +- src/storage/io/byte_slice_writer.cpp | 2 +- src/storage/io/file_reader.cpp | 12 +- src/storage/io/file_system.cppm | 2 +- src/storage/io/file_writer.cpp | 4 +- src/storage/io/local_file_system.cpp | 30 +-- src/storage/io/local_file_system.cppm | 2 +- src/storage/io/write_buffer.cpp | 10 +- src/storage/io/write_buffer.cppm | 6 +- .../knnindex/ann_ivf/ann_ivf_flat.cppm | 4 +- .../knnindex/ann_ivf/search_top_1_sgemm.cppm | 2 +- .../knnindex/ann_ivf/search_top_k.cppm | 4 +- .../knnindex/knn_flat/knn_flat_l2_blas.cppm | 2 +- .../knn_flat/knn_flat_l2_blas_reservoir.cppm | 2 +- .../knn_flat/knn_flat_l2_top1_blas.cppm | 2 +- .../knnindex/knn_hnsw/graph_store.cppm | 4 +- src/storage/knnindex/knn_hnsw/hnsw_alg.cppm | 58 ++--- src/storage/knnindex/knn_hnsw/lvq_store.cppm | 36 +-- .../knnindex/knn_hnsw/memory_pool.cppm | 6 +- .../knnindex/knn_hnsw/plain_store.cppm | 12 +- src/storage/knnindex/result_handler.cppm | 14 +- src/storage/meta/base_meta.cpp | 10 +- src/storage/meta/catalog.cpp | 84 +++---- src/storage/meta/catalog.cppm | 16 +- src/storage/meta/db_meta.cpp | 80 +++---- src/storage/meta/db_meta.cppm | 8 +- src/storage/meta/entry/base_entry.cpp | 4 +- src/storage/meta/entry/block_column_entry.cpp | 37 +-- .../meta/entry/block_column_entry.cppm | 6 +- src/storage/meta/entry/block_entry.cpp | 58 ++--- src/storage/meta/entry/block_entry.cppm | 6 +- src/storage/meta/entry/column_index_entry.cpp | 20 +- .../meta/entry/column_index_entry.cppm | 6 +- src/storage/meta/entry/db_entry.cpp | 40 ++-- src/storage/meta/entry/db_entry.cppm | 10 +- src/storage/meta/entry/irs_index_entry.cpp | 8 +- src/storage/meta/entry/irs_index_entry.cppm | 6 +- .../meta/entry/segment_column_index_entry.cpp | 20 +- .../entry/segment_column_index_entry.cppm | 6 +- src/storage/meta/entry/segment_entry.cpp | 54 ++--- src/storage/meta/entry/segment_entry.cppm | 8 +- src/storage/meta/entry/table_entry.cpp | 78 +++---- src/storage/meta/entry/table_entry.cppm | 6 +- src/storage/meta/entry/table_index_entry.cpp | 20 +- src/storage/meta/entry/table_index_entry.cppm | 6 +- src/storage/meta/entry/view_entry.cppm | 6 +- src/storage/meta/table_index_meta.cpp | 74 +++--- src/storage/meta/table_index_meta.cppm | 8 +- src/storage/meta/table_meta.cpp | 88 +++---- src/storage/meta/table_meta.cppm | 8 +- src/storage/meta/view_meta.cppm | 4 +- src/storage/storage.cpp | 10 +- src/storage/txn/txn.cpp | 22 +- src/storage/txn/txn.cppm | 4 +- src/storage/txn/txn_context.cppm | 18 +- src/storage/txn/txn_manager.cpp | 14 +- src/storage/txn/txn_manager.cppm | 4 +- src/storage/txn/txn_store.cpp | 12 +- src/storage/view.cppm | 2 +- src/storage/wal/wal_entry.cpp | 8 +- src/storage/wal/wal_entry.cppm | 16 +- src/storage/wal/wal_manager.cpp | 54 ++--- src/storage/wal/wal_manager.cppm | 4 +- .../function/aggregate/first_functions.cpp | 2 +- .../function/cast/float/double_cast.cpp | 20 +- .../function/cast/float/float_cast.cpp | 18 +- .../cast/integer_cast/bigint_cast.cpp | 18 +- .../cast/integer_cast/integer_cast.cpp | 18 +- .../cast/integer_cast/small_integer_cast.cpp | 18 +- .../cast/integer_cast/tiny_integer_cast.cpp | 18 +- .../function/scalar/equals_functions.cpp | 16 +- .../scalar/greater_equals_functions.cpp | 24 +- .../function/scalar/greater_functions.cpp | 24 +- .../function/scalar/inequals_functions.cpp | 16 +- .../function/scalar/less_equals_functions.cpp | 24 +- .../function/scalar/less_functions.cpp | 24 +- .../function/scalar/substr_function.cpp | 4 +- .../parser/type/complex/bitmap_type.cpp | 8 +- .../parser/type/complex/blob_type.cpp | 12 +- .../parser/type/complex/uuid_type.cpp | 8 +- .../parser/type/complex/varchar_type.cpp | 22 +- src/unit_test/parser/type/geo/path_type.cpp | 4 +- .../parser/type/geo/polygon_type.cpp | 4 +- .../parser/type/heterogeneous/mixed_type.cpp | 40 ++-- .../column_vector/column_vector_mixed.cpp | 20 +- .../column_vector/column_vector_varchar.cpp | 48 ++-- .../storage/invertedindex/irsdatastore.cpp | 20 +- src/unit_test/storage/meta/catalog.cpp | 11 +- .../meta/entry/table_collection_entry.cpp | 2 +- src/unit_test/storage/wal/wal_entry.cpp | 12 +- src/unit_test/storage/wal/wal_replay.cpp | 22 +- src/unit_test/test_helper/sql_runner.cpp | 2 +- src/unit_test/test_hnsw_bitmask.cpp | 2 +- src/unit_test/third_party/json.cpp | 2 +- tools/ci_tools/check_benchmark_result.py | 4 +- 412 files changed, 2537 insertions(+), 2706 deletions(-) delete mode 100644 src/common/status_check.h diff --git a/benchmark/local_infinity/fulltext/fulltext_query_benchmark.cpp b/benchmark/local_infinity/fulltext/fulltext_query_benchmark.cpp index 32fd56e983..87b43d7241 100644 --- a/benchmark/local_infinity/fulltext/fulltext_query_benchmark.cpp +++ b/benchmark/local_infinity/fulltext/fulltext_query_benchmark.cpp @@ -43,7 +43,7 @@ bool ReadJsonl(const std::string &query_str, size_t &start_pos, size_t query_siz std::string_view json_sv(query_str.data() + start_pos, end_pos - start_pos); start_pos = end_pos + 1; - Json json = Json::parse(json_sv); + nlohmann::json json = nlohmann::json::parse(json_sv); result = {json["_id"], json["text"]}; return true; } diff --git a/benchmark/local_infinity/infinity_benchmark.cpp b/benchmark/local_infinity/infinity_benchmark.cpp index 0d7237d64c..f099fa715f 100644 --- a/benchmark/local_infinity/infinity_benchmark.cpp +++ b/benchmark/local_infinity/infinity_benchmark.cpp @@ -91,28 +91,28 @@ int main() { auto tims_costing_second = Measurement("Get Database", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { __attribute__((unused)) auto ignored = infinity->GetDatabase("default"); }); - results.push_back(Format("-> Get Database QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Get Database QPS: {}", total_times / tims_costing_second)); } { auto tims_costing_second = Measurement("List Databases", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { __attribute__((unused)) auto ignored = infinity->ListDatabases(); }); - results.push_back(Format("-> List Databases QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> List Databases QPS: {}", total_times / tims_costing_second)); } { CreateDatabaseOptions create_db_opts; auto tims_costing_second = Measurement("Create Database", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { - __attribute__((unused)) auto ignored = infinity->CreateDatabase(ToStr(i), create_db_opts); + __attribute__((unused)) auto ignored = infinity->CreateDatabase(std::to_string(i), create_db_opts); }); - results.push_back(Format("-> Create Database QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Create Database QPS: {}", total_times / tims_costing_second)); } { DropDatabaseOptions drop_db_opts; auto tims_costing_second = Measurement("Drop Database", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { - __attribute__((unused)) auto ignored = infinity->DropDatabase(ToStr(i), drop_db_opts); + __attribute__((unused)) auto ignored = infinity->DropDatabase(std::to_string(i), drop_db_opts); }); - results.push_back(Format("-> Drop Database QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Drop Database QPS: {}", total_times / tims_costing_second)); } // Table { @@ -144,19 +144,19 @@ int main() { // thread_id) { // __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->ListTables(); // }); - // results.push_back(Format("-> List Tables QPS: {}", total_times / tims_costing_second)); + // results.push_back(fmt::format("-> List Tables QPS: {}", total_times / tims_costing_second)); // } { auto tims_costing_second = Measurement("Get Tables", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->GetTable("benchmark_test"); }); - results.push_back(Format("-> Get Tables QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Get Tables QPS: {}", total_times / tims_costing_second)); } { auto tims_costing_second = Measurement("Describe Tables", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->DescribeTable("benchmark_test"); }); - results.push_back(Format("-> Describe Tables QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Describe Tables QPS: {}", total_times / tims_costing_second)); } { auto tims_costing_second = Measurement("Create Tables", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { @@ -175,15 +175,15 @@ int main() { column_definitions.emplace_back(col_def_2); __attribute__((unused)) auto ignored = - infinity->GetDatabase("default")->CreateTable(ToStr(i), column_definitions, Vector(), create_table_opts); + infinity->GetDatabase("default")->CreateTable(std::to_string(i), column_definitions, Vector(), create_table_opts); }); - results.push_back(Format("-> Create Table QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Create Table QPS: {}", total_times / tims_costing_second)); } { auto tims_costing_second = Measurement("Drop Table", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { - __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->DropTable(ToStr(i), drop_table_options); + __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->DropTable(std::to_string(i), drop_table_options); }); - results.push_back(Format("-> Drop Table QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Drop Table QPS: {}", total_times / tims_costing_second)); } { { @@ -201,7 +201,7 @@ int main() { __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->GetTable("benchmark_test")->Search(nullptr, nullptr, output_columns); }); - results.push_back(Format("-> Select QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Select QPS: {}", total_times / tims_costing_second)); } { auto tims_costing_second = @@ -223,7 +223,7 @@ int main() { __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->GetTable("benchmark_test")->Insert(columns, values); }); - results.push_back(Format("-> Insert QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Insert QPS: {}", total_times / tims_costing_second)); } { auto tims_costing_second = @@ -252,14 +252,14 @@ int main() { __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->GetTable("benchmark_test")->Update(nullptr, values); }); - results.push_back(Format("-> Update QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Update QPS: {}", total_times / tims_costing_second)); } { auto tims_costing_second = Measurement("Delete", thread_num, total_times, [&](SizeT i, SharedPtr infinity, std::thread::id thread_id) { __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->GetTable("benchmark_test")->Delete(nullptr); }); - results.push_back(Format("-> Delete QPS: {}", total_times / tims_costing_second)); + results.push_back(fmt::format("-> Delete QPS: {}", total_times / tims_costing_second)); } } } @@ -311,7 +311,7 @@ int main() { __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->GetTable("benchmark_sort")->Insert(columns, values); }); - results.push_back(Format("-> Insert for Sort Time: {}s", tims_costing_second)); + results.push_back(fmt::format("-> Insert for Sort Time: {}s", tims_costing_second)); } { auto tims_costing_second = @@ -327,7 +327,7 @@ int main() { __attribute__((unused)) auto ignored = infinity->Query("select c1, c2 from benchmark_sort order by c1"); }); - results.push_back(Format("-> Select Sort Time QPS: {}", sort_times / tims_costing_second)); + results.push_back(fmt::format("-> Select Sort Time QPS: {}", sort_times / tims_costing_second)); } } @@ -396,7 +396,7 @@ int main() { // __attribute__((unused)) auto ignored = infinity->GetDatabase("default")->GetTable("benchmark_test")->Search(nullptr, nullptr, // nullptr); // }); - // results.push_back(Format("-> SEARCH QPS: {}", total_times / tims_costing_second)); + // results.push_back(fmt::format("-> SEARCH QPS: {}", total_times / tims_costing_second)); // std::cout << "OK" << std::endl; // } diff --git a/benchmark/local_infinity/knn/knn_query_benchmark.cpp b/benchmark/local_infinity/knn/knn_query_benchmark.cpp index 95229007d2..9117ee5a6c 100644 --- a/benchmark/local_infinity/knn/knn_query_benchmark.cpp +++ b/benchmark/local_infinity/knn/knn_query_benchmark.cpp @@ -236,7 +236,7 @@ int main(int argc, char *argv[]) { if (times >= 2) { auto elapsed_ns = profiler.Elapsed(); auto elapsed_s = elapsed_ns / (1'000'000'000.0); - results.push_back(Format("Total cost : {} s", elapsed_s)); + results.push_back(fmt::format("Total cost : {} s", elapsed_s)); } { size_t correct_1 = 0, correct_10 = 0, correct_100 = 0; @@ -257,9 +257,9 @@ int main(int argc, char *argv[]) { } } } - results.push_back(Format("R@1: {:.3f}", float(correct_1) / float(query_count * 1))); - results.push_back(Format("R@10: {:.3f}", float(correct_10) / float(query_count * 10))); - results.push_back(Format("R@100: {:.3f}", float(correct_100) / float(query_count * 100))); + results.push_back(fmt::format("R@1: {:.3f}", float(correct_1) / float(query_count * 1))); + results.push_back(fmt::format("R@10: {:.3f}", float(correct_10) / float(query_count * 10))); + results.push_back(fmt::format("R@100: {:.3f}", float(correct_100) / float(query_count * 100))); } } diff --git a/benchmark/remote_infinity/remote_query_benchmark.cpp b/benchmark/remote_infinity/remote_query_benchmark.cpp index 9d83964586..8899ac2635 100644 --- a/benchmark/remote_infinity/remote_query_benchmark.cpp +++ b/benchmark/remote_infinity/remote_query_benchmark.cpp @@ -244,7 +244,7 @@ int main() { ParallelFor(0, query_count, thread_num, query_function); profiler.End(); - results.push_back(infinity::Format("Total cost: {}", profiler.ElapsedToString(1000))); + results.push_back(fmt::format("Total cost: {}", profiler.ElapsedToString(1000))); { size_t correct_1 = 0, correct_10 = 0, correct_100 = 0; for (size_t query_idx = 0; query_idx < query_count; ++query_idx) { @@ -265,9 +265,9 @@ int main() { } } } - results.push_back(infinity::Format("R@1: {:.3f}", float(correct_1) / float(query_count * 1))); - results.push_back(infinity::Format("R@10: {:.3f}", float(correct_10) / float(query_count * 10))); - results.push_back(infinity::Format("R@100: {:.3f}", float(correct_100) / float(query_count * 100))); + results.push_back(fmt::format("R@1: {:.3f}", float(correct_1) / float(query_count * 1))); + results.push_back(fmt::format("R@10: {:.3f}", float(correct_10) / float(query_count * 10))); + results.push_back(fmt::format("R@100: {:.3f}", float(correct_100) / float(query_count * 100))); } } while (--total_times); diff --git a/src/bin/infinity_main.cpp b/src/bin/infinity_main.cpp index dacdffbe7d..a6ee59c979 100644 --- a/src/bin/infinity_main.cpp +++ b/src/bin/infinity_main.cpp @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "network/thrift_server.h" #include #include -#include "network/thrift_server.h" import compilation_config; import stl; @@ -27,15 +27,15 @@ namespace { infinity::DBServer db_server; -//infinity::Thread threaded_thrift_thread; -//infinity::ThreadedThriftServer threaded_thrift_server; +// infinity::Thread threaded_thrift_thread; +// infinity::ThreadedThriftServer threaded_thrift_server; infinity::Thread pool_thrift_thread; infinity::PoolThriftServer pool_thrift_server; -//infinity::NonBlockPoolThriftServer non_block_pool_thrift_server; +// infinity::NonBlockPoolThriftServer non_block_pool_thrift_server; -infinity::Mutex server_mutex; -infinity::CondVar server_cv; +std::mutex server_mutex; +std::condition_variable server_cv; bool server_running = false; @@ -43,9 +43,9 @@ infinity::Thread shut_down_thread; void ShutdownServer() { - infinity::UniqueLock lock(server_mutex); + std::unique_lock lock(server_mutex); server_running = true; - server_cv.wait(lock, [&]{ return !server_running; }); + server_cv.wait(lock, [&] { return !server_running; }); // threaded_thrift_server.Shutdown(); // threaded_thrift_thread.join(); @@ -56,7 +56,6 @@ void ShutdownServer() { // non_block_pool_thrift_server.Shutdown(); db_server.Shutdown(); - } void SignalHandler(int signal_number, siginfo_t *, void *) { @@ -65,7 +64,7 @@ void SignalHandler(int signal_number, siginfo_t *, void *) { case SIGQUIT: case SIGTERM: { - infinity::UniqueLock lock(server_mutex); + std::unique_lock lock(server_mutex); server_running = false; server_cv.notify_one(); @@ -82,7 +81,7 @@ void SignalHandler(int signal_number, siginfo_t *, void *) { printf("Other type of signal: %d\n", signal_number); } } -// exit(0); + // exit(0); } void RegisterSignal() { @@ -101,18 +100,18 @@ void RegisterSignal() { namespace infinity { void ParseArguments(int argc, char **argv, StartupParameter ¶meters) { - CxxOptions options("./infinity_main", ""); + cxxopts::Options options("./infinity_main", ""); options.add_options()("h,help", "Display this help and exit") // NOLINT ("f,config", "Specify the config file path. No default config file", - cxx_value()->default_value("")) // NOLINT + MakeShared>()->default_value("")) // NOLINT ; - ParseResult result = options.parse(argc, argv); + cxxopts::ParseResult result = options.parse(argc, argv); if (result.count("help")) { - Printf("{}", options.help()); + fmt::print("{}", options.help()); return; } @@ -127,21 +126,21 @@ void ParseArguments(int argc, char **argv, StartupParameter ¶meters) { auto main(int argc, char **argv) -> int { using namespace infinity; - Printf(" __ .__ __. _______ __ .__ __. __ .___________.____ ____ \n" - "| | | \\ | | | ____|| | | \\ | | | | | |\\ \\ / / \n" - "| | | \\| | | |__ | | | \\| | | | `---| |----` \\ \\/ / \n" - "| | | . ` | | __| | | | . ` | | | | | \\_ _/ \n" - "| | | |\\ | | | | | | |\\ | | | | | | | \n" - "|__| |__| \\__| |__| |__| |__| \\__| |__| |__| |__| \n"); - - Printf("Infinity, version: {}.{}.{} build on {} with {} mode from branch: {}, commit-id: {}\n", - version_major(), - version_minor(), - version_patch(), - current_system_time(), - build_type(), - git_branch_name(), - git_commit_id()); + fmt::print(" __ .__ __. _______ __ .__ __. __ .___________.____ ____ \n" + "| | | \\ | | | ____|| | | \\ | | | | | |\\ \\ / / \n" + "| | | \\| | | |__ | | | \\| | | | `---| |----` \\ \\/ / \n" + "| | | . ` | | __| | | | . ` | | | | | \\_ _/ \n" + "| | | |\\ | | | | | | |\\ | | | | | | | \n" + "|__| |__| \\__| |__| |__| |__| \\__| |__| |__| |__| \n"); + + fmt::print("Infinity, version: {}.{}.{} build on {} with {} mode from branch: {}, commit-id: {}\n", + version_major(), + version_minor(), + version_patch(), + current_system_time(), + build_type(), + git_branch_name(), + git_commit_id()); StartupParameter parameters; ParseArguments(argc, argv, parameters); @@ -152,15 +151,15 @@ auto main(int argc, char **argv) -> int { InfinityContext::instance().config()->PrintAll(); -// threaded_thrift_server.Init(9090); -// threaded_thrift_thread = infinity::Thread([&]() { threaded_thrift_server.Start(); }); + // threaded_thrift_server.Init(9090); + // threaded_thrift_thread = infinity::Thread([&]() { threaded_thrift_server.Start(); }); u32 thrift_server_port = InfinityContext::instance().config()->sdk_port(); pool_thrift_server.Init(thrift_server_port, 128); pool_thrift_thread = infinity::Thread([&]() { pool_thrift_server.Start(); }); -// non_block_pool_thrift_server.Init(9070, 64); -// non_block_pool_thrift_server.Start(); + // non_block_pool_thrift_server.Init(9070, 64); + // non_block_pool_thrift_server.Start(); shut_down_thread = infinity::Thread([&]() { ShutdownServer(); }); db_server.Run(); diff --git a/src/common/analyzer/analyzer_pool.cpp b/src/common/analyzer/analyzer_pool.cpp index cf1c76f09b..7ca9fd0987 100644 --- a/src/common/analyzer/analyzer_pool.cpp +++ b/src/common/analyzer/analyzer_pool.cpp @@ -42,18 +42,18 @@ void AnalyzerPool::Set(const StringView &name) { switch (Str2Int(name.data())) { case Str2Int(CHINESE.data()): { String path = InfinityContext::instance().config()->resource_dict_path(); - UniquePtr analyzer = MakeUnique(Move(path)); + UniquePtr analyzer = MakeUnique(std::move(path)); if (analyzer->Load()) - cache_[CHINESE] = Move(analyzer); + cache_[CHINESE] = std::move(analyzer); } break; case Str2Int(STANDARD.data()): { UniquePtr analyzer = MakeUnique(); - cache_[STANDARD] = Move(analyzer); + cache_[STANDARD] = std::move(analyzer); } break; case Str2Int(NGRAM.data()): { u32 ngram = 2; /// TODO config UniquePtr analyzer = MakeUnique(ngram); - cache_[NGRAM] = Move(analyzer); + cache_[NGRAM] = std::move(analyzer); } break; default: break; diff --git a/src/common/analyzer/chinese_analyzer.cpp b/src/common/analyzer/chinese_analyzer.cpp index 365c5f90a6..0e94c12bcc 100644 --- a/src/common/analyzer/chinese_analyzer.cpp +++ b/src/common/analyzer/chinese_analyzer.cpp @@ -60,23 +60,23 @@ bool ChineseAnalyzer::Load() { fs::path stopwords_path(root / STOP_WORD_PATH); if (!fs::exists(dict_path)) { - LOG_INFO(Format("Invalid jieba config {} dict for jieba_analyzer does not exist", dict_path.string())); + LOG_INFO(fmt::format("Invalid jieba config {} dict for jieba_analyzer does not exist", dict_path.string())); return false; } if (!fs::exists(hmm_path)) { - LOG_INFO(Format("Invalid jieba config {} hmm for jieba_analyzer does not exist", hmm_path.string())); + LOG_INFO(fmt::format("Invalid jieba config {} hmm for jieba_analyzer does not exist", hmm_path.string())); return false; } if (!fs::exists(userdict_path)) { - LOG_INFO(Format("Invalid jieba config {} user_dict for jieba_analyzer does not exist", userdict_path.string())); + LOG_INFO(fmt::format("Invalid jieba config {} user_dict for jieba_analyzer does not exist", userdict_path.string())); return false; } if (!fs::exists(idf_path)) { - LOG_INFO(Format("Invalid jieba config {} idf for jieba_analyzer does not exist", idf_path.string())); + LOG_INFO(fmt::format("Invalid jieba config {} idf for jieba_analyzer does not exist", idf_path.string())); return false; } if (!fs::exists(stopwords_path)) { - LOG_INFO(Format("Invalid jieba config {} stopword for jieba_analyzer does not exist", stopwords_path.string())); + LOG_INFO(fmt::format("Invalid jieba config {} stopword for jieba_analyzer does not exist", stopwords_path.string())); return false; } diff --git a/src/common/blocking_queue.cppm b/src/common/blocking_queue.cppm index 7cfaf0eb68..9e94cc91fb 100644 --- a/src/common/blocking_queue.cppm +++ b/src/common/blocking_queue.cppm @@ -35,7 +35,7 @@ public: return false; } - UniqueLock lock(queue_mutex_); + std::unique_lock lock(queue_mutex_); full_cv_.wait(lock, [this] { return queue_.size() < capacity_; }); queue_.push_back(task); empty_cv_.notify_one(); @@ -47,22 +47,22 @@ public: return false; } - UniqueLock lock(queue_mutex_); + std::unique_lock lock(queue_mutex_); full_cv_.wait(lock, [this] { return queue_.size() < capacity_; }); - queue_.push_back(Forward(task)); + queue_.push_back(std::forward(task)); empty_cv_.notify_one(); return true; } void EnqueueBulk(List &input_queue) { - UniqueLock lock(queue_mutex_); + std::unique_lock lock(queue_mutex_); full_cv_.wait(lock, [&] { return queue_.size() + input_queue.size() < capacity_; }); queue_.splice(queue_.end(), input_queue); empty_cv_.notify_one(); } void Dequeue(T& task) { - UniqueLock lock(queue_mutex_); + std::unique_lock lock(queue_mutex_); empty_cv_.wait(lock, [this] { return !queue_.empty(); }); task = queue_.front(); queue_.pop_front(); @@ -70,23 +70,23 @@ public: } T DequeueReturn() { - UniqueLock lock(queue_mutex_); + std::unique_lock lock(queue_mutex_); empty_cv_.wait(lock, [this] { return !queue_.empty(); }); - T res = Move(queue_.front()); + T res = std::move(queue_.front()); queue_.pop_front(); full_cv_.notify_one(); return res; } void DequeueBulk(List &output_queue) { - UniqueLock lock(queue_mutex_); + std::unique_lock lock(queue_mutex_); empty_cv_.wait(lock, [this] { return !queue_.empty(); }); output_queue.splice(output_queue.end(), queue_); full_cv_.notify_one(); } void DequeueBulk(Vector &output_array) { - UniqueLock lock(queue_mutex_); + std::unique_lock lock(queue_mutex_); empty_cv_.wait(lock, [this] { return !queue_.empty(); }); output_array.insert(output_array.end(), queue_.begin(), queue_.end()); queue_.clear(); @@ -94,7 +94,7 @@ public: } void DequeueBulk(Deque &output_array) { - UniqueLock lock(queue_mutex_); + std::unique_lock lock(queue_mutex_); empty_cv_.wait(lock, [this] { return !queue_.empty(); }); output_array = queue_; // output_array.insert(output_array.end(), queue_.begin(), queue_.end()); @@ -103,20 +103,20 @@ public: } [[nodiscard]] SizeT Size() const { - LockGuard lock(queue_mutex_); + std::lock_guard lock(queue_mutex_); return queue_.size(); } [[nodiscard]] bool Empty() const { - LockGuard lock(queue_mutex_); + std::lock_guard lock(queue_mutex_); return queue_.empty(); } protected: atomic_bool allow_enqueue_{true}; - mutable Mutex queue_mutex_{}; - CondVar full_cv_{}; - CondVar empty_cv_{}; + mutable std::mutex queue_mutex_{}; + std::condition_variable full_cv_{}; + std::condition_variable empty_cv_{}; Deque queue_{}; SizeT capacity_{DEFAULT_BLOCKING_QUEUE_SIZE}; }; diff --git a/src/common/boost.cppm b/src/common/boost.cppm index 6f6685ae14..4c11b2ea27 100644 --- a/src/common/boost.cppm +++ b/src/common/boost.cppm @@ -16,21 +16,19 @@ module; #include #include -#include export module boost; -namespace infinity { - -export using BoostErrorCode = boost::system::error_code; -export using AsioIpAddr = boost::asio::ip::address; -export using AsioAcceptor = boost::asio::ip::tcp::acceptor; -export using AsioIOService = boost::asio::io_service; -export using AsioEndPoint = boost::asio::ip::tcp::endpoint; -export using AsioSocket = boost::asio::ip::tcp::socket; - -export AsioIpAddr asio_make_address(const std::string &str, boost::system::error_code &ec) BOOST_ASIO_NOEXCEPT { - return boost::asio::ip::make_address(str.c_str(), ec); +namespace boost { + namespace system { + export using boost::system::error_code; + } + namespace asio { + export using boost::asio::io_service; + namespace ip { + export using boost::asio::ip::tcp; + export using boost::asio::ip::make_address; + export using boost::asio::ip::address; + } + } } - -} // namespace infinity diff --git a/src/common/default_values.cppm b/src/common/default_values.cppm index 47873283d8..94c3c8a9ba 100644 --- a/src/common/default_values.cppm +++ b/src/common/default_values.cppm @@ -44,22 +44,22 @@ export { constexpr i64 MAX_BLOCK_CAPACITY = 65536L; constexpr i64 DEFAULT_BLOCK_CAPACITY = 8192; constexpr i64 MIN_BLOCK_CAPACITY = 8192; - constexpr i16 INVALID_BLOCK_ID = i16_max; + constexpr i16 INVALID_BLOCK_ID = std::numeric_limits::max(); constexpr i64 MAX_BLOCK_COUNT_IN_SEGMENT = 65536L; // column vector related constants constexpr i64 DEFAULT_VECTOR_SIZE = DEFAULT_BLOCK_CAPACITY; - constexpr u64 INITIAL_VECTOR_CHUNK_ID = u64_max; + constexpr u64 INITIAL_VECTOR_CHUNK_ID = std::numeric_limits::max();; constexpr u64 MIN_VECTOR_CHUNK_SIZE = 4096UL; constexpr u64 MAX_VECTOR_CHUNK_SIZE = 1024 * 1024UL; - constexpr u64 MAX_VECTOR_CHUNK_COUNT = u64_max; // Each row has one chunk. + constexpr u64 MAX_VECTOR_CHUNK_COUNT = std::numeric_limits::max();; // Each row has one chunk. constexpr u64 DEFAULT_FIXLEN_CHUNK_SIZE = 65536L; // segment related constants constexpr SizeT DEFAULT_SEGMENT_CAPACITY = 1024 * 8192; // 1024 * 8192 = 8M rows constexpr SizeT SEGMENT_OFFSET_IN_DOCID = 23; // it should be adjusted together with DEFAULT_SEGMENT_CAPACITY constexpr u64 SEGMENT_MASK_IN_DOCID = 0x7FFFFF; // it should be adjusted together with DEFAULT_SEGMENT_CAPACITY - constexpr u32 INVALID_SEGMENT_ID = u32_max; + constexpr u32 INVALID_SEGMENT_ID = std::numeric_limits::max(); // queue related constants, TODO: double check the necessary constexpr SizeT DEFAULT_READER_PREPARE_QUEUE_SIZE = 1024; @@ -69,9 +69,9 @@ export { constexpr SizeT DEFAULT_BLOCKING_QUEUE_SIZE = 1024; // transaction related constants - constexpr u64 MAX_TXN_ID = u64_max; - constexpr u64 MAX_TIMESTAMP = u64_max; - constexpr TxnTimeStamp UNCOMMIT_TS = u64_max; + constexpr u64 MAX_TXN_ID = std::numeric_limits::max();; + constexpr u64 MAX_TIMESTAMP = std::numeric_limits::max();; + constexpr TxnTimeStamp UNCOMMIT_TS = std::numeric_limits::max();; constexpr SizeT KB = 1024; constexpr SizeT MB = 1024 * KB; diff --git a/src/common/memory/memory_chunk.cppm b/src/common/memory/memory_chunk.cppm index b4ec313998..fd4445d120 100644 --- a/src/common/memory/memory_chunk.cppm +++ b/src/common/memory/memory_chunk.cppm @@ -42,7 +42,7 @@ public: } auto nDataBytes = size_ - holder_; auto p = (char *)(this) + holder_; - Memset(p, 0, nDataBytes); + std::memset(p, 0, nDataBytes); } protected: diff --git a/src/common/specific_concurrent_queue.cpp b/src/common/specific_concurrent_queue.cpp index c4ece6ef16..5e18a605a3 100644 --- a/src/common/specific_concurrent_queue.cpp +++ b/src/common/specific_concurrent_queue.cpp @@ -16,7 +16,7 @@ void SpecificConcurrentQueue::Enqueue(const FloatDistHeap &item) template <> void SpecificConcurrentQueue::Enqueue(FloatDistHeap &&item) { - queue_.enqueue(Move(item)); + queue_.enqueue(std::move(item)); } template <> @@ -31,7 +31,7 @@ void SpecificConcurrentQueue::Enqueue(BufferObj *const &item) { template <> void SpecificConcurrentQueue::Enqueue(BufferObj * &&item) { - queue_.enqueue(Move(item)); + queue_.enqueue(std::move(item)); } template <> @@ -46,7 +46,7 @@ void SpecificConcurrentQueue>::Enqueue(const Vector &item) { template <> void SpecificConcurrentQueue>::Enqueue(Vector &&item) { - queue_.enqueue(Move(item)); + queue_.enqueue(std::move(item)); } template <> diff --git a/src/common/specific_concurrent_queue.cppm b/src/common/specific_concurrent_queue.cppm index 176b0d6b1e..d382542074 100644 --- a/src/common/specific_concurrent_queue.cppm +++ b/src/common/specific_concurrent_queue.cppm @@ -10,7 +10,7 @@ namespace infinity { export template class SpecificConcurrentQueue { - ConcurrentQueue queue_; + moodycamel::ConcurrentQueue queue_; public: void Enqueue(const T &item); diff --git a/src/common/status.cpp b/src/common/status.cpp index 855f504606..260164d82a 100644 --- a/src/common/status.cpp +++ b/src/common/status.cpp @@ -46,12 +46,12 @@ Status &Status::operator=(Status &&s) noexcept { void Status::MoveStatus(Status &s) { code_ = s.code_; - msg_ = Move(s.msg_); + msg_ = std::move(s.msg_); } void Status::MoveStatus(Status &&s) { code_ = s.code_; - msg_ = Move(s.msg_); + msg_ = std::move(s.msg_); s.msg_ = nullptr; } diff --git a/src/common/status.cppm b/src/common/status.cppm index c383063a90..67e5810815 100644 --- a/src/common/status.cppm +++ b/src/common/status.cppm @@ -43,7 +43,7 @@ public: inline explicit Status(ErrorCode code) : code_(code) {} - inline Status(ErrorCode code, UniquePtr message): code_(code), msg_(Move(message)) {} + inline Status(ErrorCode code, UniquePtr message): code_(code), msg_(std::move(message)) {} Status(ErrorCode code, const char *msg); diff --git a/src/common/status_check.h b/src/common/status_check.h deleted file mode 100644 index 620427f3d0..0000000000 --- a/src/common/status_check.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright(C) 2023 InfiniFlow, Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -namespace infinity { - -#define STATUS_CHECK(func) \ - do { \ - Status s = func; \ - if (!s.ok()) { \ - return s; \ - } \ - } while (false) -} diff --git a/src/common/stl.cppm b/src/common/stl.cppm index 0980aacb93..e403069f17 100644 --- a/src/common/stl.cppm +++ b/src/common/stl.cppm @@ -49,6 +49,43 @@ export namespace std { using std::experimental::source_location; // using std::stringstream; +using std::forward; +using std::move; + +using std::max; +using std::min; + +using std::to_string; +using std::from_chars; +using std::errc; + +using std::stoi; +using std::strtol; +using std::strtof; +using std::strtod; + +using std::memcpy; +using std::memset; +using std::memcmp; + +using std::is_same; +using std::fill; + +using std::shared_mutex; +using std::mutex; +using std::shared_lock; +using std::unique_lock; +using std::lock_guard; +using std::condition_variable; +using std::memory_order; + +using std::forward_list; +using std::isalpha; +using std::isalnum; +using std::pow; +using std::log2; + +using std::numeric_limits; } // namespace std @@ -135,44 +172,6 @@ export { std::transform(str.begin(), str.end(), str.begin(), [](const auto c) { return std::tolower(c); }); } - const char *FromChars(const char *first, const char *last, unsigned long &value) { - auto res = std::from_chars(first, last, value); - if (res.ec == std::errc()) { - return res.ptr; - } else { - return nullptr; - } - } - - template - inline const T &Min(const T &a, const T &b) { - return std::min(a, b); - } - - template - inline const T &Max(const T &a, const T &b) { - return std::max(a, b); - } - - // ToStr() - - template - inline String ToStr(T value) { - return std::to_string(value); - } - - // stoi - inline int StrToInt(const std::string &str, size_t *idx = 0, int base = 10) { return std::stoi(str, idx, base); } - - // StrToL - inline long StrToL(const char *__restrict nptr, char **__restrict endptr, int base) { return std::strtol(nptr, endptr, base); } - - // StrToF - inline float StrToF(const char *__restrict nptr, char **__restrict endptr) { return std::strtof(nptr, endptr); } - - // StrToD - inline double StrToD(const char *__restrict nptr, char **__restrict endptr) { return std::strtod(nptr, endptr); } - // Primitives using i8 = int8_t; @@ -202,8 +201,6 @@ export { using TxnTimeStamp = u64; // Concurrency - - using RWMutex = std::shared_mutex; using ThreadPool = ctpl::thread_pool; using Thread = std::thread; @@ -214,58 +211,6 @@ export { using aptr = std::atomic_uintptr_t; using atomic_bool = std::atomic_bool; - constexpr u64 u64_min = std::numeric_limits::min(); - constexpr i64 i64_min = std::numeric_limits::min(); - constexpr u32 u32_min = std::numeric_limits::min(); - constexpr i32 i32_min = std::numeric_limits::min(); - constexpr i16 i16_min = std::numeric_limits::min(); - constexpr u16 u16_min = std::numeric_limits::min(); - constexpr i8 i8_min = std::numeric_limits::min(); - constexpr u8 u8_min = std::numeric_limits::min(); - - constexpr u64 u64_max = std::numeric_limits::max(); - constexpr i64 i64_max = std::numeric_limits::max(); - constexpr u32 u32_max = std::numeric_limits::max(); - constexpr i32 i32_max = std::numeric_limits::max(); - constexpr i16 i16_max = std::numeric_limits::max(); - constexpr u16 u16_max = std::numeric_limits::max(); - constexpr i8 i8_max = std::numeric_limits::max(); - constexpr u8 u8_max = std::numeric_limits::max(); - - constexpr f32 f32_inf = std::numeric_limits::infinity(); - constexpr f32 f32_min = std::numeric_limits::min(); - constexpr f32 f32_max = std::numeric_limits::max(); - constexpr f64 f64_inf = std::numeric_limits::infinity(); - constexpr f64 f64_min = std::numeric_limits::min(); - constexpr f64 f64_max = std::numeric_limits::max(); - - constexpr u64 u64_inf = std::numeric_limits::infinity(); - constexpr i64 i64_inf = std::numeric_limits::infinity(); - constexpr u32 u32_inf = std::numeric_limits::infinity(); - constexpr i32 i32_inf = std::numeric_limits::infinity(); - constexpr i16 i16_inf = std::numeric_limits::infinity(); - constexpr u16 u16_inf = std::numeric_limits::infinity(); - constexpr i8 i8_inf = std::numeric_limits::infinity(); - constexpr u8 u8_inf = std::numeric_limits::infinity(); - - constexpr ptr_t ptr_inf = std::numeric_limits::infinity(); - constexpr u64 *u64_ptr_inf = std::numeric_limits::infinity(); - - template - constexpr T LimitMax() { - return std::numeric_limits::max(); - } - - template - constexpr T LimitMin() { - return std::numeric_limits::min(); - } - - template - constexpr T LimitLowest() { - return std::numeric_limits::lowest(); - } - template using Atomic = std::atomic; @@ -305,18 +250,6 @@ export { using StdException = std::exception; - // Move - template - [[nodiscard]] constexpr typename std::remove_reference::type &&Move(T && value) noexcept { - return static_cast::type &&>(value); - } - - // Forward - template - [[nodiscard]] constexpr T &&Forward(typename std::remove_reference::type & value) noexcept { - return static_cast(value); - } - // Chrono using Clock = std::chrono::high_resolution_clock; @@ -335,41 +268,12 @@ export { return std::chrono::duration_cast(nano_seconds); } - // Memcpy - void *Memcpy(void *__restrict dest, const void *__restrict src, size_t n) { return memcpy(dest, src, n); } - void *Memset(void *__restrict dest, int value, size_t n) { return memset(dest, value, n); } - - // Memcmp - int Memcmp(const void *__restrict s1, const void *__restrict s2, size_t n) { return memcmp(s1, s2, n); } // IsStandLayout template concept IsStandLayout = std::is_standard_layout_v; - template - concept IsTrivial = std::is_trivial_v; - - // Mutex - template - using SharedLock = std::shared_lock; - - template - using UniqueLock = std::unique_lock; - - template - using LockGuard = std::lock_guard; - - constexpr std::memory_order MemoryOrderRelax = std::memory_order::relaxed; - constexpr std::memory_order MemoryOrderConsume = std::memory_order::consume; - constexpr std::memory_order MemoryOrderRelease = std::memory_order::release; - constexpr std::memory_order MemoryOrderAcquire = std::memory_order::acquire; - constexpr std::memory_order MemoryOrderAcqrel = std::memory_order::acq_rel; - constexpr std::memory_order MemoryOrderSeqcst = std::memory_order::seq_cst; - - using CondVar = std::condition_variable; - // Stringstream - using StringStream = std::basic_stringstream; using IStringStream = std::istringstream; using OStringStream = std::ostringstream; @@ -396,35 +300,10 @@ export { template using EnableSharedFromThis = std::enable_shared_from_this; - using Mutex = std::mutex; - - float HugeValf() { return HUGE_VALF; } - - template > - using ForwardList = std::forward_list; - - inline bool IsAlpha(const char &c) { return std::isalpha(c); } - - inline bool IsAlNum(const char &c) { return std::isalnum(c); } - - SizeT Pow(SizeT x, SizeT y) { return std::pow(x, y); } - - u64 Log2(u64 num) { return std::log2(num); } - template OI Copy(II first, II last, OI d_first) { return std::copy(first, last, d_first); } - - template - void Fill(FI first, FI last, const T &value) { - std::fill(first, last, value); - } - - template - constexpr bool IsSame() { - return std::is_same(); - } } export template diff --git a/src/common/third_party.cppm b/src/common/third_party.cppm index c525f4660b..1413560bab 100644 --- a/src/common/third_party.cppm +++ b/src/common/third_party.cppm @@ -46,6 +46,57 @@ module; export module third_party; +namespace fmt { + + export using fmt::format; + export using fmt::print; +} + +namespace spdlog { + export using spdlog::shutdown; + export using spdlog::logger; + export using spdlog::sink_ptr; + + namespace sinks { + export using spdlog::sinks::stdout_color_sink_mt; + export using spdlog::sinks::rotating_file_sink_mt; + } + + namespace details { + export using spdlog::details::registry; + } +} + +namespace cxxopts { + // cxxopts + export using cxxopts::Options; + export using cxxopts::Value; + + namespace values { + export using cxxopts::values::standard_value; + } + + export using cxxopts::ParseResult; +} + +namespace toml { + // Toml parser + export using toml::table; + export using toml::parse_file; +} + +namespace nlohmann { + export using nlohmann::json; +} + +namespace magic_enum { + export using magic_enum::underlying_type_t; +} + +namespace moodycamel { + export using moodycamel::ConcurrentQueue; +} + namespace infinity { // spdlog @@ -72,19 +123,6 @@ export std::string LogLevel2Str(LogLevel log_level) { } } -export template -FMT_INLINE void Printf(fmt::format_string fmt, T &&...args) { - const auto &vargs = fmt::make_format_args(args...); - return fmt::detail::is_utf8() ? vprint(fmt, vargs) : fmt::detail::vprint_mojibake(stdout, fmt, vargs); -} - -export template -FMT_NODISCARD FMT_INLINE auto Format(fmt::format_string fmt, T &&...args) -> std::string { - return vformat(fmt, fmt::make_format_args(args...)); -} - -export void RegisterLogger(const std::shared_ptr &logger) { return spdlog::details::registry::instance().register_logger(logger); } - export void SetLogLevel(LogLevel log_level) { switch (log_level) { case LogLevel::kTrace: @@ -100,70 +138,6 @@ export void SetLogLevel(LogLevel log_level) { } } -export void ShutdownLogger() { spdlog::shutdown(); } - -export using spd_sink_ptr = spdlog::sink_ptr; -export using spd_stdout_color_sink = spdlog::sinks::stdout_color_sink_mt; -export using spd_rotating_file_sink = spdlog::sinks::rotating_file_sink_mt; - -export using spd_logger = spdlog::logger; -export using spd_log_level = spdlog::level::level_enum; - -export template -inline void spd_log(const T &msg, spd_log_level log_level) { - switch (log_level) { - case spdlog::level::trace: { - return spdlog::default_logger_raw()->trace(msg); - } - case spdlog::level::info: { - return spdlog::default_logger_raw()->info(msg); - } - case spdlog::level::warn: { - return spdlog::default_logger_raw()->warn(msg); - } - case spdlog::level::err: { - return spdlog::default_logger_raw()->error(msg); - } - case spdlog::level::critical: { - return spdlog::default_logger_raw()->critical(msg); - } - default: - assert(false); - } -} - -// cxxopts -export using CxxOptions = cxxopts::Options; - -export template -std::shared_ptr cxx_value() { - return std::make_shared>(); -} - -export using ParseResult = cxxopts::ParseResult; - -// Toml parser -export using TomlTable = toml::table; -// -export TomlTable TomlParseFile(const std::string &file_path) { return toml::parse_file(file_path); } - -// Returns integer value from enum value. -export template -constexpr auto EnumInteger(E value) noexcept -> magic_enum::detail::enable_if_t> { - return static_cast>(value); -} - -// Json Parser -export using Json = nlohmann::json; - -// ConcurrentQueue - -export template -using ConcurrentQueue = moodycamel::ConcurrentQueue; - -export template -using BlockingConcurrentQueue = moodycamel::BlockingConcurrentQueue; - export using Features = irs::features_t; export using IndexFeatures = irs::IndexFeatures; export using TokenStream = irs::token_stream; diff --git a/src/common/utility/defer_op.cppm b/src/common/utility/defer_op.cppm index 7af0571fb3..79d3ad99e2 100644 --- a/src/common/utility/defer_op.cppm +++ b/src/common/utility/defer_op.cppm @@ -23,7 +23,7 @@ namespace infinity { export template class DeferFn { public: - explicit DeferFn(FN func) : func_(Move(func)) {} + explicit DeferFn(FN func) : func_(std::move(func)) {} ~DeferFn() noexcept { func_(); } diff --git a/src/common/utility/exception.cpp b/src/common/utility/exception.cpp index accea0ea0c..f3de319282 100644 --- a/src/common/utility/exception.cpp +++ b/src/common/utility/exception.cpp @@ -17,12 +17,12 @@ module; #include #include +module infinity_exception; + import stl; import logger; import third_party; -module infinity_exception; - namespace infinity { void PrintStacktrace(const String &err_msg) { @@ -31,17 +31,17 @@ void PrintStacktrace(const String &err_msg) { int stack_num = backtrace(array, trace_stack_depth); char **stacktrace = backtrace_symbols(array, stack_num); - LOG_CRITICAL(Format("Error: {}", err_msg)); + LOG_CRITICAL(fmt::format("Error: {}", err_msg)); for (int i = 0; i < stack_num; ++i) { String info = stacktrace[i]; - LOG_CRITICAL(Format("{}, {}", i, info)); + LOG_CRITICAL(fmt::format("{}, {}", i, info)); } free(stacktrace); } void Error(const String &message, const char *file_name, u32 line) { String err_msg = message; - err_msg.append(" @").append(infinity::TrimPath(file_name)).append(":").append(ToStr(line)); + err_msg.append(" @").append(infinity::TrimPath(file_name)).append(":").append(std::to_string(line)); PrintStacktrace(err_msg); throw Exception(err_msg); } diff --git a/src/common/utility/exception.cppm b/src/common/utility/exception.cppm index 4485a13245..8e75042332 100644 --- a/src/common/utility/exception.cppm +++ b/src/common/utility/exception.cppm @@ -23,7 +23,7 @@ export void PrintStacktrace(const String& err_msg); export class Exception : public StdException { public: - explicit Exception(String message) : message_(Move(message)) {} + explicit Exception(String message) : message_(std::move(message)) {} [[nodiscard]] inline const char *what() const noexcept override { return message_.c_str(); } protected: @@ -59,7 +59,7 @@ String Exception::BuildMessage(Args... params) { template String Exception::BuildMessageInternal(Vector &values, T param, Args... params) { - values.push_back(Move(param)); + values.push_back(std::move(param)); return BuildMessageInternal(values, params...); } @@ -153,7 +153,7 @@ export template inline void Error(const String &message, const char *file_name = std::source_location::current().file_name(), u32 line = std::source_location::current().line()) { String err_msg = message; - err_msg.append(" @").append(infinity::TrimPath(file_name)).append(":").append(ToStr(line)); + err_msg.append(" @").append(infinity::TrimPath(file_name)).append(":").append(std::to_string(line)); throw ExceptionType(err_msg); } diff --git a/src/common/utility/serialize.cppm b/src/common/utility/serialize.cppm index 4e01e30990..d5bc982312 100644 --- a/src/common/utility/serialize.cppm +++ b/src/common/utility/serialize.cppm @@ -85,14 +85,14 @@ export template <> inline void WriteBuf(char *const buf, const String &value) { i32 len = value.length(); WriteBuf(buf, len); - Memcpy(buf + len, value.c_str(), len); + std::memcpy(buf + len, value.c_str(), len); } export template <> inline void WriteBufAdv(char *&buf, const String &value) { i32 len = value.length(); WriteBufAdv(buf, len); - Memcpy(buf, value.c_str(), len); + std::memcpy(buf, value.c_str(), len); buf += len; } diff --git a/src/common/utility/spinlock.cppm b/src/common/utility/spinlock.cppm index a582788a28..354d814743 100644 --- a/src/common/utility/spinlock.cppm +++ b/src/common/utility/spinlock.cppm @@ -178,7 +178,7 @@ public: // Writer is responsible for clearing up both the UPGRADED and WRITER bits. void unlock() noexcept { static_assert(READER > WRITER + UPGRADED, "wrong bits!"); - bits_.fetch_and(~(WRITER | UPGRADED), MemoryOrderRelease); + bits_.fetch_and(~(WRITER | UPGRADED), std::memory_order::release); } // SharedLockable Concept @@ -188,11 +188,11 @@ public: } } - void unlock_shared() noexcept { bits_.fetch_add(-READER, MemoryOrderRelease); } + void unlock_shared() noexcept { bits_.fetch_add(-READER, std::memory_order::release); } // Downgrade the lock from writer status to reader status. void unlock_and_lock_shared() noexcept { - bits_.fetch_add(READER, MemoryOrderAcquire); + bits_.fetch_add(READER, std::memory_order::acquire); unlock(); } @@ -203,7 +203,7 @@ public: } } - void unlock_upgrade() noexcept { bits_.fetch_add(-UPGRADED, MemoryOrderAcqrel); } + void unlock_upgrade() noexcept { bits_.fetch_add(-UPGRADED, std::memory_order::acq_rel); } // unlock upgrade and try to acquire write lock void unlock_upgrade_and_lock() noexcept { @@ -213,20 +213,20 @@ public: } // unlock upgrade and read lock atomically - void unlock_upgrade_and_lock_shared() noexcept { bits_.fetch_add(READER - UPGRADED, MemoryOrderAcqrel); } + void unlock_upgrade_and_lock_shared() noexcept { bits_.fetch_add(READER - UPGRADED, std::memory_order::acq_rel); } // write unlock and upgrade lock atomically void unlock_and_lock_upgrade() noexcept { // need to do it in two steps here -- as the UPGRADED bit might be OR-ed at // the same time when other threads are trying do try_lock_upgrade(). - bits_.fetch_or(UPGRADED, MemoryOrderAcquire); - bits_.fetch_add(-WRITER, MemoryOrderRelease); + bits_.fetch_or(UPGRADED, std::memory_order::acquire); + bits_.fetch_add(-WRITER, std::memory_order::release); } // Attempt to acquire writer permission. Return false if we didn't get it. bool try_lock() noexcept { i32 expect = 0; - return bits_.compare_exchange_strong(expect, WRITER, MemoryOrderAcqrel); + return bits_.compare_exchange_strong(expect, WRITER, std::memory_order::acq_rel); } // Try to get reader permission on the lock. This can fail if we @@ -238,9 +238,9 @@ public: bool try_lock_shared() noexcept { // fetch_add is considerably (100%) faster than compare_exchange, // so here we are optimizing for the common (lock success) case. - i32 value = bits_.fetch_add(READER, MemoryOrderAcquire); + i32 value = bits_.fetch_add(READER, std::memory_order::acquire); if (value & (WRITER | UPGRADED)) { - bits_.fetch_add(-READER, MemoryOrderRelease); + bits_.fetch_add(-READER, std::memory_order::release); return false; } return true; @@ -249,12 +249,12 @@ public: // try to unlock upgrade and write lock atomically bool try_unlock_upgrade_and_lock() noexcept { i32 expect = UPGRADED; - return bits_.compare_exchange_strong(expect, WRITER, MemoryOrderAcqrel); + return bits_.compare_exchange_strong(expect, WRITER, std::memory_order::acq_rel); } // try to acquire an upgradable lock. bool try_lock_upgrade() noexcept { - i32 value = bits_.fetch_or(UPGRADED, MemoryOrderAcquire); + i32 value = bits_.fetch_or(UPGRADED, std::memory_order::acquire); // Note: when failed, we cannot flip the UPGRADED bit back, // as in this case there is either another upgrade lock or a write lock. @@ -264,7 +264,7 @@ public: } // mainly for debugging purposes. - [[nodiscard]] i32 bits() const noexcept { return bits_.load(MemoryOrderAcquire); } + [[nodiscard]] i32 bits() const noexcept { return bits_.load(std::memory_order::acquire); } private: Atomic bits_; diff --git a/src/common/utility/utility.cpp b/src/common/utility/utility.cpp index d712362501..f705378888 100644 --- a/src/common/utility/utility.cpp +++ b/src/common/utility/utility.cpp @@ -42,7 +42,7 @@ String FormatByteSize(u64 byte_size) { return "0B"; } - int suffixIndex = static_cast(Log2(byte_size) / 10); + int suffixIndex = static_cast(std::log2(byte_size) / 10); double size = static_cast(byte_size) / (1 << (suffixIndex * 10)); std::ostringstream oss; diff --git a/src/executor/explain_fragment.cpp b/src/executor/explain_fragment.cpp index d945c6faf0..95d4dd47f6 100644 --- a/src/executor/explain_fragment.cpp +++ b/src/executor/explain_fragment.cpp @@ -27,10 +27,10 @@ namespace infinity { static String FragmentTitle(u64 fragment_id, bool is_head) { if (!is_head) { - return "FRAGMENT #" + ToStr(fragment_id); + return "FRAGMENT #" + std::to_string(fragment_id); } - return "FRAGMENT (" + ToStr(fragment_id) + ")"; + return "FRAGMENT (" + std::to_string(fragment_id) + ")"; } void ExplainFragment::Explain(PlanFragment *fragment_ptr, SharedPtr>> &result, i64 intent_size) { diff --git a/src/executor/explain_physical_plan.cpp b/src/executor/explain_physical_plan.cpp index da2b093e8a..3ebea79be1 100644 --- a/src/executor/explain_physical_plan.cpp +++ b/src/executor/explain_physical_plan.cpp @@ -293,7 +293,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalCreateSchema *create_node, Share create_header_str = "CREATE SCHEMA "; } - create_header_str += "(" + ToStr(create_node->node_id()) + ")"; + create_header_str += "(" + std::to_string(create_node->node_id()) + ")"; result->emplace_back(MakeShared(create_header_str)); } @@ -325,7 +325,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalCreateTable *create_node, Shared create_header_str = "CREATE TABLE "; } - create_header_str += "(" + ToStr(create_node->node_id()) + ")"; + create_header_str += "(" + std::to_string(create_node->node_id()) + ")"; result->emplace_back(MakeShared(create_header_str)); } @@ -379,7 +379,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalCreateIndex *create_node, Shared create_header_str = "CREATE INDEX "; } - create_header_str += "(" + ToStr(create_node->node_id()) + ")"; + create_header_str += "(" + std::to_string(create_node->node_id()) + ")"; result->emplace_back(MakeShared(create_header_str)); } @@ -419,7 +419,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalCreateCollection *create_node, S create_header_str = "CREATE COLLECTION "; } - create_header_str += "(" + ToStr(create_node->node_id()) + ")"; + create_header_str += "(" + std::to_string(create_node->node_id()) + ")"; result->emplace_back(MakeShared(create_header_str)); } @@ -457,7 +457,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalDropSchema *drop_node, SharedPtr drop_header_str = "DROP SCHEMA "; } - drop_header_str += "(" + ToStr(drop_node->node_id()) + ")"; + drop_header_str += "(" + std::to_string(drop_node->node_id()) + ")"; result->emplace_back(MakeShared(drop_header_str)); } @@ -489,7 +489,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalDropTable *drop_node, SharedPtr< drop_header_str = "DROP TABLE "; } - drop_header_str += "(" + ToStr(drop_node->node_id()) + ")"; + drop_header_str += "(" + std::to_string(drop_node->node_id()) + ")"; result->emplace_back(MakeShared(drop_header_str)); } @@ -527,7 +527,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalDropCollection *drop_node, Share drop_header_str = "DROP COLLECTION "; } - drop_header_str += "(" + ToStr(drop_node->node_id()) + ")"; + drop_header_str += "(" + std::to_string(drop_node->node_id()) + ")"; result->emplace_back(MakeShared(drop_header_str)); } @@ -565,7 +565,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalInsert *insert_node, SharedPtrnode_id()) + ")"; + insert_header_str += "(" + std::to_string(insert_node->node_id()) + ")"; result->emplace_back(MakeShared(insert_header_str)); } @@ -619,13 +619,13 @@ void ExplainPhysicalPlan::Explain(const PhysicalProject *project_node, SharedPtr project_header = "PROJECT "; } - project_header += "(" + ToStr(project_node->node_id()) + ")"; + project_header += "(" + std::to_string(project_node->node_id()) + ")"; result->emplace_back(MakeShared(project_header)); } // Table index { - String table_index = String(intent_size, ' ') + " - table index: #" + ToStr(project_node->TableIndex()); + String table_index = String(intent_size, ' ') + " - table index: #" + std::to_string(project_node->TableIndex()); result->emplace_back(MakeShared(table_index)); } @@ -654,7 +654,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalFilter *filter_node, SharedPtrnode_id()) + ")"; + filter_node_header += "(" + std::to_string(filter_node->node_id()) + ")"; result->emplace_back(MakeShared(filter_node_header)); // filter expression @@ -683,7 +683,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalTableScan *table_scan_node, Shar table_scan_header = "TABLE SCAN "; } - table_scan_header += "(" + ToStr(table_scan_node->node_id()) + ")"; + table_scan_header += "(" + std::to_string(table_scan_node->node_id()) + ")"; result->emplace_back(MakeShared(table_scan_header)); // Table alias and name @@ -693,14 +693,14 @@ void ExplainPhysicalPlan::Explain(const PhysicalTableScan *table_scan_node, Shar result->emplace_back(MakeShared(table_name)); // Table index - String table_index = String(intent_size, ' ') + " - table index: #" + ToStr(table_scan_node->TableIndex()); + String table_index = String(intent_size, ' ') + " - table index: #" + std::to_string(table_scan_node->TableIndex()); result->emplace_back(MakeShared(table_index)); // Output columns String output_columns = String(intent_size, ' ') + " - output_columns: ["; SizeT column_count = table_scan_node->GetOutputNames()->size(); if (column_count == 0) { - Error(Format("No column in table: {}.", table_scan_node->table_alias())); + Error(fmt::format("No column in table: {}.", table_scan_node->table_alias())); } for (SizeT idx = 0; idx < column_count - 1; ++idx) { output_columns += table_scan_node->GetOutputNames()->at(idx) + ", "; @@ -718,7 +718,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalKnnScan *knn_scan_node, SharedPt knn_scan_header = "KNN SCAN "; } - knn_scan_header += "(" + ToStr(knn_scan_node->node_id()) + ")"; + knn_scan_header += "(" + std::to_string(knn_scan_node->node_id()) + ")"; result->emplace_back(MakeShared(knn_scan_header)); // Table alias and name @@ -729,7 +729,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalKnnScan *knn_scan_node, SharedPt result->emplace_back(MakeShared(table_name)); // Table index - String table_index = String(intent_size, ' ') + " - table index: #" + ToStr(knn_scan_node->knn_table_index_); + String table_index = String(intent_size, ' ') + " - table index: #" + std::to_string(knn_scan_node->knn_table_index_); result->emplace_back(MakeShared(table_index)); KnnExpression *knn_expr_raw = knn_scan_node->knn_expression_.get(); @@ -741,7 +741,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalKnnScan *knn_scan_node, SharedPt String(intent_size + 2, ' ') + " - element type: " + EmbeddingT::EmbeddingDataType2String(knn_expr_raw->embedding_data_type_); result->emplace_back(MakeShared(embedding_type_str)); - String embedding_dimension_str = String(intent_size + 2, ' ') + " - dimension: " + ToStr(knn_expr_raw->dimension_); + String embedding_dimension_str = String(intent_size + 2, ' ') + " - dimension: " + std::to_string(knn_expr_raw->dimension_); result->emplace_back(MakeShared(embedding_dimension_str)); String distance_type_str = String(intent_size + 2, ' ') + " - distance type: " + KnnExpr::KnnDistanceType2Str(knn_expr_raw->distance_type_); @@ -765,7 +765,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalKnnScan *knn_scan_node, SharedPt String output_columns = String(intent_size, ' ') + " - output columns: ["; SizeT column_count = knn_scan_node->GetOutputNames()->size(); if (column_count == 0) { - Error(Format("No column in table: {}.", knn_scan_node->TableAlias())); + Error(fmt::format("No column in table: {}.", knn_scan_node->TableAlias())); } for (SizeT idx = 0; idx < column_count - 1; ++idx) { output_columns += knn_scan_node->GetOutputNames()->at(idx) + ", "; @@ -794,13 +794,13 @@ void ExplainPhysicalPlan::Explain(const PhysicalAggregate *aggregate_node, Share agg_header = "AGGREGATE "; } - agg_header += "(" + ToStr(aggregate_node->node_id()) + ")"; + agg_header += "(" + std::to_string(aggregate_node->node_id()) + ")"; result->emplace_back(MakeShared(agg_header)); } // Aggregate Table index { - String aggregate_table_index = String(intent_size, ' ') + " - aggregate table index: #" + ToStr(aggregate_node->AggregateTableIndex()); + String aggregate_table_index = String(intent_size, ' ') + " - aggregate table index: #" + std::to_string(aggregate_node->AggregateTableIndex()); result->emplace_back(MakeShared(aggregate_table_index)); } @@ -821,7 +821,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalAggregate *aggregate_node, Share // Group by expressions if (groups_count != 0) { // Group by table index - String group_table_index = String(intent_size, ' ') + " - group by table index: #" + ToStr(aggregate_node->GroupTableIndex()); + String group_table_index = String(intent_size, ' ') + " - group by table index: #" + std::to_string(aggregate_node->GroupTableIndex()); result->emplace_back(MakeShared(group_table_index)); String group_by_expression_str = String(intent_size, ' ') + " - group by: ["; @@ -844,7 +844,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalSort *sort_node, SharedPtrnode_id()) + ")"; + sort_header += "(" + std::to_string(sort_node->node_id()) + ")"; result->emplace_back(MakeShared(sort_header)); } @@ -857,10 +857,10 @@ void ExplainPhysicalPlan::Explain(const PhysicalSort *sort_node, SharedPtrexpressions_[idx].get(), sort_expression_str); - sort_expression_str += " " + ToStr(sort_node->order_by_types_[idx]) + ", "; + sort_expression_str += " " + std::to_string(sort_node->order_by_types_[idx]) + ", "; } ExplainLogicalPlan::Explain(sort_node->expressions_.back().get(), sort_expression_str); - sort_expression_str += " " + ToStr(sort_node->order_by_types_.back()) + "]"; + sort_expression_str += " " + std::to_string(sort_node->order_by_types_.back()) + "]"; result->emplace_back(MakeShared(sort_expression_str)); } @@ -886,7 +886,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalLimit *limit_node, SharedPtrnode_id()) + ")"; + limit_header += "(" + std::to_string(limit_node->node_id()) + ")"; result->emplace_back(MakeShared(limit_header)); } @@ -923,7 +923,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalCrossProduct *cross_product_node } else { cross_product_header = "CROSS PRODUCT "; } - cross_product_header += "(" + ToStr(cross_product_node->node_id()) + ")"; + cross_product_header += "(" + std::to_string(cross_product_node->node_id()) + ")"; result->emplace_back(MakeShared(cross_product_header)); } @@ -948,7 +948,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalNestedLoopJoin *join_node, Share join_header = "NESTED LOOP JOIN "; } - join_header += "(" + ToStr(join_node->node_id()) + ")"; + join_header += "(" + std::to_string(join_node->node_id()) + ")"; result->emplace_back(MakeShared(join_header)); // Conditions @@ -990,7 +990,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()) + ")"; + show_str += "(" + std::to_string(show_node->node_id()) + ")"; result->emplace_back(MakeShared(show_str)); String output_columns_str = @@ -1005,7 +1005,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()) + ")"; + show_str += "(" + std::to_string(show_node->node_id()) + ")"; result->emplace_back(MakeShared(show_str)); String output_columns_str = String(intent_size, ' ') + " - output columns: [schema, view, column_count]"; @@ -1019,7 +1019,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()) + ")"; + show_str += "(" + std::to_string(show_node->node_id()) + ")"; result->emplace_back(MakeShared(show_str)); String show_column_db_str = String(intent_size, ' ') + " - schema: "; @@ -1041,7 +1041,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()) + ")"; + show_str += "(" + std::to_string(show_node->node_id()) + ")"; result->emplace_back(MakeShared(show_str)); String show_column_db_str = String(intent_size, ' ') + " - schema: "; @@ -1065,7 +1065,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1083,7 +1083,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1101,7 +1101,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1120,7 +1120,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1138,7 +1138,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1156,7 +1156,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1234,7 +1234,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalImport *import_node, SharedPtrnode_id()) + ")"; + import_header_str += "(" + std::to_string(import_node->node_id()) + ")"; result->emplace_back(MakeShared(import_header_str)); } @@ -1296,7 +1296,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalExport *export_node, SharedPtrnode_id()) + ")"; + export_header_str += "(" + std::to_string(export_node->node_id()) + ")"; result->emplace_back(MakeShared(export_header_str)); } @@ -1362,7 +1362,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalCreateView *create_node, SharedP create_header_str = "CREATE VIEW "; } - create_header_str += "(" + ToStr(create_node->node_id()) + ")"; + create_header_str += "(" + std::to_string(create_node->node_id()) + ")"; result->emplace_back(MakeShared(create_header_str)); } @@ -1415,7 +1415,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalDropView *drop_node, SharedPtrnode_id()) + ")"; + drop_header_str += "(" + std::to_string(drop_node->node_id()) + ")"; result->emplace_back(MakeShared(drop_header_str)); } @@ -1448,13 +1448,13 @@ void ExplainPhysicalPlan::Explain(const PhysicalFlush *flush_node, SharedPtrflush_type()) { case FlushType::kData: - flush_header_str += "DATA (" + ToStr(flush_node->node_id()) + ")"; + flush_header_str += "DATA (" + std::to_string(flush_node->node_id()) + ")"; break; case FlushType::kLog: - flush_header_str += "LOG (" + ToStr(flush_node->node_id()) + ")"; + flush_header_str += "LOG (" + std::to_string(flush_node->node_id()) + ")"; break; case FlushType::kBuffer: - flush_header_str += "BUFFER (" + ToStr(flush_node->node_id()) + ")"; + flush_header_str += "BUFFER (" + std::to_string(flush_node->node_id()) + ")"; break; } @@ -1471,7 +1471,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalSource *source_node, } else { explain_header_str = "SOURCE "; } - explain_header_str += "(" + ToStr(source_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(source_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1482,7 +1482,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalSink *sink_node, SharedPtrnode_id()) + ")"; + explain_header_str += "(" + std::to_string(sink_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1496,7 +1496,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalParallelAggregate *parallel_aggr } else { explain_header_str = "PARALLEL AGGREGATE "; } - explain_header_str += "(" + ToStr(parallel_aggregate_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(parallel_aggregate_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1510,7 +1510,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalMergeParallelAggregate *merge_pa } else { explain_header_str = "MERGE PARALLEL AGGREGATE "; } - explain_header_str += "(" + ToStr(merge_parallel_aggregate_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(merge_parallel_aggregate_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1524,7 +1524,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalIntersect *intersect_node, } else { explain_header_str = "INTERSECT "; } - explain_header_str += "(" + ToStr(intersect_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(intersect_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1538,7 +1538,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalExcept *except_node, } else { explain_header_str = "EXCEPT "; } - explain_header_str += "(" + ToStr(except_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(except_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1549,7 +1549,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalHash *hash_node, SharedPtrnode_id()) + ")"; + explain_header_str += "(" + std::to_string(hash_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1563,7 +1563,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalMergeHash *merge_hash_node, } else { explain_header_str = "MERGE HASH "; } - explain_header_str += "(" + ToStr(merge_hash_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(merge_hash_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1577,7 +1577,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalMergeLimit *merge_limit_node, } else { explain_header_str = "MERGE LIMIT "; } - explain_header_str += "(" + ToStr(merge_limit_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(merge_limit_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1591,7 +1591,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalMergeTop *merge_top_node, } else { explain_header_str = "MERGE TOP "; } - explain_header_str += "(" + ToStr(merge_top_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(merge_top_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1605,7 +1605,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalMergeSort *merge_sort_node, } else { explain_header_str = "MERGE SORT "; } - explain_header_str += "(" + ToStr(merge_sort_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(merge_sort_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); } @@ -1619,11 +1619,11 @@ void ExplainPhysicalPlan::Explain(const PhysicalMergeKnn *merge_knn_node, } else { explain_header_str = "MERGE KNN "; } - explain_header_str += "(" + ToStr(merge_knn_node->node_id()) + ")"; + explain_header_str += "(" + std::to_string(merge_knn_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); // Table index - String table_index = String(intent_size, ' ') + " - table index: #" + ToStr(merge_knn_node->knn_table_index()); + String table_index = String(intent_size, ' ') + " - table index: #" + std::to_string(merge_knn_node->knn_table_index()); result->emplace_back(MakeShared(table_index)); // Output columns @@ -1647,7 +1647,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalMatch *match_node, SharedPtrnode_id()) + ")"; + explain_header_str += "(" + std::to_string(match_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); // Table alias and name @@ -1658,7 +1658,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalMatch *match_node, SharedPtremplace_back(MakeShared(table_name)); // Table index - String table_index = String(intent_size, ' ') + " - table index: #" + ToStr(match_node->table_index()); + String table_index = String(intent_size, ' ') + " - table index: #" + std::to_string(match_node->table_index()); result->emplace_back(MakeShared(table_index)); String match_expression = String(intent_size, ' ') + " - match expression: " + match_node->match_expr()->ToString(); @@ -1689,7 +1689,7 @@ void ExplainPhysicalPlan::Explain(const PhysicalFusion *fusion_node, SharedPtrnode_id()) + ")"; + explain_header_str += "(" + std::to_string(fusion_node->node_id()) + ")"; result->emplace_back(MakeShared(explain_header_str)); // Fusion expression diff --git a/src/executor/expression/expression_selector.cpp b/src/executor/expression/expression_selector.cpp index 63cd67d493..59cd64ee21 100644 --- a/src/executor/expression/expression_selector.cpp +++ b/src/executor/expression/expression_selector.cpp @@ -95,7 +95,7 @@ void ExpressionSelector::Select(const SharedPtr &bool_column, Size const u64 *result_null_data = null_mask->GetData(); SizeT unit_count = BitmaskBuffer::UnitCount(count); for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; ++i, end_index += BitmaskBuffer::UNIT_BITS) { - end_index = Min(end_index, count); + end_index = std::min(end_index, count); if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null for (; start_index < end_index; ++start_index) { diff --git a/src/executor/fragment/plan_fragment.cppm b/src/executor/fragment/plan_fragment.cppm index 374766f9e3..7012fbbbf5 100644 --- a/src/executor/fragment/plan_fragment.cppm +++ b/src/executor/fragment/plan_fragment.cppm @@ -59,7 +59,7 @@ public: inline void AddChild(UniquePtr child_fragment) { child_fragment->parent_ = this; - children_.emplace_back(Move(child_fragment)); + children_.emplace_back(std::move(child_fragment)); } inline Vector> &Children() { return children_; } @@ -70,7 +70,7 @@ public: [[nodiscard]] inline u64 FragmentID() const { return fragment_id_; } - inline void SetContext(UniquePtr context) { context_ = Move(context); } + inline void SetContext(UniquePtr context) { context_ = std::move(context); } inline FragmentContext *GetContext() { return context_.get(); } diff --git a/src/executor/fragment_builder.cpp b/src/executor/fragment_builder.cpp index a15644a797..eeb2dbcfb5 100644 --- a/src/executor/fragment_builder.cpp +++ b/src/executor/fragment_builder.cpp @@ -74,7 +74,7 @@ void FragmentBuilder::BuildExplain(PhysicalOperator *phys_op, PlanFragment *curr current_fragment_ptr->AddOperator(phys_op); if (explain_op->explain_type() == ExplainType::kPipeline) { - current_fragment_ptr->AddChild(Move(explain_child_fragment)); + current_fragment_ptr->AddChild(std::move(explain_child_fragment)); } break; } @@ -113,7 +113,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu case PhysicalOperatorType::kMatch: { current_fragment_ptr->AddOperator(phys_op); if (phys_op->left() != nullptr or phys_op->right() != nullptr) { - Error(Format("{} shouldn't have child.", phys_op->GetName())); + Error(fmt::format("{} shouldn't have child.", phys_op->GetName())); } current_fragment_ptr->SetFragmentType(FragmentType::kSerialMaterialize); current_fragment_ptr->SetSourceNode(query_context_ptr_, SourceType::kEmpty, phys_op->GetOutputNames(), phys_op->GetOutputTypes()); @@ -140,7 +140,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu phys_op->left()->GetOutputNames(), phys_op->left()->GetOutputTypes()); BuildFragments(phys_op->left(), next_plan_fragment.get()); - current_fragment_ptr->AddChild(Move(next_plan_fragment)); + current_fragment_ptr->AddChild(std::move(next_plan_fragment)); return; } case PhysicalOperatorType::kParallelAggregate: @@ -149,7 +149,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu case PhysicalOperatorType::kLimit: case PhysicalOperatorType::kTop: { if (phys_op->left() == nullptr) { - Error(Format("No input node of {}", phys_op->GetName())); + Error(fmt::format("No input node of {}", phys_op->GetName())); } current_fragment_ptr->SetFragmentType(FragmentType::kParallelMaterialize); current_fragment_ptr->AddOperator(phys_op); @@ -160,7 +160,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu case PhysicalOperatorType::kDelete: case PhysicalOperatorType::kSort: { if (phys_op->left() == nullptr) { - Error(Format("No input node of {}", phys_op->GetName())); + Error(fmt::format("No input node of {}", phys_op->GetName())); } current_fragment_ptr->AddOperator(phys_op); BuildFragments(phys_op->left(), current_fragment_ptr); @@ -177,7 +177,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu current_fragment_ptr->AddOperator(phys_op); current_fragment_ptr->SetSourceNode(query_context_ptr_, SourceType::kLocalQueue, phys_op->GetOutputNames(), phys_op->GetOutputTypes()); if (phys_op->left() == nullptr) { - Error(Format("No input node of {}", phys_op->GetName())); + Error(fmt::format("No input node of {}", phys_op->GetName())); } current_fragment_ptr->SetFragmentType(FragmentType::kSerialMaterialize); @@ -187,7 +187,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu phys_op->left()->GetOutputNames(), phys_op->left()->GetOutputTypes()); BuildFragments(phys_op->left(), next_plan_fragment.get()); - current_fragment_ptr->AddChild(Move(next_plan_fragment)); + current_fragment_ptr->AddChild(std::move(next_plan_fragment)); if (phys_op->right() != nullptr) { auto next_plan_fragment = MakeUnique(GetFragmentId()); next_plan_fragment->SetSinkNode(query_context_ptr_, @@ -195,7 +195,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu phys_op->right()->GetOutputNames(), phys_op->right()->GetOutputTypes()); BuildFragments(phys_op->right(), next_plan_fragment.get()); - current_fragment_ptr->AddChild(Move(next_plan_fragment)); + current_fragment_ptr->AddChild(std::move(next_plan_fragment)); } return; } @@ -208,7 +208,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu case PhysicalOperatorType::kJoinMerge: case PhysicalOperatorType::kJoinIndex: case PhysicalOperatorType::kCrossProduct: { - Error(Format("Not support {}.", phys_op->GetName())); + Error(fmt::format("Not support {}.", phys_op->GetName())); } case PhysicalOperatorType::kKnnScan: { // current_fragment_ptr->AddSourceNode(query_context_ptr_, @@ -224,10 +224,10 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu // phys_op->left()->GetOutputNames(), // phys_op->left()->GetOutputTypes()); // BuildFragments(phys_op->left(), next_plan_fragment.get()); - // current_fragment_ptr->AddChild(Move(next_plan_fragment)); + // current_fragment_ptr->AddChild(std::move(next_plan_fragment)); // current_fragment_ptr->SetFragmentType(FragmentType::kSerialMaterialize); if (phys_op->left() != nullptr or phys_op->right() != nullptr) { - Error(Format("{} shouldn't have child.", phys_op->GetName())); + Error(fmt::format("{} shouldn't have child.", phys_op->GetName())); } PhysicalKnnScan *knn_scan = static_cast(phys_op); if (knn_scan->TaskCount() == 1) { @@ -242,7 +242,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu case PhysicalOperatorType::kTableScan: case PhysicalOperatorType::kIndexScan: { if (phys_op->left() != nullptr or phys_op->right() != nullptr) { - Error(Format("{} shouldn't have child.", phys_op->GetName())); + Error(fmt::format("{} shouldn't have child.", phys_op->GetName())); } current_fragment_ptr->SetFragmentType(FragmentType::kParallelStream); current_fragment_ptr->AddOperator(phys_op); @@ -264,7 +264,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu } case PhysicalOperatorType::kCreateIndexPrepare: { if (phys_op->left() != nullptr || phys_op->right() != nullptr) { - Error(Format("Invalid input node of {}", phys_op->GetName())); + Error(fmt::format("Invalid input node of {}", phys_op->GetName())); } current_fragment_ptr->AddOperator(phys_op); current_fragment_ptr->SetFragmentType(FragmentType::kSerialMaterialize); @@ -273,7 +273,7 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu } case PhysicalOperatorType::kCreateIndexDo: { if (phys_op->left() == nullptr || phys_op->right() != nullptr) { - Error(Format("Invalid input node of {}", phys_op->GetName())); + Error(fmt::format("Invalid input node of {}", phys_op->GetName())); } current_fragment_ptr->AddOperator(phys_op); current_fragment_ptr->SetFragmentType(FragmentType::kParallelMaterialize); @@ -286,12 +286,12 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu phys_op->left()->GetOutputTypes()); BuildFragments(phys_op->left(), next_plan_fragment.get()); - current_fragment_ptr->AddChild(Move(next_plan_fragment)); + current_fragment_ptr->AddChild(std::move(next_plan_fragment)); return; } case PhysicalOperatorType::kCreateIndexFinish: { if (phys_op->left() == nullptr || phys_op->right() != nullptr) { - Error(Format("Invalid input node of {}", phys_op->GetName())); + Error(fmt::format("Invalid input node of {}", phys_op->GetName())); } current_fragment_ptr->AddOperator(phys_op); current_fragment_ptr->SetFragmentType(FragmentType::kSerialMaterialize); @@ -304,11 +304,11 @@ void FragmentBuilder::BuildFragments(PhysicalOperator *phys_op, PlanFragment *cu phys_op->left()->GetOutputTypes()); BuildFragments(phys_op->left(), next_plan_fragment.get()); - current_fragment_ptr->AddChild(Move(next_plan_fragment)); + current_fragment_ptr->AddChild(std::move(next_plan_fragment)); return; } default: { - LOG_ERROR(Format("Invalid operator type: {} in Fragment Builder", phys_op->GetName())); + LOG_ERROR(fmt::format("Invalid operator type: {} in Fragment Builder", phys_op->GetName())); break; } } diff --git a/src/executor/hash_table.cpp b/src/executor/hash_table.cpp index d6326d3459..823e520876 100644 --- a/src/executor/hash_table.cpp +++ b/src/executor/hash_table.cpp @@ -83,7 +83,7 @@ void HashTable::Append(const Vector> &columns, SizeT blo UniquePtr hash_key = MakeUnique(key_size_); SizeT column_count = columns.size(); for (SizeT row_id = 0; row_id < row_count; ++row_id) { - Memset(hash_key.get(), 0, key_size_); + std::memset(hash_key.get(), 0, key_size_); SizeT offset = 0; for (SizeT column_id = 0; column_id < column_count; ++column_id) { @@ -103,14 +103,14 @@ void HashTable::Append(const Vector> &columns, SizeT blo if (data_type.type() == kVarchar) { VarcharT *vchar_ptr = &((VarcharT *)(columns[column_id]->data_ptr_))[row_id]; if (vchar_ptr->IsInlined()) { - Memcpy(target_ptr, vchar_ptr->prefix, vchar_ptr->length); + std::memcpy(target_ptr, vchar_ptr->prefix, vchar_ptr->length); } else { - Memcpy(target_ptr, vchar_ptr->ptr, vchar_ptr->length); + std::memcpy(target_ptr, vchar_ptr->ptr, vchar_ptr->length); } offset += (vchar_ptr->length + 1); } else { SizeT type_size = types_[column_id].Size(); - Memcpy(target_ptr, columns[column_id]->data_ptr_ + type_size * row_id, type_size); + std::memcpy(target_ptr, columns[column_id]->data_ptr_ + type_size * row_id, type_size); offset += (type_size + 1); } } diff --git a/src/executor/operator/physcial_drop_view.cppm b/src/executor/operator/physcial_drop_view.cppm index b975b48adb..ac70ac4e00 100644 --- a/src/executor/operator/physcial_drop_view.cppm +++ b/src/executor/operator/physcial_drop_view.cppm @@ -35,8 +35,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kDropView, nullptr, nullptr, id, load_metas), schema_name_(Move(schema_name)), - view_name_(Move(view_name)), conflict_type_(conflict_type), output_names_(Move(output_names)), output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kDropView, nullptr, nullptr, id, load_metas), schema_name_(std::move(schema_name)), + view_name_(std::move(view_name)), conflict_type_(conflict_type), output_names_(std::move(output_names)), output_types_(std::move(output_types)) {} ~PhysicalDropView() override = default; diff --git a/src/executor/operator/physical_aggregate.cpp b/src/executor/operator/physical_aggregate.cpp index dd2022fafb..1b917ced38 100644 --- a/src/executor/operator/physical_aggregate.cpp +++ b/src/executor/operator/physical_aggregate.cpp @@ -282,14 +282,14 @@ void PhysicalAggregate::GroupByInputTable(const SharedPtr &input_tabl // = ((VarcharT // *)(input_datablocks[input_block_id]->column_vectors[column_id]->data()))[input_offset]; if // (src_ref.IsInlined()) { - // Memcpy((char *)&dst_ref, (char *)&src_ref, sizeof(VarcharT)); + // std::memcpy((char *)&dst_ref, (char *)&src_ref, sizeof(VarcharT)); // } else { // dst_ref.length = src_ref.length; - // Memcpy(dst_ref.prefix, src_ref.prefix, VarcharT::PREFIX_LENGTH); + // std::memcpy(dst_ref.prefix, src_ref.prefix, VarcharT::PREFIX_LENGTH); // // dst_ref.ptr = // output_datablock->column_vectors[column_id]->buffer_->fix_heap_mgr_->Allocate(src_ref.length); - // Memcpy(dst_ref.ptr, src_ref.ptr, src_ref.length); + // std::memcpy(dst_ref.ptr, src_ref.ptr, src_ref.length); // } break; } @@ -324,7 +324,7 @@ void PhysicalAggregate::GroupByInputTable(const SharedPtr &input_tabl } if (output_row_idx != datablock_size) { - Error("Expected block size: " + ToStr(datablock_size) + ", but only copied data size: " + ToStr(output_row_idx)); + Error("Expected block size: " + std::to_string(datablock_size) + ", but only copied data size: " + std::to_string(output_row_idx)); } for (SizeT column_id = 0; column_id < column_count; ++column_id) { @@ -413,14 +413,14 @@ void PhysicalAggregate::GenerateGroupByResult(const SharedPtr &input_ // VarcharT &src_ref = ((VarcharT // *)(input_datablocks[input_block_id]->column_vectors[column_id]->data()))[input_offset]; if // (src_ref.IsInlined()) { - // Memcpy((char *)&dst_ref, (char *)&src_ref, sizeof(VarcharT)); + // std::memcpy((char *)&dst_ref, (char *)&src_ref, sizeof(VarcharT)); // } else { // dst_ref.length = src_ref.length; - // Memcpy(dst_ref.prefix, src_ref.prefix, VarcharT::PREFIX_LENGTH); + // std::memcpy(dst_ref.prefix, src_ref.prefix, VarcharT::PREFIX_LENGTH); // // dst_ref.ptr = // output_datablock->column_vectors[column_id]->buffer_->fix_heap_mgr_->Allocate(src_ref.length); - // Memcpy(dst_ref.ptr, src_ref.ptr, src_ref.length); + // std::memcpy(dst_ref.ptr, src_ref.ptr, src_ref.length); // } break; } diff --git a/src/executor/operator/physical_aggregate.cppm b/src/executor/operator/physical_aggregate.cppm index e25016ce0b..2c1e764806 100644 --- a/src/executor/operator/physical_aggregate.cppm +++ b/src/executor/operator/physical_aggregate.cppm @@ -45,8 +45,8 @@ public: Vector> aggregates, u64 aggregate_index, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kAggregate, Move(left), nullptr, id, load_metas), groups_(Move(groups)), - aggregates_(Move(aggregates)), groupby_index_(groupby_index), aggregate_index_(aggregate_index) {} + : PhysicalOperator(PhysicalOperatorType::kAggregate, std::move(left), nullptr, id, load_metas), groups_(std::move(groups)), + aggregates_(std::move(aggregates)), groupby_index_(groupby_index), aggregate_index_(aggregate_index) {} ~PhysicalAggregate() override = default; diff --git a/src/executor/operator/physical_alter.cppm b/src/executor/operator/physical_alter.cppm index a25a3bdebe..64e7cf7624 100644 --- a/src/executor/operator/physical_alter.cppm +++ b/src/executor/operator/physical_alter.cppm @@ -34,7 +34,7 @@ public: u64 id, SharedPtr> load_metas) : PhysicalOperator(PhysicalOperatorType::kAlter, nullptr, nullptr, id, load_metas), - output_names_(Move(output_names)), output_types_(Move(output_types)) {} + output_names_(std::move(output_names)), output_types_(std::move(output_types)) {} ~PhysicalAlter() override = default; diff --git a/src/executor/operator/physical_command.cpp b/src/executor/operator/physical_command.cpp index a4b786efb4..2e6ffd59f9 100644 --- a/src/executor/operator/physical_command.cpp +++ b/src/executor/operator/physical_command.cpp @@ -51,7 +51,7 @@ bool PhysicalCommand::Execute(QueryContext *query_context, OperatorState *operat SetCmd *set_command = (SetCmd *)(command_info_.get()); if(set_command->var_name() == enable_profiling_name) { if(set_command->value_type() != SetVarType::kBool) { - Error(Format("Wrong value type: {}", set_command->var_name())); + Error(fmt::format("Wrong value type: {}", set_command->var_name())); } query_context->current_session()->options()->enable_profiling_ = set_command->value_bool(); return true; @@ -59,7 +59,7 @@ bool PhysicalCommand::Execute(QueryContext *query_context, OperatorState *operat if(set_command->var_name() == profile_history_capacity_name) { if(set_command->value_type() != SetVarType::kInteger) { - Error(Format("Wrong value type: {}", set_command->var_name())); + Error(fmt::format("Wrong value type: {}", set_command->var_name())); } query_context->current_session()->options()->profile_history_capacity_ = set_command->value_int(); return true; @@ -67,11 +67,11 @@ bool PhysicalCommand::Execute(QueryContext *query_context, OperatorState *operat if(set_command->var_name() == log_level) { if(set_command->value_type() != SetVarType::kString) { - Error(Format("Wrong value type: {}", set_command->var_name())); + Error(fmt::format("Wrong value type: {}", set_command->var_name())); } if(set_command->scope() != SetScope::kGlobal) { - Error(Format("log_level is a global config parameter.", set_command->var_name())); + Error(fmt::format("log_level is a global config parameter.", set_command->var_name())); } if(set_command->value_str() == "trace") { @@ -99,27 +99,27 @@ bool PhysicalCommand::Execute(QueryContext *query_context, OperatorState *operat return true; } - Error(Format("Unknown log level: {}.", set_command->value_str())); + Error(fmt::format("Unknown log level: {}.", set_command->value_str())); // query_context->global_config()->set_worker_cpu_number(set_command->value_int()); return true; } if(set_command->var_name() == worker_cpu_limit) { if(set_command->value_type() != SetVarType::kInteger) { - Error(Format("Wrong value type: {}", set_command->var_name())); + Error(fmt::format("Wrong value type: {}", set_command->var_name())); } if(set_command->scope() != SetScope::kGlobal) { - Error(Format("cpu_count is a global config parameter.", set_command->var_name())); + Error(fmt::format("cpu_count is a global config parameter.", set_command->var_name())); } - Error(Format("You need to change the CPU limit before start the system.", set_command->var_name())); + Error(fmt::format("You need to change the CPU limit before start the system.", set_command->var_name())); // query_context->global_config()->set_worker_cpu_number(set_command->value_int()); return true; } { - Error(Format("Unknown command: {}", set_command->var_name())); + Error(fmt::format("Unknown command: {}", set_command->var_name())); } break; } @@ -127,7 +127,7 @@ bool PhysicalCommand::Execute(QueryContext *query_context, OperatorState *operat ExportCmd *export_command = (ExportCmd *)(command_info_.get()); auto profiler_record = query_context->current_session()->GetProfilerRecord(export_command->file_no()); if (profiler_record == nullptr) { - Error(Format("The record does not exist: {}", export_command->file_no())); + Error(fmt::format("The record does not exist: {}", export_command->file_no())); } LocalFileSystem fs; FileWriter file_writer(fs, export_command->file_name(), 128); diff --git a/src/executor/operator/physical_command.cppm b/src/executor/operator/physical_command.cppm index a949dc66c2..2357791a4b 100644 --- a/src/executor/operator/physical_command.cppm +++ b/src/executor/operator/physical_command.cppm @@ -35,8 +35,8 @@ public: SharedPtr> output_names, SharedPtr>> output_types, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCommand, nullptr, nullptr, id, load_metas), command_info_(Move(command_info)), - output_names_(Move(output_names)), output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kCommand, nullptr, nullptr, id, load_metas), command_info_(std::move(command_info)), + output_names_(std::move(output_names)), output_types_(std::move(output_types)) {} ~PhysicalCommand() override = default; diff --git a/src/executor/operator/physical_create_collection.cpp b/src/executor/operator/physical_create_collection.cpp index 0a61614958..4f351899c3 100644 --- a/src/executor/operator/physical_create_collection.cpp +++ b/src/executor/operator/physical_create_collection.cpp @@ -36,9 +36,9 @@ PhysicalCreateCollection::PhysicalCreateCollection(SharedPtr schema_name u64 table_index, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCreateCollection, nullptr, nullptr, id, load_metas), schema_name_(Move(schema_name)), - collection_name_(Move(collection_name)), conflict_type_(conflict_type), table_index_(table_index), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kCreateCollection, nullptr, nullptr, id, load_metas), schema_name_(std::move(schema_name)), + collection_name_(std::move(collection_name)), conflict_type_(conflict_type), table_index_(table_index), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} void PhysicalCreateCollection::Init() {} diff --git a/src/executor/operator/physical_create_index.cpp b/src/executor/operator/physical_create_index.cpp index c272e13a86..b59cc14f96 100644 --- a/src/executor/operator/physical_create_index.cpp +++ b/src/executor/operator/physical_create_index.cpp @@ -35,7 +35,7 @@ bool PhysicalCreateIndex::Execute(QueryContext *query_context, OperatorState *op auto *txn = query_context->GetTxn(); Status status = txn->CreateIndex(*schema_name_, *table_name_, index_def_ptr_, conflict_type_, false); if (!status.ok()) { - operator_state->error_message_ = Move(status.msg_); + operator_state->error_message_ = std::move(status.msg_); } operator_state->SetComplete(); return true; diff --git a/src/executor/operator/physical_create_index_do.cpp b/src/executor/operator/physical_create_index_do.cpp index e028a3fb65..93a271da55 100644 --- a/src/executor/operator/physical_create_index_do.cpp +++ b/src/executor/operator/physical_create_index_do.cpp @@ -52,7 +52,7 @@ PhysicalCreateIndexDo::PhysicalCreateIndexDo(u64 id, SharedPtr> output_names, SharedPtr>> output_types, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCreateIndexDo, Move(left), nullptr, id, load_metas), base_table_ref_(base_table_ref), + : PhysicalOperator(PhysicalOperatorType::kCreateIndexDo, std::move(left), nullptr, id, load_metas), base_table_ref_(base_table_ref), index_name_(index_name), output_names_(output_names), output_types_(output_types) {} void PhysicalCreateIndexDo::Init() {} @@ -65,7 +65,7 @@ bool PhysicalCreateIndexDo::Execute(QueryContext *query_context, OperatorState * auto status = txn->CreateIndexDo(*base_table_ref_->schema_name(), *base_table_ref_->table_name(), *index_name_, create_index_idxes); if (!status.ok()) { - operator_state->error_message_ = Move(status.msg_); + operator_state->error_message_ = std::move(status.msg_); return false; } operator_state->SetComplete(); diff --git a/src/executor/operator/physical_create_index_finish.cpp b/src/executor/operator/physical_create_index_finish.cpp index c2649ccfac..b633621156 100644 --- a/src/executor/operator/physical_create_index_finish.cpp +++ b/src/executor/operator/physical_create_index_finish.cpp @@ -35,7 +35,7 @@ PhysicalCreateIndexFinish::PhysicalCreateIndexFinish(u64 id, SharedPtr> output_names, SharedPtr>> output_types, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCreateIndexFinish, Move(left), nullptr, id, load_metas), db_name_(db_name), table_name_(table_name), + : PhysicalOperator(PhysicalOperatorType::kCreateIndexFinish, std::move(left), nullptr, id, load_metas), db_name_(db_name), table_name_(table_name), index_def_(index_def), output_names_(output_names), output_types_(output_types) {} void PhysicalCreateIndexFinish::Init() {} diff --git a/src/executor/operator/physical_create_index_prepare.cpp b/src/executor/operator/physical_create_index_prepare.cpp index ad8b60b1e5..45f1f91c2d 100644 --- a/src/executor/operator/physical_create_index_prepare.cpp +++ b/src/executor/operator/physical_create_index_prepare.cpp @@ -62,7 +62,7 @@ bool PhysicalCreateIndexPrepare::Execute(QueryContext *query_context, OperatorSt auto *txn = query_context->GetTxn(); Status status = txn->CreateIndex(*schema_name_, *table_name_, index_def_ptr_, conflict_type_, true); if (!status.ok()) { - operator_state->error_message_ = Move(status.msg_); + operator_state->error_message_ = std::move(status.msg_); } operator_state->SetComplete(); return true; diff --git a/src/executor/operator/physical_create_schema.cpp b/src/executor/operator/physical_create_schema.cpp index 2505f971e2..0df28017ed 100644 --- a/src/executor/operator/physical_create_schema.cpp +++ b/src/executor/operator/physical_create_schema.cpp @@ -34,7 +34,7 @@ bool PhysicalCreateSchema::Execute(QueryContext *query_context, OperatorState *o auto txn = query_context->GetTxn(); Status status = txn->CreateDatabase(*schema_name_, conflict_type_); auto create_database_operator_state = (CreateDatabaseOperatorState *)(operator_state); - create_database_operator_state->error_message_ = Move(status.msg_); + create_database_operator_state->error_message_ = std::move(status.msg_); operator_state->SetComplete(); return true; } diff --git a/src/executor/operator/physical_create_schema.cppm b/src/executor/operator/physical_create_schema.cppm index c2e0b89ea5..cec50c0f39 100644 --- a/src/executor/operator/physical_create_schema.cppm +++ b/src/executor/operator/physical_create_schema.cppm @@ -36,8 +36,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCreateDatabase, nullptr, nullptr, id, load_metas), schema_name_(Move(schema_name)), - conflict_type_(conflict_type), output_names_(Move(output_names)), output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kCreateDatabase, nullptr, nullptr, id, load_metas), schema_name_(std::move(schema_name)), + conflict_type_(conflict_type), output_names_(std::move(output_names)), output_types_(std::move(output_types)) {} ~PhysicalCreateSchema() override = default; diff --git a/src/executor/operator/physical_create_table.cpp b/src/executor/operator/physical_create_table.cpp index ab00517f7e..348e993f9f 100644 --- a/src/executor/operator/physical_create_table.cpp +++ b/src/executor/operator/physical_create_table.cpp @@ -37,9 +37,9 @@ PhysicalCreateTable::PhysicalCreateTable(SharedPtr schema_name, u64 table_index, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCreateTable, nullptr, nullptr, id, load_metas), table_def_ptr_(Move(table_def_ptr)), - schema_name_(Move(schema_name)), table_index_(table_index), conflict_type_(conflict_type), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kCreateTable, nullptr, nullptr, id, load_metas), table_def_ptr_(std::move(table_def_ptr)), + schema_name_(std::move(schema_name)), table_index_(table_index), conflict_type_(conflict_type), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} PhysicalCreateTable::PhysicalCreateTable(SharedPtr schema_name, UniquePtr input, @@ -49,8 +49,8 @@ PhysicalCreateTable::PhysicalCreateTable(SharedPtr schema_name, u64 table_index, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCreateTable, Move(input), nullptr, id, load_metas), schema_name_(Move(schema_name)), - table_index_(table_index), conflict_type_(conflict_type), output_names_(Move(output_names)), output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kCreateTable, std::move(input), nullptr, id, load_metas), schema_name_(std::move(schema_name)), + table_index_(table_index), conflict_type_(conflict_type), output_names_(std::move(output_names)), output_types_(std::move(output_types)) {} void PhysicalCreateTable::Init() {} @@ -61,7 +61,7 @@ bool PhysicalCreateTable::Execute(QueryContext *query_context, OperatorState *op Status status = txn->CreateTable(*schema_name_, table_def_ptr_, conflict_type_); auto create_table_operator_state = (CreateTableOperatorState *)operator_state; if (!status.ok()) { - create_table_operator_state->error_message_ = Move(status.msg_); + create_table_operator_state->error_message_ = std::move(status.msg_); } operator_state->SetComplete(); return true; diff --git a/src/executor/operator/physical_create_view.cppm b/src/executor/operator/physical_create_view.cppm index 964adee02a..27a7bd01c2 100644 --- a/src/executor/operator/physical_create_view.cppm +++ b/src/executor/operator/physical_create_view.cppm @@ -35,8 +35,8 @@ public: SharedPtr>> types_ptr, SharedPtr create_view_info, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCreateView, nullptr, nullptr, id, load_metas), create_view_info_(Move(create_view_info)), - output_names_(Move(names_ptr)), output_types_(Move(types_ptr)) {} + : PhysicalOperator(PhysicalOperatorType::kCreateView, nullptr, nullptr, id, load_metas), create_view_info_(std::move(create_view_info)), + output_names_(std::move(names_ptr)), output_types_(std::move(types_ptr)) {} ~PhysicalCreateView() override = default; diff --git a/src/executor/operator/physical_cross_product.cppm b/src/executor/operator/physical_cross_product.cppm index 44c0c10fa3..850929941d 100644 --- a/src/executor/operator/physical_cross_product.cppm +++ b/src/executor/operator/physical_cross_product.cppm @@ -31,7 +31,7 @@ namespace infinity { export class PhysicalCrossProduct final : public PhysicalOperator { public: explicit PhysicalCrossProduct(u64 id, UniquePtr left, UniquePtr right, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kCrossProduct, Move(left), Move(right), id, load_metas) {} + : PhysicalOperator(PhysicalOperatorType::kCrossProduct, std::move(left), std::move(right), id, load_metas) {} ~PhysicalCrossProduct() override = default; diff --git a/src/executor/operator/physical_delete.cpp b/src/executor/operator/physical_delete.cpp index 8420a81aff..608fdaa15e 100644 --- a/src/executor/operator/physical_delete.cpp +++ b/src/executor/operator/physical_delete.cpp @@ -49,7 +49,7 @@ bool PhysicalDelete::Execute(QueryContext *query_context, OperatorState *operato SharedPtr column_vector = input_data_block_ptr->column_vectors[i]; if (column_vector->data_type()->type() == LogicalType::kRowID) { row_ids.resize(column_vector->Size()); - Memcpy(row_ids.data(), column_vector->data(), column_vector->Size() * sizeof(RowID)); + std::memcpy(row_ids.data(), column_vector->data(), column_vector->Size() * sizeof(RowID)); break; } } diff --git a/src/executor/operator/physical_delete.cppm b/src/executor/operator/physical_delete.cppm index e19220869a..07853b5d94 100644 --- a/src/executor/operator/physical_delete.cppm +++ b/src/executor/operator/physical_delete.cppm @@ -31,7 +31,7 @@ namespace infinity { export class PhysicalDelete final : public PhysicalOperator { public: explicit PhysicalDelete(u64 id, UniquePtr left, TableEntry *table_entry_ptr, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kDelete, Move(left), nullptr, id, load_metas), table_entry_ptr_(table_entry_ptr) {} + : PhysicalOperator(PhysicalOperatorType::kDelete, std::move(left), nullptr, id, load_metas), table_entry_ptr_(table_entry_ptr) {} ~PhysicalDelete() override = default; diff --git a/src/executor/operator/physical_drop_collection.cppm b/src/executor/operator/physical_drop_collection.cppm index f5950bf882..e9324aad83 100644 --- a/src/executor/operator/physical_drop_collection.cppm +++ b/src/executor/operator/physical_drop_collection.cppm @@ -34,8 +34,8 @@ public: ConflictType conflict_type, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kDropCollection, nullptr, nullptr, id, load_metas), schema_name_(Move(schema_name)), - collection_name_(Move(collection_name)), conflict_type_(conflict_type) {} + : PhysicalOperator(PhysicalOperatorType::kDropCollection, nullptr, nullptr, id, load_metas), schema_name_(std::move(schema_name)), + collection_name_(std::move(collection_name)), conflict_type_(conflict_type) {} ~PhysicalDropCollection() override = default; diff --git a/src/executor/operator/physical_drop_index.cpp b/src/executor/operator/physical_drop_index.cpp index e386799534..eed5af9242 100644 --- a/src/executor/operator/physical_drop_index.cpp +++ b/src/executor/operator/physical_drop_index.cpp @@ -34,7 +34,7 @@ bool PhysicalDropIndex::Execute(QueryContext *query_context, OperatorState *oper Status status = txn->DropIndexByName(*schema_name_, *table_name_, *index_name_, conflict_type_); auto drop_index_operator_state = static_cast(operator_state); - drop_index_operator_state->error_message_ = Move(status.msg_); + drop_index_operator_state->error_message_ = std::move(status.msg_); // Generate the result Vector> column_defs = { diff --git a/src/executor/operator/physical_drop_index.cppm b/src/executor/operator/physical_drop_index.cppm index 891c2908bc..70f4d74b6d 100644 --- a/src/executor/operator/physical_drop_index.cppm +++ b/src/executor/operator/physical_drop_index.cppm @@ -38,9 +38,9 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kDropIndex, nullptr, nullptr, id, load_metas), schema_name_(Move(schema_name)), - table_name_(Move(table_name)), index_name_(Move(index_name)), conflict_type_(conflict_type), - output_names_(Move(output_names)), output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kDropIndex, nullptr, nullptr, id, load_metas), schema_name_(std::move(schema_name)), + table_name_(std::move(table_name)), index_name_(std::move(index_name)), conflict_type_(conflict_type), + output_names_(std::move(output_names)), output_types_(std::move(output_types)) {} ~PhysicalDropIndex() override = default; diff --git a/src/executor/operator/physical_drop_schema.cpp b/src/executor/operator/physical_drop_schema.cpp index 4af4ca297d..0ea8ea4c4c 100644 --- a/src/executor/operator/physical_drop_schema.cpp +++ b/src/executor/operator/physical_drop_schema.cpp @@ -36,7 +36,7 @@ bool PhysicalDropSchema::Execute(QueryContext *query_context, OperatorState *ope auto txn = query_context->GetTxn(); Status status = txn->DropDatabase(*schema_name_, conflict_type_); auto drop_database_operator_state = (DropDatabaseOperatorState *)(operator_state); - drop_database_operator_state->error_message_ = Move(status.msg_); + drop_database_operator_state->error_message_ = std::move(status.msg_); // Generate the result Vector> column_defs = { diff --git a/src/executor/operator/physical_drop_schema.cppm b/src/executor/operator/physical_drop_schema.cppm index 6b0548edbf..12cdb8191a 100644 --- a/src/executor/operator/physical_drop_schema.cppm +++ b/src/executor/operator/physical_drop_schema.cppm @@ -35,8 +35,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kDropDatabase, nullptr, nullptr, id, load_metas), schema_name_(Move(schema_name)), - conflict_type_(conflict_type), output_names_(Move(output_names)), output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kDropDatabase, nullptr, nullptr, id, load_metas), schema_name_(std::move(schema_name)), + conflict_type_(conflict_type), output_names_(std::move(output_names)), output_types_(std::move(output_types)) {} ~PhysicalDropSchema() override = default; diff --git a/src/executor/operator/physical_drop_table.cpp b/src/executor/operator/physical_drop_table.cpp index fe41a80792..1705f30106 100644 --- a/src/executor/operator/physical_drop_table.cpp +++ b/src/executor/operator/physical_drop_table.cpp @@ -38,7 +38,7 @@ bool PhysicalDropTable::Execute(QueryContext *query_context, OperatorState *oper auto drop_table_operator_state = (DropTableOperatorState *)(operator_state); if(!status.ok()) { - drop_table_operator_state->error_message_ = Move(status.msg_); + drop_table_operator_state->error_message_ = std::move(status.msg_); } // Generate the result diff --git a/src/executor/operator/physical_drop_table.cppm b/src/executor/operator/physical_drop_table.cppm index c759e65761..06d82a10f9 100644 --- a/src/executor/operator/physical_drop_table.cppm +++ b/src/executor/operator/physical_drop_table.cppm @@ -36,9 +36,9 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kDropTable, nullptr, nullptr, id, load_metas), schema_name_(Move(schema_name)), - table_name_(Move(tbl_name)), conflict_type_(conflict_type), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kDropTable, nullptr, nullptr, id, load_metas), schema_name_(std::move(schema_name)), + table_name_(std::move(tbl_name)), conflict_type_(conflict_type), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalDropTable() override = default; diff --git a/src/executor/operator/physical_except.cppm b/src/executor/operator/physical_except.cppm index 246f256399..7e482f10fa 100644 --- a/src/executor/operator/physical_except.cppm +++ b/src/executor/operator/physical_except.cppm @@ -33,8 +33,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kExcept, nullptr, nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kExcept, nullptr, nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalExcept() override = default; diff --git a/src/executor/operator/physical_explain.cpp b/src/executor/operator/physical_explain.cpp index 8ccdc0f9cf..2be1df194e 100644 --- a/src/executor/operator/physical_explain.cpp +++ b/src/executor/operator/physical_explain.cpp @@ -153,7 +153,7 @@ bool PhysicalExplain::Execute(QueryContext *, OperatorState *operator_state) { output_data_block->Init(column_vectors); ExplainOperatorState *explain_operator_state = static_cast(operator_state); - explain_operator_state->data_block_array_.emplace_back(Move(output_data_block)); + explain_operator_state->data_block_array_.emplace_back(std::move(output_data_block)); operator_state->SetComplete(); return true; } diff --git a/src/executor/operator/physical_explain.cppm b/src/executor/operator/physical_explain.cppm index 316218a21b..50b269fb9f 100644 --- a/src/executor/operator/physical_explain.cppm +++ b/src/executor/operator/physical_explain.cppm @@ -34,7 +34,7 @@ public: SharedPtr>> text_array, UniquePtr left, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kExplain, Move(left), nullptr, id, load_metas), explain_type_(type), texts_(Move(text_array)) {} + : PhysicalOperator(PhysicalOperatorType::kExplain, std::move(left), nullptr, id, load_metas), explain_type_(type), texts_(std::move(text_array)) {} ~PhysicalExplain() override = default; @@ -42,9 +42,9 @@ public: bool Execute(QueryContext *query_context, OperatorState *operator_state) final; - void SetExplainText(SharedPtr>> text) { texts_ = Move(text); } + void SetExplainText(SharedPtr>> text) { texts_ = std::move(text); } - void SetExplainTaskText(SharedPtr>> text) { task_texts_ = Move(text); } + void SetExplainTaskText(SharedPtr>> text) { task_texts_ = std::move(text); } inline SharedPtr> GetOutputNames() const final { return output_names_; } diff --git a/src/executor/operator/physical_export.cppm b/src/executor/operator/physical_export.cppm index ddeaab6d73..5d014b6a13 100644 --- a/src/executor/operator/physical_export.cppm +++ b/src/executor/operator/physical_export.cppm @@ -37,8 +37,8 @@ public: char delimiter, CopyFileType type, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kExport, nullptr, nullptr, id, load_metas), file_type_(type), file_path_(Move(file_path)), - table_name_(Move(table_name)), schema_name_(Move(schema_name)), header_(header), delimiter_(delimiter) {} + : PhysicalOperator(PhysicalOperatorType::kExport, nullptr, nullptr, id, load_metas), file_type_(type), file_path_(std::move(file_path)), + table_name_(std::move(table_name)), schema_name_(std::move(schema_name)), header_(header), delimiter_(delimiter) {} ~PhysicalExport() override = default; diff --git a/src/executor/operator/physical_filter.cpp b/src/executor/operator/physical_filter.cpp index 015de727a4..f639515cf8 100644 --- a/src/executor/operator/physical_filter.cpp +++ b/src/executor/operator/physical_filter.cpp @@ -69,7 +69,7 @@ bool PhysicalFilter::Execute(QueryContext *, OperatorState *operator_state) { UniquePtr data_block = DataBlock::MakeUniquePtr(); data_block->Init(*GetOutputTypes()); DataBlock* output_data_block = data_block.get(); - operator_state->data_block_array_.emplace_back(Move(data_block)); + operator_state->data_block_array_.emplace_back(std::move(data_block)); SharedPtr condition_state = ExpressionState::CreateState(condition_); DataBlock* input_data_block = prev_op_state->data_block_array_[block_idx].get(); @@ -80,7 +80,7 @@ bool PhysicalFilter::Execute(QueryContext *, OperatorState *operator_state) { output_data_block, input_data_block->row_count()); - LOG_TRACE(Format("{} rows after filter", selected_count)); + LOG_TRACE(fmt::format("{} rows after filter", selected_count)); } // Clean input data block array; diff --git a/src/executor/operator/physical_filter.cppm b/src/executor/operator/physical_filter.cppm index 60a0982a69..298a9f24ce 100644 --- a/src/executor/operator/physical_filter.cppm +++ b/src/executor/operator/physical_filter.cppm @@ -34,7 +34,7 @@ namespace infinity { export class PhysicalFilter : public PhysicalOperator { public: explicit PhysicalFilter(u64 id, UniquePtr left, SharedPtr condition, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kFilter, Move(left), nullptr, id, load_metas), condition_(Move(condition)) {} + : PhysicalOperator(PhysicalOperatorType::kFilter, std::move(left), nullptr, id, load_metas), condition_(std::move(condition)) {} ~PhysicalFilter() override = default; diff --git a/src/executor/operator/physical_fusion.cpp b/src/executor/operator/physical_fusion.cpp index 28b1d42f84..be911217c2 100644 --- a/src/executor/operator/physical_fusion.cpp +++ b/src/executor/operator/physical_fusion.cpp @@ -54,7 +54,7 @@ PhysicalFusion::PhysicalFusion(u64 id, UniquePtr right, SharedPtr fusion_expr, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kFusion, Move(left), Move(right), id, load_metas), fusion_expr_(fusion_expr) {} + : PhysicalOperator(PhysicalOperatorType::kFusion, std::move(left), std::move(right), id, load_metas), fusion_expr_(fusion_expr) {} PhysicalFusion::~PhysicalFusion() {} @@ -66,7 +66,7 @@ bool PhysicalFusion::Execute(QueryContext *query_context, OperatorState *operato return false; } if ( fusion_expr_->method_.compare("rrf") != 0) { - throw ExecutorException(Format("Fusion method {} is not implemented.", fusion_expr_->method_)); + throw ExecutorException(fmt::format("Fusion method {} is not implemented.", fusion_expr_->method_)); } SizeT rank_constant = 60; if (fusion_expr_->options_.get() != nullptr) { @@ -88,7 +88,7 @@ bool PhysicalFusion::Execute(QueryContext *query_context, OperatorState *operato SizeT base_rank = 1; for (UniquePtr &input_data_block : input_blocks) { if (input_data_block->column_count() != GetOutputTypes()->size()) { - Error(Format("input_data_block column count {} is incorrect, expect {}.", input_data_block->column_count(), GetOutputTypes()->size())); + Error(fmt::format("input_data_block column count {} is incorrect, expect {}.", input_data_block->column_count(), GetOutputTypes()->size())); } auto &row_id_column = *input_data_block->column_vectors[input_data_block->column_count() - 1]; auto row_ids = reinterpret_cast(row_id_column.data()); @@ -123,27 +123,27 @@ bool PhysicalFusion::Execute(QueryContext *query_context, OperatorState *operato std::sort(std::begin(rrf_vec), std::end(rrf_vec), [](const RRFRankDoc &lhs, const RRFRankDoc &rhs) noexcept { return lhs.score > rhs.score; }); // 4 generate output data blocks - UniquePtr output_data_block = Move(DataBlock::MakeUniquePtr()); + UniquePtr output_data_block = DataBlock::MakeUniquePtr(); output_data_block->Init(*GetOutputTypes()); SizeT row_count = 0; for (RRFRankDoc &doc : rrf_vec) { // 4.1 get every doc's columns from input data blocks if (row_count == output_data_block->capacity()) { output_data_block->Finalize(); - operator_state->data_block_array_.push_back(Move(output_data_block)); - output_data_block = Move(DataBlock::MakeUniquePtr()); + operator_state->data_block_array_.push_back(std::move(output_data_block)); + output_data_block = DataBlock::MakeUniquePtr(); row_count = 0; } SizeT fragment_idx = 0; while (fragment_idx < doc.ranks.size() && doc.ranks[fragment_idx] == 0) fragment_idx++; if (fragment_idx >= doc.ranks.size()) { - throw ExecutorException(Format("Cannot find fragment_idx")); + throw ExecutorException(fmt::format("Cannot find fragment_idx")); } u64 fragment_id = fragment_ids[fragment_idx]; auto &input_blocks = fusion_operator_state->input_data_blocks_[fragment_id]; if (input_blocks.size() == 0) { - throw ExecutorException(Format("input_data_blocks_[{}] is empty.", fragment_id)); + throw ExecutorException(fmt::format("input_data_blocks_[{}] is empty.", fragment_id)); } SizeT block_idx = 0; SizeT row_idx = doc.ranks[fragment_idx] - 1; @@ -152,7 +152,7 @@ bool PhysicalFusion::Execute(QueryContext *query_context, OperatorState *operato block_idx++; } if (block_idx >= input_blocks.size()) { - throw ExecutorException(Format("Cannot find block_idx")); + throw ExecutorException(fmt::format("Cannot find block_idx")); } SizeT column_n = GetOutputTypes()->size() - 2; @@ -166,7 +166,7 @@ bool PhysicalFusion::Execute(QueryContext *query_context, OperatorState *operato row_count++; } output_data_block->Finalize(); - operator_state->data_block_array_.push_back(Move(output_data_block)); + operator_state->data_block_array_.push_back(std::move(output_data_block)); fusion_operator_state->input_data_blocks_.clear(); operator_state->SetComplete(); return true; @@ -180,7 +180,7 @@ String PhysicalFusion::ToString(i64 &space) const { } else { arrow_str = "PhysicalFusion "; } - String res = Format("{} {}", arrow_str, fusion_expr_->ToString()); + String res = fmt::format("{} {}", arrow_str, fusion_expr_->ToString()); return res; } diff --git a/src/executor/operator/physical_hash.cppm b/src/executor/operator/physical_hash.cppm index c2d9134314..864f2488df 100644 --- a/src/executor/operator/physical_hash.cppm +++ b/src/executor/operator/physical_hash.cppm @@ -33,8 +33,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kHash, nullptr, nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kHash, nullptr, nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalHash() override = default; diff --git a/src/executor/operator/physical_import.cpp b/src/executor/operator/physical_import.cpp index b6d0a7a9a0..e15855d0af 100644 --- a/src/executor/operator/physical_import.cpp +++ b/src/executor/operator/physical_import.cpp @@ -109,10 +109,10 @@ void PhysicalImport::ImportFVECS(QueryContext *query_context, ImportOperatorStat i64 nbytes = fs.Read(*file_handler, &dimension, sizeof(dimension)); fs.Seek(*file_handler, 0); if (nbytes != sizeof(dimension)) { - Error(Format("Read dimension which length isn't {}.", nbytes)); + Error(fmt::format("Read dimension which length isn't {}.", nbytes)); } if ((int)embedding_info->Dimension() != dimension) { - Error(Format("Dimension in file ({}) doesn't match with table definition ({}).", dimension, embedding_info->Dimension())); + Error(fmt::format("Dimension in file ({}) doesn't match with table definition ({}).", dimension, embedding_info->Dimension())); } SizeT file_size = fs.GetFileSize(*file_handler); SizeT row_size = dimension * sizeof(FloatT) + sizeof(dimension); @@ -134,7 +134,7 @@ void PhysicalImport::ImportFVECS(QueryContext *query_context, ImportOperatorStat int dim; nbytes = fs.Read(*file_handler, &dim, sizeof(dimension)); if (dim != dimension or nbytes != sizeof(dimension)) { - Error(Format("Dimension in file ({}) doesn't match with table definition ({}).", dim, dimension)); + Error(fmt::format("Dimension in file ({}) doesn't match with table definition ({}).", dim, dimension)); } ptr_t dst_ptr = buf_ptr + last_block_entry->row_count() * sizeof(FloatT) * dimension; fs.Read(*file_handler, dst_ptr, sizeof(FloatT) * dimension); @@ -168,8 +168,8 @@ void PhysicalImport::ImportFVECS(QueryContext *query_context, ImportOperatorStat buf_ptr = static_cast(buffer_handle.GetDataMut()); } } - auto result_msg = MakeUnique(Format("IMPORT {} Rows", vector_n)); - import_op_state->result_msg_ = Move(result_msg); + auto result_msg = MakeUnique(fmt::format("IMPORT {} Rows", vector_n)); + import_op_state->result_msg_ = std::move(result_msg); } void PhysicalImport::ImportCSV(QueryContext *query_context, ImportOperatorState *import_op_state) { @@ -223,8 +223,8 @@ void PhysicalImport::ImportCSV(QueryContext *query_context, ImportOperatorState } NewCatalog::IncreaseTableRowCount(table_entry_, parser_context->row_count_); - auto result_msg = MakeUnique(Format("IMPORT {} Rows", parser_context->row_count_)); - import_op_state->result_msg_ = Move(result_msg); + auto result_msg = MakeUnique(fmt::format("IMPORT {} Rows", parser_context->row_count_)); + import_op_state->result_msg_ = std::move(result_msg); } void PhysicalImport::ImportJSONL(QueryContext *query_context, ImportOperatorState *import_op_state) { @@ -236,7 +236,7 @@ void PhysicalImport::ImportJSONL(QueryContext *query_context, ImportOperatorStat String jsonl_str(file_size + 1, 0); SizeT read_n = file_handler->Read(jsonl_str.data(), file_size); if (read_n != file_size) { - Error(Format("Read file size {} doesn't match with file size {}.", read_n, file_size)); + Error(fmt::format("Read file size {} doesn't match with file size {}.", read_n, file_size)); } Txn *txn = query_context->GetTxn(); @@ -255,17 +255,17 @@ void PhysicalImport::ImportJSONL(QueryContext *query_context, ImportOperatorStat } StringView json_sv(jsonl_str.data() + start_pos, end_pos - start_pos); start_pos = end_pos + 1; - Json line_json = Json::parse(json_sv); + nlohmann::json line_json = nlohmann::json::parse(json_sv); if (segment_entry->Room() <= 0) { - LOG_INFO(Format("Segment {} saved", segment_entry->segment_id())); + LOG_INFO(fmt::format("Segment {} saved", segment_entry->segment_id())); SaveSegmentData(txn_store, segment_entry); u64 segment_id = NewCatalog::GetNextSegmentID(table_entry_); segment_entry = SegmentEntry::MakeNewSegmentEntry(table_entry_, segment_id, txn->GetBufferMgr()); } BlockEntry *block_entry = segment_entry->GetLastEntry(); if (block_entry->GetAvailableCapacity() <= 0) { - LOG_INFO(Format("Block {} saved", block_entry->block_id())); + LOG_INFO(fmt::format("Block {} saved", block_entry->block_id())); segment_entry->AppendBlockEntry(MakeUnique(segment_entry.get(), segment_entry->block_entries().size(), 0, @@ -283,8 +283,8 @@ void PhysicalImport::ImportJSONL(QueryContext *query_context, ImportOperatorStat SaveSegmentData(txn_store, segment_entry); } - auto result_msg = MakeUnique(Format("IMPORT {} Rows", table_entry_->row_count())); - import_op_state->result_msg_ = Move(result_msg); + auto result_msg = MakeUnique(fmt::format("IMPORT {} Rows", table_entry_->row_count())); + import_op_state->result_msg_ = std::move(result_msg); } void PhysicalImport::ImportJSON(QueryContext *, ImportOperatorState *) { Error("Import JSON is not implemented yet."); } @@ -296,7 +296,7 @@ void PhysicalImport::CSVHeaderHandler(void *context) { SizeT table_column_count = parser_context->table_entry_->ColumnCount(); if (csv_column_count != table_column_count) { - parser_context->err_msg_ = MakeShared(Format("Unmatched column count ({} != {})", csv_column_count, table_column_count)); + parser_context->err_msg_ = MakeShared(fmt::format("Unmatched column count ({} != {})", csv_column_count, table_column_count)); parser.Abort(); // return zsv_status_cancelled return; @@ -307,7 +307,7 @@ void PhysicalImport::CSVHeaderHandler(void *context) { auto *csv_col_name = reinterpret_cast(parser.GetCellStr(idx)); const char *table_col_name = parser_context->table_entry_->GetColumnDefByID(idx)->name().c_str(); if (!strcmp(csv_col_name, table_col_name)) { - parser_context->err_msg_ = MakeShared(Format("Unmatched column name({} != {})", csv_col_name, table_col_name)); + parser_context->err_msg_ = MakeShared(fmt::format("Unmatched column name({} != {})", csv_col_name, table_col_name)); parser.Abort(); // return zsv_status_cancelled return; @@ -393,7 +393,7 @@ void PhysicalImport::CSVRowHandler(void *context) { // if column count is larger than columns defined from schema, extra columns are abandoned if (column_count != table_entry->ColumnCount()) { UniquePtr err_msg = - MakeUnique(Format("CSV file row count isn't match with table schema, row id: {}.", parser_context->row_count_)); + MakeUnique(fmt::format("CSV file row count isn't match with table schema, row id: {}.", parser_context->row_count_)); LOG_ERROR(*err_msg); Error(*err_msg); } @@ -505,7 +505,7 @@ void AppendEmbeddingJsonl(BlockColumnEntry *block_column_entry, const Vector block_column_entry->AppendRaw(dst_offset, reinterpret_cast(embedding.data()), embedding.size() * sizeof(T), nullptr); } -void PhysicalImport::JSONLRowHandler(const Json &line_json, BlockEntry *block_entry) { +void PhysicalImport::JSONLRowHandler(const nlohmann::json &line_json, BlockEntry *block_entry) { SizeT column_n = table_entry_->ColumnCount(); SizeT row_cnt = block_entry->row_count(); for (SizeT i = 0; i < column_n; ++i) { @@ -602,14 +602,14 @@ void PhysicalImport::SaveSegmentData(TxnTableStore *txn_store, SharedPtrFlushData(block_entry->row_count()); - auto size = Max(block_entries.size(), static_cast(block_entry->block_id() + 1)); + auto size = std::max(block_entries.size(), static_cast(block_entry->block_id() + 1)); block_row_counts.resize(size); block_row_counts[block_entry->block_id()] = block_entry->row_count(); } - LOG_TRACE(Format("Block rows count {}", block_row_counts.size())); + LOG_TRACE(fmt::format("Block rows count {}", block_row_counts.size())); for (SizeT i = 0; i < block_row_counts.size(); ++i) { - LOG_TRACE(Format("Block {} row count {}", i, block_row_counts[i])); + LOG_TRACE(fmt::format("Block {} row count {}", i, block_row_counts[i])); } const String &db_name = *txn_store->table_entry_->GetDBName(); diff --git a/src/executor/operator/physical_import.cppm b/src/executor/operator/physical_import.cppm index 2280517524..2f58eafb7a 100644 --- a/src/executor/operator/physical_import.cppm +++ b/src/executor/operator/physical_import.cppm @@ -58,7 +58,7 @@ public: CopyFileType type, SharedPtr> load_metas) : PhysicalOperator(PhysicalOperatorType::kImport, nullptr, nullptr, id, load_metas), table_entry_(table_entry), - file_type_(type), file_path_(Move(file_path)), header_(header), delimiter_(delimiter) {} + file_type_(type), file_path_(std::move(file_path)), header_(header), delimiter_(delimiter) {} ~PhysicalImport() override = default; @@ -102,7 +102,7 @@ private: static void CSVRowHandler(void *); - void JSONLRowHandler(const Json &line_json, BlockEntry *block_entry); + void JSONLRowHandler(const nlohmann::json &line_json, BlockEntry *block_entry); private: SharedPtr> output_names_{}; diff --git a/src/executor/operator/physical_insert.cpp b/src/executor/operator/physical_insert.cpp index 4112ec5903..98d9ff1963 100644 --- a/src/executor/operator/physical_insert.cpp +++ b/src/executor/operator/physical_insert.cpp @@ -44,7 +44,7 @@ bool PhysicalInsert::Execute(QueryContext *query_context, OperatorState *operato SizeT table_collection_column_count = table_entry_->ColumnCount(); if (column_count != table_collection_column_count) { Error( - Format("Insert values count{} isn't matched with table column count{}.", column_count, table_collection_column_count)); + fmt::format("Insert values count{} isn't matched with table column count{}.", column_count, table_collection_column_count)); ; } @@ -77,16 +77,16 @@ bool PhysicalInsert::Execute(QueryContext *query_context, OperatorState *operato const String &table_name = *table_entry_->GetTableName(); txn->Append(db_name, table_name, output_block); - UniquePtr result_msg = MakeUnique(Format("INSERTED {} Rows", output_block->row_count())); + UniquePtr result_msg = MakeUnique(fmt::format("INSERTED {} Rows", output_block->row_count())); if (operator_state == nullptr) { // Generate the result table Vector> column_defs; SharedPtr result_table_def_ptr = MakeShared(MakeShared("default"), MakeShared("Tables"), column_defs); output_ = MakeShared(result_table_def_ptr, TableType::kDataTable); - output_->SetResultMsg(Move(result_msg)); + output_->SetResultMsg(std::move(result_msg)); } else { InsertOperatorState *insert_operator_state = static_cast(operator_state); - insert_operator_state->result_msg_ = Move(result_msg); + insert_operator_state->result_msg_ = std::move(result_msg); } operator_state->SetComplete(); return true; diff --git a/src/executor/operator/physical_insert.cppm b/src/executor/operator/physical_insert.cppm index 76172c4fec..0785fc79de 100644 --- a/src/executor/operator/physical_insert.cppm +++ b/src/executor/operator/physical_insert.cppm @@ -37,7 +37,7 @@ public: Vector>> value_list, SharedPtr> load_metas) : PhysicalOperator(PhysicalOperatorType::kInsert, nullptr, nullptr, id, load_metas), table_entry_(table_entry), - table_index_(table_index), value_list_(Move(value_list)) {} + table_index_(table_index), value_list_(std::move(value_list)) {} ~PhysicalInsert() override = default; diff --git a/src/executor/operator/physical_intersect.cppm b/src/executor/operator/physical_intersect.cppm index 237111d81a..401e844572 100644 --- a/src/executor/operator/physical_intersect.cppm +++ b/src/executor/operator/physical_intersect.cppm @@ -33,8 +33,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kParallelAggregate, nullptr, nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kParallelAggregate, nullptr, nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalIntersect() override = default; diff --git a/src/executor/operator/physical_knn_scan.cpp b/src/executor/operator/physical_knn_scan.cpp index 6e9281b274..be34bfdb79 100644 --- a/src/executor/operator/physical_knn_scan.cpp +++ b/src/executor/operator/physical_knn_scan.cpp @@ -103,7 +103,7 @@ void MergeIntoBitmask(const VectorBuffer *input_bool_column_buffer, bool bitmask_use_unit = (bitmask_offset % BitmaskBuffer::UNIT_BITS) == 0; SizeT bitmask_unit_offset = bitmask_offset / BitmaskBuffer::UNIT_BITS; for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; - ++i, end_index = Min(end_index + BitmaskBuffer::UNIT_BITS, count)) { + ++i, end_index = std::min(end_index + BitmaskBuffer::UNIT_BITS, count)) { if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null for (; start_index < end_index; ++start_index) { @@ -224,7 +224,7 @@ void PhysicalKnnScan::PlanWithIndex(QueryContext *query_context) { // TODO: retu } } } - LOG_TRACE(Format("KnnScan: brute force task: {}, index task: {}", block_column_entries_->size(), index_entries_->size())); + LOG_TRACE(fmt::format("KnnScan: brute force task: {}, index task: {}", block_column_entries_->size(), index_entries_->size())); } SizeT PhysicalKnnScan::BlockEntryCount() const { return base_table_ref_->block_index_->BlockCount(); } @@ -242,7 +242,7 @@ void PhysicalKnnScan::ExecuteInternal(QueryContext *query_context, KnnScanOperat SizeT brute_task_n = knn_scan_shared_data->block_column_entries_->size(); if (u64 block_column_idx = knn_scan_shared_data->current_block_idx_++; block_column_idx < brute_task_n) { - LOG_TRACE(Format("KnnScan: {} brute force {}/{}", knn_scan_function_data->task_id_, block_column_idx + 1, brute_task_n)); + LOG_TRACE(fmt::format("KnnScan: {} brute force {}/{}", knn_scan_function_data->task_id_, block_column_idx + 1, brute_task_n)); // brute force BlockColumnEntry *block_column_entry = knn_scan_shared_data->block_column_entries_->at(block_column_idx); const BlockEntry *block_entry = block_column_entry->block_entry(); @@ -280,7 +280,7 @@ void PhysicalKnnScan::ExecuteInternal(QueryContext *query_context, KnnScanOperat block_entry->block_id(), bitmask); } else if (u64 index_idx = knn_scan_shared_data->current_index_idx_++; index_idx < index_task_n) { - LOG_TRACE(Format("KnnScan: {} index {}/{}", knn_scan_function_data->task_id_, index_idx + 1, index_task_n)); + LOG_TRACE(fmt::format("KnnScan: {} index {}/{}", knn_scan_function_data->task_id_, index_idx + 1, index_task_n)); // with index SegmentColumnIndexEntry *segment_column_index_entry = knn_scan_shared_data->index_entries_->at(index_idx); BufferManager *buffer_mgr = query_context->storage()->buffer_manager(); @@ -289,7 +289,7 @@ void PhysicalKnnScan::ExecuteInternal(QueryContext *query_context, KnnScanOperat SegmentEntry *segment_entry = nullptr; auto &segment_index_hashmap = base_table_ref_->block_index_->segment_index_; if (auto iter = segment_index_hashmap.find(segment_id); iter == segment_index_hashmap.end()) { - Error(Format("Cannot find SegmentEntry for segment id: {}", segment_id)); + Error(fmt::format("Cannot find SegmentEntry for segment id: {}", segment_id)); } else { segment_entry = iter->second; } @@ -318,7 +318,7 @@ void PhysicalKnnScan::ExecuteInternal(QueryContext *query_context, KnnScanOperat bool_column->Reset(); } if (segment_row_count_real != segment_row_count) { - Error(Format("Segment_row_count mismatch: In segment {}: segment_row_count_real: {}, segment_row_count: {}", + Error(fmt::format("Segment_row_count mismatch: In segment {}: segment_row_count_real: {}, segment_row_count: {}", segment_id, segment_row_count_real, segment_row_count)); @@ -380,7 +380,7 @@ void PhysicalKnnScan::ExecuteInternal(QueryContext *query_context, KnnScanOperat for (u64 query_idx = 0; query_idx < knn_scan_shared_data->query_count_; ++query_idx) { const DataType *query = static_cast(knn_scan_shared_data->query_embedding_) + query_idx * knn_scan_shared_data->dimension_; - auto bitmask_optional = bitmask.IsAllTrue() ? None : Optional(Move(bitmask)); + auto bitmask_optional = bitmask.IsAllTrue() ? None : Optional(std::move(bitmask)); auto [result_n1, d_ptr, v_ptr] = index->template KnnSearch(query, knn_scan_shared_data->topk_, bitmask_optional); if (result_n < 0) { result_n = result_n1; @@ -462,12 +462,12 @@ void PhysicalKnnScan::ExecuteInternal(QueryContext *query_context, KnnScanOperat } } if (knn_scan_shared_data->current_index_idx_ >= index_task_n && knn_scan_shared_data->current_block_idx_ >= brute_task_n) { - LOG_TRACE(Format("KnnScan: {} task finished", knn_scan_function_data->task_id_)); + LOG_TRACE(fmt::format("KnnScan: {} task finished", knn_scan_function_data->task_id_)); // all task Complete BlockIndex *block_index = knn_scan_shared_data->table_ref_->block_index_.get(); merge_heap->End(); - i64 result_n = Min(knn_scan_shared_data->topk_, merge_heap->total_count()); + i64 result_n = std::min(knn_scan_shared_data->topk_, merge_heap->total_count()); if (!operator_state->data_block_array_.empty()) { Error("In physical_knn_scan : operator_state->data_block_array_ is not empty."); @@ -478,7 +478,7 @@ void PhysicalKnnScan::ExecuteInternal(QueryContext *query_context, KnnScanOperat do { auto data_block = DataBlock::MakeUniquePtr(); data_block->Init(*GetOutputTypes()); - operator_state->data_block_array_.emplace_back(Move(data_block)); + operator_state->data_block_array_.emplace_back(std::move(data_block)); row_idx += DEFAULT_BLOCK_CAPACITY; } while (row_idx < total_data_row_count); } @@ -500,7 +500,7 @@ void PhysicalKnnScan::ExecuteInternal(QueryContext *query_context, KnnScanOperat BlockEntry *block_entry = block_index->GetBlockEntry(segment_id, block_id); if (block_entry == nullptr) { - Error(Format("Cannot find block segment id: {}, block id: {}", segment_id, block_id)); + Error(fmt::format("Cannot find block segment id: {}, block id: {}", segment_id, block_id)); } if (output_block_row_id == DEFAULT_BLOCK_CAPACITY) { diff --git a/src/executor/operator/physical_knn_scan.cppm b/src/executor/operator/physical_knn_scan.cppm index 482133cb0c..2612308c37 100644 --- a/src/executor/operator/physical_knn_scan.cppm +++ b/src/executor/operator/physical_knn_scan.cppm @@ -43,9 +43,9 @@ public: SharedPtr>> output_types, u64 knn_table_index, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kKnnScan, nullptr, nullptr, id, load_metas), base_table_ref_(Move(base_table_ref)), - knn_expression_(Move(knn_expression)), filter_expression_(Move(filter_expression)), output_names_(Move(output_names)), - output_types_(Move(output_types)), knn_table_index_(knn_table_index) {} + : PhysicalOperator(PhysicalOperatorType::kKnnScan, nullptr, nullptr, id, load_metas), base_table_ref_(std::move(base_table_ref)), + knn_expression_(std::move(knn_expression)), filter_expression_(std::move(filter_expression)), output_names_(std::move(output_names)), + output_types_(std::move(output_types)), knn_table_index_(knn_table_index) {} ~PhysicalKnnScan() override = default; diff --git a/src/executor/operator/physical_limit.cpp b/src/executor/operator/physical_limit.cpp index 7891b7d03f..2b00392e8b 100644 --- a/src/executor/operator/physical_limit.cpp +++ b/src/executor/operator/physical_limit.cpp @@ -141,8 +141,8 @@ PhysicalLimit::PhysicalLimit(u64 id, SharedPtr limit_expr, SharedPtr offset_expr, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kLimit, Move(left), nullptr, id, load_metas), limit_expr_(Move(limit_expr)), - offset_expr_(Move(offset_expr)) { + : PhysicalOperator(PhysicalOperatorType::kLimit, std::move(left), nullptr, id, load_metas), limit_expr_(std::move(limit_expr)), + offset_expr_(std::move(offset_expr)) { i64 offset = 0; i64 limit = (static_pointer_cast(limit_expr_))->GetValue().value_.big_int; @@ -207,7 +207,7 @@ bool PhysicalLimit::Execute(QueryContext *query_context, limit = 0; } block->Finalize(); - output_blocks.push_back(Move(block)); + output_blocks.push_back(std::move(block)); offset = 0; if (limit == 0) { diff --git a/src/executor/operator/physical_limit.cppm b/src/executor/operator/physical_limit.cppm index 8cb04602c1..50d98569e8 100644 --- a/src/executor/operator/physical_limit.cppm +++ b/src/executor/operator/physical_limit.cppm @@ -34,6 +34,8 @@ class DataBlock; export class LimitCounter { public: + virtual ~LimitCounter() = default; + // Returns the left index after offset virtual SizeT Offset(SizeT row_count) = 0; @@ -43,13 +45,15 @@ public: virtual bool IsLimitOver() = 0; }; -export class AtomicCounter : public LimitCounter { +export class AtomicCounter final : public LimitCounter { public: AtomicCounter(i64 offset, i64 limit) : offset_(offset), limit_(limit) {} - SizeT Offset(SizeT row_count); + ~AtomicCounter() final = default; + + SizeT Offset(SizeT row_count) final; - SizeT Limit(SizeT row_count); + SizeT Limit(SizeT row_count) final; bool IsLimitOver(); @@ -58,13 +62,15 @@ private: ai64 limit_{}; }; -export class UnSyncCounter : public LimitCounter { +export class UnSyncCounter final : public LimitCounter { public: UnSyncCounter(i64 offset, i64 limit) : offset_(offset), limit_(limit) {} - SizeT Offset(SizeT row_count); + ~UnSyncCounter() final = default; + + SizeT Offset(SizeT row_count) final; - SizeT Limit(SizeT row_count); + SizeT Limit(SizeT row_count) final; bool IsLimitOver(); @@ -73,7 +79,7 @@ private: i64 limit_{}; }; -export class PhysicalLimit : public PhysicalOperator { +export class PhysicalLimit final : public PhysicalOperator { public: explicit PhysicalLimit(u64 id, UniquePtr left, @@ -81,9 +87,9 @@ public: SharedPtr offset_expr, SharedPtr> load_metas); - ~PhysicalLimit() override = default; + ~PhysicalLimit() final = default; - void Init() override; + void Init() final; static bool Execute(QueryContext *query_context, const Vector> &input_blocks, @@ -92,17 +98,15 @@ public: bool Execute(QueryContext *query_context, OperatorState *operator_state) final; - inline SharedPtr> GetOutputNames() const final { return left_->GetOutputNames(); } + [[nodiscard]] inline SharedPtr> GetOutputNames() const final { return left_->GetOutputNames(); } - inline SharedPtr>> GetOutputTypes() const final { return left_->GetOutputTypes(); } + [[nodiscard]] inline SharedPtr>> GetOutputTypes() const final { return left_->GetOutputTypes(); } - SizeT TaskletCount() override { - return left_->TaskletCount(); - } + SizeT TaskletCount() override { return left_->TaskletCount(); } - inline const SharedPtr &limit_expr() const { return limit_expr_; } + [[nodiscard]] inline const SharedPtr &limit_expr() const { return limit_expr_; } - inline const SharedPtr &offset_expr() const { return offset_expr_; } + [[nodiscard]] inline const SharedPtr &offset_expr() const { return offset_expr_; } private: SharedPtr limit_expr_{}; diff --git a/src/executor/operator/physical_match.cpp b/src/executor/operator/physical_match.cpp index 2358c2ae03..72e0d7a52a 100644 --- a/src/executor/operator/physical_match.cpp +++ b/src/executor/operator/physical_match.cpp @@ -54,7 +54,7 @@ PhysicalMatch::PhysicalMatch(u64 id, u64 match_table_index, SharedPtr> load_metas) : PhysicalOperator(PhysicalOperatorType::kMatch, nullptr, nullptr, id, load_metas), table_index_(match_table_index), - base_table_ref_(Move(base_table_ref)), match_expr_(Move(match_expr)) {} + base_table_ref_(std::move(base_table_ref)), match_expr_(std::move(match_expr)) {} PhysicalMatch::~PhysicalMatch() = default; @@ -96,7 +96,7 @@ bool PhysicalMatch::Execute(QueryContext *query_context, OperatorState *operator SharedPtr &dataStore = irs_index_entry->irs_index_; if (dataStore == nullptr) { throw ExecutorException( - Format("IrsIndexEntry::irs_index_ is nullptr for table {}", *base_table_ref_->table_entry_ptr_->GetTableName())); + fmt::format("IrsIndexEntry::irs_index_ is nullptr for table {}", *base_table_ref_->table_entry_ptr_->GetTableName())); } rc = dataStore->Search(flt.get(), search_ops.options_, result); if (rc != 0) { @@ -135,7 +135,7 @@ bool PhysicalMatch::Execute(QueryContext *query_context, OperatorState *operator output_data_block->column_vectors[column_id]->AppendWith(row_id, 1); } output_data_block->Finalize(); - operator_state->data_block_array_.emplace_back(Move(output_data_block)); + operator_state->data_block_array_.emplace_back(std::move(output_data_block)); operator_state->SetComplete(); return true; @@ -169,7 +169,7 @@ String PhysicalMatch::ToString(i64 &space) const { } else { arrow_str = "PhysicalMatch "; } - String res = Format("{} Table: {}, {}", arrow_str, *(base_table_ref_->table_entry_ptr_->GetTableName()), match_expr_->ToString()); + String res = fmt::format("{} Table: {}, {}", arrow_str, *(base_table_ref_->table_entry_ptr_->GetTableName()), match_expr_->ToString()); return res; } diff --git a/src/executor/operator/physical_merge_aggregate.cpp b/src/executor/operator/physical_merge_aggregate.cpp index 79770fbf57..0af2e08b57 100644 --- a/src/executor/operator/physical_merge_aggregate.cpp +++ b/src/executor/operator/physical_merge_aggregate.cpp @@ -60,7 +60,7 @@ bool PhysicalMergeAggregate::Execute(QueryContext *query_context, OperatorState void PhysicalMergeAggregate::SimpleMergeAggregateExecute(MergeAggregateOperatorState *op_state) { if (op_state->data_block_array_.empty()) { - op_state->data_block_array_.emplace_back(Move(op_state->input_data_block_)); + op_state->data_block_array_.emplace_back(std::move(op_state->input_data_block_)); LOG_TRACE("Physical MergeAggregate execute first block"); } else { auto agg_op = dynamic_cast(this->left()); @@ -120,7 +120,7 @@ void PhysicalMergeAggregate::HandleAggregateFunction(const String &function_name } else if (function_name == "COUNT_STAR") { // no action for "COUNT_STAR" } else { - Error(Format("Function type {} not Implement.", function_name)); + Error(fmt::format("Function type {} not Implement.", function_name)); } } diff --git a/src/executor/operator/physical_merge_aggregate.cppm b/src/executor/operator/physical_merge_aggregate.cppm index 98a29391cd..af4eaf9e85 100644 --- a/src/executor/operator/physical_merge_aggregate.cppm +++ b/src/executor/operator/physical_merge_aggregate.cppm @@ -38,8 +38,8 @@ public: SharedPtr> output_names, SharedPtr>> output_types, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kMergeAggregate, Move(left), nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)), table_ref_(Move(table_ref)) {} + : PhysicalOperator(PhysicalOperatorType::kMergeAggregate, std::move(left), nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)), table_ref_(std::move(table_ref)) {} ~PhysicalMergeAggregate() override = default; diff --git a/src/executor/operator/physical_merge_hash.cppm b/src/executor/operator/physical_merge_hash.cppm index b24c6a5311..bbe3b37cdc 100644 --- a/src/executor/operator/physical_merge_hash.cppm +++ b/src/executor/operator/physical_merge_hash.cppm @@ -30,8 +30,8 @@ namespace infinity { export class PhysicalMergeHash final : public PhysicalOperator { public: explicit PhysicalMergeHash(SharedPtr> output_names, SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kMergeHash, nullptr, nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kMergeHash, nullptr, nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalMergeHash() override = default; diff --git a/src/executor/operator/physical_merge_knn.cpp b/src/executor/operator/physical_merge_knn.cpp index 5b23fec753..4a03e65341 100644 --- a/src/executor/operator/physical_merge_knn.cpp +++ b/src/executor/operator/physical_merge_knn.cpp @@ -111,7 +111,7 @@ void PhysicalMergeKnn::ExecuteInner(QueryContext *query_context, MergeKnnOperato BlockIndex *block_index = merge_knn_data.table_ref_->block_index_.get(); u64 output_row_count{0}; - i64 result_n = Min(merge_knn_data.topk_, merge_knn->total_count()); + i64 result_n = std::min(merge_knn_data.topk_, merge_knn->total_count()); for (i64 query_idx = 0; query_idx < merge_knn_data.query_count_; ++query_idx) { DataType *result_dists = merge_knn->GetDistancesByIdx(query_idx); RowID *result_row_ids = merge_knn->GetIDsByIdx(query_idx); @@ -120,11 +120,11 @@ void PhysicalMergeKnn::ExecuteInner(QueryContext *query_context, MergeKnnOperato u32 segment_offset = result_row_ids[top_idx].segment_offset_; u16 block_id = segment_offset / DEFAULT_BLOCK_CAPACITY; u16 block_offset = segment_offset % DEFAULT_BLOCK_CAPACITY; - // LOG_TRACE(Format("Row offset: {}: {}: {}, distance: {}", segment_id, block_id, block_offset, result_dists[top_idx])); + // LOG_TRACE(fmt::format("Row offset: {}: {}: {}, distance: {}", segment_id, block_id, block_offset, result_dists[top_idx])); BlockEntry *block_entry = block_index->GetBlockEntry(segment_id, block_id); if (block_entry == nullptr) { - Error(Format("Cannot find block segment id: {}, block id: {}", segment_id, block_id)); + Error(fmt::format("Cannot find block segment id: {}, block id: {}", segment_id, block_id)); } DataBlock *output_data_block = merge_knn_state->data_block_array_.back().get(); @@ -159,7 +159,7 @@ void PhysicalMergeKnn::ExecuteInner(QueryContext *query_context, MergeKnnOperato ++output_row_count; } // for (SizeT i = 0; i < column_n; ++i) { - // LOG_TRACE(Format("Output Column ID: {}, Name: {}", merge_knn_data.table_ref_->column_ids_[i], output_names_->at(i))); + // LOG_TRACE(fmt::format("Output Column ID: {}, Name: {}", merge_knn_data.table_ref_->column_ids_[i], output_names_->at(i))); //} } diff --git a/src/executor/operator/physical_merge_knn.cppm b/src/executor/operator/physical_merge_knn.cppm index 1af3792d6e..0ffb87b13a 100644 --- a/src/executor/operator/physical_merge_knn.cppm +++ b/src/executor/operator/physical_merge_knn.cppm @@ -41,8 +41,8 @@ public: SharedPtr knn_expr, u64 knn_table_index, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kMergeKnn, Move(left), nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)), knn_table_index_(knn_table_index), knn_expression_(Move(knn_expr)), table_ref_(table_ref) {} + : PhysicalOperator(PhysicalOperatorType::kMergeKnn, std::move(left), nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)), knn_table_index_(knn_table_index), knn_expression_(std::move(knn_expr)), table_ref_(table_ref) {} ~PhysicalMergeKnn() override = default; diff --git a/src/executor/operator/physical_merge_limit.cpp b/src/executor/operator/physical_merge_limit.cpp index 3870f24421..b65cc78d4e 100644 --- a/src/executor/operator/physical_merge_limit.cpp +++ b/src/executor/operator/physical_merge_limit.cpp @@ -34,8 +34,8 @@ PhysicalMergeLimit::PhysicalMergeLimit(u64 id, SharedPtr limit_expr, SharedPtr offset_expr, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kMergeLimit, Move(left), nullptr, id, load_metas), limit_expr_(Move(limit_expr)), - offset_expr_(Move(offset_expr)) { + : PhysicalOperator(PhysicalOperatorType::kMergeLimit, std::move(left), nullptr, id, load_metas), limit_expr_(std::move(limit_expr)), + offset_expr_(std::move(offset_expr)) { i64 offset = 0; i64 limit = (static_pointer_cast(limit_expr_))->GetValue().value_.big_int; diff --git a/src/executor/operator/physical_merge_parallel_aggregate.cppm b/src/executor/operator/physical_merge_parallel_aggregate.cppm index d11821e636..69cea6e033 100644 --- a/src/executor/operator/physical_merge_parallel_aggregate.cppm +++ b/src/executor/operator/physical_merge_parallel_aggregate.cppm @@ -33,8 +33,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kMergeParallelAggregate, nullptr, nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kMergeParallelAggregate, nullptr, nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalMergeParallelAggregate() override = default; diff --git a/src/executor/operator/physical_merge_sort.cppm b/src/executor/operator/physical_merge_sort.cppm index be959ae651..b2f72842fa 100644 --- a/src/executor/operator/physical_merge_sort.cppm +++ b/src/executor/operator/physical_merge_sort.cppm @@ -33,8 +33,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kMergeSort, nullptr, nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kMergeSort, nullptr, nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalMergeSort() override = default; diff --git a/src/executor/operator/physical_merge_top.cppm b/src/executor/operator/physical_merge_top.cppm index 926e9a1dff..ea051022dd 100644 --- a/src/executor/operator/physical_merge_top.cppm +++ b/src/executor/operator/physical_merge_top.cppm @@ -30,8 +30,8 @@ namespace infinity { export class PhysicalMergeTop final : public PhysicalOperator { public: explicit PhysicalMergeTop(SharedPtr> output_names, SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kMergeTop, nullptr, nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kMergeTop, nullptr, nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalMergeTop() override = default; diff --git a/src/executor/operator/physical_nested_loop_join.cppm b/src/executor/operator/physical_nested_loop_join.cppm index 242d1f31f0..a7ec7d32df 100644 --- a/src/executor/operator/physical_nested_loop_join.cppm +++ b/src/executor/operator/physical_nested_loop_join.cppm @@ -37,8 +37,8 @@ public: UniquePtr left, UniquePtr right, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kJoinNestedLoop, Move(left), Move(right), id, load_metas), join_type_(join_type), - conditions_(Move(conditions)) {} + : PhysicalOperator(PhysicalOperatorType::kJoinNestedLoop, std::move(left), std::move(right), id, load_metas), join_type_(join_type), + conditions_(std::move(conditions)) {} ~PhysicalNestedLoopJoin() override = default; diff --git a/src/executor/operator/physical_optimize.cpp b/src/executor/operator/physical_optimize.cpp index 739604e197..0d0e11e2fa 100644 --- a/src/executor/operator/physical_optimize.cpp +++ b/src/executor/operator/physical_optimize.cpp @@ -51,12 +51,12 @@ void PhysicalOptimize::OptimizeIndex(QueryContext *query_context, OperatorState // Get tables from catalog auto txn = query_context->GetTxn(); u64 txn_id = txn->TxnID(); - LOG_INFO(Format("OptimizeIndex {} {}", db_name_, object_name_)); + LOG_INFO(fmt::format("OptimizeIndex {} {}", db_name_, object_name_)); TxnTimeStamp begin_ts = query_context->GetTxn()->BeginTS(); auto [table_entry, table_status] = txn->GetTableByName(db_name_, object_name_); if (!table_status.ok()) { - operator_state->error_message_ = Move(table_status.msg_); - Error(Format("{} isn't found", object_name_)); + operator_state->error_message_ = std::move(table_status.msg_); + Error(fmt::format("{} isn't found", object_name_)); return; } @@ -69,7 +69,7 @@ void PhysicalOptimize::OptimizeIndex(QueryContext *query_context, OperatorState irs_index_entry = table_index_entry->irs_index_entry(); } if (irs_index_entry) { - LOG_INFO(Format("ScheduleOptimize")); + LOG_INFO(fmt::format("ScheduleOptimize")); irs_index_entry->irs_index_->ScheduleOptimize(); } LOG_TRACE("Optimize index"); diff --git a/src/executor/operator/physical_optimize.cppm b/src/executor/operator/physical_optimize.cppm index 73b6b97f9a..839bcf8628 100644 --- a/src/executor/operator/physical_optimize.cppm +++ b/src/executor/operator/physical_optimize.cppm @@ -31,8 +31,8 @@ namespace infinity { export class PhysicalOptimize final : public PhysicalOperator { public: explicit PhysicalOptimize(u64 id, String db_name, String object_name, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kOptimize, nullptr, nullptr, id, load_metas), db_name_(Move(db_name)), - object_name_(Move(object_name)) {} + : PhysicalOperator(PhysicalOperatorType::kOptimize, nullptr, nullptr, id, load_metas), db_name_(std::move(db_name)), + object_name_(std::move(object_name)) {} ~PhysicalOptimize() override = default; diff --git a/src/executor/operator/physical_parallel_aggregate.cppm b/src/executor/operator/physical_parallel_aggregate.cppm index 962b1f5eb9..12ee3e2297 100644 --- a/src/executor/operator/physical_parallel_aggregate.cppm +++ b/src/executor/operator/physical_parallel_aggregate.cppm @@ -34,8 +34,8 @@ public: SharedPtr>> output_types, u64 id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kParallelAggregate, nullptr, nullptr, id, load_metas), output_names_(Move(output_names)), - output_types_(Move(output_types)) {} + : PhysicalOperator(PhysicalOperatorType::kParallelAggregate, nullptr, nullptr, id, load_metas), output_names_(std::move(output_names)), + output_types_(std::move(output_types)) {} ~PhysicalParallelAggregate() override = default; diff --git a/src/executor/operator/physical_project.cppm b/src/executor/operator/physical_project.cppm index 101d36b77c..146f4bee88 100644 --- a/src/executor/operator/physical_project.cppm +++ b/src/executor/operator/physical_project.cppm @@ -35,7 +35,7 @@ public: UniquePtr left, Vector> expressions, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kProjection, Move(left), nullptr, id, load_metas), expressions_(Move(expressions)), + : PhysicalOperator(PhysicalOperatorType::kProjection, std::move(left), nullptr, id, load_metas), expressions_(std::move(expressions)), projection_table_index_(table_index) {} ~PhysicalProject() override = default; diff --git a/src/executor/operator/physical_show.cpp b/src/executor/operator/physical_show.cpp index 363d3ecd64..c209f1861c 100644 --- a/src/executor/operator/physical_show.cpp +++ b/src/executor/operator/physical_show.cpp @@ -302,7 +302,7 @@ void PhysicalShow::ExecuteShowDatabases(QueryContext *query_context, ShowOperato } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } /** @@ -462,7 +462,7 @@ void PhysicalShow::ExecuteShowTable(QueryContext *query_context, ShowOperatorSta } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } void PhysicalShow::ExecuteShowViews(QueryContext *query_context, ShowOperatorState *show_operator_state) { @@ -516,7 +516,7 @@ void PhysicalShow::ExecuteShowViews(QueryContext *query_context, ShowOperatorSta } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } void PhysicalShow::ExecuteShowProfiles(QueryContext *query_context, ShowOperatorState *show_operator_state) { @@ -559,7 +559,7 @@ void PhysicalShow::ExecuteShowProfiles(QueryContext *query_context, ShowOperator for (SizeT i = 0; i < records.size(); ++i) { // Output record no - ValueExpression record_no_expr(Value::MakeVarchar(Format("{}", i))); + ValueExpression record_no_expr(Value::MakeVarchar(fmt::format("{}", i))); record_no_expr.AppendToChunk(output_block_ptr->column_vectors[0]); // Output each query phase @@ -580,7 +580,7 @@ void PhysicalShow::ExecuteShowProfiles(QueryContext *query_context, ShowOperator phase_cost_expr.AppendToChunk(output_block_ptr->column_vectors.back()); } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } /** @@ -594,8 +594,8 @@ void PhysicalShow::ExecuteShowColumns(QueryContext *query_context, ShowOperatorS auto [table_entry, status] = txn->GetTableByName(db_name_, object_name_); if (!status.ok()) { - show_operator_state->error_message_ = Move(status.msg_); - Error(Format("{} isn't found", object_name_)); + show_operator_state->error_message_ = std::move(status.msg_); + Error(fmt::format("{} isn't found", object_name_)); return; } @@ -638,7 +638,7 @@ void PhysicalShow::ExecuteShowColumns(QueryContext *query_context, ShowOperatorS if (column->type()->type() == kEmbedding) { auto type = column->type(); auto embedding_type = type->type_info()->ToString(); - column_type = Format("{}({})", type->ToString(), embedding_type); + column_type = fmt::format("{}({})", type->ToString(), embedding_type); } else { column_type = column->type()->ToString(); @@ -663,7 +663,7 @@ void PhysicalShow::ExecuteShowColumns(QueryContext *query_context, ShowOperatorS } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } void PhysicalShow::ExecuteShowSegments(QueryContext *query_context, ShowOperatorState *show_operator_state) { @@ -671,8 +671,8 @@ void PhysicalShow::ExecuteShowSegments(QueryContext *query_context, ShowOperator auto [table_entry, status] = txn->GetTableByName(db_name_, object_name_); if (!status.ok()) { - show_operator_state->error_message_ = Move(status.msg_); - Error(Format("{} isn't found", object_name_)); + show_operator_state->error_message_ = std::move(status.msg_); + Error(fmt::format("{} isn't found", object_name_)); return; } @@ -746,7 +746,7 @@ void PhysicalShow::ExecuteShowSegments(QueryContext *query_context, ShowOperator } } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } // Execute describe system table @@ -806,7 +806,7 @@ void PhysicalShow::ExecuteShowConfigs(QueryContext *query_context, ShowOperatorS } { // option name type - Value value = Value::MakeVarchar(Format("{}-{}", global_config->time_zone(), global_config->time_zone_bias())); + Value value = Value::MakeVarchar(fmt::format("{}-{}", global_config->time_zone(), global_config->time_zone_bias())); ValueExpression value_expr(value); value_expr.AppendToChunk(output_block_ptr->column_vectors[1]); } @@ -1037,7 +1037,7 @@ void PhysicalShow::ExecuteShowConfigs(QueryContext *query_context, ShowOperatorS } { // option name type - Value value = Value::MakeVarchar(ToStr(global_config->worker_cpu_limit())); + Value value = Value::MakeVarchar(std::to_string(global_config->worker_cpu_limit())); ValueExpression value_expr(value); value_expr.AppendToChunk(output_block_ptr->column_vectors[1]); } @@ -1281,7 +1281,7 @@ void PhysicalShow::ExecuteShowConfigs(QueryContext *query_context, ShowOperatorS } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } void PhysicalShow::ExecuteShowIndexes(QueryContext *query_context, ShowOperatorState *show_operator_state) { @@ -1289,7 +1289,7 @@ void PhysicalShow::ExecuteShowIndexes(QueryContext *query_context, ShowOperatorS auto [table_entry, table_status] = txn->GetTableByName(db_name_, object_name_); if (!table_status.ok()) { - show_operator_state->error_message_ = Move(table_status.msg_); + show_operator_state->error_message_ = std::move(table_status.msg_); // Error(table_status.message()); return; } @@ -1370,7 +1370,7 @@ void PhysicalShow::ExecuteShowIndexes(QueryContext *query_context, ShowOperatorS // Append Index segment SizeT segment_count = table_entry->segment_map().size(); SizeT index_segment_count = column_index_entry->index_by_segment().size(); - String result_value = Format("{}/{}", index_segment_count, segment_count); + String result_value = fmt::format("{}/{}", index_segment_count, segment_count); Value value = Value::MakeVarchar(result_value); ValueExpression value_expr(value); value_expr.AppendToChunk(output_block_ptr->column_vectors[column_id]); @@ -1382,14 +1382,14 @@ void PhysicalShow::ExecuteShowIndexes(QueryContext *query_context, ShowOperatorS switch (index_base->index_type_) { case IndexType::kIVFFlat: { const IndexIVFFlat *index_ivfflat = static_cast(index_base); - other_parameters = Format("metric = {}, centroids_count = {}", + other_parameters = fmt::format("metric = {}, centroids_count = {}", MetricTypeToString(index_ivfflat->metric_type_), index_ivfflat->centroids_count_); break; } case IndexType::kHnsw: { const IndexHnsw *index_hnsw = static_cast(index_base); - other_parameters = Format("metric = {}, encode_type = {}, M = {}, ef_construction = {}, ef = {}", + other_parameters = fmt::format("metric = {}, encode_type = {}, M = {}, ef_construction = {}, ef = {}", MetricTypeToString(index_hnsw->metric_type_), HnswEncodeTypeToString(index_hnsw->encode_type_), index_hnsw->M_, @@ -1399,7 +1399,7 @@ void PhysicalShow::ExecuteShowIndexes(QueryContext *query_context, ShowOperatorS } case IndexType::kIRSFullText: { const IndexFullText *index_full_text = static_cast(index_base); - other_parameters = Format("analyzer = {}", index_full_text->analyzer_); + other_parameters = fmt::format("analyzer = {}", index_full_text->analyzer_); break; } case IndexType::kInvalid: { @@ -1417,7 +1417,7 @@ void PhysicalShow::ExecuteShowIndexes(QueryContext *query_context, ShowOperatorS } } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } void PhysicalShow::ExecuteShowTableDetail(QueryContext *query_context, const Vector> &table_collecton_columns) { @@ -1550,14 +1550,14 @@ void PhysicalShow::ExecuteShowSessionStatus(QueryContext *query_context, ShowOpe { // option value SizeT query_count = query_context->current_session()->query_count(); - Value value = Value::MakeVarchar(ToStr(query_count)); + Value value = Value::MakeVarchar(std::to_string(query_count)); ValueExpression value_expr(value); value_expr.AppendToChunk(output_block_ptr->column_vectors[1]); } } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } void PhysicalShow::ExecuteShowGlobalStatus(QueryContext *query_context, ShowOperatorState *show_operator_state) { @@ -1590,7 +1590,7 @@ void PhysicalShow::ExecuteShowGlobalStatus(QueryContext *query_context, ShowOper BufferManager *buffer_manager = query_context->storage()->buffer_manager(); u64 memory_limit = buffer_manager->memory_limit(); u64 memory_usage = buffer_manager->memory_usage(); - Value value = Value::MakeVarchar(Format("{}/{}", Utility::FormatByteSize(memory_usage), Utility::FormatByteSize(memory_limit))); + Value value = Value::MakeVarchar(fmt::format("{}/{}", Utility::FormatByteSize(memory_usage), Utility::FormatByteSize(memory_limit))); ValueExpression value_expr(value); value_expr.AppendToChunk(output_block_ptr->column_vectors[1]); } @@ -1607,14 +1607,14 @@ void PhysicalShow::ExecuteShowGlobalStatus(QueryContext *query_context, ShowOper // option value SessionManager *session_manager = query_context->session_manager(); u64 session_count = session_manager->GetSessionCount(); - Value value = Value::MakeVarchar(ToStr(session_count)); + Value value = Value::MakeVarchar(std::to_string(session_count)); ValueExpression value_expr(value); value_expr.AppendToChunk(output_block_ptr->column_vectors[1]); } } output_block_ptr->Finalize(); - show_operator_state->output_.emplace_back(Move(output_block_ptr)); + show_operator_state->output_.emplace_back(std::move(output_block_ptr)); } } // namespace infinity diff --git a/src/executor/operator/physical_show.cppm b/src/executor/operator/physical_show.cppm index c3b97eb9f3..4ccc9fa0a8 100644 --- a/src/executor/operator/physical_show.cppm +++ b/src/executor/operator/physical_show.cppm @@ -39,8 +39,8 @@ public: Optional segment_id, Optional block_id, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kShow, nullptr, nullptr, id, load_metas), scan_type_(type), db_name_(Move(db_name)), - object_name_(Move(object_name)), table_index_(table_index), segment_id_(segment_id), block_id_(block_id) {} + : PhysicalOperator(PhysicalOperatorType::kShow, nullptr, nullptr, id, load_metas), scan_type_(type), db_name_(std::move(db_name)), + object_name_(std::move(object_name)), table_index_(table_index), segment_id_(segment_id), block_id_(block_id) {} ~PhysicalShow() override = default; diff --git a/src/executor/operator/physical_sink.cpp b/src/executor/operator/physical_sink.cpp index 35425b7b70..6faffd9ae5 100644 --- a/src/executor/operator/physical_sink.cpp +++ b/src/executor/operator/physical_sink.cpp @@ -83,7 +83,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(MaterializeSinkState *mate case PhysicalOperatorType::kShow: { ShowOperatorState *show_output_state = static_cast(task_op_state); for (auto &data_block : show_output_state->output_) { - materialize_sink_state->data_block_array_.emplace_back(Move(data_block)); + materialize_sink_state->data_block_array_.emplace_back(std::move(data_block)); } show_output_state->output_.clear(); break; @@ -95,7 +95,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(MaterializeSinkState *mate } for (auto &data_block : explain_output_state->data_block_array_) { - materialize_sink_state->data_block_array_.emplace_back(Move(data_block)); + materialize_sink_state->data_block_array_.emplace_back(std::move(data_block)); } explain_output_state->data_block_array_.clear(); break; @@ -106,7 +106,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(MaterializeSinkState *mate materialize_sink_state->empty_result_ = true; } else { for (auto &data_block : projection_output_state->data_block_array_) { - materialize_sink_state->data_block_array_.emplace_back(Move(data_block)); + materialize_sink_state->data_block_array_.emplace_back(std::move(data_block)); } projection_output_state->data_block_array_.clear(); } @@ -122,7 +122,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(MaterializeSinkState *mate } } else { for (auto &data_block : sort_output_state->data_block_array_) { - materialize_sink_state->data_block_array_.emplace_back(Move(data_block)); + materialize_sink_state->data_block_array_.emplace_back(std::move(data_block)); } sort_output_state->data_block_array_.clear(); } @@ -137,12 +137,12 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(MaterializeSinkState *mate Error("Empty agg output"); } } else { - materialize_sink_state->data_block_array_ = Move(agg_output_state->data_block_array_); + materialize_sink_state->data_block_array_ = std::move(agg_output_state->data_block_array_); } break; } default: { - Error(Format("{} isn't supported here.", PhysicalOperatorToString(task_op_state->operator_type_))); + Error(fmt::format("{} isn't supported here.", PhysicalOperatorToString(task_op_state->operator_type_))); } } } @@ -166,7 +166,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(SummarySinkState *summary_ break; } default: { - Error(Format("{} isn't supported here.", PhysicalOperatorToString(task_operator_state->operator_type_))); + Error(fmt::format("{} isn't supported here.", PhysicalOperatorToString(task_operator_state->operator_type_))); } } } @@ -180,7 +180,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kCreateTable: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -190,7 +190,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kCreateIndex: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet()), @@ -201,7 +201,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kCreateCollection: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -211,7 +211,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kCreateDatabase: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -221,7 +221,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kCreateView: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -231,7 +231,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kDropTable: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -241,7 +241,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kDropIndex: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet()), @@ -252,7 +252,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kDropCollection: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -262,7 +262,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kDropDatabase: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -272,7 +272,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kDropView: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -282,7 +282,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kCommand: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -292,7 +292,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kFlush: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -302,7 +302,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kOptimize: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); } else { result_sink_state->result_def_ = { MakeShared(0, MakeShared(LogicalType::kInteger), "OK", HashSet())}; @@ -312,7 +312,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si case PhysicalOperatorType::kCreateIndexFinish: { auto *output_state = static_cast(task_operator_state); if (output_state->error_message_.get() != nullptr) { - result_sink_state->error_message_ = Move(output_state->error_message_); + result_sink_state->error_message_ = std::move(output_state->error_message_); break; } result_sink_state->result_def_ = { @@ -321,7 +321,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(ResultSinkState *result_si break; } default: { - Error(Format("{} isn't supported here.", PhysicalOperatorToString(task_operator_state->operator_type_))); + Error(fmt::format("{} isn't supported here.", PhysicalOperatorToString(task_operator_state->operator_type_))); } } } @@ -330,16 +330,16 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(MessageSinkState *message_ switch (task_operator_state->operator_type_) { case PhysicalOperatorType::kImport: { auto *import_output_state = static_cast(task_operator_state); - message_sink_state->message_ = Move(import_output_state->result_msg_); + message_sink_state->message_ = std::move(import_output_state->result_msg_); break; } case PhysicalOperatorType::kInsert: { auto *insert_output_state = static_cast(task_operator_state); - message_sink_state->message_ = Move(insert_output_state->result_msg_); + message_sink_state->message_ = std::move(insert_output_state->result_msg_); break; } default: { - Error(Format("{} isn't supported here.", PhysicalOperatorToString(task_operator_state->operator_type_))); + Error(fmt::format("{} isn't supported here.", PhysicalOperatorToString(task_operator_state->operator_type_))); break; } } @@ -349,7 +349,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(FragmentContext *fragment_ QueueSinkState *queue_sink_state, OperatorState *task_operator_state) { if (queue_sink_state->error_message_.get() != nullptr) { - LOG_TRACE(Format("Error: {} is sent to notify next fragment", *queue_sink_state->error_message_)); + LOG_TRACE(fmt::format("Error: {} is sent to notify next fragment", *queue_sink_state->error_message_)); auto fragment_error = MakeShared(queue_sink_state->fragment_id_, MakeUnique(*queue_sink_state->error_message_)); for (const auto &next_fragment_queue : queue_sink_state->fragment_data_queues_) { next_fragment_queue->Enqueue(fragment_error); @@ -373,7 +373,7 @@ void PhysicalSink::FillSinkStateFromLastOperatorState(FragmentContext *fragment_ default: { for (SizeT idx = 0; idx < output_data_block_count; ++idx) { auto fragment_data = MakeShared(queue_sink_state->fragment_id_, - Move(task_operator_state->data_block_array_[idx]), + std::move(task_operator_state->data_block_array_[idx]), queue_sink_state->task_id_, idx, output_data_block_count); diff --git a/src/executor/operator/physical_sink.cppm b/src/executor/operator/physical_sink.cppm index 51a6f721af..454626f042 100644 --- a/src/executor/operator/physical_sink.cppm +++ b/src/executor/operator/physical_sink.cppm @@ -39,7 +39,7 @@ export enum class SinkType { export class PhysicalSink final : public PhysicalOperator { public: explicit PhysicalSink(u64 id, SinkType sink_type, SharedPtr> names, SharedPtr>> types, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kSink, nullptr, nullptr, id, load_metas), output_names_(Move(names)), output_types_(Move(types)), + : PhysicalOperator(PhysicalOperatorType::kSink, nullptr, nullptr, id, load_metas), output_names_(std::move(names)), output_types_(std::move(types)), type_(sink_type) {} ~PhysicalSink() override = default; diff --git a/src/executor/operator/physical_sort.cpp b/src/executor/operator/physical_sort.cpp index a7c4b9f287..bf618a3ede 100644 --- a/src/executor/operator/physical_sort.cpp +++ b/src/executor/operator/physical_sort.cpp @@ -131,7 +131,7 @@ class Comparator { COMPARE(DoubleT) } default: { - Error(Format("{} not implemented.", type.type())); + Error(fmt::format("{} not implemented.", type.type())); } } } @@ -182,8 +182,8 @@ Vector MergeIndexes(Vector> &indexes_group, if (l > r) return Vector(); SizeT mid = (l + r) >> 1; - return MergeTwoIndexes(Move(MergeIndexes(indexes_group, l, mid, comparator)), - Move(MergeIndexes(indexes_group, mid + 1, r, comparator)), + return MergeTwoIndexes(MergeIndexes(indexes_group, l, mid, comparator), + MergeIndexes(indexes_group, mid + 1, r, comparator), comparator); } @@ -202,7 +202,7 @@ void CopyWithIndexes(const Vector> &input_blocks, auto sorted_datablock = DataBlock::MakeUniquePtr(); sorted_datablock->Init(input_blocks[0]->types()); - output_blocks.push_back(Move(sorted_datablock)); + output_blocks.push_back(std::move(sorted_datablock)); } for (SizeT index_idx = 0; index_idx < block_indexes.size(); ++index_idx) { auto &block_index = block_indexes[index_idx]; diff --git a/src/executor/operator/physical_sort.cppm b/src/executor/operator/physical_sort.cppm index e556ce0265..029e748118 100644 --- a/src/executor/operator/physical_sort.cppm +++ b/src/executor/operator/physical_sort.cppm @@ -43,8 +43,8 @@ public: Vector> expressions, Vector order_by_types, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kSort, Move(left), nullptr, id, load_metas), expressions_(Move(expressions)), - order_by_types_(Move(order_by_types)) {} + : PhysicalOperator(PhysicalOperatorType::kSort, std::move(left), nullptr, id, load_metas), expressions_(std::move(expressions)), + order_by_types_(std::move(order_by_types)) {} ~PhysicalSort() override = default; diff --git a/src/executor/operator/physical_source.cppm b/src/executor/operator/physical_source.cppm index 7b85afc5eb..6e4c403990 100644 --- a/src/executor/operator/physical_source.cppm +++ b/src/executor/operator/physical_source.cppm @@ -42,7 +42,7 @@ public: SharedPtr> names, SharedPtr>> types, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kSource, nullptr, nullptr, id, load_metas), output_names_(Move(names)), output_types_(Move(types)), + : PhysicalOperator(PhysicalOperatorType::kSource, nullptr, nullptr, id, load_metas), output_names_(std::move(names)), output_types_(std::move(types)), type_(source_type) {} ~PhysicalSource() override = default; diff --git a/src/executor/operator/physical_table_scan.cpp b/src/executor/operator/physical_table_scan.cpp index b5653bd53a..61f89b1fdc 100644 --- a/src/executor/operator/physical_table_scan.cpp +++ b/src/executor/operator/physical_table_scan.cpp @@ -142,7 +142,7 @@ void PhysicalTableScan::ExecuteInternal(QueryContext *query_context, TableScanOp BlockEntry *current_block_entry = block_index->GetBlockEntry(segment_id, block_id); auto [row_begin, row_end] = current_block_entry->GetVisibleRange(begin_ts, read_offset); - auto write_size = Min(write_capacity, SizeT(row_end - row_begin)); + auto write_size = std::min(write_capacity, SizeT(row_end - row_begin)); if (write_size > 0) { read_offset = row_begin; diff --git a/src/executor/operator/physical_table_scan.cppm b/src/executor/operator/physical_table_scan.cppm index b631b88a08..cc3dcc616e 100644 --- a/src/executor/operator/physical_table_scan.cppm +++ b/src/executor/operator/physical_table_scan.cppm @@ -34,7 +34,7 @@ namespace infinity { export class PhysicalTableScan : public PhysicalOperator { public: explicit PhysicalTableScan(u64 id, SharedPtr base_table_ref, SharedPtr> load_metas, bool add_row_id = false) - : PhysicalOperator(PhysicalOperatorType::kTableScan, nullptr, nullptr, id, load_metas), base_table_ref_(Move(base_table_ref)), + : PhysicalOperator(PhysicalOperatorType::kTableScan, nullptr, nullptr, id, load_metas), base_table_ref_(std::move(base_table_ref)), add_row_id_(add_row_id) {} ~PhysicalTableScan() override = default; diff --git a/src/executor/operator/physical_update.cpp b/src/executor/operator/physical_update.cpp index ac6a213e90..6c63026a49 100644 --- a/src/executor/operator/physical_update.cpp +++ b/src/executor/operator/physical_update.cpp @@ -51,7 +51,7 @@ bool PhysicalUpdate::Execute(QueryContext *query_context, OperatorState *operato SharedPtr column_vector = input_data_block_ptr->column_vectors[i]; if (column_vector->data_type()->type() == LogicalType::kRowID) { row_ids.resize(column_vector->Size()); - Memcpy(row_ids.data(), column_vector->data(), column_vector->Size() * sizeof(RowID)); + std::memcpy(row_ids.data(), column_vector->data(), column_vector->Size() * sizeof(RowID)); break; } else { column_vectors.push_back(column_vector); diff --git a/src/executor/operator/physical_update.cppm b/src/executor/operator/physical_update.cppm index 3aaf2a955e..ae24aab068 100644 --- a/src/executor/operator/physical_update.cppm +++ b/src/executor/operator/physical_update.cppm @@ -36,7 +36,7 @@ public: TableEntry *table_entry_ptr, const Vector>> &update_columns, SharedPtr> load_metas) - : PhysicalOperator(PhysicalOperatorType::kUpdate, Move(left), nullptr, id, load_metas), table_entry_ptr_(table_entry_ptr), + : PhysicalOperator(PhysicalOperatorType::kUpdate, std::move(left), nullptr, id, load_metas), table_entry_ptr_(table_entry_ptr), update_columns_(update_columns) {} ~PhysicalUpdate() override = default; diff --git a/src/executor/operator_state.cpp b/src/executor/operator_state.cpp index 5644280fc3..c82282f222 100644 --- a/src/executor/operator_state.cpp +++ b/src/executor/operator_state.cpp @@ -58,7 +58,7 @@ bool QueueSourceState::GetData() { auto *fragment_error = static_cast(fragment_data_base.get()); if (this->error_message_.get() == nullptr) { // Only record the first error of input data. - this->error_message_ = Move(fragment_error->error_message_); + this->error_message_ = std::move(fragment_error->error_message_); } // Get an error message from predecessor fragment MarkCompletedTask(fragment_error->fragment_id_); @@ -81,21 +81,21 @@ bool QueueSourceState::GetData() { case PhysicalOperatorType::kMergeKnn: { auto *fragment_data = static_cast(fragment_data_base.get()); MergeKnnOperatorState *merge_knn_op_state = (MergeKnnOperatorState *)next_op_state; - merge_knn_op_state->input_data_block_ = Move(fragment_data->data_block_); + merge_knn_op_state->input_data_block_ = std::move(fragment_data->data_block_); merge_knn_op_state->input_complete_ = completed; break; } case PhysicalOperatorType::kFusion: { auto *fragment_data = static_cast(fragment_data_base.get()); FusionOperatorState *fusion_op_state = (FusionOperatorState *)next_op_state; - fusion_op_state->input_data_blocks_[fragment_data->fragment_id_].push_back(Move(fragment_data->data_block_)); + fusion_op_state->input_data_blocks_[fragment_data->fragment_id_].push_back(std::move(fragment_data->data_block_)); fusion_op_state->input_complete_ = completed; break; } case PhysicalOperatorType::kMergeLimit: { auto *fragment_data = static_cast(fragment_data_base.get()); MergeLimitOperatorState *limit_op_state = (MergeLimitOperatorState *)next_op_state; - limit_op_state->input_data_blocks_.push_back(Move(fragment_data->data_block_)); + limit_op_state->input_data_blocks_.push_back(std::move(fragment_data->data_block_)); if (!limit_op_state->input_complete_) { limit_op_state->input_complete_ = completed; } @@ -107,8 +107,8 @@ bool QueueSourceState::GetData() { case PhysicalOperatorType::kMergeAggregate: { auto *fragment_data = static_cast(fragment_data_base.get()); MergeAggregateOperatorState *merge_aggregate_op_state = (MergeAggregateOperatorState *)next_op_state; - // merge_aggregate_op_state->input_data_blocks_.push_back(Move(fragment_data->data_block_)); - merge_aggregate_op_state->input_data_block_ = Move(fragment_data->data_block_); + // merge_aggregate_op_state->input_data_blocks_.push_back(std::move(fragment_data->data_block_)); + merge_aggregate_op_state->input_data_block_ = std::move(fragment_data->data_block_); merge_aggregate_op_state->input_complete_ = completed; break; } diff --git a/src/executor/operator_state.cppm b/src/executor/operator_state.cppm index 2d4e7635ff..9d5d69f33b 100644 --- a/src/executor/operator_state.cppm +++ b/src/executor/operator_state.cppm @@ -390,7 +390,7 @@ export struct AggregateSourceState : public SourceState { export struct TableScanSourceState : public SourceState { explicit TableScanSourceState(SharedPtr> global_ids) - : SourceState(SourceStateType::kTableScan), global_ids_(Move(global_ids)) {} + : SourceState(SourceStateType::kTableScan), global_ids_(std::move(global_ids)) {} SharedPtr> global_ids_; }; diff --git a/src/executor/physical_operator.cppm b/src/executor/physical_operator.cppm index 74f9757861..97e51617f6 100644 --- a/src/executor/physical_operator.cppm +++ b/src/executor/physical_operator.cppm @@ -31,7 +31,7 @@ export class PhysicalOperator : public EnableSharedFromThis { public: inline explicit PhysicalOperator(PhysicalOperatorType type, UniquePtr left, UniquePtr right, u64 id, SharedPtr> &load_metas) - : operator_id_(id), operator_type_(type), left_(Move(left)), right_(Move(right)) { + : operator_id_(id), operator_type_(type), left_(std::move(left)), right_(std::move(right)) { load_metas_ = load_metas; } diff --git a/src/executor/physical_planner.cpp b/src/executor/physical_planner.cpp index 6be063c855..b46ec13156 100644 --- a/src/executor/physical_planner.cpp +++ b/src/executor/physical_planner.cpp @@ -338,14 +338,14 @@ UniquePtr PhysicalPlanner::BuildCreateIndex(const SharedPtrGetOutputTypes(), logical_create_index->load_metas()); auto create_index_do = MakeUnique(logical_create_index->node_id(), - Move(create_index_prepare), + std::move(create_index_prepare), logical_create_index->base_table_ref(), logical_create_index->index_definition()->index_name_, logical_create_index->GetOutputNames(), logical_create_index->GetOutputTypes(), logical_create_index->load_metas()); auto create_index_finish = MakeUnique(logical_create_index->node_id(), - Move(create_index_do), + std::move(create_index_do), schema_name, table_name, logical_create_index->index_definition(), @@ -465,7 +465,7 @@ UniquePtr PhysicalPlanner::BuildDelete(const SharedPtrleft_node(); auto input_physical_operator = BuildPhysicalOperator(input_logical_node); auto physical_delete = MakeUnique(logical_operator->node_id(), - Move(input_physical_operator), + std::move(input_physical_operator), logical_delete->table_entry_ptr_, logical_operator->load_metas()); return physical_delete; @@ -482,7 +482,7 @@ UniquePtr PhysicalPlanner::BuildUpdate(const SharedPtrleft_node(); auto input_physical_operator = BuildPhysicalOperator(input_logical_node); auto physical_update = MakeUnique(logical_operator->node_id(), - Move(input_physical_operator), + std::move(input_physical_operator), logical_update->table_entry_ptr_, logical_update->update_columns_, logical_operator->load_metas()); @@ -533,7 +533,7 @@ UniquePtr PhysicalPlanner::BuildAggregate(const SharedPtrTaskletCount(); auto physical_agg_op = MakeUnique(logical_aggregate->node_id(), - Move(input_physical_operator), + std::move(input_physical_operator), logical_aggregate->groups_, logical_aggregate->groupby_index_, logical_aggregate->aggregates_, @@ -545,7 +545,7 @@ UniquePtr PhysicalPlanner::BuildAggregate(const SharedPtr(query_context_ptr_->GetNextNodeID(), logical_aggregate->base_table_ref_, - Move(physical_agg_op), + std::move(physical_agg_op), logical_aggregate->GetOutputNames(), logical_aggregate->GetOutputTypes(), logical_operator->load_metas()); @@ -575,8 +575,8 @@ UniquePtr PhysicalPlanner::BuildJoin(const SharedPtr(logical_operator->node_id(), logical_join->join_type_, logical_join->conditions_, - Move(left_physical_operator), - Move(right_physical_operator), + std::move(left_physical_operator), + std::move(right_physical_operator), logical_operator->load_metas()); } @@ -601,8 +601,8 @@ UniquePtr PhysicalPlanner::BuildCrossProduct(const SharedPtr(logical_operator->node_id(), - Move(left_physical_operator), - Move(right_physical_operator), + std::move(left_physical_operator), + std::move(right_physical_operator), logical_operator->load_metas()); } @@ -621,7 +621,7 @@ UniquePtr PhysicalPlanner::BuildSort(const SharedPtr logical_sort = static_pointer_cast(logical_operator); return MakeUnique(logical_operator->node_id(), - Move(input_physical_operator), + std::move(input_physical_operator), logical_sort->expressions_, logical_sort->order_by_types_, logical_operator->load_metas()); @@ -641,7 +641,7 @@ UniquePtr PhysicalPlanner::BuildLimit(const SharedPtr input_physical_operator = BuildPhysicalOperator(input_logical_node); if (input_physical_operator->TaskletCount() <= 1) { return MakeUnique(logical_operator->node_id(), - Move(input_physical_operator), + std::move(input_physical_operator), logical_limit->limit_expression_, logical_limit->offset_expression_, logical_operator->load_metas()); @@ -652,12 +652,12 @@ UniquePtr PhysicalPlanner::BuildLimit(const SharedPtr(logical_limit->offset_expression_))->GetValue().value_.big_int; } auto child_limit_op = MakeUnique(logical_operator->node_id(), - Move(input_physical_operator), + std::move(input_physical_operator), MakeShared(Value::MakeBigInt(child_limit)), nullptr, logical_operator->load_metas()); return MakeUnique(query_context_ptr_->GetNextNodeID(), - Move(child_limit_op), + std::move(child_limit_op), logical_limit->limit_expression_, logical_limit->offset_expression_, logical_operator->load_metas()); @@ -676,7 +676,7 @@ UniquePtr PhysicalPlanner::BuildProjection(const SharedPtr(logical_operator->node_id(), logical_project->table_index_, - Move(input_physical_operator), + std::move(input_physical_operator), logical_project->expressions_, logical_operator->load_metas()); } @@ -695,7 +695,7 @@ UniquePtr PhysicalPlanner::BuildFilter(const SharedPtr logical_filter = static_pointer_cast(logical_operator); return MakeUnique(logical_operator->node_id(), - Move(input_physical_operator), + std::move(input_physical_operator), logical_filter->expression(), logical_operator->load_metas()); } @@ -776,8 +776,8 @@ UniquePtr PhysicalPlanner::BuildFusion(const SharedPtr(logical_fusion->node_id(), - Move(left_phy), - Move(right_phy), + std::move(left_phy), + std::move(right_phy), logical_fusion->fusion_expr_, logical_operator->load_metas()); } @@ -800,7 +800,7 @@ UniquePtr PhysicalPlanner::BuildKnn(const SharedPtr(query_context_ptr_->GetNextNodeID(), logical_knn_scan->base_table_ref_, - Move(knn_scan_op), + std::move(knn_scan_op), logical_knn_scan->GetOutputNames(), logical_knn_scan->GetOutputTypes(), logical_knn_scan->knn_expression_, @@ -859,7 +859,7 @@ UniquePtr PhysicalPlanner::BuildExplain(const SharedPtr(logical_explain->node_id(), logical_explain->explain_type(), nullptr, - Move(input_physical_operator), + std::move(input_physical_operator), logical_operator->load_metas()); break; } diff --git a/src/expression/aggregate_expression.cpp b/src/expression/aggregate_expression.cpp index 788528c757..ff8deeed6b 100644 --- a/src/expression/aggregate_expression.cpp +++ b/src/expression/aggregate_expression.cpp @@ -25,7 +25,7 @@ module aggregate_expression; namespace infinity { AggregateExpression::AggregateExpression(AggregateFunction aggregate_function, Vector> arguments) - : BaseExpression(ExpressionType::kAggregate, Move(arguments)), aggregate_function_(Move(aggregate_function)) {} + : BaseExpression(ExpressionType::kAggregate, std::move(arguments)), aggregate_function_(std::move(aggregate_function)) {} bool AggregateExpression::IsCountStar() const { return false; } diff --git a/src/expression/base_expression.cppm b/src/expression/base_expression.cppm index 1183c12ba1..641e692c93 100644 --- a/src/expression/base_expression.cppm +++ b/src/expression/base_expression.cppm @@ -35,17 +35,17 @@ export struct SourcePosition { explicit SourcePosition(u64 bind_context_id, ExprSourceType source_type) : bind_context_id_(bind_context_id), source_type_(source_type) {} - u64 bind_context_id_{u64_max}; + u64 bind_context_id_{std::numeric_limits::max()}; ExprSourceType source_type_{ExprSourceType::kInvalid}; String binding_name_{}; }; export class BaseExpression : public EnableSharedFromThis { public: - explicit BaseExpression(ExpressionType type, Vector> arguments) : type_(type), arguments_(Move(arguments)){}; + explicit BaseExpression(ExpressionType type, Vector> arguments) : type_(type), arguments_(std::move(arguments)){}; explicit BaseExpression(ExpressionType type, Vector> arguments, String alias) - : alias_(Move(alias)), type_(type), arguments_(Move(arguments)){}; + : alias_(std::move(alias)), type_(type), arguments_(std::move(arguments)){}; virtual ~BaseExpression() = default; diff --git a/src/expression/case_expression.cppm b/src/expression/case_expression.cppm index bb8bd7d978..c79721c726 100644 --- a/src/expression/case_expression.cppm +++ b/src/expression/case_expression.cppm @@ -24,7 +24,7 @@ namespace infinity { export struct CaseCheck { CaseCheck(SharedPtr when_expr, SharedPtr then_expr) - : when_expr_(Move(when_expr)), then_expr_(Move(then_expr)) {} + : when_expr_(std::move(when_expr)), then_expr_(std::move(then_expr)) {} SharedPtr when_expr_; SharedPtr then_expr_; diff --git a/src/expression/cast_expression.cpp b/src/expression/cast_expression.cpp index 7f32fd7aed..7ba879ca16 100644 --- a/src/expression/cast_expression.cpp +++ b/src/expression/cast_expression.cpp @@ -36,7 +36,7 @@ SharedPtr CastExpression::AddCastToType(const SharedPtrType(), target_type); return MakeShared(cast, source_expr_ptr, target_type); } else { - Error(Format("Can't cast from: {} to {}", source_expr_ptr->Type().ToString(), target_type.ToString())); + Error(fmt::format("Can't cast from: {} to {}", source_expr_ptr->Type().ToString(), target_type.ToString())); } return nullptr; } @@ -131,6 +131,6 @@ bool CastExpression::CanCast(const DataType &source, const DataType &target) { return false; } -String CastExpression::ToString() const { return Format("Cast({} AS {})", arguments_[0]->Name(), target_type_.ToString()); } +String CastExpression::ToString() const { return fmt::format("Cast({} AS {})", arguments_[0]->Name(), target_type_.ToString()); } } // namespace infinity diff --git a/src/expression/cast_expression.cppm b/src/expression/cast_expression.cppm index eabe1ad2d0..fdba30eeec 100644 --- a/src/expression/cast_expression.cppm +++ b/src/expression/cast_expression.cppm @@ -28,7 +28,7 @@ namespace infinity { export class CastExpression : public BaseExpression { public: CastExpression(BoundCastFunc cast_function, const SharedPtr &argument, DataType target_type) - : BaseExpression(ExpressionType::kCast, {argument}), func_(cast_function), target_type_(Move(target_type)) {} + : BaseExpression(ExpressionType::kCast, {argument}), func_(cast_function), target_type_(std::move(target_type)) {} inline DataType Type() const override { return target_type_; } diff --git a/src/expression/column_expression.cpp b/src/expression/column_expression.cpp index 7fba349312..a88ea00b18 100644 --- a/src/expression/column_expression.cpp +++ b/src/expression/column_expression.cpp @@ -33,8 +33,8 @@ ColumnExpression::ColumnExpression(DataType data_type, i64 column_index, i64 depth, Optional special) - : BaseExpression(ExpressionType::kColumn, {}), data_type_(Move(data_type)), binding_(table_index, column_index), table_name_(Move(table_name)), - column_name_(Move(column_name)), depth_(depth), special_(special) {} + : BaseExpression(ExpressionType::kColumn, {}), data_type_(std::move(data_type)), binding_(table_index, column_index), table_name_(std::move(table_name)), + column_name_(std::move(column_name)), depth_(depth), special_(special) {} String ColumnExpression::ToString() const { if (alias_.empty()) { @@ -48,7 +48,7 @@ String ColumnExpression::ToString() const { } } if (all_digits) { - return Format("{}.{}", table_name_, column_name_); + return fmt::format("{}.{}", table_name_, column_name_); } else { return column_name_; } diff --git a/src/expression/column_expression.cppm b/src/expression/column_expression.cppm index 982a42aefb..c5dbcaf022 100644 --- a/src/expression/column_expression.cppm +++ b/src/expression/column_expression.cppm @@ -33,7 +33,7 @@ public: i64 column_index, i64 depth, Optional special = None) { - return MakeShared(Move(data_type), Move(table_name), table_index, Move(column_name), column_index, depth, special); + return MakeShared(std::move(data_type), std::move(table_name), table_index, std::move(column_name), column_index, depth, special); } public: diff --git a/src/expression/correlated_column_expression.cpp b/src/expression/correlated_column_expression.cpp index e59a5ee239..a941229422 100644 --- a/src/expression/correlated_column_expression.cpp +++ b/src/expression/correlated_column_expression.cpp @@ -24,7 +24,7 @@ module correlated_column_expression; namespace infinity { CorrelatedColumnExpression::CorrelatedColumnExpression(DataType data_type, String column_name) - : BaseExpression(ExpressionType::kCorrelatedColumn, {}), data_type_(Move(data_type)), column_name_(Move(column_name)) {} + : BaseExpression(ExpressionType::kCorrelatedColumn, {}), data_type_(std::move(data_type)), column_name_(std::move(column_name)) {} String CorrelatedColumnExpression::ToString() const { return {}; } diff --git a/src/expression/expression_transformer.cpp b/src/expression/expression_transformer.cpp index a0cf6004ea..3ead8d7c20 100644 --- a/src/expression/expression_transformer.cpp +++ b/src/expression/expression_transformer.cpp @@ -145,7 +145,7 @@ void VisitExpression(const SharedPtr &expression, const StdFunct case ExpressionType::kValue: break; default: { - Error(Format("Unsupported expression type: {}", expression->Name())); + Error(fmt::format("Unsupported expression type: {}", expression->Name())); } } } diff --git a/src/expression/function_expression.cpp b/src/expression/function_expression.cpp index a0c54331cf..49b209a1ee 100644 --- a/src/expression/function_expression.cpp +++ b/src/expression/function_expression.cpp @@ -25,7 +25,7 @@ module function_expression; namespace infinity { FunctionExpression::FunctionExpression(ScalarFunction function, Vector> arguments) - : BaseExpression(ExpressionType::kFunction, Move(arguments)), func_(Move(function)) {} + : BaseExpression(ExpressionType::kFunction, std::move(arguments)), func_(std::move(function)) {} String FunctionExpression::ToString() const { if (!alias_.empty()) { diff --git a/src/expression/fusion_expression.cpp b/src/expression/fusion_expression.cpp index f50b0de634..06bcb67d85 100644 --- a/src/expression/fusion_expression.cpp +++ b/src/expression/fusion_expression.cpp @@ -34,7 +34,7 @@ String FusionExpression::ToString() const { if (!alias_.empty()) { return alias_; } - String expr_str = Format("FUSION('{}', '{}')", method_, options_ ? options_->ToString() : ""); + String expr_str = fmt::format("FUSION('{}', '{}')", method_, options_ ? options_->ToString() : ""); return expr_str; } diff --git a/src/expression/in_expression.cpp b/src/expression/in_expression.cpp index 977ff20af0..d640b5d89f 100644 --- a/src/expression/in_expression.cpp +++ b/src/expression/in_expression.cpp @@ -25,7 +25,7 @@ module in_expression; namespace infinity { InExpression::InExpression(InType in_type, SharedPtr left_operand, const Vector> &value_list) - : BaseExpression(ExpressionType::kIn, value_list), left_operand_ptr_(Move(left_operand)), in_type_(in_type) {} + : BaseExpression(ExpressionType::kIn, value_list), left_operand_ptr_(std::move(left_operand)), in_type_(in_type) {} String InExpression::ToString() const { diff --git a/src/expression/knn_expression.cpp b/src/expression/knn_expression.cpp index 892cf6cea8..51b93637bb 100644 --- a/src/expression/knn_expression.cpp +++ b/src/expression/knn_expression.cpp @@ -54,8 +54,8 @@ KnnExpression::KnnExpression(EmbeddingDataType embedding_data_type, Vector> arguments, i64 topn, Vector *opt_params) - : BaseExpression(ExpressionType::kKnn, Move(arguments)), dimension_(dimension), embedding_data_type_(embedding_data_type), - distance_type_(knn_distance_type), query_embedding_(Move(query_embedding)), + : BaseExpression(ExpressionType::kKnn, std::move(arguments)), dimension_(dimension), embedding_data_type_(embedding_data_type), + distance_type_(knn_distance_type), query_embedding_(std::move(query_embedding)), topn_(topn) // Should call move constructor, otherwise there will be memory leak. { if (opt_params) { @@ -70,7 +70,7 @@ String KnnExpression::ToString() const { return alias_; } - String expr_str = Format("KNN({}, Float32, {}, {})", + String expr_str = fmt::format("KNN({}, Float32, {}, {})", arguments_.at(0)->Name(), // EmbeddingT::Embedding2String(query_embedding_, embedding_data_type_, dimension_), KnnDistanceType2Str(distance_type_), diff --git a/src/expression/match_expression.cpp b/src/expression/match_expression.cpp index e7b6e0cec2..c83fb43fb4 100644 --- a/src/expression/match_expression.cpp +++ b/src/expression/match_expression.cpp @@ -34,7 +34,7 @@ String MatchExpression::ToString() const { if (!alias_.empty()) { return alias_; } - String expr_str = Format("MATCH('{}', '{}', '{}')", fields_, matching_text_, options_text_); + String expr_str = fmt::format("MATCH('{}', '{}', '{}')", fields_, matching_text_, options_text_); return expr_str; } diff --git a/src/expression/reference_expression.cpp b/src/expression/reference_expression.cpp index 61ceb694ef..f585bfcd70 100644 --- a/src/expression/reference_expression.cpp +++ b/src/expression/reference_expression.cpp @@ -35,7 +35,7 @@ String ReferenceExpression::ToString() const { } } if (all_digits) { - return Format("{}.{}", table_name_, column_name_); + return fmt::format("{}.{}", table_name_, column_name_); } else { return column_name_; } diff --git a/src/expression/reference_expression.cppm b/src/expression/reference_expression.cppm index 94a87a00b9..2a32c2bb59 100644 --- a/src/expression/reference_expression.cppm +++ b/src/expression/reference_expression.cppm @@ -26,13 +26,13 @@ namespace infinity { export class ReferenceExpression : public BaseExpression { public: static inline SharedPtr Make(DataType data_type, String table_name, String column_name, String alias, SizeT column_idx) { - return MakeShared(Move(data_type), Move(table_name), Move(column_name), Move(alias), column_idx); + return MakeShared(std::move(data_type), std::move(table_name), std::move(column_name), std::move(alias), column_idx); } public: explicit ReferenceExpression(DataType data_type, String table_name, String column_name, String alias, SizeT column_idx) - : BaseExpression(ExpressionType::kReference, {}, Move(alias)), data_type_(Move(data_type)), table_name_(Move(table_name)), - column_name_(Move(column_name)), column_index_(column_idx) {} + : BaseExpression(ExpressionType::kReference, {}, std::move(alias)), data_type_(std::move(data_type)), table_name_(std::move(table_name)), + column_name_(std::move(column_name)), column_index_(column_idx) {} inline SizeT column_index() const { return column_index_; } diff --git a/src/expression/subquery_expression.cpp b/src/expression/subquery_expression.cpp index cfccfa8e04..fe86248d9d 100644 --- a/src/expression/subquery_expression.cpp +++ b/src/expression/subquery_expression.cpp @@ -25,7 +25,7 @@ module subquery_expression; namespace infinity { SubqueryExpression::SubqueryExpression(UniquePtr bound_select_statement, SubqueryType subquery_type) - : BaseExpression(ExpressionType::kSubQuery, {}), bound_select_statement_ptr_(Move(bound_select_statement)), subquery_type_(subquery_type) {} + : BaseExpression(ExpressionType::kSubQuery, {}), bound_select_statement_ptr_(std::move(bound_select_statement)), subquery_type_(subquery_type) {} String SubqueryExpression::ToString() const { std::stringstream ss; diff --git a/src/expression/value_expression.cppm b/src/expression/value_expression.cppm index 97deded71a..377d2dabfb 100644 --- a/src/expression/value_expression.cppm +++ b/src/expression/value_expression.cppm @@ -28,7 +28,7 @@ namespace infinity { export class ValueExpression : public BaseExpression { public: - explicit ValueExpression(Value value) : BaseExpression(ExpressionType::kValue, {}), value_(Move(value)) {} + explicit ValueExpression(Value value) : BaseExpression(ExpressionType::kValue, {}), value_(std::move(value)) {} String ToString() const override; diff --git a/src/function/aggregate/avg.cpp b/src/function/aggregate/avg.cpp index 5cc07fb792..ba73a4e1d2 100644 --- a/src/function/aggregate/avg.cpp +++ b/src/function/aggregate/avg.cpp @@ -40,7 +40,7 @@ struct AvgState { inline ptr_t Finalize() { Error("Finalize average state."); } - inline static SizeT Size(const DataType &data_type) { Error(Format("Average state type size: {}", data_type.ToString())); } + inline static SizeT Size(const DataType &data_type) { Error(fmt::format("Average state type size: {}", data_type.ToString())); } }; template <> @@ -56,8 +56,8 @@ struct AvgState { } inline void Update(const TinyIntT *__restrict input, SizeT idx) { - if (count_ == i64_max) { - Error(Format("Data count exceeds: {}", count_)); + if (count_ == std::numeric_limits::max()) { + Error(fmt::format("Data count exceeds: {}", count_)); } this->count_++; value_ += input[idx]; @@ -89,8 +89,8 @@ struct AvgState { } inline void Update(const SmallIntT *__restrict input, SizeT idx) { - if (count_ == i64_max) { - Error(Format("Data count exceeds: {}", count_)); + if (count_ == std::numeric_limits::max()) { + Error(fmt::format("Data count exceeds: {}", count_)); } this->count_++; value_ += input[idx]; @@ -123,8 +123,8 @@ struct AvgState { } inline void Update(const IntegerT *__restrict input, SizeT idx) { - if (count_ == i64_max) { - Error(Format("Data count exceeds: {}", count_)); + if (count_ == std::numeric_limits::max()) { + Error(fmt::format("Data count exceeds: {}", count_)); } this->count_++; value_ += input[idx]; @@ -157,8 +157,8 @@ struct AvgState { } inline void Update(const BigIntT *__restrict input, SizeT idx) { - if (count_ == i64_max) { - Error(Format("Data count exceeds: {}", count_)); + if (count_ == std::numeric_limits::max()) { + Error(fmt::format("Data count exceeds: {}", count_)); } this->count_++; value_ += input[idx]; @@ -191,8 +191,8 @@ struct AvgState { } inline void Update(const FloatT *__restrict input, SizeT idx) { - if (count_ == i64_max) { - Error(Format("Data count exceeds: {}", count_)); + if (count_ == std::numeric_limits::max()) { + Error(fmt::format("Data count exceeds: {}", count_)); } this->count_++; value_ += input[idx]; @@ -225,8 +225,8 @@ struct AvgState { } inline void Update(const DoubleT *__restrict input, SizeT idx) { - if (count_ == i64_max) { - Error(Format("Data count exceeds: {}", count_)); + if (count_ == std::numeric_limits::max()) { + Error(fmt::format("Data count exceeds: {}", count_)); } this->count_++; value_ += input[idx]; diff --git a/src/function/aggregate/max.cpp b/src/function/aggregate/max.cpp index c2e208b4bf..4139646cdb 100644 --- a/src/function/aggregate/max.cpp +++ b/src/function/aggregate/max.cpp @@ -64,7 +64,7 @@ struct MaxState { public: TinyIntT value_; - void Initialize() { this->value_ = i8_min; } + void Initialize() { this->value_ = std::numeric_limits::min(); } void Update(const TinyIntT *__restrict input, SizeT idx) { value_ = value_ < input[idx] ? input[idx] : value_; } @@ -80,7 +80,7 @@ struct MaxState { public: SmallIntT value_; - void Initialize() { this->value_ = i16_min; } + void Initialize() { this->value_ = std::numeric_limits::min(); } void Update(const SmallIntT *__restrict input, SizeT idx) { value_ = value_ < input[idx] ? input[idx] : value_; } @@ -96,7 +96,7 @@ struct MaxState { public: IntegerT value_; - void Initialize() { this->value_ = i32_min; } + void Initialize() { this->value_ = std::numeric_limits::min(); } void Update(const IntegerT *__restrict input, SizeT idx) { value_ = value_ < input[idx] ? input[idx] : value_; } @@ -112,7 +112,7 @@ struct MaxState { public: BigIntT value_; - void Initialize() { this->value_ = i64_min; } + void Initialize() { this->value_ = std::numeric_limits::min(); } void Update(const BigIntT *__restrict input, SizeT idx) { value_ = value_ < input[idx] ? input[idx] : value_; } @@ -129,8 +129,8 @@ struct MaxState { HugeIntT value_; void Initialize() { - this->value_.lower = i64_min; - this->value_.upper = i64_min; + this->value_.lower = std::numeric_limits::min(); + this->value_.upper = std::numeric_limits::min(); } void Update(const HugeIntT *__restrict input, SizeT idx) { value_ = value_ < input[idx] ? input[idx] : value_; } @@ -147,7 +147,7 @@ struct MaxState { public: FloatT value_; - void Initialize() { this->value_ = f32_min; } + void Initialize() { this->value_ = std::numeric_limits::min(); } void Update(const FloatT *__restrict input, SizeT idx) { value_ = value_ < input[idx] ? input[idx] : value_; } @@ -163,7 +163,7 @@ struct MaxState { public: DoubleT value_; - void Initialize() { this->value_ = f64_min; } + void Initialize() { this->value_ = std::numeric_limits::min(); } void Update(const DoubleT *__restrict input, SizeT idx) { value_ = value_ < input[idx] ? input[idx] : value_; } diff --git a/src/function/aggregate/min.cpp b/src/function/aggregate/min.cpp index 9e589d7a6c..96980ec7dc 100644 --- a/src/function/aggregate/min.cpp +++ b/src/function/aggregate/min.cpp @@ -64,7 +64,7 @@ struct MinState { public: TinyIntT value_; - void Initialize() { this->value_ = i8_max; } + void Initialize() { this->value_ = std::numeric_limits::max(); } void Update(const TinyIntT *__restrict input, SizeT idx) { value_ = input[idx] < value_ ? input[idx] : value_; } @@ -80,7 +80,7 @@ struct MinState { public: SmallIntT value_; - void Initialize() { this->value_ = i16_max; } + void Initialize() { this->value_ = std::numeric_limits::max(); } void Update(const SmallIntT *__restrict input, SizeT idx) { value_ = input[idx] < value_ ? input[idx] : value_; } @@ -96,7 +96,7 @@ struct MinState { public: IntegerT value_; - void Initialize() { this->value_ = i32_max; } + void Initialize() { this->value_ = std::numeric_limits::max();; } void Update(const IntegerT *__restrict input, SizeT idx) { value_ = input[idx] < value_ ? input[idx] : value_; } @@ -112,7 +112,7 @@ struct MinState { public: BigIntT value_; - void Initialize() { this->value_ = i64_max; } + void Initialize() { this->value_ = std::numeric_limits::max();; } void Update(const BigIntT *__restrict input, SizeT idx) { value_ = input[idx] < value_ ? input[idx] : value_; } @@ -129,8 +129,8 @@ struct MinState { HugeIntT value_; void Initialize() { - this->value_.lower = i64_max; - this->value_.upper = i64_max; + this->value_.lower = std::numeric_limits::max();; + this->value_.upper = std::numeric_limits::max();; } void Update(const HugeIntT *__restrict input, SizeT idx) { value_ = input[idx] < value_ ? input[idx] : value_; } @@ -147,7 +147,7 @@ struct MinState { public: FloatT value_; - void Initialize() { this->value_ = f32_max; } + void Initialize() { this->value_ = std::numeric_limits::max(); } void Update(const FloatT *__restrict input, SizeT idx) { value_ = input[idx] < value_ ? input[idx] : value_; } @@ -163,7 +163,7 @@ struct MinState { public: DoubleT value_; - void Initialize() { this->value_ = f64_max; } + void Initialize() { this->value_ = std::numeric_limits::max(); } void Update(const DoubleT *__restrict input, SizeT idx) { value_ = input[idx] < value_ ? input[idx] : value_; } diff --git a/src/function/aggregate_function.cppm b/src/function/aggregate_function.cppm index 1cc5091316..6ace40efdb 100644 --- a/src/function/aggregate_function.cppm +++ b/src/function/aggregate_function.cppm @@ -106,8 +106,8 @@ public: AggregateInitializeFuncType init_func, AggregateUpdateFuncType update_func, AggregateFinalizeFuncType finalize_func) - : Function(Move(name), FunctionType::kAggregate), init_func_(Move(init_func)), update_func_(Move(update_func)), - finalize_func_(Move(finalize_func)), argument_type_(Move(argument_type)), return_type_(Move(return_type)), state_size_(state_size) { + : Function(std::move(name), FunctionType::kAggregate), init_func_(std::move(init_func)), update_func_(std::move(update_func)), + finalize_func_(std::move(finalize_func)), argument_type_(std::move(argument_type)), return_type_(std::move(return_type)), state_size_(state_size) { state_data_ = SharedPtr(new char[state_size_]()); } diff --git a/src/function/aggregate_function_set.cpp b/src/function/aggregate_function_set.cpp index 766a9171c0..b4e7015530 100644 --- a/src/function/aggregate_function_set.cpp +++ b/src/function/aggregate_function_set.cpp @@ -32,7 +32,7 @@ AggregateFunctionSet::~AggregateFunctionSet() { functions_.clear(); } void AggregateFunctionSet::AddFunction(const AggregateFunction &func) { functions_.emplace_back(func); } AggregateFunction AggregateFunctionSet::GetMostMatchFunction(const SharedPtr &input_argument) { - i64 lowest_cost = i64_max; + i64 lowest_cost = std::numeric_limits::max();; SizeT function_count = functions_.size(); Vector candidates_index; diff --git a/src/function/aggregate_function_set.cppm b/src/function/aggregate_function_set.cppm index 3ffaee85f9..66ca7bb217 100644 --- a/src/function/aggregate_function_set.cppm +++ b/src/function/aggregate_function_set.cppm @@ -26,7 +26,7 @@ namespace infinity { export class AggregateFunctionSet final : public FunctionSet { public: - explicit AggregateFunctionSet(String name) : FunctionSet(Move(name), FunctionType::kAggregate) {} + explicit AggregateFunctionSet(String name) : FunctionSet(std::move(name), FunctionType::kAggregate) {} ~AggregateFunctionSet() final; diff --git a/src/function/cast/bitmap_cast.cppm b/src/function/cast/bitmap_cast.cppm index 24a67fd6fa..10bf363289 100644 --- a/src/function/cast/bitmap_cast.cppm +++ b/src/function/cast/bitmap_cast.cppm @@ -35,7 +35,7 @@ export inline BoundCastFunc BindBitmapCast(DataType &target) { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Can't cast from Time type to {}", target.ToString())); + Error(fmt::format("Can't cast from Time type to {}", target.ToString())); } } return BoundCastFunc(nullptr); diff --git a/src/function/cast/blob_cast.cppm b/src/function/cast/blob_cast.cppm index d8988c9fda..6c6d01433d 100644 --- a/src/function/cast/blob_cast.cppm +++ b/src/function/cast/blob_cast.cppm @@ -36,7 +36,7 @@ export inline BoundCastFunc BindBlobCast(DataType &target) { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Can't cast from Blob type to {}", target.ToString())); + Error(fmt::format("Can't cast from Blob type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -46,7 +46,7 @@ struct BlobTryCastToVarlen { template static inline bool Run(const SourceType &source, TargetType &target, const SharedPtr &vector_ptr) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -60,16 +60,16 @@ inline bool BlobTryCastToVarlen::Run(const BlobT &source, VarcharT &target, cons target.length = static_cast(source.size); if (target.length <= VarcharT::INLINE_LENGTH) { // inline varchar - Memcpy(target.prefix, source.ptr, target.length); - Memset(target.prefix + target.length, 0, VarcharT::INLINE_LENGTH - target.length); + std::memcpy(target.prefix, source.ptr, target.length); + std::memset(target.prefix + target.length, 0, VarcharT::INLINE_LENGTH - target.length); } else { Assert(vector_ptr->buffer_->buffer_type_ == VectorBufferType::kHeap, "Varchar column vector should use MemoryVectorBuffer. "); // Set varchar prefix - Memcpy(target.prefix, source.ptr, VarcharT::PREFIX_LENGTH); + std::memcpy(target.prefix, source.ptr, VarcharT::PREFIX_LENGTH); ptr_t ptr = vector_ptr->buffer_->fix_heap_mgr_->Allocate(target.length); - Memcpy(ptr, source.ptr, target.length); + std::memcpy(ptr, source.ptr, target.length); target.ptr = ptr; } diff --git a/src/function/cast/bool_cast.cppm b/src/function/cast/bool_cast.cppm index f552cfc362..e45aa3e136 100644 --- a/src/function/cast/bool_cast.cppm +++ b/src/function/cast/bool_cast.cppm @@ -30,7 +30,7 @@ export struct TryCastBoolean { template static inline bool Run(SourceType, TargetType &) { Error( - Format("No implementation to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("No implementation to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -40,13 +40,13 @@ export struct TryCastBoolean { // inline bool TryCastBoolean::Run(BooleanT source, VarcharT &target) { // if (source) { // constexpr u16 TRUE_LEN = 4; -// Memcpy(target.prefix, "true", TRUE_LEN); -// Memset(target.prefix + TRUE_LEN, 0, VarcharT::INLINE_LENGTH - TRUE_LEN); +// std::memcpy(target.prefix, "true", TRUE_LEN); +// std::memset(target.prefix + TRUE_LEN, 0, VarcharT::INLINE_LENGTH - TRUE_LEN); // target.length = TRUE_LEN; // } else { // constexpr u16 FALSE_LEN = 5; -// Memcpy(target.prefix, "false", FALSE_LEN); -// Memset(target.prefix + FALSE_LEN, 0, VarcharT::INLINE_LENGTH - FALSE_LEN); +// std::memcpy(target.prefix, "false", FALSE_LEN); +// std::memset(target.prefix + FALSE_LEN, 0, VarcharT::INLINE_LENGTH - FALSE_LEN); // target.length = FALSE_LEN; // } // return true; @@ -54,7 +54,7 @@ export struct TryCastBoolean { export inline BoundCastFunc BindBoolCast(const DataType &source, const DataType &target) { if (source.type() != LogicalType::kBoolean) { - Error(Format("Expect boolean type, but it is {}", source.ToString())); + Error(fmt::format("Expect boolean type, but it is {}", source.ToString())); } switch (target.type()) { @@ -62,7 +62,7 @@ export inline BoundCastFunc BindBoolCast(const DataType &source, const DataType return BoundCastFunc(&ColumnVectorCast::TryCastColumnVector); } default: { - Error(Format("Can't cast from Boolean to {}", target.ToString())); + Error(fmt::format("Can't cast from Boolean to {}", target.ToString())); } } return BoundCastFunc(nullptr); diff --git a/src/function/cast/cast_function.cpp b/src/function/cast/cast_function.cpp index 9c32a8f9a3..de3171d535 100644 --- a/src/function/cast/cast_function.cpp +++ b/src/function/cast/cast_function.cpp @@ -32,35 +32,35 @@ template static BoundCastFunc NumericCast(const DataType &target) { switch (target.type()) { case kTinyInt: { - Error(Format("Can't cast to {}", target.ToString())); + Error(fmt::format("Can't cast to {}", target.ToString())); } case kSmallInt: { - Error(Format("Can't cast to {}", target.ToString())); + Error(fmt::format("Can't cast to {}", target.ToString())); } case kInteger: { - Error(Format("Can't cast to {}", target.ToString())); + Error(fmt::format("Can't cast to {}", target.ToString())); } case kBigInt: { - Error(Format("Can't cast to {}", target.ToString())); + Error(fmt::format("Can't cast to {}", target.ToString())); } case kHugeInt: { - Error(Format("Can't cast to {}", target.ToString())); + Error(fmt::format("Can't cast to {}", target.ToString())); } case kFloat: { - Error(Format("Can't cast to {}", target.ToString())); + Error(fmt::format("Can't cast to {}", target.ToString())); } case kDouble: { - Error(Format("Can't cast to {}", target.ToString())); + Error(fmt::format("Can't cast to {}", target.ToString())); } default: { - Error(Format("Can't cast to {}", target.ToString())); + Error(fmt::format("Can't cast to {}", target.ToString())); } } } BoundCastFunc CastFunction::GetBoundFunc(const DataType &source, const DataType &target) { if (source == target) { - Error(Format("Attempt to cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Attempt to cast from {} to {}", source.ToString(), target.ToString())); } switch (source.type()) { @@ -89,76 +89,76 @@ BoundCastFunc CastFunction::GetBoundFunc(const DataType &source, const DataType return BindFloatCast(source, target); } case kDecimal: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kVarchar: { return BindVarcharCast(source, target); } case kDate: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kTime: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kDateTime: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kTimestamp: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kInterval: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kArray: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kTuple: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kPoint: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kLine: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kLineSeg: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kBox: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } // case kPath: { -// Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); +// Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); // } // case kPolygon: { -// Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); +// Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); // } case kCircle: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } // case kBitmap: { -// Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); +// Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); // } case kUuid: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } // case kBlob: { -// Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); +// Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); // } case kEmbedding: { return BindEmbeddingCast(source, target); } case kRowID: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kMixed: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } case kNull: { - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } default: - Error(Format("Can't cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Can't cast from {} to {}", source.ToString(), target.ToString())); } return BoundCastFunc(nullptr); } diff --git a/src/function/cast/column_vector_cast.cppm b/src/function/cast/column_vector_cast.cppm index cae845d032..1571d266f3 100644 --- a/src/function/cast/column_vector_cast.cppm +++ b/src/function/cast/column_vector_cast.cppm @@ -29,7 +29,7 @@ namespace infinity { struct ColumnVectorCastData { explicit ColumnVectorCastData(bool strict, SharedPtr &column_vector_ptr, DataType source_type, DataType target_type) - : source_type_(Move(source_type)), target_type_(Move(target_type)), strict_(strict), column_vector_ptr_(column_vector_ptr) {} + : source_type_(std::move(source_type)), target_type_(std::move(target_type)), strict_(strict), column_vector_ptr_(column_vector_ptr) {} DataType source_type_{LogicalType::kInvalid}; DataType target_type_{LogicalType::kInvalid}; @@ -42,7 +42,7 @@ template struct TryCastValue { template inline static void Execute(SourceValueType input, TargetValueType &result, Bitmask *nulls_ptr, SizeT idx, void *state_ptr) { - if (Operator::template Run(Move(input), result)) { + if (Operator::template Run(std::move(input), result)) { return; } diff --git a/src/function/cast/date_cast.cppm b/src/function/cast/date_cast.cppm index 062be4b2b9..6e48def13e 100644 --- a/src/function/cast/date_cast.cppm +++ b/src/function/cast/date_cast.cppm @@ -43,7 +43,7 @@ export inline BoundCastFunc BindDateCast(DataType &target) { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Can't cast from Date type to {}", target.ToString())); + Error(fmt::format("Can't cast from Date type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -53,7 +53,7 @@ struct DateTryCastToFixlen { template static inline bool Run(SourceType , TargetType &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -62,7 +62,7 @@ struct DateTryCastToVarlen { template static inline bool Run(SourceType , TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; diff --git a/src/function/cast/datetime_cast.cppm b/src/function/cast/datetime_cast.cppm index 1b1535bdf8..7394b54505 100644 --- a/src/function/cast/datetime_cast.cppm +++ b/src/function/cast/datetime_cast.cppm @@ -46,7 +46,7 @@ export inline BoundCastFunc BindDateTimeCast(DataType &target) { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Can't cast from DateTime type to {}", target.ToString())); + Error(fmt::format("Can't cast from DateTime type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -56,7 +56,7 @@ struct DateTimeTryCastToFixlen { template static inline bool Run(SourceType, TargetType &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -65,7 +65,7 @@ struct DateTimeTryCastToVarlen { template static inline bool Run(SourceType, TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; diff --git a/src/function/cast/decimal_cast.cppm b/src/function/cast/decimal_cast.cppm index cebb1f0380..423be34387 100644 --- a/src/function/cast/decimal_cast.cppm +++ b/src/function/cast/decimal_cast.cppm @@ -65,7 +65,7 @@ inline BoundCastFunc BindDecimalCast(const DataType &source, DataType &target) { Error("Not implemented"); } default: { - Error(Format("Can't cast from Decimal type to {}", target.ToString())); + Error(fmt::format("Can't cast from Decimal type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -75,7 +75,7 @@ struct DecimalTryCastToFixlen { template static inline bool Run(SourceType , TargetType &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -84,7 +84,7 @@ struct DecimalTryCastToVarlen { template static inline bool Run(SourceType , TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; diff --git a/src/function/cast/embedding_cast.cppm b/src/function/cast/embedding_cast.cppm index 26bfd7ed77..635622f721 100644 --- a/src/function/cast/embedding_cast.cppm +++ b/src/function/cast/embedding_cast.cppm @@ -38,12 +38,12 @@ BoundCastFunc BindEmbeddingCast(const EmbeddingInfo *target); export inline BoundCastFunc BindEmbeddingCast(const DataType &source, const DataType &target) { if (source.type() != LogicalType::kEmbedding || target.type() != LogicalType::kEmbedding) { - Error(Format("Type here is expected as Embedding, but actually it is: {} and {}", source.ToString(), target.ToString())); + Error(fmt::format("Type here is expected as Embedding, but actually it is: {} and {}", source.ToString(), target.ToString())); } auto source_info = static_cast(source.type_info().get()); auto target_info = static_cast(target.type_info().get()); if (source_info->Dimension() != target_info->Dimension()) { - Error(Format("Can't cast from Embedding type to {}", target.ToString())); + Error(fmt::format("Can't cast from Embedding type to {}", target.ToString())); } switch (source_info->Type()) { case EmbeddingDataType::kElemInt8: { @@ -65,7 +65,7 @@ export inline BoundCastFunc BindEmbeddingCast(const DataType &source, const Data return BindEmbeddingCast(target_info); } default: { - Error(Format("Can't cast from {} to Embedding type", target.ToString())); + Error(fmt::format("Can't cast from {} to Embedding type", target.ToString())); } } return BoundCastFunc(nullptr); @@ -93,7 +93,7 @@ inline BoundCastFunc BindEmbeddingCast(const EmbeddingInfo *target) { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorEmbedding); } default: { - Error(Format("Can't cast from Embedding type to {}", target->ToString())); + Error(fmt::format("Can't cast from Embedding type to {}", target->ToString())); } } return BoundCastFunc(nullptr); @@ -102,15 +102,15 @@ inline BoundCastFunc BindEmbeddingCast(const EmbeddingInfo *target) { struct EmbeddingTryCastToFixlen { template static inline bool Run(const SourceElemType *source, TargetElemType *target, SizeT len) { - if constexpr (IsSame() || IsSame() || IsSame() || - IsSame()) { + if constexpr (std::is_same() || std::is_same() || + std::is_same() || std::is_same()) { for (SizeT i = 0; i < len; ++i) { if (!IntegerTryCastToFixlen::Run(source[i], target[i])) { return false; } } return true; - } else if constexpr (IsSame() || IsSame()) { + } else if constexpr (std::is_same() || std::is_same()) { for (SizeT i = 0; i < len; ++i) { if (!FloatTryCastToFixlen::Run(source[i], target[i])) { return false; @@ -119,19 +119,15 @@ struct EmbeddingTryCastToFixlen { return true; } Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); } }; struct EmbeddingTryCastToVarlen { template - static inline bool Run(const SourceType &, - const DataType &, - TargetType &, - const DataType &, - const SharedPtr &) { + static inline bool Run(const SourceType &, const DataType &, TargetType &, const DataType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -143,13 +139,13 @@ inline bool EmbeddingTryCastToVarlen::Run(const EmbeddingT &source, const DataType &, const SharedPtr &vector_ptr) { if (source_type.type() != LogicalType::kEmbedding) { - Error(Format("Type here is expected as Embedding, but actually it is: {}", source_type.ToString())); + Error(fmt::format("Type here is expected as Embedding, but actually it is: {}", source_type.ToString())); } EmbeddingInfo *embedding_info = (EmbeddingInfo *)(source_type.type_info().get()); for (SizeT j = 0; j < embedding_info->Dimension(); ++j) { - LOG_TRACE(Format("{}", ((float *)(source.ptr))[j])); + LOG_TRACE(fmt::format("{}", ((float *)(source.ptr))[j])); } String res = EmbeddingT::Embedding2String(source, embedding_info->Type(), embedding_info->Dimension()); @@ -157,14 +153,14 @@ inline bool EmbeddingTryCastToVarlen::Run(const EmbeddingT &source, target.is_value_ = false; if (target.length_ <= VARCHAR_PREFIX_LEN) { // inline varchar - Memcpy(target.short_.data_, res.c_str(), target.length_); + std::memcpy(target.short_.data_, res.c_str(), target.length_); } else { if (vector_ptr->buffer_->buffer_type_ != VectorBufferType::kHeap) { - Error(Format("Varchar column vector should use MemoryVectorBuffer.")); + Error(fmt::format("Varchar column vector should use MemoryVectorBuffer.")); } // Set varchar prefix - Memcpy(target.vector_.prefix_, res.c_str(), VARCHAR_PREFIX_LEN); + std::memcpy(target.vector_.prefix_, res.c_str(), VARCHAR_PREFIX_LEN); auto [chunk_id, chunk_offset] = vector_ptr->buffer_->fix_heap_mgr_->AppendToHeap(res.c_str(), target.length_); target.vector_.chunk_id_ = chunk_id; diff --git a/src/function/cast/float_cast.cppm b/src/function/cast/float_cast.cppm index ed246d9079..d313f4aef3 100644 --- a/src/function/cast/float_cast.cppm +++ b/src/function/cast/float_cast.cppm @@ -61,13 +61,13 @@ inline BoundCastFunc BindFloatCast(const DataType &source, const DataType &targe return BoundCastFunc(&ColumnVectorCast::TryCastColumnVector); } case LogicalType::kDecimal: { - Error(Format("Not implement cast from numeric to decimal128 type.", source.ToString(), target.ToString())); + Error(fmt::format("Not implement cast from numeric to decimal128 type.", source.ToString(), target.ToString())); } case LogicalType::kVarchar: { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Attempt to cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Attempt to cast from {} to {}", source.ToString(), target.ToString())); } } return BoundCastFunc(nullptr); @@ -77,7 +77,7 @@ struct FloatTryCastToFixlen { template static inline bool Run(SourceType, TargetType &) { Error( - Format("Not implemented to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not implemented to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -86,7 +86,7 @@ struct FloatTryCastToVarlen { template static inline bool Run(SourceType, TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -155,13 +155,13 @@ inline bool FloatTryCastToFixlen::Run(FloatT, DecimalT &) { template <> inline bool FloatTryCastToVarlen::Run(FloatT source, VarcharT &target, const SharedPtr &vector_ptr) { target.is_value_ = false; - String tmp_str = ToStr(source); + String tmp_str = std::to_string(source); target.length_ = static_cast(tmp_str.size()); if (target.length_ <= VARCHAR_INLINE_LEN) { - Memcpy(target.short_.data_, tmp_str.c_str(), target.length_); + std::memcpy(target.short_.data_, tmp_str.c_str(), target.length_); } else { - Memcpy(target.vector_.prefix_, tmp_str.c_str(), VARCHAR_PREFIX_LEN); + std::memcpy(target.vector_.prefix_, tmp_str.c_str(), VARCHAR_PREFIX_LEN); if (vector_ptr->buffer_->buffer_type_ != VectorBufferType::kHeap) { Error("Varchar column vector should use MemoryVectorBuffer. "); } @@ -238,13 +238,13 @@ template <> inline bool FloatTryCastToVarlen::Run(DoubleT source, VarcharT &target, const SharedPtr &vector_ptr) { // TODO: High-performance to_string implementation is needed. target.is_value_ = false; - String tmp_str = ToStr(source); + String tmp_str = std::to_string(source); target.length_ = static_cast(tmp_str.size()); if (target.length_ <= VARCHAR_INLINE_LEN) { - Memcpy(target.short_.data_, tmp_str.c_str(), target.length_); + std::memcpy(target.short_.data_, tmp_str.c_str(), target.length_); } else { - Memcpy(target.vector_.prefix_, tmp_str.c_str(), VARCHAR_PREFIX_LEN); + std::memcpy(target.vector_.prefix_, tmp_str.c_str(), VARCHAR_PREFIX_LEN); if (vector_ptr->buffer_->buffer_type_ != VectorBufferType::kHeap) { Error("Varchar column vector should use MemoryVectorBuffer. "); } diff --git a/src/function/cast/geography_cast.cppm b/src/function/cast/geography_cast.cppm index 85288b0852..76a55190c1 100644 --- a/src/function/cast/geography_cast.cppm +++ b/src/function/cast/geography_cast.cppm @@ -40,7 +40,7 @@ inline BoundCastFunc BindGeographyCast(const DataType &source, DataType &target) return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Can't cast from geography type to {}", target.ToString())); + Error(fmt::format("Can't cast from geography type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -50,7 +50,7 @@ struct GeographyTryCastToVarlen { template static inline bool Run(const SourceType &, TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; diff --git a/src/function/cast/integer_cast.cppm b/src/function/cast/integer_cast.cppm index dd874dc279..a04261f3c7 100644 --- a/src/function/cast/integer_cast.cppm +++ b/src/function/cast/integer_cast.cppm @@ -65,7 +65,7 @@ inline BoundCastFunc BindIntegerCast(const DataType &source, const DataType &tar return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Attempt to cast from {} to {}", source.ToString(), target.ToString())); + Error(fmt::format("Attempt to cast from {} to {}", source.ToString(), target.ToString())); } } return BoundCastFunc(nullptr); @@ -75,7 +75,7 @@ struct IntegerTryCastToFixlen { template static inline bool Run(SourceType, TargetType &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -84,7 +84,7 @@ struct IntegerTryCastToVarlen { template static inline bool Run(SourceType, TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -130,7 +130,7 @@ inline bool IntegerTryCastToFixlen::Run(TinyIntT source, DoubleT &target) { // TODO template <> inline bool IntegerTryCastToFixlen::Run(TinyIntT, DecimalT &) { - Error(Format("Not implemented")); + Error(fmt::format("Not implemented")); return false; } @@ -144,19 +144,19 @@ inline bool IntegerTryCastToVarlen::Run(TinyIntT source, VarcharT &target, const return true; } // TODO: High performance itoa needed here. - String tmp_str = ToStr(source); + String tmp_str = std::to_string(source); target.length_ = static_cast(tmp_str.size()); if (target.length_ > VARCHAR_INLINE_LEN) { Error("Integer digits number should less than 14."); } - Memcpy(target.short_.data_, tmp_str.c_str(), target.length_); + std::memcpy(target.short_.data_, tmp_str.c_str(), target.length_); return true; } // Cast SmallInt to other numeric type template <> inline bool IntegerTryCastToFixlen::Run(SmallIntT source, TinyIntT &target) { - if (source < i8_min || source > i8_max) { + if (source < std::numeric_limits::min() || source > std::numeric_limits::max()) { return false; } target = static_cast(source); @@ -211,19 +211,19 @@ inline bool IntegerTryCastToVarlen::Run(SmallIntT source, VarcharT &target, cons return true; } // TODO: High performance itoa needed here. - String tmp_str = ToStr(source); + String tmp_str = std::to_string(source); target.length_ = static_cast(tmp_str.size()); if (target.length_ > VARCHAR_INLINE_LEN) { Error("Integer digits number should less than 14."); } - Memcpy(target.short_.data_, tmp_str.c_str(), target.length_); + std::memcpy(target.short_.data_, tmp_str.c_str(), target.length_); return true; } // Cast Integer to other numeric type template <> inline bool IntegerTryCastToFixlen::Run(IntegerT source, TinyIntT &target) { - if (source < i8_min || source > i8_max) { + if (source < std::numeric_limits::min() || source > std::numeric_limits::max()) { return false; } target = static_cast(source); @@ -232,7 +232,7 @@ inline bool IntegerTryCastToFixlen::Run(IntegerT source, TinyIntT &target) { template <> inline bool IntegerTryCastToFixlen::Run(IntegerT source, SmallIntT &target) { - if (source < i16_min || source > i16_max) { + if (source < std::numeric_limits::min() || source > std::numeric_limits::max()) { return false; } target = static_cast(source); @@ -281,19 +281,19 @@ inline bool IntegerTryCastToVarlen::Run(IntegerT source, VarcharT &target, const return true; } // TODO: High performance itoa needed here. - String tmp_str = ToStr(source); + String tmp_str = std::to_string(source); target.length_ = static_cast(tmp_str.size()); if (target.length_ > VARCHAR_INLINE_LEN) { Error("Integer digits number should less than 14."); } - Memcpy(target.short_.data_, tmp_str.c_str(), target.length_); + std::memcpy(target.short_.data_, tmp_str.c_str(), target.length_); return true; } // Cast BigInt to other numeric type template <> inline bool IntegerTryCastToFixlen::Run(BigIntT source, TinyIntT &target) { - if (source < i8_min || source > i8_max) { + if (source < std::numeric_limits::min() || source > std::numeric_limits::max()) { return false; } target = static_cast(source); @@ -302,7 +302,7 @@ inline bool IntegerTryCastToFixlen::Run(BigIntT source, TinyIntT &target) { template <> inline bool IntegerTryCastToFixlen::Run(BigIntT source, SmallIntT &target) { - if (source < i16_min || source > i16_max) { + if (source < std::numeric_limits::min() || source > std::numeric_limits::max()) { return false; } target = static_cast(source); @@ -311,7 +311,7 @@ inline bool IntegerTryCastToFixlen::Run(BigIntT source, SmallIntT &target) { template <> inline bool IntegerTryCastToFixlen::Run(BigIntT source, IntegerT &target) { - if (source < i32_min || source > i32_max) { + if (source < std::numeric_limits::min() || source > std::numeric_limits::max()) { return false; } target = static_cast(source); @@ -354,12 +354,12 @@ inline bool IntegerTryCastToVarlen::Run(BigIntT source, VarcharT &target, const return true; } // TODO: High performance itoa needed here. - String tmp_str = ToStr(source); + String tmp_str = std::to_string(source); target.length_ = static_cast(tmp_str.size()); if (target.length_ <= VARCHAR_INLINE_LEN) { - Memcpy(target.short_.data_, tmp_str.c_str(), target.length_); + std::memcpy(target.short_.data_, tmp_str.c_str(), target.length_); } else { - Memcpy(target.vector_.prefix_, tmp_str.c_str(), VARCHAR_PREFIX_LEN); + std::memcpy(target.vector_.prefix_, tmp_str.c_str(), VARCHAR_PREFIX_LEN); if (vector_ptr->buffer_->buffer_type_ != VectorBufferType::kHeap) { Error("Varchar column vector should use MemoryVectorBuffer. "); } diff --git a/src/function/cast/interval_cast.cppm b/src/function/cast/interval_cast.cppm index 327b607843..b3fc7ff3a5 100644 --- a/src/function/cast/interval_cast.cppm +++ b/src/function/cast/interval_cast.cppm @@ -37,7 +37,7 @@ export inline BoundCastFunc BindTimeCast(DataType &target) { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Can't cast from Interval type to {}", target.ToString())); + Error(fmt::format("Can't cast from Interval type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -47,7 +47,7 @@ struct IntervalTryCastToVarlen { template static inline bool Run(SourceType, TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; diff --git a/src/function/cast/time_cast.cppm b/src/function/cast/time_cast.cppm index 00f448d8dc..6f0f3f93ac 100644 --- a/src/function/cast/time_cast.cppm +++ b/src/function/cast/time_cast.cppm @@ -36,7 +36,7 @@ export inline BoundCastFunc BindTimeCast(DataType &target) { } default: { Error( - Format("Can't cast from Time type to {}", target.ToString())); + fmt::format("Can't cast from Time type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -46,7 +46,7 @@ struct TimeTryCastToVarlen { template static inline bool Run(SourceType, TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; diff --git a/src/function/cast/timestamp_cast.cppm b/src/function/cast/timestamp_cast.cppm index 7cf9f29834..6e75675f46 100644 --- a/src/function/cast/timestamp_cast.cppm +++ b/src/function/cast/timestamp_cast.cppm @@ -45,7 +45,7 @@ export inline BoundCastFunc BindTimestampCast(DataType &target) { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Can't cast from Timestamp type to {}", target.ToString())); + Error(fmt::format("Can't cast from Timestamp type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -55,7 +55,7 @@ struct TimestampTryCastToFixlen { template static inline bool Run(SourceType, TargetType &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -64,7 +64,7 @@ struct TimestampTryCastToVarlen { template static inline bool Run(SourceType, TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; diff --git a/src/function/cast/uuid_cast.cppm b/src/function/cast/uuid_cast.cppm index 341c95a972..ac9c3defe4 100644 --- a/src/function/cast/uuid_cast.cppm +++ b/src/function/cast/uuid_cast.cppm @@ -36,7 +36,7 @@ export inline BoundCastFunc BindUuidCast(DataType &target) { return BoundCastFunc(&ColumnVectorCast::TryCastColumnVectorToVarlen); } default: { - Error(Format("Can't cast from Uuid type to {}", target.ToString())); + Error(fmt::format("Can't cast from Uuid type to {}", target.ToString())); } } return BoundCastFunc(nullptr); @@ -46,7 +46,7 @@ struct UuidTryCastToVarlen { template static inline bool Run(const SourceType &, TargetType &, const SharedPtr &) { Error( - Format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("Not support to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -55,12 +55,12 @@ template <> inline bool UuidTryCastToVarlen::Run(const UuidT &, VarcharT &, const SharedPtr &) { Error("Not implemented"); // target.length_ = UuidT::LENGTH; -// Memcpy(target.prefix, source.body, VarcharT::PREFIX_LENGTH); +// std::memcpy(target.prefix, source.body, VarcharT::PREFIX_LENGTH); // Assert(vector_ptr->buffer_->buffer_type_ == VectorBufferType::kHeap, // "Varchar column vector should use MemoryVectorBuffer."); // // ptr_t ptr = vector_ptr->buffer_->fix_heap_mgr_->Allocate(target.length); -// Memcpy(ptr, source.body, target.length); +// std::memcpy(ptr, source.body, target.length); // target.ptr = ptr; return true; diff --git a/src/function/cast/varchar_cast.cppm b/src/function/cast/varchar_cast.cppm index 3f14de4db4..f6a6d7c274 100644 --- a/src/function/cast/varchar_cast.cppm +++ b/src/function/cast/varchar_cast.cppm @@ -34,7 +34,7 @@ export struct TryCastVarcharToVarchar; export inline BoundCastFunc BindVarcharCast(const DataType &source, const DataType &target) { if (source.type() != LogicalType::kVarchar) { - Error(Format("Expect Varchar type, but it is {}", source.ToString())); + Error(fmt::format("Expect Varchar type, but it is {}", source.ToString())); } switch (target.type()) { case kBoolean: { @@ -62,7 +62,7 @@ export inline BoundCastFunc BindVarcharCast(const DataType &source, const DataTy return BoundCastFunc(&ColumnVectorCast::TryCastColumnVector); } case kDecimal: { - Error(Format("Not implement cast from varchar to decimal128 type.", source.ToString(), target.ToString())); + Error(fmt::format("Not implement cast from varchar to decimal128 type.", source.ToString(), target.ToString())); } case kVarchar: { Error("Attempt to cast from varchar to varchar"); @@ -138,7 +138,7 @@ struct TryCastVarchar { template static inline bool Run(const SourceType &, TargetType &) { Error( - Format("No implementation to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); + fmt::format("No implementation to cast from {} to {}", DataType::TypeToString(), DataType::TypeToString())); return false; } }; @@ -177,7 +177,7 @@ inline bool TryCastVarchar::Run(const VarcharT &source, TinyIntT &target) { char *endptr{nullptr}; SizeT len{0}; if (source.IsInlined()) { - value = StrToL(source.short_.data_, &endptr, 10); + value = std::strtol(source.short_.data_, &endptr, 10); len = (endptr - source.short_.data_); } else { // No tiny int isn't inline @@ -197,7 +197,7 @@ inline bool TryCastVarchar::Run(const VarcharT &source, SmallIntT &target) { char *endptr{nullptr}; SizeT len{0}; if (source.IsInlined()) { - value = StrToL(source.short_.data_, &endptr, 10); + value = std::strtol(source.short_.data_, &endptr, 10); } else { // No tiny int isn't inline return false; @@ -216,7 +216,7 @@ inline bool TryCastVarchar::Run(const VarcharT &source, IntegerT &target) { char *endptr{nullptr}; SizeT len{0}; if (source.IsInlined()) { - value = StrToL(source.short_.data_, &endptr, 10); + value = std::strtol(source.short_.data_, &endptr, 10); } else { return false; } @@ -236,9 +236,9 @@ inline bool TryCastVarchar::Run(const VarcharT &source, i64 &target) { char *endptr{nullptr}; SizeT len{0}; if (source.IsInlined()) { - target = StrToL(source.short_.data_, &endptr, 10); + target = std::strtol(source.short_.data_, &endptr, 10); } else { - target = StrToL(source.value_.ptr_, &endptr, 10); + target = std::strtol(source.value_.ptr_, &endptr, 10); } if (len != source.length_) { return false; @@ -262,9 +262,9 @@ inline bool TryCastVarchar::Run(const VarcharT &source, FloatT &target) { char *endptr{nullptr}; SizeT len{0}; if (source.IsInlined()) { - target = StrToF(source.short_.data_, &endptr); + target = std::strtof(source.short_.data_, &endptr); } else { - target = StrToF(source.value_.ptr_, &endptr); + target = std::strtof(source.value_.ptr_, &endptr); } if (len != source.length_) { return false; @@ -278,9 +278,9 @@ inline bool TryCastVarchar::Run(const VarcharT &source, DoubleT &target) { char *endptr{nullptr}; SizeT len{0}; if (source.IsInlined()) { - target = StrToD(source.short_.data_, &endptr); + target = std::strtod(source.short_.data_, &endptr); } else { - target = StrToD(source.value_.ptr_, &endptr); + target = std::strtod(source.value_.ptr_, &endptr); } if (len != source.length_) { return false; diff --git a/src/function/function.cppm b/src/function/function.cppm index ebf0973c36..0903abbc0f 100644 --- a/src/function/function.cppm +++ b/src/function/function.cppm @@ -31,7 +31,7 @@ export enum class FunctionType { export class Function { public: - explicit Function(String name, FunctionType type) : name_(Move(name)), type_(type) {} + explicit Function(String name, FunctionType type) : name_(std::move(name)), type_(type) {} virtual ~Function() = default; diff --git a/src/function/function_set.cppm b/src/function/function_set.cppm index 2d3a068e92..a83b13fd0d 100644 --- a/src/function/function_set.cppm +++ b/src/function/function_set.cppm @@ -34,7 +34,7 @@ public: static String ToString(const String &name, const Vector> &arguments); public: - explicit FunctionSet(String name, FunctionType type) : name_(Move(name)), type_(type) {} + explicit FunctionSet(String name, FunctionType type) : name_(std::move(name)), type_(type) {} virtual ~FunctionSet() = default; diff --git a/src/function/scalar/equals.cpp b/src/function/scalar/equals.cpp index 4436d50975..81331749ab 100644 --- a/src/function/scalar/equals.cpp +++ b/src/function/scalar/equals.cpp @@ -46,13 +46,13 @@ inline void EqualsFunction::Run(VarcharT left, VarcharT right, bool &result) { return; } if (left.IsInlined()) { - result = (Memcmp(left.short_.data_, right.short_.data_, left.length_) == 0); + result = (std::memcmp(left.short_.data_, right.short_.data_, left.length_) == 0); return; } else { // Both left and right are not inline if(left.IsValue() && right.IsValue()) { - if (Memcmp(left.value_.prefix_, right.value_.prefix_, VARCHAR_PREFIX_LEN) == 0) { - result = (Memcmp(left.value_.ptr_, right.value_.ptr_, left.length_) == 0); + if (std::memcmp(left.value_.prefix_, right.value_.prefix_, VARCHAR_PREFIX_LEN) == 0) { + result = (std::memcmp(left.value_.ptr_, right.value_.ptr_, left.length_) == 0); return; } } else { diff --git a/src/function/scalar/greater.cpp b/src/function/scalar/greater.cpp index 0fb848426f..0b61e549ee 100644 --- a/src/function/scalar/greater.cpp +++ b/src/function/scalar/greater.cpp @@ -41,16 +41,16 @@ inline void GreaterFunction::Run(VarcharT, VarcharT, bool &) { Error("Not implement: varchar > varchar"); // if (left.IsInlined()) { // if (right.IsInlined()) { -// result = (Memcmp(left.prefix, right.prefix, VarcharT::INLINE_LENGTH) > 0); +// result = (std::memcmp(left.prefix, right.prefix, VarcharT::INLINE_LENGTH) > 0); // return; // } // } else if (right.IsInlined()) { // ; // } else { // // Both left and right are not inline -// u16 min_len = Min(right.length, left.length); -// if (Memcmp(left.prefix, right.prefix, VarcharT::PREFIX_LENGTH) > 0) { -// result = (Memcmp(left.ptr, right.ptr, min_len) > 0); +// u16 min_len = std::min(right.length, left.length); +// if (std::memcmp(left.prefix, right.prefix, VarcharT::PREFIX_LENGTH) > 0) { +// result = (std::memcmp(left.ptr, right.ptr, min_len) > 0); // return; // } // } diff --git a/src/function/scalar/greater_equals.cpp b/src/function/scalar/greater_equals.cpp index 83bc942ef1..3558d07197 100644 --- a/src/function/scalar/greater_equals.cpp +++ b/src/function/scalar/greater_equals.cpp @@ -42,16 +42,16 @@ inline void GreaterEqualsFunction::Run(VarcharT, VarcharT, bool &) { // if (left.IsInlined()) { // if (right.IsInlined()) { -// result = (Memcmp(left.prefix, right.prefix, VarcharT::INLINE_LENGTH) >= 0); +// result = (std::memcmp(left.prefix, right.prefix, VarcharT::INLINE_LENGTH) >= 0); // return; // } // } else if (right.IsInlined()) { // ; // } else { // // Both left and right are not inline -// u16 min_len = Min(right.length, left.length); -// if (Memcmp(left.prefix, right.prefix, VarcharT::PREFIX_LENGTH) >= 0) { -// result = (Memcmp(left.ptr, right.ptr, min_len) >= 0); +// u16 min_len = std::min(right.length, left.length); +// if (std::memcmp(left.prefix, right.prefix, VarcharT::PREFIX_LENGTH) >= 0) { +// result = (std::memcmp(left.ptr, right.ptr, min_len) >= 0); // return; // } // } diff --git a/src/function/scalar/inequals.cpp b/src/function/scalar/inequals.cpp index 51d25fc4a8..1b162555ac 100644 --- a/src/function/scalar/inequals.cpp +++ b/src/function/scalar/inequals.cpp @@ -48,13 +48,13 @@ inline void InEqualsFunction::Run(VarcharT left, VarcharT right, bool &result) { return; } if (left.IsInlined()) { - result = (Memcmp(left.short_.data_, right.short_.data_, left.length_) != 0); + result = (std::memcmp(left.short_.data_, right.short_.data_, left.length_) != 0); return; } else { // Both left and right are not inline if(left.IsValue() && right.IsValue()) { - if (Memcmp(left.value_.prefix_, right.value_.prefix_, VARCHAR_PREFIX_LEN) != 0) { - result = (Memcmp(left.value_.ptr_, right.value_.ptr_, left.length_) != 0); + if (std::memcmp(left.value_.prefix_, right.value_.prefix_, VARCHAR_PREFIX_LEN) != 0) { + result = (std::memcmp(left.value_.ptr_, right.value_.ptr_, left.length_) != 0); return; } } else { diff --git a/src/function/scalar/less.cpp b/src/function/scalar/less.cpp index 781a742449..846acd6882 100644 --- a/src/function/scalar/less.cpp +++ b/src/function/scalar/less.cpp @@ -41,16 +41,16 @@ inline void LessFunction::Run(VarcharT, VarcharT, bool &) { Error("Not implement: varchar < varchar"); // if (left.IsInlined()) { // if (right.IsInlined()) { -// result = (Memcmp(left.prefix, right.prefix, VarcharT::INLINE_LENGTH) < 0); +// result = (std::memcmp(left.prefix, right.prefix, VarcharT::INLINE_LENGTH) < 0); // return; // } // } else if (right.IsInlined()) { // ; // } else { // // Both left and right are not inline -// u16 min_len = Min(right.length, left.length); -// if (Memcmp(left.prefix, right.prefix, VarcharT::PREFIX_LENGTH) < 0) { -// result = (Memcmp(left.ptr, right.ptr, min_len) < 0); +// u16 min_len = std::min(right.length, left.length); +// if (std::memcmp(left.prefix, right.prefix, VarcharT::PREFIX_LENGTH) < 0) { +// result = (std::memcmp(left.ptr, right.ptr, min_len) < 0); // return; // } // } diff --git a/src/function/scalar/less_equals.cpp b/src/function/scalar/less_equals.cpp index a18680e3e3..6a59550f4a 100644 --- a/src/function/scalar/less_equals.cpp +++ b/src/function/scalar/less_equals.cpp @@ -41,16 +41,16 @@ inline void LessEqualsFunction::Run(VarcharT, VarcharT, bool &) { Error("Not implement: varchar <= varchar"); // if (left.IsInlined()) { // if (right.IsInlined()) { -// result = (Memcmp(left.prefix, right.prefix, VarcharT::INLINE_LENGTH) <= 0); +// result = (std::memcmp(left.prefix, right.prefix, VarcharT::INLINE_LENGTH) <= 0); // return; // } // } else if (right.IsInlined()) { // ; // } else { // // Both left and right are not inline -// u16 min_len = Min(right.length, left.length); -// if (Memcmp(left.prefix, right.prefix, VarcharT::PREFIX_LENGTH) <= 0) { -// result = (Memcmp(left.ptr, right.ptr, min_len) <= 0); +// u16 min_len = std::min(right.length, left.length); +// if (std::memcmp(left.prefix, right.prefix, VarcharT::PREFIX_LENGTH) <= 0) { +// result = (std::memcmp(left.ptr, right.ptr, min_len) <= 0); // return; // } // } diff --git a/src/function/scalar/substring.cpp b/src/function/scalar/substring.cpp index de5aa4e762..eaf8045cab 100644 --- a/src/function/scalar/substring.cpp +++ b/src/function/scalar/substring.cpp @@ -41,11 +41,11 @@ inline bool SubstrFunction::Run(VarcharT, BigIntT, BigIntT, VarcharT &, ColumnVe Error("Not implement"); // if (second < 0) { -// Error(Format("substring start offset should >= 0, currently it is {}", second)); +// Error(fmt::format("substring start offset should >= 0, currently it is {}", second)); // } // // if (third < 0) { -// Error(Format("substring length should >= 0, currently it is {}", second)); +// Error(fmt::format("substring length should >= 0, currently it is {}", second)); // } // // if (third == 0) { @@ -73,12 +73,12 @@ inline bool SubstrFunction::Run(VarcharT, BigIntT, BigIntT, VarcharT &, ColumnVe // ptr_t source_ptr = first.GetDataPtr(); // if (copied_length <= VarcharT::INLINE_LENGTH) { // // inline varchar -// Memcpy(result.prefix, source_ptr + start_offset, copied_length); +// std::memcpy(result.prefix, source_ptr + start_offset, copied_length); // result.length = copied_length; // } else { -// Memcpy(result.prefix, source_ptr + start_offset, VarcharT::INLINE_LENGTH); +// std::memcpy(result.prefix, source_ptr + start_offset, VarcharT::INLINE_LENGTH); // result.ptr = column_vector_ptr->buffer_->fix_heap_mgr_->Allocate(copied_length); -// Memcpy(result.ptr, source_ptr + start_offset, copied_length); +// std::memcpy(result.ptr, source_ptr + start_offset, copied_length); // } return true; diff --git a/src/function/scalar_function.cpp b/src/function/scalar_function.cpp index b8c8204f5d..4606559552 100644 --- a/src/function/scalar_function.cpp +++ b/src/function/scalar_function.cpp @@ -29,14 +29,14 @@ module scalar_function; namespace infinity { ScalarFunction::ScalarFunction(String name, Vector argument_types, DataType return_type, ScalarFunctionType function) - : Function(Move(name), FunctionType::kScalar), parameter_types_(Move(argument_types)), return_type_(Move(return_type)), - function_(Move(function)) {} + : Function(std::move(name), FunctionType::kScalar), parameter_types_(std::move(argument_types)), return_type_(std::move(return_type)), + function_(std::move(function)) {} void ScalarFunction::CastArgumentTypes(Vector &input_arguments) { // Check and add a cast function to cast the input arguments expression type to target type auto arguments_count = input_arguments.size(); if (input_arguments.size() == arguments_count) { - Error(Format("Function: {} arguments number isn't matched.", name_)); + Error(fmt::format("Function: {} arguments number isn't matched.", name_)); } for (SizeT idx = 0; idx < arguments_count; ++idx) { if (parameter_types_[idx] != input_arguments[idx].Type()) { diff --git a/src/function/scalar_function_set.cpp b/src/function/scalar_function_set.cpp index 674e65a5d5..0c3f9f799f 100644 --- a/src/function/scalar_function_set.cpp +++ b/src/function/scalar_function_set.cpp @@ -32,7 +32,7 @@ void ScalarFunctionSet::AddFunction(const ScalarFunction &func) { functions_.emp ScalarFunction ScalarFunctionSet::GetMostMatchFunction(const Vector> &input_arguments) { - i64 lowest_cost = i64_max; + i64 lowest_cost = std::numeric_limits::max();; SizeT function_count = functions_.size(); Vector candidates_index; diff --git a/src/function/scalar_function_set.cppm b/src/function/scalar_function_set.cppm index cce832cf7d..0764f8debb 100644 --- a/src/function/scalar_function_set.cppm +++ b/src/function/scalar_function_set.cppm @@ -26,7 +26,7 @@ namespace infinity { export class ScalarFunctionSet final : public FunctionSet { public: - explicit ScalarFunctionSet(String name) : FunctionSet(Move(name), FunctionType::kScalar) {} + explicit ScalarFunctionSet(String name) : FunctionSet(std::move(name), FunctionType::kScalar) {} ~ScalarFunctionSet() final; diff --git a/src/function/special_function.cppm b/src/function/special_function.cppm index 772c22e5b6..b5f86f7efa 100644 --- a/src/function/special_function.cppm +++ b/src/function/special_function.cppm @@ -33,7 +33,7 @@ export enum class SpecialType { export class SpecialFunction final : public Function { public: SpecialFunction(const String func_name, DataType data_type, SizeT extra_idx, SpecialType special_type) - : Function(Move(func_name), FunctionType::kSpecial), data_type_(Move(data_type)), special_type_(special_type), extra_idx_(extra_idx) {} + : Function(std::move(func_name), FunctionType::kSpecial), data_type_(std::move(data_type)), special_type_(special_type), extra_idx_(extra_idx) {} const String &name() const { return name_; } diff --git a/src/function/table/knn_scan.cpp b/src/function/table/knn_scan.cpp index b47c5119de..4bed5b1fe9 100644 --- a/src/function/table/knn_scan.cpp +++ b/src/function/table/knn_scan.cpp @@ -81,7 +81,7 @@ void KnnScanFunc(QueryContext *, TableFunctionData *, DataBlock &) { // for (i64 top_idx = 0; top_idx < knn_scan_function_data_ptr->topk_; ++top_idx) { // SizeT id = query_idx * knn_scan_function_data_ptr->query_embedding_count_ + top_idx; // LOG_TRACE( - // Format("Row offset: {}: {}, distance {}", row_id[id].segment_id_, row_id[id].segment_offset_, + // fmt::format("Row offset: {}: {}, distance {}", row_id[id].segment_id_, row_id[id].segment_offset_, // top_distance[id])); // } // } @@ -235,7 +235,7 @@ void KnnScanFunc(QueryContext *, TableFunctionData *, DataBlock &) { // for (i64 top_idx = 0; top_idx < knn_scan_function_data_ptr->topk_; ++top_idx) { // SizeT id = query_idx * knn_scan_function_data_ptr->query_embedding_count_ + top_idx; // LOG_TRACE( - // Format("Row offset: {}: {}, distance {}", row_id[id].segment_id_, row_id[id].segment_offset_, + // fmt::format("Row offset: {}: {}, distance {}", row_id[id].segment_id_, row_id[id].segment_offset_, // top_distance[id])); // } // } @@ -387,7 +387,7 @@ void KnnScanFunc(QueryContext *, TableFunctionData *, DataBlock &) { // while(write_capacity > 0 && segments_idx < segment_indexes->size()) { // SegmentEntry* current_segment_entry = segment_entries[segments_idx]; // auto remaining_rows = current_segment_entry->current_row_ - read_offset; - // auto write_size = Min(write_capacity, remaining_rows); + // auto write_size = std::min(write_capacity, remaining_rows); // SizeT output_column_id{0}; // for (auto column_id : column_ids) { diff --git a/src/function/table/knn_scan.cppm b/src/function/table/knn_scan.cppm index 6c92157fa9..ce08add7d7 100644 --- a/src/function/table/knn_scan.cppm +++ b/src/function/table/knn_scan.cppm @@ -31,7 +31,7 @@ public: static SharedPtr Make(NewCatalog *catalog, const String &func_name); public: - inline explicit KnnScanFunction(String name, TableFunctionType function) : TableFunction(Move(name), {}, Move(function)) {} + inline explicit KnnScanFunction(String name, TableFunctionType function) : TableFunction(std::move(name), {}, std::move(function)) {} private: }; diff --git a/src/function/table/knn_scan_data.cpp b/src/function/table/knn_scan_data.cpp index f76575d8ff..9763d36cb9 100644 --- a/src/function/table/knn_scan_data.cpp +++ b/src/function/table/knn_scan_data.cpp @@ -85,14 +85,14 @@ void KnnScanFunctionData::Init() { case KnnDistanceType::kHamming: { auto merge_knn_max = MakeUnique>(knn_scan_shared_data_->query_count_, knn_scan_shared_data_->topk_); merge_knn_max->Begin(); - merge_knn_base_ = Move(merge_knn_max); + merge_knn_base_ = std::move(merge_knn_max); break; } case KnnDistanceType::kCosine: case KnnDistanceType::kInnerProduct: { auto merge_knn_min = MakeUnique>(knn_scan_shared_data_->query_count_, knn_scan_shared_data_->topk_); merge_knn_min->Begin(); - merge_knn_base_ = Move(merge_knn_min); + merge_knn_base_ = std::move(merge_knn_min); break; } } diff --git a/src/function/table/knn_scan_data.cppm b/src/function/table/knn_scan_data.cppm index bc4a67ddea..93df263a80 100644 --- a/src/function/table/knn_scan_data.cppm +++ b/src/function/table/knn_scan_data.cppm @@ -47,8 +47,8 @@ public: void *query_embedding, EmbeddingDataType elem_type, KnnDistanceType knn_distance_type) - : table_ref_(table_ref), filter_expression_(filter_expression), block_column_entries_(Move(block_column_entries)), - index_entries_(Move(index_entries)), opt_params_(Move(opt_params)), topk_(topk), dimension_(dimension), + : table_ref_(table_ref), filter_expression_(filter_expression), block_column_entries_(std::move(block_column_entries)), + index_entries_(std::move(index_entries)), opt_params_(std::move(opt_params)), topk_(topk), dimension_(dimension), query_count_(query_embedding_count), query_embedding_(query_embedding), elem_type_(elem_type), knn_distance_type_(knn_distance_type) {} public: diff --git a/src/function/table/merge_knn_data.cpp b/src/function/table/merge_knn_data.cpp index ba75cc819b..a7e8b1a462 100644 --- a/src/function/table/merge_knn_data.cpp +++ b/src/function/table/merge_knn_data.cpp @@ -56,7 +56,7 @@ void MergeKnnFunctionData::InitMergeKnn(KnnDistanceType knn_distance_type) { case KnnDistanceType::kHamming: { auto merge_knn_max = MakeShared>(query_count_, topk_); merge_knn_max->Begin(); - merge_knn_base_ = Move(merge_knn_max); + merge_knn_base_ = std::move(merge_knn_max); heap_type_ = MergeKnnHeapType::kMaxHeap; break; } @@ -64,7 +64,7 @@ void MergeKnnFunctionData::InitMergeKnn(KnnDistanceType knn_distance_type) { case KnnDistanceType::kInnerProduct: { auto merge_knn_min = MakeShared>(query_count_, topk_); merge_knn_min->Begin(); - merge_knn_base_ = Move(merge_knn_min); + merge_knn_base_ = std::move(merge_knn_min); heap_type_ = MergeKnnHeapType::kMinHeap; break; } diff --git a/src/function/table/table_scan.cpp b/src/function/table/table_scan.cpp index c7826703aa..52cf189a68 100644 --- a/src/function/table/table_scan.cpp +++ b/src/function/table/table_scan.cpp @@ -53,7 +53,7 @@ void TableScanFunc(QueryContext *query_context, TableFunctionData *table_functio BlockEntry *current_block_entry = block_index->GetBlockEntry(segment_id, block_id); auto remaining_rows = current_block_entry->row_count() - read_offset; - auto write_size = Min(write_capacity, remaining_rows); + auto write_size = std::min(write_capacity, remaining_rows); SizeT output_column_id{0}; for (auto column_id : column_ids) { diff --git a/src/function/table/table_scan.cppm b/src/function/table/table_scan.cppm index 0c45732636..10dc0a4851 100644 --- a/src/function/table/table_scan.cppm +++ b/src/function/table/table_scan.cppm @@ -31,7 +31,7 @@ public: static SharedPtr Make(NewCatalog *catalog, const String &func_name); public: - explicit TableScanFunction(String name, TableFunctionType function) : TableFunction(Move(name), {}, Move(function)) {} + explicit TableScanFunction(String name, TableFunctionType function) : TableFunction(std::move(name), {}, std::move(function)) {} private: }; diff --git a/src/function/table_function.cpp b/src/function/table_function.cpp index 5096d48951..9c8d92793c 100644 --- a/src/function/table_function.cpp +++ b/src/function/table_function.cpp @@ -24,7 +24,7 @@ module table_function; namespace infinity { TableFunction::TableFunction(String name, Vector argument_types, TableFunctionType function) - : Function(Move(name), FunctionType::kTable), main_function_(Move(function)), parameter_types_(Move(argument_types)) {} + : Function(std::move(name), FunctionType::kTable), main_function_(std::move(function)), parameter_types_(std::move(argument_types)) {} String TableFunction::ToString() const { std::stringstream ss; diff --git a/src/function/table_function_set.cppm b/src/function/table_function_set.cppm index ae67c1f995..64cde35f44 100644 --- a/src/function/table_function_set.cppm +++ b/src/function/table_function_set.cppm @@ -25,7 +25,7 @@ namespace infinity { class TableFunctionSet final : public FunctionSet { public: - explicit TableFunctionSet(String name) : FunctionSet(Move(name), FunctionType::kTable) {} + explicit TableFunctionSet(String name) : FunctionSet(std::move(name), FunctionType::kTable) {} ~TableFunctionSet() final; diff --git a/src/main/config.cpp b/src/main/config.cpp index 2bee8cb30f..369f52c933 100644 --- a/src/main/config.cpp +++ b/src/main/config.cpp @@ -38,7 +38,7 @@ u64 Config::GetAvailableMem() { void Config::ParseTimeZoneStr(const String &time_zone_str, String &parsed_time_zone, i32 &parsed_time_zone_bias) { parsed_time_zone = time_zone_str.substr(0, 3); ToUpper(parsed_time_zone); - parsed_time_zone_bias = StrToInt(time_zone_str.substr(3, String::npos)); + parsed_time_zone_bias = std::stoi(time_zone_str.substr(3, String::npos)); } SharedPtr Config::ParseByteSize(const String &byte_size_str, u64 &byte_size) { @@ -46,15 +46,12 @@ SharedPtr Config::ParseByteSize(const String &byte_size_str, u64 &byte_s HashMap byte_unit = {{"kb", 1024ul}, {"mb", 1024ul * 1024ul}, {"gb", 1024ul * 1024ul * 1024ul}}; if (byte_size_str.empty()) { return MakeShared("No byte size is given"); - ; } u64 factor; - const char *ptr = FromChars(byte_size_str.data(), byte_size_str.data() + byte_size_str.size(), factor); - if (ptr == nullptr) { - return MakeShared("Unrecognized byte size"); - } else { - String unit = ptr; + auto res = std::from_chars(byte_size_str.data(), byte_size_str.data() + byte_size_str.size(), factor); + if(res.ec == std::errc()) { + String unit = res.ptr; ToLower(unit); auto it = byte_unit.find(unit); if (it != byte_unit.end()) { @@ -63,6 +60,8 @@ SharedPtr Config::ParseByteSize(const String &byte_size_str, u64 &byte_s } else { return MakeShared("Unrecognized byte size"); } + } else { + return MakeShared("Unrecognized byte size"); } } @@ -72,7 +71,7 @@ SharedPtr Config::Init(const SharedPtr &config_path) { SharedPtr result; // Default general config - String default_version = Format("{}.{}.{}", version_major(), version_minor(), version_patch()); + String default_version = fmt::format("{}.{}.{}", version_major(), version_minor(), version_patch()); String default_time_zone = "UTC"; i32 default_time_zone_bias = 8; @@ -125,7 +124,7 @@ SharedPtr Config::Init(const SharedPtr &config_path) { LocalFileSystem fs; if (config_path.get() == nullptr || !fs.Exists(*config_path)) { - Printf("No config file is given, use default configs.\n"); + fmt::print("No config file is given, use default configs.\n"); // General { @@ -160,7 +159,7 @@ SharedPtr Config::Init(const SharedPtr &config_path) { { system_option_.log_filename = default_log_filename; system_option_.log_dir = default_log_dir; - system_option_.log_file_path = MakeShared(Format("{}/{}", *system_option_.log_dir, *system_option_.log_filename)); + system_option_.log_file_path = MakeShared(fmt::format("{}/{}", *system_option_.log_dir, *system_option_.log_filename)); system_option_.log_to_stdout = default_log_to_stdout; system_option_.log_max_size = default_log_max_size; // 1Gib system_option_.log_file_rotate_count = default_log_file_rotate_count; @@ -191,8 +190,8 @@ SharedPtr Config::Init(const SharedPtr &config_path) { // Resource { system_option_.resource_dict_path_ = default_resource_dict_path; } } else { - Printf("Read config from: {}\n", *config_path); - TomlTable config = TomlParseFile(*config_path); + fmt::print("Read config from: {}\n", *config_path); + toml::table config = toml::parse_file(*config_path); // General { auto general_config = config["general"]; @@ -212,7 +211,7 @@ SharedPtr Config::Init(const SharedPtr &config_path) { try { ParseTimeZoneStr(time_zone_str, system_option_.time_zone, system_option_.time_zone_bias); } catch (...) { - result = MakeShared(Format("Timezone can't be recognized: {}", time_zone_str)); + result = MakeShared(fmt::format("Timezone can't be recognized: {}", time_zone_str)); return result; } } @@ -221,13 +220,13 @@ SharedPtr Config::Init(const SharedPtr &config_path) { { auto system_config = config["system"]; system_option_.worker_cpu_limit = system_config["worker_cpu_limit"].value_or(default_total_cpu_number); - if(system_option_.worker_cpu_limit == 0) { + if (system_option_.worker_cpu_limit == 0) { system_option_.worker_cpu_limit = default_total_cpu_number; } - if(system_config["total_memory_size"].as_integer() != 0) { + if (system_config["total_memory_size"].as_integer() != 0) { i64 total_memory_size_int = system_config["total_memory_size"].value_or(default_total_memory_size); - if(total_memory_size_int <= 0) { + if (total_memory_size_int <= 0) { system_option_.total_memory_size = default_total_memory_size; } else { system_option_.total_memory_size = total_memory_size_int; @@ -245,18 +244,18 @@ SharedPtr Config::Init(const SharedPtr &config_path) { } system_option_.query_cpu_limit = system_config["query_cpu_limit"].value_or(default_query_cpu_limit); - if(system_option_.query_cpu_limit == 0) { + if (system_option_.query_cpu_limit == 0) { system_option_.query_cpu_limit = default_query_cpu_limit; } system_option_.query_memory_limit = system_config["query_memory_limit"].value_or(default_query_memory_limit); - if(system_option_.query_memory_limit == 0) { + if (system_option_.query_memory_limit == 0) { system_option_.query_memory_limit = default_query_memory_limit; } - if(system_config["query_memory_limit"].as_integer() != 0) { + if (system_config["query_memory_limit"].as_integer() != 0) { i64 query_memory_size_int = system_config["query_memory_limit"].value_or(default_query_memory_limit); - if(query_memory_size_int <= 0) { + if (query_memory_size_int <= 0) { system_option_.query_memory_limit = default_query_memory_limit; } else { system_option_.query_memory_limit = query_memory_size_int; @@ -287,10 +286,10 @@ SharedPtr Config::Init(const SharedPtr &config_path) { system_option_.listen_address = network_config["listen_address"].value_or(default_listen_address); // Validate the address format - BoostErrorCode error; - asio_make_address(system_option_.listen_address, error); + boost::system::error_code error; + boost::asio::ip::make_address(system_option_.listen_address, error); if (error) { - String err_msg = Format("Not a valid IPv4 address: {}", system_option_.listen_address); + String err_msg = fmt::format("Not a valid IPv4 address: {}", system_option_.listen_address); result = MakeShared(err_msg); return result; } @@ -306,7 +305,7 @@ SharedPtr Config::Init(const SharedPtr &config_path) { system_option_.log_filename = MakeShared(log_config["log_filename"].value_or(*default_log_filename)); system_option_.log_dir = MakeShared(log_config["log_dir"].value_or(*default_log_dir)); - String log_file_path = Format("{}/{}", *system_option_.log_dir, *system_option_.log_filename); + String log_file_path = fmt::format("{}/{}", *system_option_.log_dir, *system_option_.log_filename); system_option_.log_file_path = MakeShared(log_file_path); system_option_.log_to_stdout = log_config["log_to_stdout"].value_or(default_log_to_stdout); @@ -379,53 +378,53 @@ SharedPtr Config::Init(const SharedPtr &config_path) { } void Config::PrintAll() const { - Printf("Infinity system parameters: \n"); + fmt::print("Infinity system parameters: \n"); // General - Printf(" - version: {}\n", system_option_.version); - Printf(" - timezone: {}{}\n", system_option_.time_zone, system_option_.time_zone_bias); + fmt::print(" - version: {}\n", system_option_.version); + fmt::print(" - timezone: {}{}\n", system_option_.time_zone, system_option_.time_zone_bias); // System - Printf(" - worker_cpu_limit: {}\n", system_option_.worker_cpu_limit); - Printf(" - total_memory_size: {}\n", Utility::FormatByteSize(system_option_.total_memory_size)); - Printf(" - query_cpu_limit: {}\n", system_option_.query_cpu_limit); - Printf(" - query_memory_limit: {}\n", Utility::FormatByteSize(system_option_.query_memory_limit)); + fmt::print(" - worker_cpu_limit: {}\n", system_option_.worker_cpu_limit); + fmt::print(" - total_memory_size: {}\n", Utility::FormatByteSize(system_option_.total_memory_size)); + fmt::print(" - query_cpu_limit: {}\n", system_option_.query_cpu_limit); + fmt::print(" - query_memory_limit: {}\n", Utility::FormatByteSize(system_option_.query_memory_limit)); // Profiler - Printf(" - enable_profiler: {}\n", system_option_.enable_profiler); - Printf(" - profile_record_capacity: {}\n", system_option_.profile_record_capacity); + fmt::print(" - enable_profiler: {}\n", system_option_.enable_profiler); + fmt::print(" - profile_record_capacity: {}\n", system_option_.profile_record_capacity); // Network - Printf(" - listen address: {}\n", system_option_.listen_address); - Printf(" - postgres port: {}\n", system_option_.pg_port); - Printf(" - http port: {}\n", system_option_.http_port); - Printf(" - sdk port: {}\n", system_option_.sdk_port); + fmt::print(" - listen address: {}\n", system_option_.listen_address); + fmt::print(" - postgres port: {}\n", system_option_.pg_port); + fmt::print(" - http port: {}\n", system_option_.http_port); + fmt::print(" - sdk port: {}\n", system_option_.sdk_port); // Log - Printf(" - log_file_path: {}\n", system_option_.log_file_path->c_str()); - Printf(" - log_to_stdout: {}\n", system_option_.log_to_stdout); - Printf(" - log_max_size: {}\n", Utility::FormatByteSize(system_option_.log_max_size)); - Printf(" - log_file_rotate_count: {}\n", system_option_.log_file_rotate_count); - Printf(" - log_level: {}\n", LogLevel2Str(system_option_.log_level)); + fmt::print(" - log_file_path: {}\n", system_option_.log_file_path->c_str()); + fmt::print(" - log_to_stdout: {}\n", system_option_.log_to_stdout); + fmt::print(" - log_max_size: {}\n", Utility::FormatByteSize(system_option_.log_max_size)); + fmt::print(" - log_file_rotate_count: {}\n", system_option_.log_file_rotate_count); + fmt::print(" - log_level: {}\n", LogLevel2Str(system_option_.log_level)); // Storage - Printf(" - data_dir: {}\n", system_option_.data_dir->c_str()); - Printf(" - wal_dir: {}\n", system_option_.wal_dir->c_str()); - Printf(" - default_row_size: {}\n", system_option_.default_row_size); + fmt::print(" - data_dir: {}\n", system_option_.data_dir->c_str()); + fmt::print(" - wal_dir: {}\n", system_option_.wal_dir->c_str()); + fmt::print(" - default_row_size: {}\n", system_option_.default_row_size); // Buffer - Printf(" - buffer_pool_size: {}\n", Utility::FormatByteSize(system_option_.buffer_pool_size)); - Printf(" - temp_dir: {}\n", system_option_.temp_dir->c_str()); + fmt::print(" - buffer_pool_size: {}\n", Utility::FormatByteSize(system_option_.buffer_pool_size)); + fmt::print(" - temp_dir: {}\n", system_option_.temp_dir->c_str()); // Wal - Printf(" - full_checkpoint_interval_sec: {}\n", system_option_.full_checkpoint_interval_sec_); - Printf(" - full_checkpoint_txn_interval: {}\n", system_option_.full_checkpoint_txn_interval_); - Printf(" - delta_checkpoint_interval_sec: {}\n", system_option_.delta_checkpoint_interval_sec_); - Printf(" - delta_checkpoint_interval_wal_bytes: {}\n", system_option_.delta_checkpoint_interval_wal_bytes_); - Printf(" - wal_size_threshold: {}\n", system_option_.wal_size_threshold_); + fmt::print(" - full_checkpoint_interval_sec: {}\n", system_option_.full_checkpoint_interval_sec_); + fmt::print(" - full_checkpoint_txn_interval: {}\n", system_option_.full_checkpoint_txn_interval_); + fmt::print(" - delta_checkpoint_interval_sec: {}\n", system_option_.delta_checkpoint_interval_sec_); + fmt::print(" - delta_checkpoint_interval_wal_bytes: {}\n", system_option_.delta_checkpoint_interval_wal_bytes_); + fmt::print(" - wal_size_threshold: {}\n", system_option_.wal_size_threshold_); // Resource - Printf(" - dictionary_dir: {}\n", system_option_.resource_dict_path_.c_str()); + fmt::print(" - dictionary_dir: {}\n", system_option_.resource_dict_path_.c_str()); } } // namespace infinity diff --git a/src/main/database.cpp b/src/main/database.cpp index c0113ccbae..515fedf102 100644 --- a/src/main/database.cpp +++ b/src/main/database.cpp @@ -39,9 +39,9 @@ QueryResult Database::CreateTable(const String &table_name, UniquePtr create_statement = MakeUnique(); SharedPtr create_table_info = MakeShared(); create_table_info->table_name_ = table_name; - create_table_info->column_defs_ = Move(column_defs); - create_table_info->constraints_ = Move(constraints); - create_statement->create_info_ = Move(create_table_info); + create_table_info->column_defs_ = std::move(column_defs); + create_table_info->constraints_ = std::move(constraints); + create_statement->create_info_ = std::move(create_table_info); QueryResult result = query_context_ptr->QueryStatement(create_statement.get()); return result; } diff --git a/src/main/database.cppm b/src/main/database.cppm index 48fa69b859..1a355d4ea0 100644 --- a/src/main/database.cppm +++ b/src/main/database.cppm @@ -26,7 +26,7 @@ namespace infinity { export class Database { public: - explicit Database(const String &db_name, SharedPtr session) : db_name_(db_name), session_(Move(session)) {} + explicit Database(const String &db_name, SharedPtr session) : db_name_(db_name), session_(std::move(session)) {} QueryResult CreateTable(const String &table_name, Vector column_defs, diff --git a/src/main/infinity.cpp b/src/main/infinity.cpp index e0932b92ef..5cbbd0cfcb 100644 --- a/src/main/infinity.cpp +++ b/src/main/infinity.cpp @@ -80,7 +80,7 @@ SharedPtr Infinity::LocalConnect() { } void Infinity::LocalDisconnect() { -// Printf("To disconnect the database.\n"); +// fmt::print("To disconnect the database.\n"); } QueryResult Infinity::CreateDatabase(const String &db_name, const CreateDatabaseOptions &create_db_options) { @@ -89,7 +89,7 @@ QueryResult Infinity::CreateDatabase(const String &db_name, const CreateDatabase query_result.result_table_ = nullptr; UniquePtr err_msg = MakeUnique("Empty database name is given."); LOG_ERROR(*err_msg); - query_result.status_ = Status(ErrorCode::kError, Move(err_msg)); + query_result.status_ = Status(ErrorCode::kError, std::move(err_msg)); return query_result; } diff --git a/src/main/logger.cpp b/src/main/logger.cpp index 1c1e430379..7a8bec669f 100644 --- a/src/main/logger.cpp +++ b/src/main/logger.cpp @@ -22,29 +22,29 @@ import third_party; namespace infinity { -static SharedPtr stdout_sinker = nullptr; -static SharedPtr rotating_file_sinker = nullptr; +static SharedPtr stdout_sinker = nullptr; +static SharedPtr rotating_file_sinker = nullptr; -SharedPtr infinity_logger = nullptr; +SharedPtr infinity_logger = nullptr; void Logger::Initialize(const Config *config_ptr) { if (stdout_sinker.get() == nullptr) { - stdout_sinker = MakeShared(); // NOLINT + stdout_sinker = MakeShared(); // NOLINT } SizeT log_max_size = config_ptr->log_max_size(); SizeT log_file_rotate_count = config_ptr->log_file_rotate_count(); if (rotating_file_sinker.get() == nullptr) { - rotating_file_sinker = MakeShared(*config_ptr->log_file_path(), log_max_size, + rotating_file_sinker = MakeShared(*config_ptr->log_file_path(), log_max_size, log_file_rotate_count); // NOLINT } - Vector sinks{stdout_sinker, rotating_file_sinker}; + Vector sinks{stdout_sinker, rotating_file_sinker}; - infinity_logger = MakeShared("infinity", sinks.begin(), sinks.end()); // NOLINT + infinity_logger = MakeShared("infinity", sinks.begin(), sinks.end()); // NOLINT infinity_logger->set_pattern("[%H:%M:%S.%e] [%t] [%^%l%$] %v"); - RegisterLogger(infinity_logger); + spdlog::details::registry::instance().register_logger(infinity_logger); SetLogLevel(config_ptr->log_level()); @@ -53,7 +53,7 @@ void Logger::Initialize(const Config *config_ptr) { void Logger::Shutdown() { if (stdout_sinker.get() != nullptr && rotating_file_sinker.get() != nullptr) { - ShutdownLogger(); + spdlog::shutdown(); stdout_sinker = nullptr; rotating_file_sinker = nullptr; infinity_logger = nullptr; diff --git a/src/main/logger.cppm b/src/main/logger.cppm index c8f19f3ab3..63469c4c76 100644 --- a/src/main/logger.cppm +++ b/src/main/logger.cppm @@ -13,18 +13,14 @@ // limitations under the License. module; -import stl; -import third_party; - export module logger; -//import config; -//import third_party; -//import stl; +import stl; +import third_party; namespace infinity { -export extern SharedPtr infinity_logger; +export extern SharedPtr infinity_logger; class Config; diff --git a/src/main/profiler.cpp b/src/main/profiler.cpp index 00b311b88b..4d1513d47f 100644 --- a/src/main/profiler.cpp +++ b/src/main/profiler.cpp @@ -49,13 +49,13 @@ NanoSeconds BaseProfiler::ElapsedInternal() const { String BaseProfiler::ElapsedToString(NanoSeconds duration, i64 scale) { String result; if (duration.count() <= 1000 * scale) { - result.append(Format("{}ns", duration.count())); + result.append(fmt::format("{}ns", duration.count())); } else if (duration.count() <= 1000 * 1000 * scale) { - result.append(Format("{}us", ChronoCast(duration).count())); + result.append(fmt::format("{}us", ChronoCast(duration).count())); } else if (duration.count() <= 1000 * 1000 * 1000 * scale) { - result.append(Format("{}ms", ChronoCast(duration).count())); + result.append(fmt::format("{}ms", ChronoCast(duration).count())); } else { - result.append(Format("{}s", ChronoCast(duration).count())); + result.append(fmt::format("{}s", ChronoCast(duration).count())); } return result; } @@ -78,7 +78,7 @@ String OptimizerProfiler::ToString(SizeT intent) const { SizeT profiler_count = profilers_.size(); for (SizeT idx = 0; idx < profiler_count; ++idx) { const auto &profiler = profilers_[idx]; - result.append(Format("{}{}: {}", space, profiler.name(), profiler.ElapsedToString())); + result.append(fmt::format("{}{}: {}", space, profiler.name(), profiler.ElapsedToString())); } return result; @@ -123,7 +123,7 @@ void TaskProfiler::StopOperator(const OperatorState *operator_state) { OperatorInformation info(active_operator_->GetName(), profiler_.GetBegin(), profiler_.GetEnd(), profiler_.Elapsed(), input_rows, output_data_size, output_rows); - timings_.push_back(Move(info)); + timings_.push_back(std::move(info)); active_operator_ = nullptr; } @@ -167,13 +167,13 @@ void QueryProfiler::StartPhase(QueryPhase phase) { if (!enable_) { return; } - SizeT phase_idx = EnumInteger(phase); + SizeT phase_idx = static_cast>(phase); // Validate current query phase. if (current_phase_ == QueryPhase::kInvalid) { current_phase_ = phase; } else { - Error(Format("Can't start new query phase before current phase({}) is finished", QueryPhaseToString(current_phase_))); + Error(fmt::format("Can't start new query phase before current phase({}) is finished", QueryPhaseToString(current_phase_))); } BaseProfiler& phase_profiler = profilers_[phase_idx]; @@ -192,14 +192,14 @@ void QueryProfiler::StopPhase(QueryPhase phase) { } current_phase_ = QueryPhase::kInvalid; - profilers_[EnumInteger(phase)].End(); + profilers_[static_cast>(phase)].End(); } void QueryProfiler::Stop() { if (current_phase_ == QueryPhase::kInvalid) { return; } - profilers_[EnumInteger(current_phase_)].End(); + profilers_[static_cast>(current_phase_)].End(); current_phase_ = QueryPhase::kInvalid; } @@ -208,7 +208,7 @@ void QueryProfiler::Flush(TaskProfiler &&profiler) { return; } - UniqueLock lk(flush_lock_); + std::unique_lock lk(flush_lock_); records_[profiler.binding_.fragment_id_][profiler.binding_.task_id_].push_back(profiler); } @@ -263,32 +263,32 @@ String QueryProfiler::ToString() const { return ss.str(); } -Json QueryProfiler::Serialize(const QueryProfiler *profiler) { - Json json; +nlohmann::json QueryProfiler::Serialize(const QueryProfiler *profiler) { + nlohmann::json json; i64 start = std::numeric_limits::max(); i64 end = 0; for (const auto &fragment : profiler->records_) { - Json json_fragments; + nlohmann::json json_fragments; json_fragments["fragment_id"] = fragment.first; i64 fragment_start = std::numeric_limits::max(); i64 fragment_end = 0; for (const auto &task : fragment.second) { - Json json_tasks; + nlohmann::json json_tasks; SizeT times = 0; json_tasks["task_id"] = task.first; i64 task_start = std::numeric_limits::max(); i64 task_end = 0; for (const auto &operators : task.second) { - task_start = Min(task_start, operators.task_profiler_.GetBegin()); - task_end = Max(task_end, operators.task_profiler_.GetEnd()); + task_start = std::min(task_start, operators.task_profiler_.GetBegin()); + task_end = std::max(task_end, operators.task_profiler_.GetEnd()); - Json json_operators; + nlohmann::json json_operators; json_operators["times"] = times; for (const auto &op : operators.timings_) { - Json json_info; + nlohmann::json json_info; json_info["name"] = op.name_; json_info["start"] = op.start_; json_info["end"] = op.end_; @@ -305,8 +305,8 @@ Json QueryProfiler::Serialize(const QueryProfiler *profiler) { json_tasks["task_end"] = task_end; json_tasks["task_total"] = task_end - task_start; - fragment_start = Min(fragment_start, task_start); - fragment_end = Max(fragment_end, task_end); + fragment_start = std::min(fragment_start, task_start); + fragment_end = std::max(fragment_end, task_end); json_fragments["tasks"].push_back(json_tasks); } @@ -316,8 +316,8 @@ Json QueryProfiler::Serialize(const QueryProfiler *profiler) { json_fragments["fragment_end"] = fragment_end; json_fragments["fragment_total"] = fragment_total; - start = Min(start, fragment_start); - end = Max(end, fragment_end); + start = std::min(start, fragment_start); + end = std::max(end, fragment_end); json["fragments"].push_back(json_fragments); } diff --git a/src/main/profiler.cppm b/src/main/profiler.cppm index b92b5dd916..582c12fd7a 100644 --- a/src/main/profiler.cppm +++ b/src/main/profiler.cppm @@ -25,7 +25,7 @@ export class BaseProfiler { public: BaseProfiler() = default; - explicit BaseProfiler(String name) : name_(Move(name)) {} + explicit BaseProfiler(String name) : name_(std::move(name)) {} // Start the profiler void Begin(); @@ -89,19 +89,19 @@ struct OperatorInformation { } OperatorInformation(OperatorInformation&& other) - : name_(Move(other.name_)), start_(other.start_), end_(other.end_), elapsed_(other.elapsed_), input_rows_(other.input_rows_), + : name_(std::move(other.name_)), start_(other.start_), end_(other.end_), elapsed_(other.elapsed_), input_rows_(other.input_rows_), output_data_size_(other.output_data_size_), output_rows_(other.output_rows_) { } OperatorInformation(String name, i64 start, i64 end, i64 elapsed, u16 input_rows, i32 output_data_size, u16 output_rows) - : name_(Move(name)), start_(start), end_(end), elapsed_(elapsed), input_rows_(input_rows), output_data_size_(output_data_size), output_rows_(output_rows) { + : name_(std::move(name)), start_(start), end_(end), elapsed_(elapsed), input_rows_(input_rows), output_data_size_(output_data_size), output_rows_(output_rows) { } OperatorInformation& operator=(OperatorInformation&& other) { if (this != &other) { - name_ = Move(other.name_); - start_ = Move(other.start_); - end_ = Move(other.end_); + name_ = std::move(other.name_); + start_ = std::move(other.start_); + end_ = std::move(other.end_); elapsed_ = other.elapsed_; input_rows_ = other.input_rows_; output_rows_ = other.output_rows_; @@ -202,14 +202,14 @@ public: static String QueryPhaseToString(QueryPhase phase); - static Json Serialize(const QueryProfiler *profiler); + static nlohmann::json Serialize(const QueryProfiler *profiler); private: bool enable_ {}; - Mutex flush_lock_{}; + std::mutex flush_lock_{}; HashMap>> records_{}; - Vector profilers_{EnumInteger(QueryPhase::kInvalid)}; + Vector profilers_{static_cast>(QueryPhase::kInvalid)}; OptimizerProfiler optimizer_; QueryPhase current_phase_{QueryPhase::kInvalid}; diff --git a/src/main/query_context.cpp b/src/main/query_context.cpp index 7b90aafe6f..1c06678874 100644 --- a/src/main/query_context.cpp +++ b/src/main/query_context.cpp @@ -105,7 +105,7 @@ QueryResult QueryContext::QueryStatement(const BaseStatement *statement) { try { this->CreateTxn(); this->BeginTxn(); -// LOG_INFO(Format("created transaction, txn_id: {}, begin_ts: {}, statement: {}", +// LOG_INFO(fmt::format("created transaction, txn_id: {}, begin_ts: {}, statement: {}", // session_ptr_->GetTxn()->TxnID(), // session_ptr_->GetTxn()->BeginTS(), // statement->ToString())); diff --git a/src/main/query_context.cppm b/src/main/query_context.cppm index e7565576d9..a91f31994c 100644 --- a/src/main/query_context.cppm +++ b/src/main/query_context.cppm @@ -114,7 +114,7 @@ public: void FlushProfiler(TaskProfiler &&profiler) { if(query_profiler_) { - query_profiler_->Flush(Move(profiler)); + query_profiler_->Flush(std::move(profiler)); } } diff --git a/src/main/query_result.cppm b/src/main/query_result.cppm index 52116ad021..574d959774 100644 --- a/src/main/query_result.cppm +++ b/src/main/query_result.cppm @@ -28,8 +28,8 @@ public: BaseResult(BaseResult& other): status_(other.status_), result_table_(other.result_table_) {} BaseResult& operator=(BaseResult&& other) noexcept { - status_ = Move(other.status_); - result_table_ = Move(other.result_table_); + status_ = std::move(other.status_); + result_table_ = std::move(other.result_table_); return *this; } diff --git a/src/main/session_manager.cppm b/src/main/session_manager.cppm index 2081d48397..86f33e6dbb 100644 --- a/src/main/session_manager.cppm +++ b/src/main/session_manager.cppm @@ -29,7 +29,7 @@ public: u64 session_id = ++ session_id_generator_; SharedPtr remote_session = MakeShared(session_id); { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); sessions_.emplace(session_id, remote_session.get()); } return remote_session; @@ -39,14 +39,14 @@ public: u64 session_id = ++ session_id_generator_; SharedPtr local_session = MakeShared(session_id); { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); sessions_.emplace(session_id, local_session.get()); } return local_session; } BaseSession* GetSessionByID(u64 session_id) { - SharedLock r_locker(rw_locker_); + std::shared_lock r_locker(rw_locker_); auto iter = sessions_.find(session_id); if(iter == sessions_.end()) { return nullptr; @@ -56,17 +56,17 @@ public: } void RemoveSessionByID(u64 session_id) { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); sessions_.erase(session_id); } SizeT GetSessionCount() { - SharedLock r_locker(rw_locker_); + std::shared_lock r_locker(rw_locker_); return sessions_.size(); } private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; HashMap sessions_; // First session is ONE; diff --git a/src/main/table.cppm b/src/main/table.cppm index 0cb7125139..6f9394ac9d 100644 --- a/src/main/table.cppm +++ b/src/main/table.cppm @@ -25,7 +25,7 @@ namespace infinity { export class Table { public: - Table(String table_name, SharedPtr session) : table_name_(Move(table_name)), session_(Move(session)) {} + Table(String table_name, SharedPtr session) : table_name_(std::move(table_name)), session_(std::move(session)) {} QueryResult CreateIndex(const String &index_name, Vector *index_info_list, CreateIndexOptions create_index_options); diff --git a/src/network/buffer_reader.cpp b/src/network/buffer_reader.cpp index 62d70f48d0..304c0a5566 100644 --- a/src/network/buffer_reader.cpp +++ b/src/network/buffer_reader.cpp @@ -118,12 +118,12 @@ String BufferReader::read_string(const SizeT string_length, NullTerminator null_ result.reserve(string_length); if (size() != 0) { - RingBufferIterator::CopyN(start_pos_, Min(string_length, size()), result); + RingBufferIterator::CopyN(start_pos_, std::min(string_length, size()), result); start_pos_.increment(result.size()); } while (result.size() < string_length) { - const auto substring_length = Min(string_length - result.size(), max_capacity()); + const auto substring_length = std::min(string_length - result.size(), max_capacity()); receive_more(substring_length); RingBufferIterator::CopyN(start_pos_, substring_length, result); start_pos_.increment(substring_length); diff --git a/src/network/buffer_reader.cppm b/src/network/buffer_reader.cppm index 03ef57d8ab..9c2ff2b2b4 100644 --- a/src/network/buffer_reader.cppm +++ b/src/network/buffer_reader.cppm @@ -26,7 +26,7 @@ namespace infinity { export class BufferReader { public: - explicit BufferReader(const SharedPtr &socket) : socket_(socket){}; + explicit BufferReader(const SharedPtr &socket) : socket_(socket){}; [[nodiscard]] SizeT size() const; @@ -57,7 +57,7 @@ private: RingBufferIterator start_pos_{data_}; RingBufferIterator current_pos_{data_}; - SharedPtr socket_; + SharedPtr socket_; }; } // namespace infinity diff --git a/src/network/buffer_writer.cpp b/src/network/buffer_writer.cpp index 8696561f59..34a912124d 100644 --- a/src/network/buffer_writer.cpp +++ b/src/network/buffer_writer.cpp @@ -37,13 +37,13 @@ void BufferWriter::send_string(const String &value, NullTerminator null_terminat auto position_in_string = 0u; if (!full()) { - position_in_string = static_cast(Min(max_capacity() - size(), value.size())); + position_in_string = static_cast(std::min(max_capacity() - size(), value.size())); RingBufferIterator::CopyN(value.c_str(), position_in_string, current_pos_); current_pos_.increment(position_in_string); } while (position_in_string < value.size()) { - const auto bytes_to_transfer = Min(max_capacity(), value.size() - position_in_string); + const auto bytes_to_transfer = std::min(max_capacity(), value.size() - position_in_string); try_flush(bytes_to_transfer); RingBufferIterator::CopyN(value.c_str() + position_in_string, bytes_to_transfer, current_pos_); current_pos_.increment(bytes_to_transfer); diff --git a/src/network/buffer_writer.cppm b/src/network/buffer_writer.cppm index e5a0e0a7de..828dee0684 100644 --- a/src/network/buffer_writer.cppm +++ b/src/network/buffer_writer.cppm @@ -26,7 +26,7 @@ namespace infinity { export class BufferWriter { public: - explicit BufferWriter(const SharedPtr &socket) : socket_(socket) {} + explicit BufferWriter(const SharedPtr &socket) : socket_(socket) {} [[nodiscard]] SizeT size() const; @@ -57,7 +57,7 @@ private: Array data_{}; RingBufferIterator start_pos_{data_}; RingBufferIterator current_pos_{data_}; - SharedPtr socket_{}; + SharedPtr socket_{}; }; } // namespace infinity diff --git a/src/network/connection.cpp b/src/network/connection.cpp index 22ff509942..a723adf55b 100644 --- a/src/network/connection.cpp +++ b/src/network/connection.cpp @@ -37,8 +37,8 @@ module connection; namespace infinity { -Connection::Connection(AsioIOService &io_service) - : socket_(MakeShared(io_service)), pg_handler_(MakeShared(socket())) {} +Connection::Connection(boost::asio::io_service &io_service) + : socket_(MakeShared(io_service)), pg_handler_(MakeShared(socket())) {} Connection::~Connection() { if(session_ == nullptr) { @@ -137,7 +137,7 @@ void Connection::HandleRequest() { void Connection::HandlerSimpleQuery(QueryContext *query_context) { const String &query = pg_handler_->read_command_body(); - LOG_TRACE(Format("Query: {}", query)); + LOG_TRACE(fmt::format("Query: {}", query)); // Start to execute the query. QueryResult result = query_context->Query(query); @@ -334,7 +334,7 @@ void Connection::SendQueryResponse(const QueryResult &query_result) { break; } default: { - message = Format("SELECT {}", ToStr(query_result.result_table_->row_count())); + message = fmt::format("SELECT {}", std::to_string(query_result.result_table_->row_count())); } } diff --git a/src/network/connection.cppm b/src/network/connection.cppm index 2825508bc0..2a72c42791 100644 --- a/src/network/connection.cppm +++ b/src/network/connection.cppm @@ -28,13 +28,13 @@ namespace infinity { export class Connection { public: - explicit Connection(AsioIOService &io_service); + explicit Connection(boost::asio::io_service &io_service); ~Connection(); void Run(); - inline SharedPtr socket() { return socket_; } + inline SharedPtr socket() { return socket_; } private: void HandleConnection(); @@ -48,7 +48,7 @@ private: void SendQueryResponse(const QueryResult &query_result); private: - const SharedPtr socket_{}; + const SharedPtr socket_{}; const SharedPtr pg_handler_{}; diff --git a/src/network/db_server.cpp b/src/network/db_server.cpp index b055985c58..1f8ada9e20 100644 --- a/src/network/db_server.cpp +++ b/src/network/db_server.cpp @@ -39,24 +39,24 @@ void DBServer::Run() { u16 pg_port = InfinityContext::instance().config()->pg_port(); const String &pg_listen_addr = InfinityContext::instance().config()->listen_address(); - BoostErrorCode error; - AsioIpAddr address = asio_make_address(pg_listen_addr, error); + boost::system::error_code error; + boost::asio::ip::address address = boost::asio::ip::make_address(pg_listen_addr, error); if (error) { - Printf("{} isn't a valid IPv4 address.\n", pg_listen_addr); + fmt::print("{} isn't a valid IPv4 address.\n", pg_listen_addr); infinity::InfinityContext::instance().UnInit(); return ; } - acceptor_ptr_ = MakeUnique(io_service_, AsioEndPoint(address, pg_port)); + acceptor_ptr_ = MakeUnique(io_service_, boost::asio::ip::tcp::endpoint(address, pg_port)); CreateConnection(); - Printf("Run 'psql -h {} -p {}' to connect to the server.\n", pg_listen_addr, pg_port); + fmt::print("Run 'psql -h {} -p {}' to connect to the server.\n", pg_listen_addr, pg_port); io_service_.run(); } void DBServer::Shutdown() { - Printf("Shutdown infinity server ...\n"); + fmt::print("Shutdown infinity server ...\n"); while (running_connection_count_ > 0) { // Running connection exists. std::this_thread::yield(); @@ -67,7 +67,7 @@ void DBServer::Shutdown() { acceptor_ptr_->close(); infinity::InfinityContext::instance().UnInit(); - Printf("Shutdown infinity server successfully\n"); + fmt::print("Shutdown infinity server successfully\n"); } void DBServer::CreateConnection() { diff --git a/src/network/db_server.cppm b/src/network/db_server.cppm index 1e4d0465f2..67b6242f0d 100644 --- a/src/network/db_server.cppm +++ b/src/network/db_server.cppm @@ -40,8 +40,8 @@ private: atomic_bool initialized{false}; atomic_u64 running_connection_count_{0}; - AsioIOService io_service_{}; - UniquePtr acceptor_ptr_{}; + boost::asio::io_service io_service_{}; + UniquePtr acceptor_ptr_{}; }; } diff --git a/src/network/pg_protocol_handler.cpp b/src/network/pg_protocol_handler.cpp index d963d1f73e..499c371b71 100644 --- a/src/network/pg_protocol_handler.cpp +++ b/src/network/pg_protocol_handler.cpp @@ -21,7 +21,7 @@ module pg_protocol_handler; namespace infinity { -PGProtocolHandler::PGProtocolHandler(const SharedPtr &socket) : buffer_reader_(socket), buffer_writer_(socket) {} +PGProtocolHandler::PGProtocolHandler(const SharedPtr &socket) : buffer_reader_(socket), buffer_writer_(socket) {} u32 PGProtocolHandler::read_startup_header() { constexpr u32 SSL_MESSAGE_VERSION = 80877103u; diff --git a/src/network/pg_protocol_handler.cppm b/src/network/pg_protocol_handler.cppm index 26afb851bf..1a4a2b7884 100644 --- a/src/network/pg_protocol_handler.cppm +++ b/src/network/pg_protocol_handler.cppm @@ -25,7 +25,7 @@ namespace infinity { export class PGProtocolHandler { public: - explicit PGProtocolHandler(const SharedPtr &socket); + explicit PGProtocolHandler(const SharedPtr &socket); u32 read_startup_header(); diff --git a/src/network/thrift_server.cpp b/src/network/thrift_server.cpp index 9fda92148f..31df6f3926 100644 --- a/src/network/thrift_server.cpp +++ b/src/network/thrift_server.cpp @@ -61,9 +61,9 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi if (infinity == nullptr) { response.success = false; response.error_msg = "Connect failed"; - LOG_ERROR(Format("THRIFT ERROR: Connect failed")); + LOG_ERROR(fmt::format("THRIFT ERROR: Connect failed")); } else { - std::lock_guard lock(infinity_session_map_mutex_); + std::lock_guard lock(infinity_session_map_mutex_); infinity_session_map_.emplace(infinity->GetSessionId(), infinity); response.session_id = infinity->GetSessionId(); response.success = true; @@ -75,13 +75,13 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi if (infinity == nullptr) { response.success = false; response.error_msg = "Disconnect failed"; - LOG_ERROR(Format("THRIFT ERROR: Disconnect failed")); + LOG_ERROR(fmt::format("THRIFT ERROR: Disconnect failed")); } else { auto session_id = infinity->GetSessionId(); infinity->RemoteDisconnect(); - std::lock_guard lock(infinity_session_map_mutex_); + std::lock_guard lock(infinity_session_map_mutex_); infinity_session_map_.erase(session_id); - LOG_TRACE(Format("THRIFT : Disconnect success")); + LOG_TRACE(fmt::format("THRIFT : Disconnect success")); response.success = true; } } @@ -185,7 +185,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi auto table = database->GetTable(request.table_name); Path path( - Format("{}_{}_{}_{}", *InfinityContext::instance().config()->temp_dir().get(), request.db_name, request.table_name, request.file_name)); + fmt::format("{}_{}_{}_{}", *InfinityContext::instance().config()->temp_dir().get(), request.db_name, request.table_name, request.file_name)); ImportOptions import_options; import_options.copy_file_type_ = GetCopyFileType(request.import_option.copy_file_type); @@ -197,7 +197,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi void UploadFileChunk(infinity_thrift_rpc::UploadResponse &response, const infinity_thrift_rpc::FileChunk &request) override { LocalFileSystem fs; Path path( - Format("{}_{}_{}_{}", *InfinityContext::instance().config()->temp_dir().get(), request.db_name, request.table_name, request.file_name)); + fmt::format("{}_{}_{}_{}", *InfinityContext::instance().config()->temp_dir().get(), request.db_name, request.table_name, request.file_name)); if (request.index != 0) { FileWriter file_writer(fs, path.c_str(), request.data.size(), FileFlags::WRITE_FLAG | FileFlags::APPEND_FLAG); file_writer.Write(request.data.data(), request.data.size()); @@ -207,7 +207,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi if (fs.Exists(path.c_str())) { auto exist_file_size = LocalFileSystem::GetFileSizeByPath(path.c_str()); if ((i64)exist_file_size != request.total_size) { - LOG_TRACE(Format("Exist file size: {} , request total size: {}", exist_file_size, request.total_size)); + LOG_TRACE(fmt::format("Exist file size: {} , request total size: {}", exist_file_size, request.total_size)); fs.DeleteFile(path.c_str()); } else { response.__set_success(true); @@ -219,7 +219,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi file_writer.Write(request.data.data(), request.data.size()); file_writer.Flush(); } - LOG_TRACE(Format("Upload file name: {} , index: {}", path.c_str(), request.index)); + LOG_TRACE(fmt::format("Upload file name: {} , index: {}", path.c_str(), request.index)); response.__set_success(true); response.__set_can_skip(false); } @@ -249,8 +249,8 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi auto size = column_vector->data_type()->Size() * row_count; String dst; dst.resize(size); - Memcpy(dst.data(), column_vector->data(), size); - output_column_field.column_vectors.emplace_back(Move(dst)); + std::memcpy(dst.data(), column_vector->data(), size); + output_column_field.column_vectors.emplace_back(std::move(dst)); } void @@ -271,16 +271,16 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi VarcharT &varchar = ((VarcharT *)column_vector->data())[index]; i32 length = varchar.length_; if (varchar.IsInlined()) { - Memcpy(dst.data() + current_offset, &length, sizeof(i32)); - Memcpy(dst.data() + current_offset + sizeof(i32), varchar.short_.data_, varchar.length_); + std::memcpy(dst.data() + current_offset, &length, sizeof(i32)); + std::memcpy(dst.data() + current_offset + sizeof(i32), varchar.short_.data_, varchar.length_); } else { auto varchar_ptr = MakeUnique(varchar.length_ + 1); column_vector->buffer_->fix_heap_mgr_->ReadFromHeap(varchar_ptr.get(), varchar.vector_.chunk_id_, varchar.vector_.chunk_offset_, varchar.length_); - Memcpy(dst.data() + current_offset, &length, sizeof(i32)); - Memcpy(dst.data() + current_offset + sizeof(i32), varchar_ptr.get(), varchar.length_); + std::memcpy(dst.data() + current_offset, &length, sizeof(i32)); + std::memcpy(dst.data() + current_offset + sizeof(i32), varchar_ptr.get(), varchar.length_); } current_offset += sizeof(i32) + varchar.length_; } @@ -289,7 +289,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi Error("Bug"); } - output_column_field.column_vectors.emplace_back(Move(dst)); + output_column_field.column_vectors.emplace_back(std::move(dst)); output_column_field.__set_column_type(DataTypeToProtoColumnType(column_vector->data_type())); } @@ -298,8 +298,8 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi auto size = column_vector->data_type()->Size() * row_count; String dst; dst.resize(size); - Memcpy(dst.data(), column_vector->data(), size); - output_column_field.column_vectors.emplace_back(Move(dst)); + std::memcpy(dst.data(), column_vector->data(), size); + output_column_field.column_vectors.emplace_back(std::move(dst)); output_column_field.__set_column_type(DataTypeToProtoColumnType(column_vector->data_type())); } @@ -307,8 +307,8 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi auto size = column_vector->data_type()->Size() * row_count; String dst; dst.resize(size); - Memcpy(dst.data(), column_vector->data(), size); - output_column_field.column_vectors.emplace_back(Move(dst)); + std::memcpy(dst.data(), column_vector->data(), size); + output_column_field.column_vectors.emplace_back(std::move(dst)); output_column_field.__set_column_type(DataTypeToProtoColumnType(column_vector->data_type())); } @@ -446,14 +446,14 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi } else { response.__set_success(false); response.__set_error_msg(result.ErrorStr()); - LOG_ERROR(Format("THRIFT ERROR: {}", result.ErrorStr())); + LOG_ERROR(fmt::format("THRIFT ERROR: {}", result.ErrorStr())); } // auto end4 = std::chrono::steady_clock::now(); // phase_4_duration_ += end4 - start4; // // if (count_ % 10000 == 0) { - // LOG_ERROR(Format("Phase 1: {} Phase 2: {} Phase 3: {} Phase 4: {} Total: {} seconds", + // LOG_ERROR(fmt::format("Phase 1: {} Phase 2: {} Phase 3: {} Phase 4: {} Total: {} seconds", // phase_1_duration_.count(), // phase_2_duration_.count(), // phase_3_duration_.count(), @@ -464,7 +464,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi // phase_3_duration_ = std::chrono::duration(); // phase_4_duration_ = std::chrono::duration(); // } else if (count_ % 1000 == 0) { - // LOG_ERROR(Format("Phase 1: {} Phase 2: {} Phase 3: {} Phase 4: {} Total: {} seconds", + // LOG_ERROR(fmt::format("Phase 1: {} Phase 2: {} Phase 3: {} Phase 4: {} Total: {} seconds", // phase_1_duration_.count(), // phase_2_duration_.count(), // phase_3_duration_.count(), @@ -531,7 +531,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi } else { response.__set_success(false); response.__set_error_msg(result.ErrorStr()); - LOG_ERROR(Format("THRIFT ERROR: {}", result.ErrorStr())); + LOG_ERROR(fmt::format("THRIFT ERROR: {}", result.ErrorStr())); } } @@ -553,7 +553,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi } else { response.__set_success(false); response.__set_error_msg(result.ErrorStr()); - LOG_ERROR(Format("THRIFT ERROR: {}", result.ErrorStr())); + LOG_ERROR(fmt::format("THRIFT ERROR: {}", result.ErrorStr())); } } @@ -576,7 +576,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi } else { response.__set_success(false); response.__set_error_msg("Database not found"); - LOG_ERROR(Format("THRIFT ERROR: Database not found")); + LOG_ERROR(fmt::format("THRIFT ERROR: Database not found")); } } @@ -587,7 +587,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi } else { response.__set_success(false); response.__set_error_msg("Table not found"); - LOG_ERROR(Format("THRIFT ERROR: Table not found")); + LOG_ERROR(fmt::format("THRIFT ERROR: Table not found")); } } @@ -632,7 +632,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi } private: - Mutex infinity_session_map_mutex_{}; + std::mutex infinity_session_map_mutex_{}; HashMap> infinity_session_map_{}; // SizeT count_ = 0; @@ -643,7 +643,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi private: SharedPtr GetInfinityBySessionID(i64 session_id) { - std::lock_guard lock(infinity_session_map_mutex_); + std::lock_guard lock(infinity_session_map_mutex_); if (infinity_session_map_.count(session_id) > 0) { return infinity_session_map_[session_id]; } else { @@ -658,7 +658,7 @@ class InfinityServiceHandler : virtual public infinity_thrift_rpc::InfinityServi } else { response.__set_success(false); response.__set_error_msg(result.ErrorStr()); - LOG_ERROR(Format("THRIFT ERROR: {}", result.ErrorStr())); + LOG_ERROR(fmt::format("THRIFT ERROR: {}", result.ErrorStr())); } } @@ -1061,7 +1061,7 @@ class InfinityServiceCloneFactory : virtual public infinity_thrift_rpc::Infinity infinity_thrift_rpc::InfinityServiceIf *getHandler(const ::apache::thrift::TConnectionInfo &connInfo) override { SharedPtr sock = std::dynamic_pointer_cast(connInfo.transport); - LOG_TRACE(Format("Incoming connection, SocketInfo: {}, PeerHost: {}, PeerAddress: {}, PeerPort: {}", + LOG_TRACE(fmt::format("Incoming connection, SocketInfo: {}, PeerHost: {}, PeerAddress: {}, PeerPort: {}", sock->getSocketInfo(), sock->getPeerHost(), sock->getPeerAddress(), diff --git a/src/parser/query_parser.h b/src/parser/query_parser.h index 504cb40dc8..3960e8d6de 100644 --- a/src/parser/query_parser.h +++ b/src/parser/query_parser.h @@ -342,7 +342,7 @@ namespace infinity { std::swap (as (), that.as ()); } - /// Move the content of \a that to this. + /// std::move the content of \a that to this. /// /// Destroys \a that. template @@ -359,7 +359,7 @@ namespace infinity { } # if 201103L <= YY_CPLUSPLUS - /// Move the content of \a that to this. + /// std::move the content of \a that to this. template void move (self_type&& that) @@ -596,7 +596,7 @@ namespace infinity { {} #if 201103L <= YY_CPLUSPLUS - /// Move constructor. + /// std::move constructor. basic_symbol (basic_symbol&& that) : Base (std::move (that)) , value () @@ -810,7 +810,7 @@ switch (yykind) by_kind () YY_NOEXCEPT; #if 201103L <= YY_CPLUSPLUS - /// Move constructor. + /// std::move constructor. by_kind (by_kind&& that) YY_NOEXCEPT; #endif @@ -1480,7 +1480,7 @@ switch (yykind) typedef basic_symbol super_type; /// Construct an empty symbol. stack_symbol_type (); - /// Move or copy construction. + /// std::move or copy construction. stack_symbol_type (YY_RVREF (stack_symbol_type) that); /// Steal the contents from \a sym to build this. stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym); diff --git a/src/parser/type/complex/blob_type.cpp b/src/parser/type/complex/blob_type.cpp index a6390da61b..6c9e9c5575 100644 --- a/src/parser/type/complex/blob_type.cpp +++ b/src/parser/type/complex/blob_type.cpp @@ -20,7 +20,7 @@ namespace infinity { BlobType::BlobType(const BlobType &other) { this->Copy(other.ptr, other.size); } BlobType::BlobType(BlobType &&other) noexcept { - Move(other.ptr, other.size); + std::move(other.ptr, other.size); other.ptr = nullptr; other.size = 0; } @@ -35,7 +35,7 @@ BlobType &BlobType::operator=(const BlobType &other) { BlobType &BlobType::operator=(BlobType &&other) noexcept { if (this == &other) return *this; - this->Move(other.ptr, other.size); + this->std::move(other.ptr, other.size); other.ptr = nullptr; other.size = 0; return *this; @@ -62,7 +62,7 @@ void BlobType::Copy(char *blob_ptr, uint64_t blob_size) { this->size = blob_size; } -void BlobType::Move(char *blob_ptr, uint64_t blob_size) { +void BlobType::std::move(char *blob_ptr, uint64_t blob_size) { Reset(); this->ptr = blob_ptr; this->size = blob_size; diff --git a/src/parser/type/complex/blob_type.h b/src/parser/type/complex/blob_type.h index c8e89a5e20..f8f7b36b11 100644 --- a/src/parser/type/complex/blob_type.h +++ b/src/parser/type/complex/blob_type.h @@ -49,7 +49,7 @@ struct BlobType { public: void Copy(char *blob_ptr, uint64_t blob_size); - void Move(char *blob_ptr, uint64_t blob_size); + void std::move(char *blob_ptr, uint64_t blob_size); inline void Reset() { if (size != 0) { diff --git a/src/parser/type/complex/varchar.cpp b/src/parser/type/complex/varchar.cpp index 9ca62184b4..6bb9268cd4 100644 --- a/src/parser/type/complex/varchar.cpp +++ b/src/parser/type/complex/varchar.cpp @@ -31,7 +31,7 @@ Varchar::~Varchar() { Reset(); } Varchar::Varchar(const Varchar &other) { DeepCopy(other); } // Varchar::Varchar(Varchar &&other) noexcept { -// // LOG_TRACE("Move constructor"); +// // LOG_TRACE("std::move constructor"); // this->length_ = other.length_; // if (other.IsInlined()) { // memcpy(this->short_.data_, other.short_.data_, length_); @@ -59,7 +59,7 @@ Varchar &Varchar::operator=(const Varchar &other) { } Varchar &Varchar::operator=(Varchar &&other) noexcept { - // LOG_TRACE("Move assignment"); + // LOG_TRACE("std::move assignment"); if(this->IsValue()) { // Free memory Reset(); diff --git a/src/planner/bind_context.cpp b/src/planner/bind_context.cpp index 9a71e9af70..dd51362ea7 100644 --- a/src/planner/bind_context.cpp +++ b/src/planner/bind_context.cpp @@ -131,7 +131,7 @@ void BindContext::AddSubqueryBinding(const String &name, u64 table_index, SharedPtr>> column_types, SharedPtr> column_names) { - auto binding = Binding::MakeBinding(BindingType::kSubquery, name, table_index, Move(column_types), Move(column_names)); + auto binding = Binding::MakeBinding(BindingType::kSubquery, name, table_index, std::move(column_types), std::move(column_names)); AddBinding(binding); // Consider the subquery as the table table_names_.emplace_back(name); @@ -143,7 +143,7 @@ void BindContext::AddCTEBinding(const String &name, u64 table_index, SharedPtr>> column_types, SharedPtr> column_names) { - auto binding = Binding::MakeBinding(BindingType::kCTE, name, table_index, Move(column_types), Move(column_names)); + auto binding = Binding::MakeBinding(BindingType::kCTE, name, table_index, std::move(column_types), std::move(column_names)); AddBinding(binding); // Consider the CTE as the table table_names_.emplace_back(name); @@ -155,7 +155,7 @@ void BindContext::AddViewBinding(const String &name, u64 table_index, SharedPtr>> column_types, SharedPtr> column_names) { - auto binding = Binding::MakeBinding(BindingType::kView, name, table_index, Move(column_types), Move(column_names)); + auto binding = Binding::MakeBinding(BindingType::kView, name, table_index, std::move(column_types), std::move(column_names)); AddBinding(binding); } @@ -169,9 +169,9 @@ void BindContext::AddTableBinding(const String &table_alias, table_alias, table_index, table_collection_entry_ptr, - Move(column_types), - Move(column_names), - Move(block_index)); + std::move(column_types), + std::move(column_names), + std::move(block_index)); AddBinding(binding); table_names_.emplace_back(table_alias); table_name2table_index_[table_alias] = table_index; @@ -201,7 +201,7 @@ void BindContext::AddBindContext(const SharedPtr &other_ptr) { for (const auto &table_name2index_pair : other_ptr->table_name2table_index_) { const String &table_name = table_name2index_pair.first; if (table_name2table_index_.contains(table_name)) { - Error(Format("{} was bound before", table_name)); + Error(fmt::format("{} was bound before", table_name)); } table_name2table_index_[table_name] = table_name2index_pair.second; } @@ -209,7 +209,7 @@ void BindContext::AddBindContext(const SharedPtr &other_ptr) { for (const auto &table_index2name_pair : other_ptr->table_table_index2table_name_) { u64 table_index = table_index2name_pair.first; if (table_table_index2table_name_.contains(table_index)) { - Error(Format("Table index: {} is bound before", table_index)); + Error(fmt::format("Table index: {} is bound before", table_index)); } table_table_index2table_name_[table_index] = table_index2name_pair.second; } @@ -217,7 +217,7 @@ void BindContext::AddBindContext(const SharedPtr &other_ptr) { for (auto &name_binding_pair : other_ptr->binding_by_name_) { auto &binding_name = name_binding_pair.first; if (binding_by_name_.contains(binding_name)) { - Error(Format("Table: {} was bound before", binding_name)); + Error(fmt::format("Table: {} was bound before", binding_name)); } this->binding_by_name_.emplace(name_binding_pair); } @@ -262,7 +262,7 @@ SharedPtr BindContext::ResolveColumnId(const ColumnIdentifier // TODO: What will happen, when different tables have the same column name? Vector &binding_names = binding_names_by_column_[column_name_ref]; if (binding_names.size() > 1) { - Error(Format("Ambiguous column table_name: {}", column_identifier.ToString())); + Error(fmt::format("Ambiguous column table_name: {}", column_identifier.ToString())); } String &binding_name = binding_names[0]; @@ -270,7 +270,7 @@ SharedPtr BindContext::ResolveColumnId(const ColumnIdentifier auto binding_iter = binding_by_name_.find(binding_name); if (binding_iter == binding_by_name_.end()) { // Found the binding, but the binding don't have the column, which should happen. - Error(Format("{} doesn't exist.", column_identifier.ToString())); + Error(fmt::format("{} doesn't exist.", column_identifier.ToString())); } const auto &binding = binding_iter->second; @@ -286,7 +286,7 @@ SharedPtr BindContext::ResolveColumnId(const ColumnIdentifier bound_column_expr->source_position_.binding_name_ = binding->table_name_; } else { // Found the binding, but the binding don't have the column, which should happen. - Error(Format("{} doesn't exist.", column_identifier.ToString())); + Error(fmt::format("{} doesn't exist.", column_identifier.ToString())); } } else { // Table isn't found in current bind context, maybe its parent has it. @@ -309,7 +309,7 @@ SharedPtr BindContext::ResolveColumnId(const ColumnIdentifier bound_column_expr->source_position_ = SourcePosition(binding_context_id_, ExprSourceType::kBinding); bound_column_expr->source_position_.binding_name_ = binding->table_name_; } else { - Error(Format("{} doesn't exist.", column_identifier.ToString())); + Error(fmt::format("{} doesn't exist.", column_identifier.ToString())); } } else { // Table isn't found in current bind context, maybe its parent has it. diff --git a/src/planner/bind_context.cppm b/src/planner/bind_context.cppm index e59f0c8889..d74bfdcdb3 100644 --- a/src/planner/bind_context.cppm +++ b/src/planner/bind_context.cppm @@ -35,7 +35,7 @@ class ExpressionBinder; export struct CommonTableExpressionInfo { CommonTableExpressionInfo(String alias, SelectStatement *select_stmt, HashSet masked_name_set) - : alias_(Move(alias)), select_statement_(select_stmt), masked_name_set_(Move(masked_name_set)) {} + : alias_(std::move(alias)), select_statement_(select_stmt), masked_name_set_(std::move(masked_name_set)) {} String alias_; SelectStatement *select_statement_; diff --git a/src/planner/binder/bind_alias_proxy.cpp b/src/planner/binder/bind_alias_proxy.cpp index 3bc9c5e50f..6a03a4dc41 100644 --- a/src/planner/binder/bind_alias_proxy.cpp +++ b/src/planner/binder/bind_alias_proxy.cpp @@ -39,7 +39,7 @@ BindAliasProxy::BindAlias(ExpressionBinder &expression_binder, const ParsedExpr const ParsedExpr *select_expr = bind_context_ptr->select_expression_[alias_pair->second]; if (binding_alias_) { - Error(Format("Trying to bind an alias table_name: {} in another alias", expr_name)); + Error(fmt::format("Trying to bind an alias table_name: {} in another alias", expr_name)); } binding_alias_ = true; diff --git a/src/planner/binder/group_binder.cpp b/src/planner/binder/group_binder.cpp index c45da9771f..5e1046867e 100644 --- a/src/planner/binder/group_binder.cpp +++ b/src/planner/binder/group_binder.cpp @@ -68,7 +68,7 @@ SharedPtr GroupBinder::BuildExpression(const ParsedExpr &expr, B String expr_name = expr.GetName(); if (bind_context_ptr->group_index_by_name_.contains(expr_name)) { - Error(Format("Duplicated group by expression: {}", expr_name)); + Error(fmt::format("Duplicated group by expression: {}", expr_name)); } // Add the group by expression into bind context @@ -115,7 +115,7 @@ SharedPtr GroupBinder::BindConstantExpression(const ConstantExpr Vector &expr_array = bind_context_ptr->select_expression_; if (select_idx > (i64)expr_array.size() or select_idx < 1) { - Error(Format("GROUP BY clause out of range - should be from 1 to {}", expr_array.size())); + Error(fmt::format("GROUP BY clause out of range - should be from 1 to {}", expr_array.size())); } select_idx -= 1; diff --git a/src/planner/binder/having_binder.cpp b/src/planner/binder/having_binder.cpp index 8c0c8080bd..de0bb52924 100644 --- a/src/planner/binder/having_binder.cpp +++ b/src/planner/binder/having_binder.cpp @@ -43,7 +43,7 @@ SharedPtr HavingBinder::BuildExpression(const ParsedExpr &expr, SharedPtr result = ColumnExpression::Make(group_expr->Type(), bind_context_ptr->group_by_table_name_, bind_context_ptr->group_by_table_index_, - ToStr(groupby_index), + std::to_string(groupby_index), groupby_index, depth); @@ -61,7 +61,7 @@ SharedPtr HavingBinder::BuildExpression(const ParsedExpr &expr, SharedPtr result = ColumnExpression::Make(aggregate_expr->Type(), bind_context_ptr->aggregate_table_name_, bind_context_ptr->aggregate_table_index_, - ToStr(aggregate_index), + std::to_string(aggregate_index), aggregate_index, depth); @@ -92,7 +92,7 @@ SharedPtr HavingBinder::BuildColExpr(const ColumnExpr &expr, Bin return result; } else { - Error(Format("Column {} must appear in the GROUP BY clause or be used in an aggregate function", expr.GetName())); + Error(fmt::format("Column {} must appear in the GROUP BY clause or be used in an aggregate function", expr.GetName())); } return nullptr; } @@ -122,7 +122,7 @@ SharedPtr HavingBinder::BuildFuncExpr(const FunctionExpr &expr, SharedPtr result = ColumnExpression::Make(func_expr_ptr->Type(), bind_context_ptr->aggregate_table_name_, bind_context_ptr->aggregate_table_index_, - ToStr(aggregate_index), + std::to_string(aggregate_index), aggregate_index, depth); diff --git a/src/planner/binder/order_binder.cpp b/src/planner/binder/order_binder.cpp index 7b38516eba..7db81f7425 100644 --- a/src/planner/binder/order_binder.cpp +++ b/src/planner/binder/order_binder.cpp @@ -40,7 +40,7 @@ void OrderBinder::PushExtraExprToSelectList(ParsedExpr *expr, const SharedPtrGetName(); if (bind_context_ptr->binding_names_by_column_.contains(expr_name)) { - expr_name = Format("{}.{}", bind_context_ptr->binding_names_by_column_[expr_name][0], expr_name); + expr_name = fmt::format("{}.{}", bind_context_ptr->binding_names_by_column_[expr_name][0], expr_name); } if (bind_context_ptr->select_alias2index_.contains(expr_name)) { @@ -84,7 +84,7 @@ SharedPtr OrderBinder::BuildExpression(const ParsedExpr &expr, B if (bind_context_ptr->binding_names_by_column_.contains(expr_name)) { auto table_name = bind_context_ptr->binding_names_by_column_[expr_name][0]; - expr_name = Format("{}.{}", table_name, expr_name); + expr_name = fmt::format("{}.{}", table_name, expr_name); binding_table_name = table_name; binding_table_index = bind_context_ptr->table_name2table_index_[table_name]; } @@ -98,7 +98,7 @@ SharedPtr OrderBinder::BuildExpression(const ParsedExpr &expr, B } if (column_id == -1) { - Error(Format("{} isn't found in project list.", expr_name)); + Error(fmt::format("{} isn't found in project list.", expr_name)); } } @@ -107,7 +107,7 @@ SharedPtr OrderBinder::BuildExpression(const ParsedExpr &expr, B SharedPtr result = ColumnExpression::Make(project_expr->Type(), binding_table_name, binding_table_index, - ToStr(column_id), + std::to_string(column_id), column_id, depth); result->source_position_ = SourcePosition(bind_context_ptr->binding_context_id_, ExprSourceType::kProjection); diff --git a/src/planner/binder/project_binder.cpp b/src/planner/binder/project_binder.cpp index c4512c44f1..b5c062edd1 100644 --- a/src/planner/binder/project_binder.cpp +++ b/src/planner/binder/project_binder.cpp @@ -66,7 +66,7 @@ SharedPtr ProjectBinder::BuildExpression(const ParsedExpr &expr, if (IsEqual(function_set_ptr->name(), String("AVG")) && function_expression.arguments_->size() == 1 && (*function_expression.arguments_)[0]->type_ == ParsedExprType::kColumn) { auto column_expr = (ColumnExpr *)(*function_expression.arguments_)[0]; - Vector column_names(Move(column_expr->names_)); + Vector column_names(std::move(column_expr->names_)); delete column_expr; ConvertAvgToSumDivideCount(function_expression, column_names); return ExpressionBinder::BuildExpression(expr, bind_context_ptr, depth, root); @@ -134,7 +134,7 @@ SharedPtr ProjectBinder::BuildFuncExpr(const FunctionExpr &expr, SharedPtr function_set_ptr = FunctionSet::GetFunctionSet(query_context_->storage()->catalog(), expr); if (function_set_ptr->type_ == FunctionType::kAggregate) { if (this->binding_agg_func_) { - Error(Format("Aggregate function {} is called in another aggregate function.", function_set_ptr->name())); + Error(fmt::format("Aggregate function {} is called in another aggregate function.", function_set_ptr->name())); } else { this->binding_agg_func_ = true; } diff --git a/src/planner/binder/where_binder.cpp b/src/planner/binder/where_binder.cpp index db1297a2fc..5287f333fa 100644 --- a/src/planner/binder/where_binder.cpp +++ b/src/planner/binder/where_binder.cpp @@ -52,7 +52,7 @@ SharedPtr WhereBinder::BuildColExpr(const ColumnExpr &expr, Bind } if (result.get() == nullptr) { - Error(Format("Can't bind the expr: {}", expr.GetName())); + Error(fmt::format("Can't bind the expr: {}", expr.GetName())); } return result; } diff --git a/src/planner/binding.cpp b/src/planner/binding.cpp index e7507ecb4d..c315894ce6 100644 --- a/src/planner/binding.cpp +++ b/src/planner/binding.cpp @@ -39,8 +39,8 @@ SharedPtr Binding::MakeBinding(BindingType binding_type, if (column_count != column_types->size()) { Error("Make binding error: column size isn't valid."); } - binding->column_types_ = Move(column_types); - binding->column_names_ = Move(column_names); + binding->column_types_ = std::move(column_types); + binding->column_names_ = std::move(column_names); for (SizeT idx = 0; idx < column_count; ++idx) { binding->name2index_[binding->column_names_->at(idx)] = static_cast(idx); @@ -55,10 +55,10 @@ SharedPtr Binding::MakeBinding(BindingType binding_type, SharedPtr>> column_types, SharedPtr> column_names, SharedPtr block_index) { - auto binding = MakeBinding(binding_type, binding_alias, table_index, Move(column_types), Move(column_names)); + auto binding = MakeBinding(binding_type, binding_alias, table_index, std::move(column_types), std::move(column_names)); binding->table_collection_entry_ptr_ = table_ptr; - binding->block_index_ = Move(block_index); - // binding->logical_node_ptr_ = Move(logical_node_ptr); + binding->block_index_ = std::move(block_index); + // binding->logical_node_ptr_ = std::move(logical_node_ptr); // binding->logical_node_id_ = logical_node_id; return binding; } diff --git a/src/planner/bound/base_table_ref.cppm b/src/planner/bound/base_table_ref.cppm index 3c2a5d31a1..45566186ce 100644 --- a/src/planner/bound/base_table_ref.cppm +++ b/src/planner/bound/base_table_ref.cppm @@ -38,8 +38,8 @@ public: u64 table_index, SharedPtr> column_names, SharedPtr>> column_types) - : TableRef(TableRefType::kTable, alias), table_entry_ptr_(table_entry_ptr), column_ids_(Move(column_ids)), - block_index_(Move(block_index)), column_names_(Move(column_names)), column_types_(Move(column_types)), table_index_(table_index) {} + : TableRef(TableRefType::kTable, alias), table_entry_ptr_(table_entry_ptr), column_ids_(std::move(column_ids)), + block_index_(std::move(block_index)), column_names_(std::move(column_names)), column_types_(std::move(column_types)), table_index_(table_index) {} void RetainColumnByIndices(const Vector &&indices) { replace_field(column_ids_, indices); diff --git a/src/planner/bound/join_table_ref.cppm b/src/planner/bound/join_table_ref.cppm index f0656874cc..7ecf3e23a7 100644 --- a/src/planner/bound/join_table_ref.cppm +++ b/src/planner/bound/join_table_ref.cppm @@ -27,7 +27,7 @@ class BindContext; export class JoinTableRef : public TableRef { public: - explicit JoinTableRef(String alias) : TableRef(TableRefType::kJoin, Move(alias)) {} + explicit JoinTableRef(String alias) : TableRef(TableRefType::kJoin, std::move(alias)) {} SharedPtr left_bind_context_; SharedPtr right_bind_context_; diff --git a/src/planner/bound/subquery_table_ref.cppm b/src/planner/bound/subquery_table_ref.cppm index 58ebe18e34..db468886d1 100644 --- a/src/planner/bound/subquery_table_ref.cppm +++ b/src/planner/bound/subquery_table_ref.cppm @@ -26,7 +26,7 @@ namespace infinity { export class SubqueryTableRef : public TableRef { public: explicit SubqueryTableRef(UniquePtr subquery_node, u64 table_index, String alias) - : TableRef(TableRefType::kSubquery, Move(alias)), subquery_node_(Move(subquery_node)), table_index_(table_index) {} + : TableRef(TableRefType::kSubquery, std::move(alias)), subquery_node_(std::move(subquery_node)), table_index_(table_index) {} UniquePtr subquery_node_{nullptr}; u64 table_index_{}; diff --git a/src/planner/bound/table_ref.cppm b/src/planner/bound/table_ref.cppm index 6ff14b06f0..899d7b8053 100644 --- a/src/planner/bound/table_ref.cppm +++ b/src/planner/bound/table_ref.cppm @@ -23,7 +23,7 @@ namespace infinity { export class TableRef { public: - explicit TableRef(TableRefType type, String alias) : type_(type), alias_(Move(alias)) {} + explicit TableRef(TableRefType type, String alias) : type_(type), alias_(std::move(alias)) {} virtual ~TableRef() = default; [[nodiscard]] inline TableRefType type() const { return type_; } diff --git a/src/planner/bound_delete_statement.cppm b/src/planner/bound_delete_statement.cppm index e8083c2be8..0bb8a21bdc 100644 --- a/src/planner/bound_delete_statement.cppm +++ b/src/planner/bound_delete_statement.cppm @@ -29,11 +29,11 @@ namespace infinity { export struct BoundDeleteStatement final : public BoundStatement { public: static inline UniquePtr Make(SharedPtr bind_context) { - return MakeUnique(Move(bind_context)); + return MakeUnique(std::move(bind_context)); } public: - inline explicit BoundDeleteStatement(SharedPtr bind_context) : bind_context_(Move(bind_context)) {} + inline explicit BoundDeleteStatement(SharedPtr bind_context) : bind_context_(std::move(bind_context)) {} SharedPtr BuildPlan(QueryContext *query_context) final; diff --git a/src/planner/bound_select_statement.cpp b/src/planner/bound_select_statement.cpp index 33ee8b5cb0..0b718a0881 100644 --- a/src/planner/bound_select_statement.cpp +++ b/src/planner/bound_select_statement.cpp @@ -273,7 +273,7 @@ SharedPtr BoundSelectStatement::BuildCrossProductTable(SharedPtrGetNewLogicalNodeId(); - String alias("cross_product" + ToStr(logical_node_id)); + String alias("cross_product" + std::to_string(logical_node_id)); SharedPtr logical_cross_product_node = MakeShared(logical_node_id, alias, left_node, right_node); return logical_cross_product_node; } @@ -288,7 +288,7 @@ BoundSelectStatement::BuildJoinTable(SharedPtr &table_ref, QueryContex // TODO: Merge bind context ? u64 logical_node_id = bind_context->GetNewLogicalNodeId(); - String alias("join" + ToStr(logical_node_id)); + String alias("join" + std::to_string(logical_node_id)); SharedPtr logical_join_node = MakeShared(logical_node_id, join_table_ref->join_type_, alias, join_table_ref->on_conditions_, left_node, right_node); return logical_join_node; @@ -296,7 +296,7 @@ BoundSelectStatement::BuildJoinTable(SharedPtr &table_ref, QueryContex SharedPtr BoundSelectStatement::BuildDummyTable(SharedPtr &, QueryContext *, const SharedPtr &bind_context) { u64 logical_node_id = bind_context->GetNewLogicalNodeId(); - String alias("DummyTable" + ToStr(logical_node_id)); + String alias("DummyTable" + std::to_string(logical_node_id)); SharedPtr dummy_scan_node = MakeShared(logical_node_id, alias, bind_context->GenerateTableIndex()); return dummy_scan_node; } diff --git a/src/planner/bound_select_statement.cppm b/src/planner/bound_select_statement.cppm index d95fdc6387..087ab15bea 100644 --- a/src/planner/bound_select_statement.cppm +++ b/src/planner/bound_select_statement.cppm @@ -33,11 +33,11 @@ namespace infinity { export struct BoundSelectStatement final: public BoundStatement { public: static inline UniquePtr Make(SharedPtr bind_context) { - return MakeUnique(Move(bind_context)); + return MakeUnique(std::move(bind_context)); } public: - inline explicit BoundSelectStatement(SharedPtr bind_context): bind_context_(Move(bind_context)) {} + inline explicit BoundSelectStatement(SharedPtr bind_context): bind_context_(std::move(bind_context)) {} SharedPtr BuildPlan(QueryContext *query_context) final; diff --git a/src/planner/bound_update_statement.cppm b/src/planner/bound_update_statement.cppm index 1e5694c2b3..d6c69a5f9f 100644 --- a/src/planner/bound_update_statement.cppm +++ b/src/planner/bound_update_statement.cppm @@ -29,11 +29,11 @@ namespace infinity { export struct BoundUpdateStatement final : public BoundStatement { public: static inline UniquePtr Make(SharedPtr bind_context) { - return MakeUnique(Move(bind_context)); + return MakeUnique(std::move(bind_context)); } public: - inline explicit BoundUpdateStatement(SharedPtr bind_context) : bind_context_(Move(bind_context)) {} + inline explicit BoundUpdateStatement(SharedPtr bind_context) : bind_context_(std::move(bind_context)) {} SharedPtr BuildPlan(QueryContext *query_context) final; diff --git a/src/planner/column_identifier.cpp b/src/planner/column_identifier.cpp index 1c28ab1286..6763b5cd16 100644 --- a/src/planner/column_identifier.cpp +++ b/src/planner/column_identifier.cpp @@ -66,12 +66,12 @@ ColumnIdentifier::ColumnIdentifier(SharedPtr db_name, SharedPtr table_name, SharedPtr column_name, SharedPtr alias_name) - : db_name_ptr_(Move(db_name)), schema_name_ptr_(Move(schema_name)), column_name_ptr_(Move(column_name)), table_name_ptr_(Move(table_name)), - alias_name_ptr_(Move(alias_name)) {} + : db_name_ptr_(std::move(db_name)), schema_name_ptr_(std::move(schema_name)), column_name_ptr_(std::move(column_name)), table_name_ptr_(std::move(table_name)), + alias_name_ptr_(std::move(alias_name)) {} String ColumnIdentifier::ToString() const { if (table_name_ptr_.get() != nullptr) - return Format("{}.{}", *table_name_ptr_, *column_name_ptr_); + return fmt::format("{}.{}", *table_name_ptr_, *column_name_ptr_); else return *column_name_ptr_; } diff --git a/src/planner/explain_logical_plan.cpp b/src/planner/explain_logical_plan.cpp index 3e8e7870b4..d3c61d22df 100644 --- a/src/planner/explain_logical_plan.cpp +++ b/src/planner/explain_logical_plan.cpp @@ -212,30 +212,30 @@ void ExplainLogicalPlan::Explain(const LogicalCreateSchema *create_node, SharedP { String create_header_str; if (intent_size != 0) { - create_header_str = Format("{}-> CREATE SCHEMA ", String(intent_size - 2, ' ')); + create_header_str = fmt::format("{}-> CREATE SCHEMA ", String(intent_size - 2, ' ')); } else { create_header_str = "CREATE SCHEMA "; } - create_header_str += Format("({})", create_node->node_id()); + create_header_str += fmt::format("({})", create_node->node_id()); result->emplace_back(MakeShared(create_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), *create_node->schema_name()); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), *create_node->schema_name()); result->emplace_back(MakeShared(schema_name_str)); } // Conflict type { - String conflict_type_str = Format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(create_node->conflict_type())); + String conflict_type_str = fmt::format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(create_node->conflict_type())); result->emplace_back(MakeShared(conflict_type_str)); } // Output column { - String output_columns_str = Format("{} - output columns: [OK]", String(intent_size, ' ')); + String output_columns_str = fmt::format("{} - output columns: [OK]", String(intent_size, ' ')); result->emplace_back(MakeShared(output_columns_str)); } } @@ -244,24 +244,24 @@ void ExplainLogicalPlan::Explain(const LogicalCreateTable *create_node, SharedPt { String create_header_str; if (intent_size != 0) { - create_header_str = Format("{}-> CREATE TABLE ", String(intent_size - 2, ' ')); + create_header_str = fmt::format("{}-> CREATE TABLE ", String(intent_size - 2, ' ')); } else { create_header_str = "CREATE TABLE "; } - create_header_str += Format("({})", create_node->node_id()); + create_header_str += fmt::format("({})", create_node->node_id()); result->emplace_back(MakeShared(create_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), *create_node->schema_name()); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), *create_node->schema_name()); result->emplace_back(MakeShared(schema_name_str)); } // Table name { - String table_name_str = Format("{} - table name: {}", String(intent_size, ' '), *create_node->table_definitions()->table_name()); + String table_name_str = fmt::format("{} - table name: {}", String(intent_size, ' '), *create_node->table_definitions()->table_name()); result->emplace_back(MakeShared(table_name_str)); } @@ -284,13 +284,13 @@ void ExplainLogicalPlan::Explain(const LogicalCreateTable *create_node, SharedPt // Conflict type { - String conflict_type_str = Format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(create_node->conflict_type())); + String conflict_type_str = fmt::format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(create_node->conflict_type())); result->emplace_back(MakeShared(conflict_type_str)); } // Output column { - String output_columns_str = Format("{} - output columns: [OK]", String(intent_size, ' ')); + String output_columns_str = fmt::format("{} - output columns: [OK]", String(intent_size, ' ')); result->emplace_back(MakeShared(output_columns_str)); } } @@ -304,7 +304,7 @@ void ExplainLogicalPlan::Explain(const LogicalCreateIndex *create_node, SharedPt create_header_str = "CREATE INDEX "; } - create_header_str += "(" + ToStr(create_node->node_id()) + ")"; + create_header_str += "(" + std::to_string(create_node->node_id()) + ")"; result->emplace_back(MakeShared(create_header_str)); } @@ -339,36 +339,36 @@ void ExplainLogicalPlan::Explain(const LogicalCreateCollection *create_node, Sha { String create_header_str; if (intent_size != 0) { - create_header_str = Format("{}-> CREATE COLLECTION ", String(intent_size - 2, ' ')); + create_header_str = fmt::format("{}-> CREATE COLLECTION ", String(intent_size - 2, ' ')); } else { create_header_str = "CREATE COLLECTION "; } - create_header_str += Format("({})", create_node->node_id()); + create_header_str += fmt::format("({})", create_node->node_id()); result->emplace_back(MakeShared(create_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), *create_node->schema_name()); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), *create_node->schema_name()); result->emplace_back(MakeShared(schema_name_str)); } // Collection name { - String collection_name_str = Format("{} - collection name: {}", String(intent_size, ' '), *create_node->collection_name()); + String collection_name_str = fmt::format("{} - collection name: {}", String(intent_size, ' '), *create_node->collection_name()); result->emplace_back(MakeShared(collection_name_str)); } // Conflict type { - String conflict_type_str = Format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(create_node->conflict_type())); + String conflict_type_str = fmt::format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(create_node->conflict_type())); result->emplace_back(MakeShared(conflict_type_str)); } // Output column { - String output_columns_str = Format("{} - output columns: [OK]", String(intent_size, ' ')); + String output_columns_str = fmt::format("{} - output columns: [OK]", String(intent_size, ' ')); result->emplace_back(MakeShared(output_columns_str)); } } @@ -377,23 +377,23 @@ void ExplainLogicalPlan::Explain(const LogicalCreateView *create_node, SharedPtr { String create_header_str; if (intent_size != 0) { - create_header_str = Format("{}-> CREATE VIEW ", String(intent_size - 2, ' ')); + create_header_str = fmt::format("{}-> CREATE VIEW ", String(intent_size - 2, ' ')); } else { create_header_str = "CREATE VIEW "; } - create_header_str += Format("({})", create_node->node_id()); + create_header_str += fmt::format("({})", create_node->node_id()); result->emplace_back(MakeShared(create_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), create_node->create_view_info()->schema_name_); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), create_node->create_view_info()->schema_name_); result->emplace_back(MakeShared(schema_name_str)); } // View name { - String view_name_str = Format("{} - view name: {}", String(intent_size, ' '), create_node->create_view_info()->view_name_); + String view_name_str = fmt::format("{} - view name: {}", String(intent_size, ' '), create_node->create_view_info()->view_name_); result->emplace_back(MakeShared(view_name_str)); } @@ -417,19 +417,19 @@ void ExplainLogicalPlan::Explain(const LogicalCreateView *create_node, SharedPtr // Conflict type { String conflict_type_str = - Format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(create_node->create_view_info()->conflict_type_)); + fmt::format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(create_node->create_view_info()->conflict_type_)); result->emplace_back(MakeShared(conflict_type_str)); } // Text { - String sql_text = Format("{} - text: Not implemented", String(intent_size, ' ')); + String sql_text = fmt::format("{} - text: Not implemented", String(intent_size, ' ')); result->emplace_back(MakeShared(sql_text)); } // Output column { - String output_columns_str = Format("{} - output columns: [OK]", String(intent_size, ' ')); + String output_columns_str = fmt::format("{} - output columns: [OK]", String(intent_size, ' ')); result->emplace_back(MakeShared(output_columns_str)); } } @@ -438,30 +438,30 @@ void ExplainLogicalPlan::Explain(const LogicalDropSchema *drop_node, SharedPtr CREATE SCHEMA ", String(intent_size - 2, ' ')); + drop_header_str = fmt::format("{}-> CREATE SCHEMA ", String(intent_size - 2, ' ')); } else { drop_header_str = "DROP SCHEMA "; } - drop_header_str += Format("({})", drop_node->node_id()); + drop_header_str += fmt::format("({})", drop_node->node_id()); result->emplace_back(MakeShared(drop_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), *drop_node->schema_name()); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), *drop_node->schema_name()); result->emplace_back(MakeShared(schema_name_str)); } // Conflict type { - String conflict_type_str = Format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(drop_node->conflict_type())); + String conflict_type_str = fmt::format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(drop_node->conflict_type())); result->emplace_back(MakeShared(conflict_type_str)); } // Output column { - String output_columns_str = Format("{} - output columns: [OK]", String(intent_size, ' ')); + String output_columns_str = fmt::format("{} - output columns: [OK]", String(intent_size, ' ')); result->emplace_back(MakeShared(output_columns_str)); } } @@ -470,36 +470,36 @@ void ExplainLogicalPlan::Explain(const LogicalDropTable *drop_node, SharedPtr DROP TABLE ", String(intent_size - 2, ' ')); + drop_header_str = fmt::format("{}-> DROP TABLE ", String(intent_size - 2, ' ')); } else { drop_header_str = "DROP TABLE "; } - drop_header_str += Format("({})", drop_node->node_id()); + drop_header_str += fmt::format("({})", drop_node->node_id()); result->emplace_back(MakeShared(drop_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), *drop_node->schema_name()); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), *drop_node->schema_name()); result->emplace_back(MakeShared(schema_name_str)); } // Table name { - String table_name_str = Format("{} - table: {}", String(intent_size, ' '), *drop_node->table_name()); + String table_name_str = fmt::format("{} - table: {}", String(intent_size, ' '), *drop_node->table_name()); result->emplace_back(MakeShared(table_name_str)); } // Conflict type { - String conflict_type_str = Format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(drop_node->conflict_type())); + String conflict_type_str = fmt::format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(drop_node->conflict_type())); result->emplace_back(MakeShared(conflict_type_str)); } // Output column { - String output_columns_str = Format("{} - output columns: [OK]", String(intent_size, ' ')); + String output_columns_str = fmt::format("{} - output columns: [OK]", String(intent_size, ' ')); result->emplace_back(MakeShared(output_columns_str)); } } @@ -508,36 +508,36 @@ void ExplainLogicalPlan::Explain(const LogicalDropCollection *drop_node, SharedP { String drop_header_str; if (intent_size != 0) { - drop_header_str = Format("{}-> DROP COLLECTION ", String(intent_size - 2, ' ')); + drop_header_str = fmt::format("{}-> DROP COLLECTION ", String(intent_size - 2, ' ')); } else { drop_header_str = "DROP COLLECTION "; } - drop_header_str += Format("({})", drop_node->node_id()); + drop_header_str += fmt::format("({})", drop_node->node_id()); result->emplace_back(MakeShared(drop_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), *drop_node->schema_name()); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), *drop_node->schema_name()); result->emplace_back(MakeShared(schema_name_str)); } // Collection name { - String table_name_str = Format("{} - collection: {}", String(intent_size, ' '), *drop_node->collection_name()); + String table_name_str = fmt::format("{} - collection: {}", String(intent_size, ' '), *drop_node->collection_name()); result->emplace_back(MakeShared(table_name_str)); } // Conflict type { - String conflict_type_str = Format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(drop_node->conflict_type())); + String conflict_type_str = fmt::format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(drop_node->conflict_type())); result->emplace_back(MakeShared(conflict_type_str)); } // Output column { - String output_columns_str = Format("{} - output columns: [OK]", String(intent_size, ' ')); + String output_columns_str = fmt::format("{} - output columns: [OK]", String(intent_size, ' ')); result->emplace_back(MakeShared(output_columns_str)); } } @@ -546,36 +546,36 @@ void ExplainLogicalPlan::Explain(const LogicalDropView *drop_node, SharedPtr DROP VIEW ", String(intent_size - 2, ' ')); + drop_header_str = fmt::format("{}-> DROP VIEW ", String(intent_size - 2, ' ')); } else { drop_header_str = "DROP VIEW "; } - drop_header_str += Format("({})", drop_node->node_id()); + drop_header_str += fmt::format("({})", drop_node->node_id()); result->emplace_back(MakeShared(drop_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), *drop_node->schema_name()); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), *drop_node->schema_name()); result->emplace_back(MakeShared(schema_name_str)); } // View name { - String table_name_str = Format("{} - view name: {}", String(intent_size, ' '), *drop_node->view_name()); + String table_name_str = fmt::format("{} - view name: {}", String(intent_size, ' '), *drop_node->view_name()); result->emplace_back(MakeShared(table_name_str)); } // Conflict type { - String conflict_type_str = Format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(drop_node->conflict_type())); + String conflict_type_str = fmt::format("{} - conflict type: {}", String(intent_size, ' '), ConflictType2Str(drop_node->conflict_type())); result->emplace_back(MakeShared(conflict_type_str)); } // Output column { - String output_columns_str = Format("{} - output columns: [OK]", String(intent_size, ' ')); + String output_columns_str = fmt::format("{} - output columns: [OK]", String(intent_size, ' ')); result->emplace_back(MakeShared(output_columns_str)); } } @@ -584,25 +584,25 @@ void ExplainLogicalPlan::Explain(const LogicalInsert *insert_node, SharedPtr INSERT ", String(intent_size - 2, ' ')); + insert_header_str = fmt::format("{}-> INSERT ", String(intent_size - 2, ' ')); } else { insert_header_str = "INSERT "; } - insert_header_str += Format("({})", insert_node->node_id()); + insert_header_str += fmt::format("({})", insert_node->node_id()); result->emplace_back(MakeShared(insert_header_str)); } // Schema name { - String schema_name_str = Format("{} - schema name: {}", String(intent_size, ' '), *insert_node->table_entry()->GetDBName()); + String schema_name_str = fmt::format("{} - schema name: {}", String(intent_size, ' '), *insert_node->table_entry()->GetDBName()); result->emplace_back(MakeShared(schema_name_str)); } // Table name { - String table_name_str = Format("{} - table name: {}", String(intent_size, ' '), *insert_node->table_entry()->GetTableName()); + String table_name_str = fmt::format("{} - table name: {}", String(intent_size, ' '), *insert_node->table_entry()->GetTableName()); result->emplace_back(MakeShared(table_name_str)); } @@ -649,18 +649,18 @@ void ExplainLogicalPlan::Explain(const LogicalProject *project_node, SharedPtr PROJECT ", String(intent_size - 2, ' ')); + project_header = fmt::format("{}-> PROJECT ", String(intent_size - 2, ' ')); } else { project_header = "PROJECT "; } - project_header += Format("({})", project_node->node_id()); + project_header += fmt::format("({})", project_node->node_id()); result->emplace_back(MakeShared(project_header)); } // Table index { - String table_index = Format("{} - table index: #{}", String(intent_size, ' '), project_node->table_index_); + String table_index = fmt::format("{} - table index: #{}", String(intent_size, ' '), project_node->table_index_); result->emplace_back(MakeShared(table_index)); } @@ -685,12 +685,12 @@ void ExplainLogicalPlan::Explain(const LogicalProject *project_node, SharedPtr>> &result, i64 intent_size) { String filter_node_header; if (intent_size != 0) { - filter_node_header = Format("{}-> FILTER ", String(intent_size - 2, ' ')); + filter_node_header = fmt::format("{}-> FILTER ", String(intent_size - 2, ' ')); } else { filter_node_header = "FILTER "; } - filter_node_header += Format("({})", filter_node->node_id()); + filter_node_header += fmt::format("({})", filter_node->node_id()); result->emplace_back(MakeShared(filter_node_header)); // filter expression @@ -725,7 +725,7 @@ void ExplainLogicalPlan::Explain(const LogicalTableScan *table_scan_node, Shared table_scan_header = "TABLE SCAN "; } - table_scan_header += Format("({})", table_scan_node->node_id()); + table_scan_header += fmt::format("({})", table_scan_node->node_id()); result->emplace_back(MakeShared(table_scan_header)); // Table alias and name @@ -743,7 +743,7 @@ void ExplainLogicalPlan::Explain(const LogicalTableScan *table_scan_node, Shared // Table index String table_index = String(intent_size, ' '); table_index += " - table index: #"; - table_index += ToStr(table_scan_node->TableIndex()); + table_index += std::to_string(table_scan_node->TableIndex()); result->emplace_back(MakeShared(table_index)); // Output columns @@ -751,7 +751,7 @@ void ExplainLogicalPlan::Explain(const LogicalTableScan *table_scan_node, Shared output_columns += " - output columns: ["; SizeT column_count = table_scan_node->GetOutputNames()->size(); if (column_count == 0) { - Error(Format("No column in table: {}.", table_scan_node->TableAlias())); + Error(fmt::format("No column in table: {}.", table_scan_node->TableAlias())); } for (SizeT idx = 0; idx < column_count - 1; ++idx) { output_columns += table_scan_node->GetOutputNames()->at(idx); @@ -771,7 +771,7 @@ void ExplainLogicalPlan::Explain(const LogicalKnnScan *knn_scan_node, SharedPtr< knn_scan_header = "KNN SCAN "; } - knn_scan_header += Format("({})", knn_scan_node->node_id()); + knn_scan_header += fmt::format("({})", knn_scan_node->node_id()); result->emplace_back(MakeShared(knn_scan_header)); // Table alias and name @@ -789,7 +789,7 @@ void ExplainLogicalPlan::Explain(const LogicalKnnScan *knn_scan_node, SharedPtr< // Table index String table_index = String(intent_size, ' '); table_index += " - table index: #"; - table_index += ToStr(knn_scan_node->TableIndex()); + table_index += std::to_string(knn_scan_node->TableIndex()); result->emplace_back(MakeShared(table_index)); const auto &knn_expression = knn_scan_node->knn_expression_; @@ -807,7 +807,7 @@ void ExplainLogicalPlan::Explain(const LogicalKnnScan *knn_scan_node, SharedPtr< String embedding_dimension_str = String(intent_size + 2, ' '); embedding_dimension_str += " - dimension: "; - embedding_type_str += ToStr(knn_expr_raw->dimension_); + embedding_type_str += std::to_string(knn_expr_raw->dimension_); result->emplace_back(MakeShared(embedding_dimension_str)); String distance_type_str = String(intent_size + 2, ' '); @@ -834,7 +834,7 @@ void ExplainLogicalPlan::Explain(const LogicalKnnScan *knn_scan_node, SharedPtr< output_columns += " - output columns: ["; SizeT column_count = knn_scan_node->GetOutputNames()->size(); if (column_count == 0) { - Error(Format("No column in table: {}.", knn_scan_node->TableAlias())); + Error(fmt::format("No column in table: {}.", knn_scan_node->TableAlias())); } for (SizeT idx = 0; idx < column_count - 1; ++idx) { output_columns += knn_scan_node->GetOutputNames()->at(idx); @@ -862,7 +862,7 @@ void ExplainLogicalPlan::Explain(const LogicalAggregate *aggregate_node, SharedP } agg_header += "("; - agg_header += ToStr(aggregate_node->node_id()); + agg_header += std::to_string(aggregate_node->node_id()); agg_header += ")"; result->emplace_back(MakeShared(agg_header)); } @@ -871,7 +871,7 @@ void ExplainLogicalPlan::Explain(const LogicalAggregate *aggregate_node, SharedP { String aggregate_table_index = String(intent_size, ' '); aggregate_table_index += " - aggregate table index: #"; - aggregate_table_index += ToStr(aggregate_node->aggregate_index_); + aggregate_table_index += std::to_string(aggregate_node->aggregate_index_); result->emplace_back(MakeShared(aggregate_table_index)); } @@ -895,7 +895,7 @@ void ExplainLogicalPlan::Explain(const LogicalAggregate *aggregate_node, SharedP // Group by table index String group_table_index = String(intent_size, ' '); group_table_index += " - group by table index: #"; - group_table_index += ToStr(aggregate_node->groupby_index_); + group_table_index += std::to_string(aggregate_node->groupby_index_); result->emplace_back(MakeShared(group_table_index)); String group_by_expression_str = String(intent_size, ' '); @@ -921,7 +921,7 @@ void ExplainLogicalPlan::Explain(const LogicalSort *sort_node, SharedPtrnode_id()); + sort_header += std::to_string(sort_node->node_id()); sort_header += ")"; result->emplace_back(MakeShared(sort_header)); } @@ -974,7 +974,7 @@ void ExplainLogicalPlan::Explain(const LogicalLimit *limit_node, SharedPtrnode_id()); + limit_header += std::to_string(limit_node->node_id()); limit_header += ")"; result->emplace_back(MakeShared(limit_header)); } @@ -1019,7 +1019,7 @@ void ExplainLogicalPlan::Explain(const LogicalCrossProduct *cross_product_node, cross_product_header = "CROSS PRODUCT "; } cross_product_header += "("; - cross_product_header += ToStr(cross_product_node->node_id()); + cross_product_header += std::to_string(cross_product_node->node_id()); cross_product_header += ")"; result->emplace_back(MakeShared(cross_product_header)); } @@ -1049,7 +1049,7 @@ void ExplainLogicalPlan::Explain(const LogicalJoin *join_node, SharedPtrjoin_type_); join_header += "("; - join_header += ToStr(join_node->node_id()); + join_header += std::to_string(join_node->node_id()); join_header += ")"; result->emplace_back(MakeShared(join_header)); } @@ -1099,7 +1099,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1117,7 +1117,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1135,7 +1135,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1163,7 +1163,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1181,7 +1181,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1199,7 +1199,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1218,7 +1218,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1236,19 +1236,19 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); if (show_node->segment_id().has_value()) { String output_columns_str = String(intent_size, ' '); - output_columns_str += " - segment: " + ToStr(*show_node->segment_id()); + output_columns_str += " - segment: " + std::to_string(*show_node->segment_id()); result->emplace_back(MakeShared(output_columns_str)); } if (show_node->block_id().has_value()) { String output_columns_str = String(intent_size, ' '); - output_columns_str += " - block: " + ToStr(*show_node->block_id()); + output_columns_str += " - block: " + std::to_string(*show_node->block_id()); result->emplace_back(MakeShared(output_columns_str)); } @@ -1266,7 +1266,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1284,7 +1284,7 @@ void ExplainLogicalPlan::Explain(const LogicalShow *show_node, SharedPtrnode_id()); + show_str += std::to_string(show_node->node_id()); show_str += ")"; result->emplace_back(MakeShared(show_str)); @@ -1349,9 +1349,9 @@ void ExplainLogicalPlan::Explain(const BaseExpression *base_expression, String & ColumnExpression *column_expression = (ColumnExpression *)base_expression; expr_str += column_expression->Name(); expr_str += " (#"; - expr_str += ToStr(column_expression->binding().table_idx); + expr_str += std::to_string(column_expression->binding().table_idx); expr_str += "."; - expr_str += ToStr(column_expression->binding().column_idx); + expr_str += std::to_string(column_expression->binding().column_idx); expr_str += ")"; break; } @@ -1427,7 +1427,7 @@ void ExplainLogicalPlan::Explain(const BaseExpression *base_expression, String & ReferenceExpression *reference_expression = (ReferenceExpression *)base_expression; expr_str += reference_expression->Name(); expr_str += " (#"; - expr_str += ToStr(reference_expression->column_index()); + expr_str += std::to_string(reference_expression->column_index()); expr_str += ")"; break; } @@ -1451,54 +1451,54 @@ void ExplainLogicalPlan::Explain(const LogicalImport *import_node, SharedPtrnode_id()); + import_header_str += std::to_string(import_node->node_id()); import_header_str += ")"; result->emplace_back(MakeShared(import_header_str)); } { SharedPtr schema_name = - MakeShared(Format("{} - schema name: {}", String(intent_size, ' '), *import_node->table_entry()->GetDBName())); + MakeShared(fmt::format("{} - schema name: {}", String(intent_size, ' '), *import_node->table_entry()->GetDBName())); result->emplace_back(schema_name); } { SharedPtr table_name = - MakeShared(Format("{} - table name: {}", String(intent_size, ' '), *import_node->table_entry()->GetTableName())); + MakeShared(fmt::format("{} - table name: {}", String(intent_size, ' '), *import_node->table_entry()->GetTableName())); result->emplace_back(table_name); } { - SharedPtr path = MakeShared(Format("{} - file: {}", String(intent_size, ' '), import_node->file_path())); + SharedPtr path = MakeShared(fmt::format("{} - file: {}", String(intent_size, ' '), import_node->file_path())); result->emplace_back(path); } switch (import_node->FileType()) { case CopyFileType::kCSV: { - SharedPtr file_type = MakeShared(Format("{} - type: CSV", String(intent_size, ' '))); + SharedPtr file_type = MakeShared(fmt::format("{} - type: CSV", String(intent_size, ' '))); result->emplace_back(file_type); SharedPtr header = - MakeShared(Format("{} - header: {}", String(intent_size, ' '), (import_node->header() ? "Yes" : "No"))); + MakeShared(fmt::format("{} - header: {}", String(intent_size, ' '), (import_node->header() ? "Yes" : "No"))); result->emplace_back(header); SharedPtr delimiter = - MakeShared(Format("{} - header: {} - delimiter: ", String(intent_size, ' '), import_node->delimiter())); + MakeShared(fmt::format("{} - header: {} - delimiter: ", String(intent_size, ' '), import_node->delimiter())); result->emplace_back(delimiter); break; } case CopyFileType::kJSON: { - SharedPtr file_type = MakeShared(Format("{} - type: JSON", String(intent_size, ' '))); + SharedPtr file_type = MakeShared(fmt::format("{} - type: JSON", String(intent_size, ' '))); result->emplace_back(file_type); break; } case CopyFileType::kJSONL: { - SharedPtr file_type = MakeShared(Format("{} - type: JSONL", String(intent_size, ' '))); + SharedPtr file_type = MakeShared(fmt::format("{} - type: JSONL", String(intent_size, ' '))); result->emplace_back(file_type); break; } case CopyFileType::kFVECS: { - SharedPtr file_type = MakeShared(Format("{} - type: FVECS", String(intent_size, ' '))); + SharedPtr file_type = MakeShared(fmt::format("{} - type: FVECS", String(intent_size, ' '))); result->emplace_back(file_type); break; } @@ -1520,52 +1520,52 @@ void ExplainLogicalPlan::Explain(const LogicalExport *export_node, SharedPtrnode_id()); + export_header_str += std::to_string(export_node->node_id()); export_header_str += ")"; result->emplace_back(MakeShared(export_header_str)); } { - SharedPtr schema_name = MakeShared(Format("{} - schema name: {}", String(intent_size, ' '), export_node->schema_name())); + SharedPtr schema_name = MakeShared(fmt::format("{} - schema name: {}", String(intent_size, ' '), export_node->schema_name())); result->emplace_back(schema_name); } { - SharedPtr table_name = MakeShared(Format("{} - table name: {}", String(intent_size, ' '), export_node->table_name())); + SharedPtr table_name = MakeShared(fmt::format("{} - table name: {}", String(intent_size, ' '), export_node->table_name())); result->emplace_back(table_name); } { - SharedPtr path = MakeShared(Format("{} - file: {}", String(intent_size, ' '), export_node->file_path())); + SharedPtr path = MakeShared(fmt::format("{} - file: {}", String(intent_size, ' '), export_node->file_path())); result->emplace_back(path); } switch (export_node->FileType()) { case CopyFileType::kCSV: { - SharedPtr file_type = MakeShared(Format("{} - type: CSV", String(intent_size, ' '))); + SharedPtr file_type = MakeShared(fmt::format("{} - type: CSV", String(intent_size, ' '))); result->emplace_back(file_type); SharedPtr header = - MakeShared(Format("{} - header: {}", String(intent_size, ' '), (export_node->header() ? "Yes" : "No"))); + MakeShared(fmt::format("{} - header: {}", String(intent_size, ' '), (export_node->header() ? "Yes" : "No"))); result->emplace_back(header); SharedPtr delimiter = - MakeShared(Format("{} - header: {} - delimiter: ", String(intent_size, ' '), export_node->delimiter())); + MakeShared(fmt::format("{} - header: {} - delimiter: ", String(intent_size, ' '), export_node->delimiter())); result->emplace_back(delimiter); break; } case CopyFileType::kJSON: { - SharedPtr file_type = MakeShared(Format("{} - type: JSON", String(intent_size, ' '))); + SharedPtr file_type = MakeShared(fmt::format("{} - type: JSON", String(intent_size, ' '))); result->emplace_back(file_type); break; } case CopyFileType::kJSONL: { - SharedPtr file_type = MakeShared(Format("{} - type: JSONL", String(intent_size, ' '))); + SharedPtr file_type = MakeShared(fmt::format("{} - type: JSONL", String(intent_size, ' '))); result->emplace_back(file_type); break; } case CopyFileType::kFVECS: { - SharedPtr file_type = MakeShared(Format("{} - type: FVECS", String(intent_size, ' '))); + SharedPtr file_type = MakeShared(fmt::format("{} - type: FVECS", String(intent_size, ' '))); result->emplace_back(file_type); break; } @@ -1588,17 +1588,17 @@ void ExplainLogicalPlan::Explain(const LogicalFlush *flush_node, SharedPtrflush_type()) { case FlushType::kData: flush_header_str += "DATA ("; - flush_header_str += ToStr(flush_node->node_id()); + flush_header_str += std::to_string(flush_node->node_id()); flush_header_str += ")"; break; case FlushType::kLog: flush_header_str += "LOG ("; - flush_header_str += ToStr(flush_node->node_id()); + flush_header_str += std::to_string(flush_node->node_id()); flush_header_str += ")"; break; case FlushType::kBuffer: flush_header_str += "BUFFER ("; - flush_header_str += ToStr(flush_node->node_id()); + flush_header_str += std::to_string(flush_node->node_id()); flush_header_str += ")"; break; } @@ -1617,7 +1617,7 @@ void ExplainLogicalPlan::Explain(const LogicalOptimize *optimize_node, SharedPtr switch (optimize_node->optimize_type()) { case OptimizeType::kIRS: optimize_header_str += "DATA ("; - optimize_header_str += ToStr(optimize_node->node_id()); + optimize_header_str += std::to_string(optimize_node->node_id()); optimize_header_str += ")"; break; } diff --git a/src/planner/expression_binder.cpp b/src/planner/expression_binder.cpp index 13bfeb729a..b4359b599a 100644 --- a/src/planner/expression_binder.cpp +++ b/src/planner/expression_binder.cpp @@ -67,7 +67,7 @@ SharedPtr ExpressionBinder::Bind(const ParsedExpr &expr, BindCon SharedPtr result = BuildExpression(expr, bind_context_ptr, depth, root); if (result.get() == nullptr) { if (result.get() == nullptr) { - Error(Format("Fail to bind the expression: {}", expr.GetName())); + Error(fmt::format("Fail to bind the expression: {}", expr.GetName())); } // Maybe the correlated expression, trying to bind it in the parent context. // result = Bind(expr, bind_context_ptr->parent_, depth + 1, root); @@ -250,7 +250,7 @@ SharedPtr ExpressionBinder::BuildColExpr(const ColumnExpr &expr, SharedPtr column_expr = bind_context_ptr->ResolveColumnId(column_identifier, depth); if (column_expr != nullptr && column_expr->IsCorrelated()) { // Correlated column expression - LOG_TRACE(Format("Has correlated expr {}", column_expr->column_name())); + LOG_TRACE(fmt::format("Has correlated expr {}", column_expr->column_name())); bind_context_ptr->AddCorrelatedColumnExpr(column_expr); } return column_expr; @@ -328,7 +328,7 @@ SharedPtr ExpressionBinder::BuildFuncExpr(const FunctionExpr &ex case FunctionType::kTable: Error("Table function shouldn't be bound here."); default: { - Error(Format("Unknown function type: {}", function_set_ptr->name())); + Error(fmt::format("Unknown function type: {}", function_set_ptr->name())); } } return nullptr; @@ -444,7 +444,7 @@ SharedPtr ExpressionBinder::BuildKnnExpr(const KnnExpr &parsed_k } else { EmbeddingInfo *embedding_info = (EmbeddingInfo *)type_info; if ((i64)embedding_info->Dimension() != parsed_knn_expr.dimension_) { - Error(Format("Query embedding with dimension: {} which doesn't not matched with {}", + Error(fmt::format("Query embedding with dimension: {} which doesn't not matched with {}", parsed_knn_expr.dimension_, embedding_info->Dimension())); } @@ -458,7 +458,7 @@ SharedPtr ExpressionBinder::BuildKnnExpr(const KnnExpr &parsed_k SharedPtr bound_knn_expr = MakeShared(parsed_knn_expr.embedding_data_type_, parsed_knn_expr.dimension_, parsed_knn_expr.distance_type_, - Move(query_embedding), + std::move(query_embedding), arguments, parsed_knn_expr.topn_, parsed_knn_expr.opt_params_); @@ -496,7 +496,7 @@ ExpressionBinder::BuildSubquery(const SubqueryExpr &expr, BindContext *bind_cont QueryBinder query_binder(this->query_context_, subquery_binding_context_ptr); UniquePtr bound_statement_ptr = query_binder.BindSelect(*expr.select_); - SharedPtr in_subquery_expr = MakeShared(Move(bound_statement_ptr), subquery_type); + SharedPtr in_subquery_expr = MakeShared(std::move(bound_statement_ptr), subquery_type); in_subquery_expr->left_ = bound_left_expr; in_subquery_expr->correlated_columns = bind_context_ptr->correlated_column_exprs_; return in_subquery_expr; @@ -508,7 +508,7 @@ ExpressionBinder::BuildSubquery(const SubqueryExpr &expr, BindContext *bind_cont QueryBinder query_binder(this->query_context_, subquery_binding_context_ptr); UniquePtr bound_statement_ptr = query_binder.BindSelect(*expr.select_); - SharedPtr subquery_expr = MakeShared(Move(bound_statement_ptr), subquery_type); + SharedPtr subquery_expr = MakeShared(std::move(bound_statement_ptr), subquery_type); subquery_expr->correlated_columns = bind_context_ptr->correlated_column_exprs_; return subquery_expr; diff --git a/src/planner/logical_node_visitor.cpp b/src/planner/logical_node_visitor.cpp index c785b71dc0..d7f0b4caf0 100644 --- a/src/planner/logical_node_visitor.cpp +++ b/src/planner/logical_node_visitor.cpp @@ -134,7 +134,7 @@ void LogicalNodeVisitor::VisitNodeExpression(LogicalNode &op) { break; } default: { -// LOG_TRACE(Format("Visit logical node: {}", op.name())); +// LOG_TRACE(fmt::format("Visit logical node: {}", op.name())); } } } @@ -272,7 +272,7 @@ void LogicalNodeVisitor::VisitExpression(SharedPtr &expression) break; } default: { - Error(Format("Unexpected expression type: {}", expression->Name())); + Error(fmt::format("Unexpected expression type: {}", expression->Name())); } } } diff --git a/src/planner/logical_planner.cpp b/src/planner/logical_planner.cpp index 6c9bb7cb59..c6f8510fe2 100644 --- a/src/planner/logical_planner.cpp +++ b/src/planner/logical_planner.cpp @@ -231,7 +231,7 @@ Status LogicalPlanner::BuildInsertValue(const InsertStatement *statement, Shared } else { SizeT table_column_count = table_entry->ColumnCount(); if (value_list.size() != table_column_count) { - Error(Format("INSERT: Table column count ({}) and " + Error(fmt::format("INSERT: Table column count ({}) and " "input value count mismatch ({})", table_column_count, value_list.size())); @@ -450,7 +450,7 @@ Status LogicalPlanner::BuildCreateIndex(const CreateStatement *statement, Shared // Error("Creating index only support single column now."); // } - SharedPtr index_name = MakeShared(Move(create_index_info->index_name_)); + SharedPtr index_name = MakeShared(std::move(create_index_info->index_name_)); SharedPtr index_def_ptr = MakeShared(index_name); Vector &index_info_list = *create_index_info->index_info_list_; @@ -567,7 +567,7 @@ Status LogicalPlanner::BuildDropCollection(const DropStatement *statement, Share Status LogicalPlanner::BuildDropSchema(const DropStatement *statement, SharedPtr &bind_context_ptr) { auto *drop_schema_info = (DropSchemaInfo *)statement->drop_info_.get(); if (drop_schema_info->schema_name_ == query_context_ptr_->schema_name()) { - Error(Format("Can't drop using database: {}", drop_schema_info->schema_name_)); + Error(fmt::format("Can't drop using database: {}", drop_schema_info->schema_name_)); } SharedPtr schema_name_ptr = MakeShared(drop_schema_info->schema_name_); @@ -649,7 +649,7 @@ Status LogicalPlanner::BuildExport(const CopyStatement *statement, SharedPtrfile_path_)) { - Error(Format("File: {} doesn't exist.", statement->file_path_)); + Error(fmt::format("File: {} doesn't exist.", statement->file_path_)); } SharedPtr logical_export = MakeShared(bind_context_ptr->GetNewLogicalNodeId(), @@ -677,7 +677,7 @@ Status LogicalPlanner::BuildImport(const CopyStatement *statement, SharedPtrfile_path_)) { - Error(Format("File: {} doesn't exist.", fs.GetAbsolutePath(statement->file_path_))); + Error(fmt::format("File: {} doesn't exist.", fs.GetAbsolutePath(statement->file_path_))); } SharedPtr logical_import = MakeShared(bind_context_ptr->GetNewLogicalNodeId(), @@ -709,7 +709,7 @@ Status LogicalPlanner::BuildCommand(const CommandStatement *statement, SharedPtr this->logical_plan_ = logical_command; } else { - Error(Format("Unknown database name:{}.", use_command_info->db_name())); + Error(fmt::format("Unknown database name:{}.", use_command_info->db_name())); } break; } diff --git a/src/planner/logical_planner.cppm b/src/planner/logical_planner.cppm index 437169c4f2..22bd15a836 100644 --- a/src/planner/logical_planner.cppm +++ b/src/planner/logical_planner.cppm @@ -139,12 +139,12 @@ private: if (identifier.empty()) { return false; } - if (!IsAlpha(identifier[0]) && identifier[0] != '_') { + if (!std::isalpha(identifier[0]) && identifier[0] != '_') { return false; } for (SizeT i = 1; i < identifier.length(); i++) { char ch = identifier[i]; - if (!IsAlNum(ch) && ch != '_') { + if (!std::isalnum(ch) && ch != '_') { return false; } } diff --git a/src/planner/node/logical_aggregate.cppm b/src/planner/node/logical_aggregate.cppm index 979727b4b0..c56f549787 100644 --- a/src/planner/node/logical_aggregate.cppm +++ b/src/planner/node/logical_aggregate.cppm @@ -34,8 +34,8 @@ public: u64 groupby_index, Vector> aggregates, u64 aggregate_index) - : LogicalNode(node_id, LogicalNodeType::kAggregate), groups_(Move(groups)), groupby_index_(groupby_index), aggregates_(Move(aggregates)), - aggregate_index_(aggregate_index), base_table_ref_(Move(base_table_ref)) {} + : LogicalNode(node_id, LogicalNodeType::kAggregate), groups_(std::move(groups)), groupby_index_(groupby_index), aggregates_(std::move(aggregates)), + aggregate_index_(aggregate_index), base_table_ref_(std::move(base_table_ref)) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_command.cppm b/src/planner/node/logical_command.cppm index 3814d9b591..f5433952e2 100644 --- a/src/planner/node/logical_command.cppm +++ b/src/planner/node/logical_command.cppm @@ -27,7 +27,7 @@ namespace infinity { export class LogicalCommand : public LogicalNode { public: LogicalCommand(u64 node_id, SharedPtr command_info) - : LogicalNode(node_id, LogicalNodeType::kCommand), command_info_(Move(command_info)) {} + : LogicalNode(node_id, LogicalNodeType::kCommand), command_info_(std::move(command_info)) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_create_collection.cppm b/src/planner/node/logical_create_collection.cppm index 51a85134ff..cf5c4b2457 100644 --- a/src/planner/node/logical_create_collection.cppm +++ b/src/planner/node/logical_create_collection.cppm @@ -37,8 +37,8 @@ public: SharedPtr collection_name_, u64 table_index, ConflictType conflict_type) - : LogicalNode(node_id, LogicalNodeType::kCreateCollection), schema_name_(Move(schema_name)), - collection_name_(Move(collection_name_)), table_index_(table_index), conflict_type_(conflict_type) {} + : LogicalNode(node_id, LogicalNodeType::kCreateCollection), schema_name_(std::move(schema_name)), + collection_name_(std::move(collection_name_)), table_index_(table_index), conflict_type_(conflict_type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_create_schema.cppm b/src/planner/node/logical_create_schema.cppm index 1e37ef112e..da31fd3535 100644 --- a/src/planner/node/logical_create_schema.cppm +++ b/src/planner/node/logical_create_schema.cppm @@ -33,7 +33,7 @@ public: public: LogicalCreateSchema(u64 node_id, SharedPtr schema_name, ConflictType conflict_type) - : LogicalNode(node_id, LogicalNodeType::kCreateSchema), schema_name_(Move(schema_name)), conflict_type_(conflict_type) {} + : LogicalNode(node_id, LogicalNodeType::kCreateSchema), schema_name_(std::move(schema_name)), conflict_type_(conflict_type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_create_table.cppm b/src/planner/node/logical_create_table.cppm index 198a369ef1..8fbd344b0c 100644 --- a/src/planner/node/logical_create_table.cppm +++ b/src/planner/node/logical_create_table.cppm @@ -34,7 +34,7 @@ public: public: LogicalCreateTable(u64 node_id, SharedPtr schema_name, SharedPtr table_def_ptr, u64 table_index, ConflictType conflict_type) - : LogicalNode(node_id, LogicalNodeType::kCreateTable), schema_name_(Move(schema_name)), table_definition_(Move(table_def_ptr)), + : LogicalNode(node_id, LogicalNodeType::kCreateTable), schema_name_(std::move(schema_name)), table_definition_(std::move(table_def_ptr)), table_index_(table_index), conflict_type_(conflict_type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_create_view.cppm b/src/planner/node/logical_create_view.cppm index 509a84d045..7ec9f25f65 100644 --- a/src/planner/node/logical_create_view.cppm +++ b/src/planner/node/logical_create_view.cppm @@ -38,8 +38,8 @@ public: SharedPtr> names_ptr, SharedPtr>> types_ptr, SharedPtr create_view_info) - : LogicalNode(node_id, LogicalNodeType::kCreateView), names_ptr_(Move(names_ptr)), types_ptr_(Move(types_ptr)), - create_view_info_(Move(create_view_info)) {} + : LogicalNode(node_id, LogicalNodeType::kCreateView), names_ptr_(std::move(names_ptr)), types_ptr_(std::move(types_ptr)), + create_view_info_(std::move(create_view_info)) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_cross_product.cpp b/src/planner/node/logical_cross_product.cpp index e28fb1a77e..b2cd40e0a7 100644 --- a/src/planner/node/logical_cross_product.cpp +++ b/src/planner/node/logical_cross_product.cpp @@ -26,7 +26,7 @@ module logical_cross_product; namespace infinity { LogicalCrossProduct::LogicalCrossProduct(u64 node_id, String alias, const SharedPtr &left, const SharedPtr &right) - : LogicalNode(node_id, LogicalNodeType::kCrossProduct), alias_(Move(alias)) { + : LogicalNode(node_id, LogicalNodeType::kCrossProduct), alias_(std::move(alias)) { this->set_left_node(left); this->set_right_node(right); } diff --git a/src/planner/node/logical_drop_collection.cppm b/src/planner/node/logical_drop_collection.cppm index 2363af81d4..97fa540737 100644 --- a/src/planner/node/logical_drop_collection.cppm +++ b/src/planner/node/logical_drop_collection.cppm @@ -27,7 +27,7 @@ namespace infinity { export class LogicalDropCollection final : public LogicalNode { public: LogicalDropCollection(u64 node_id, SharedPtr schema_name, SharedPtr collection_name, ConflictType conflict_type) - : LogicalNode(node_id, LogicalNodeType::kDropCollection), schema_name_(Move(schema_name)), collection_name_(Move(collection_name)), + : LogicalNode(node_id, LogicalNodeType::kDropCollection), schema_name_(std::move(schema_name)), collection_name_(std::move(collection_name)), conflict_type_(conflict_type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_drop_index.cppm b/src/planner/node/logical_drop_index.cppm index 50024c27dd..93a11e23d0 100644 --- a/src/planner/node/logical_drop_index.cppm +++ b/src/planner/node/logical_drop_index.cppm @@ -31,8 +31,8 @@ public: SharedPtr table_name, SharedPtr index_name, ConflictType conflict_type) - : LogicalNode(node_id, LogicalNodeType::kDropIndex), schema_name_(Move(schema_name)), table_name_(Move(table_name)), - index_name_(Move(index_name)), conflict_type_(conflict_type) {} + : LogicalNode(node_id, LogicalNodeType::kDropIndex), schema_name_(std::move(schema_name)), table_name_(std::move(table_name)), + index_name_(std::move(index_name)), conflict_type_(conflict_type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_drop_schema.cppm b/src/planner/node/logical_drop_schema.cppm index 7f3615b2e6..409724b641 100644 --- a/src/planner/node/logical_drop_schema.cppm +++ b/src/planner/node/logical_drop_schema.cppm @@ -27,7 +27,7 @@ namespace infinity { export class LogicalDropSchema final : public LogicalNode { public: LogicalDropSchema(u64 node_id, SharedPtr schema_name, ConflictType conflict_type) - : LogicalNode(node_id, LogicalNodeType::kDropSchema), schema_name_(Move(schema_name)), conflict_type_(conflict_type) {} + : LogicalNode(node_id, LogicalNodeType::kDropSchema), schema_name_(std::move(schema_name)), conflict_type_(conflict_type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_drop_table.cppm b/src/planner/node/logical_drop_table.cppm index 6a84a5dc47..63fddba3f9 100644 --- a/src/planner/node/logical_drop_table.cppm +++ b/src/planner/node/logical_drop_table.cppm @@ -27,7 +27,7 @@ namespace infinity { export class LogicalDropTable : public LogicalNode { public: LogicalDropTable(u64 node_id, SharedPtr schema_name, SharedPtr table_name, ConflictType conflict_type) - : LogicalNode(node_id, LogicalNodeType::kDropTable), schema_name_(Move(schema_name)), table_name_(Move(table_name)), + : LogicalNode(node_id, LogicalNodeType::kDropTable), schema_name_(std::move(schema_name)), table_name_(std::move(table_name)), conflict_type_(conflict_type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_drop_view.cppm b/src/planner/node/logical_drop_view.cppm index 076f778a74..9d77a5de71 100644 --- a/src/planner/node/logical_drop_view.cppm +++ b/src/planner/node/logical_drop_view.cppm @@ -27,7 +27,7 @@ namespace infinity { export class LogicalDropView final : public LogicalNode { public: LogicalDropView(u64 node_id, SharedPtr schema_name, SharedPtr view_name, ConflictType conflict_type) - : LogicalNode(node_id, LogicalNodeType::kDropView), schema_name_(Move(schema_name)), view_name_(Move(view_name)), + : LogicalNode(node_id, LogicalNodeType::kDropView), schema_name_(std::move(schema_name)), view_name_(std::move(view_name)), conflict_type_(conflict_type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_dummy_scan.cppm b/src/planner/node/logical_dummy_scan.cppm index 8a6babd697..ef2ef7785b 100644 --- a/src/planner/node/logical_dummy_scan.cppm +++ b/src/planner/node/logical_dummy_scan.cppm @@ -27,7 +27,7 @@ namespace infinity { export class LogicalDummyScan : public LogicalNode { public: explicit LogicalDummyScan(u64 node_id, String table_alias, u64 table_index) - : LogicalNode(node_id, LogicalNodeType::kDummyScan), table_alias_(Move(table_alias)), table_index_(table_index) {} + : LogicalNode(node_id, LogicalNodeType::kDummyScan), table_alias_(std::move(table_alias)), table_index_(table_index) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_export.cppm b/src/planner/node/logical_export.cppm index 5f47d7de6c..300357c84b 100644 --- a/src/planner/node/logical_export.cppm +++ b/src/planner/node/logical_export.cppm @@ -27,8 +27,8 @@ namespace infinity { export class LogicalExport : public LogicalNode { public: explicit LogicalExport(u64 node_id, String schema_name, String table_name, String file_path, bool header, char delimiter, CopyFileType type) - : LogicalNode(node_id, LogicalNodeType::kExport), schema_name_(Move(schema_name)), table_name_(Move(table_name)), - file_path_(Move(file_path)), header_(header), delimiter_(delimiter), file_type_(type) {} + : LogicalNode(node_id, LogicalNodeType::kExport), schema_name_(std::move(schema_name)), table_name_(std::move(table_name)), + file_path_(std::move(file_path)), header_(header), delimiter_(delimiter), file_type_(type) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_filter.cppm b/src/planner/node/logical_filter.cppm index 199436f117..022069a3f9 100644 --- a/src/planner/node/logical_filter.cppm +++ b/src/planner/node/logical_filter.cppm @@ -28,7 +28,7 @@ namespace infinity { export class LogicalFilter : public LogicalNode { public: explicit LogicalFilter(u64 node_id, SharedPtr expression) - : LogicalNode(node_id, LogicalNodeType::kFilter), expression_(Move(expression)) {} + : LogicalNode(node_id, LogicalNodeType::kFilter), expression_(std::move(expression)) {} [[nodiscard]] Vector GetColumnBindings() const; diff --git a/src/planner/node/logical_import.cppm b/src/planner/node/logical_import.cppm index b8c8e927b4..e376c38fe0 100644 --- a/src/planner/node/logical_import.cppm +++ b/src/planner/node/logical_import.cppm @@ -34,7 +34,7 @@ public: char delimiter, CopyFileType type) : LogicalNode(node_id, LogicalNodeType::kImport), table_entry_(table_entry), file_type_(type), - file_path_(Move(file_path)), header_(header), delimiter_(delimiter) {} + file_path_(std::move(file_path)), header_(header), delimiter_(delimiter) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_insert.cppm b/src/planner/node/logical_insert.cppm index 68562aa3db..fa3e9cf6fb 100644 --- a/src/planner/node/logical_insert.cppm +++ b/src/planner/node/logical_insert.cppm @@ -30,7 +30,7 @@ export class LogicalInsert : public LogicalNode { public: explicit inline LogicalInsert(u64 node_id, TableEntry *table_collection_ptr, u64 table_index, Vector>> value_list) - : LogicalNode(node_id, LogicalNodeType::kInsert), table_entry_(table_collection_ptr), value_list_(Move(value_list)), + : LogicalNode(node_id, LogicalNodeType::kInsert), table_entry_(table_collection_ptr), value_list_(std::move(value_list)), table_index_(table_index){}; [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_join.cpp b/src/planner/node/logical_join.cpp index 49fa13bf32..e5f10020c0 100644 --- a/src/planner/node/logical_join.cpp +++ b/src/planner/node/logical_join.cpp @@ -33,7 +33,7 @@ LogicalJoin::LogicalJoin(u64 node_id, Vector> conditions, const SharedPtr &left, const SharedPtr &right) - : LogicalNode(node_id, LogicalNodeType::kJoin), alias_(Move(alias)), join_type_(join_type), conditions_(Move(conditions)) { + : LogicalNode(node_id, LogicalNodeType::kJoin), alias_(std::move(alias)), join_type_(join_type), conditions_(std::move(conditions)) { this->set_left_node(left); this->set_right_node(right); } diff --git a/src/planner/node/logical_knn_scan.cpp b/src/planner/node/logical_knn_scan.cpp index a8883981d5..fcb2838de6 100644 --- a/src/planner/node/logical_knn_scan.cpp +++ b/src/planner/node/logical_knn_scan.cpp @@ -30,7 +30,7 @@ module logical_knn_scan; namespace infinity { LogicalKnnScan::LogicalKnnScan(u64 node_id, SharedPtr base_table_ref) - : LogicalNode(node_id, LogicalNodeType::kKnnScan), base_table_ref_(Move(base_table_ref)) {} + : LogicalNode(node_id, LogicalNodeType::kKnnScan), base_table_ref_(std::move(base_table_ref)) {} Vector LogicalKnnScan::GetColumnBindings() const { Vector result; diff --git a/src/planner/node/logical_limit.cppm b/src/planner/node/logical_limit.cppm index c3d79c3670..392ee39b75 100644 --- a/src/planner/node/logical_limit.cppm +++ b/src/planner/node/logical_limit.cppm @@ -28,8 +28,8 @@ namespace infinity { export class LogicalLimit : public LogicalNode { public: inline explicit LogicalLimit(u64 node_id, SharedPtr limit_expression, SharedPtr offset_expression) - : LogicalNode(node_id, LogicalNodeType::kLimit), limit_expression_(Move(limit_expression)), - offset_expression_(Move(offset_expression)) {} + : LogicalNode(node_id, LogicalNodeType::kLimit), limit_expression_(std::move(limit_expression)), + offset_expression_(std::move(offset_expression)) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_match.cpp b/src/planner/node/logical_match.cpp index d5ec6818eb..bb1c4e8ec7 100644 --- a/src/planner/node/logical_match.cpp +++ b/src/planner/node/logical_match.cpp @@ -31,7 +31,7 @@ module logical_match; namespace infinity { LogicalMatch::LogicalMatch(u64 node_id, SharedPtr base_table_ref, SharedPtr match_expr) - : LogicalNode(node_id, LogicalNodeType::kMatch), base_table_ref_(base_table_ref), match_expr_(Move(match_expr)) {} + : LogicalNode(node_id, LogicalNodeType::kMatch), base_table_ref_(base_table_ref), match_expr_(std::move(match_expr)) {} Vector LogicalMatch::GetColumnBindings() const { Vector result; @@ -80,7 +80,7 @@ String LogicalMatch::ToString(i64 &space) const { } else { arrow_str = "LogicalMatch "; } - arrow_str += Format("({})", this->node_id()); + arrow_str += fmt::format("({})", this->node_id()); ss << arrow_str << std::endl; // Table alias and name @@ -97,7 +97,7 @@ String LogicalMatch::ToString(i64 &space) const { // Table index String table_index = String(space, ' '); table_index += " - table index: #"; - table_index += ToStr(this->TableIndex()); + table_index += std::to_string(this->TableIndex()); ss << table_index << std::endl; String match_info = String(space, ' '); diff --git a/src/planner/node/logical_optimize.cppm b/src/planner/node/logical_optimize.cppm index 8becd24e35..f5993e07ac 100644 --- a/src/planner/node/logical_optimize.cppm +++ b/src/planner/node/logical_optimize.cppm @@ -27,7 +27,7 @@ namespace infinity { export class LogicalOptimize : public LogicalNode { public: explicit LogicalOptimize(u64 node_id, String schema_name, String object_name) - : LogicalNode(node_id, LogicalNodeType::kOptimize), schema_name_(Move(schema_name)), object_name_(Move(object_name)) {} + : LogicalNode(node_id, LogicalNodeType::kOptimize), schema_name_(std::move(schema_name)), object_name_(std::move(object_name)) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_project.cppm b/src/planner/node/logical_project.cppm index 551802289b..4313c08517 100644 --- a/src/planner/node/logical_project.cppm +++ b/src/planner/node/logical_project.cppm @@ -29,7 +29,7 @@ namespace infinity { export class LogicalProject : public LogicalNode { public: inline LogicalProject(u64 node_id, Vector> expressions, u64 projection_index) - : LogicalNode(node_id, LogicalNodeType::kProjection), expressions_(Move(expressions)), table_index_(projection_index) {} + : LogicalNode(node_id, LogicalNodeType::kProjection), expressions_(std::move(expressions)), table_index_(projection_index) {} [[nodiscard]] Vector GetColumnBindings() const final; @@ -39,7 +39,7 @@ public: String ToString(i64 &space) const final; - inline String name() final { return Format("logical_project_{}", ToStr(table_index_)); } + inline String name() final { return fmt::format("logical_project_{}", std::to_string(table_index_)); } Vector> expressions_{}; diff --git a/src/planner/node/logical_show.cppm b/src/planner/node/logical_show.cppm index 30c0f591e6..2409a6f977 100644 --- a/src/planner/node/logical_show.cppm +++ b/src/planner/node/logical_show.cppm @@ -49,7 +49,7 @@ public: u64 table_index, Optional segment_id = None, Optional block_id = None) - : LogicalNode(node_id, LogicalNodeType::kShow), scan_type_(type), schema_name_(Move(schema_name)), object_name_(Move(object_name)), + : LogicalNode(node_id, LogicalNodeType::kShow), scan_type_(type), schema_name_(std::move(schema_name)), object_name_(std::move(object_name)), table_index_(table_index), segment_id_(segment_id), block_id_(block_id) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_sort.cppm b/src/planner/node/logical_sort.cppm index 1973e795f1..91c0b5f726 100644 --- a/src/planner/node/logical_sort.cppm +++ b/src/planner/node/logical_sort.cppm @@ -28,7 +28,7 @@ namespace infinity { export class LogicalSort : public LogicalNode { public: inline LogicalSort(u64 node_id, Vector> expressions, Vector order_by_types) - : LogicalNode(node_id, LogicalNodeType::kSort), expressions_(Move(expressions)), order_by_types_(Move(order_by_types)) {} + : LogicalNode(node_id, LogicalNodeType::kSort), expressions_(std::move(expressions)), order_by_types_(std::move(order_by_types)) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/node/logical_table_scan.cpp b/src/planner/node/logical_table_scan.cpp index ea40154f7b..67e71253fd 100644 --- a/src/planner/node/logical_table_scan.cpp +++ b/src/planner/node/logical_table_scan.cpp @@ -33,7 +33,7 @@ module logical_table_scan; namespace infinity { LogicalTableScan::LogicalTableScan(u64 node_id, SharedPtr base_table_ref, bool add_row_id) - : LogicalNode(node_id, LogicalNodeType::kTableScan), base_table_ref_(Move(base_table_ref)), add_row_id_(add_row_id) {} + : LogicalNode(node_id, LogicalNodeType::kTableScan), base_table_ref_(std::move(base_table_ref)), add_row_id_(add_row_id) {} Vector LogicalTableScan::GetColumnBindings() const { Vector result; diff --git a/src/planner/node/logical_view_scan.cppm b/src/planner/node/logical_view_scan.cppm index 15a4ddbb08..81202dcdea 100644 --- a/src/planner/node/logical_view_scan.cppm +++ b/src/planner/node/logical_view_scan.cppm @@ -29,7 +29,7 @@ export class LogicalViewScan : public LogicalNode { public: explicit LogicalViewScan(u64 node_id, SharedPtr view_ptr) - : LogicalNode(node_id, LogicalNodeType::kViewScan), view_ptr_(Move(view_ptr)) {} + : LogicalNode(node_id, LogicalNodeType::kViewScan), view_ptr_(std::move(view_ptr)) {} [[nodiscard]] Vector GetColumnBindings() const final; diff --git a/src/planner/optimizer.cpp b/src/planner/optimizer.cpp index 43ca761c17..5d69858361 100644 --- a/src/planner/optimizer.cpp +++ b/src/planner/optimizer.cpp @@ -37,7 +37,7 @@ Optimizer::Optimizer(QueryContext *query_context_ptr) : query_context_ptr_(query AddRule(MakeUnique()); } -void Optimizer::AddRule(UniquePtr rule) { rules_.emplace_back(Move(rule)); } +void Optimizer::AddRule(UniquePtr rule) { rules_.emplace_back(std::move(rule)); } void Optimizer::optimize(SharedPtr &unoptimized_plan) { SizeT rule_count = rules_.size(); diff --git a/src/planner/optimizer/column_pruner.cpp b/src/planner/optimizer/column_pruner.cpp index 551de67ca9..f8a1147d27 100644 --- a/src/planner/optimizer/column_pruner.cpp +++ b/src/planner/optimizer/column_pruner.cpp @@ -50,7 +50,7 @@ void RemoveUnusedColumns::VisitNode(LogicalNode &op) { auto &aggr = op.Cast(); auto filtered_aggregates = ClearUnusedExpressions(aggr.aggregates_, aggr.aggregate_index_); - aggr.aggregates_ = Move(filtered_aggregates); + aggr.aggregates_ = std::move(filtered_aggregates); if (aggr.aggregates_.empty() && aggr.groups_.empty()) { // TODO: CountStar -> Count(*) is not supported yet } @@ -85,7 +85,7 @@ void RemoveUnusedColumns::VisitNode(LogicalNode &op) { auto &proj = op.Cast(); auto filtered_expressions = ClearUnusedExpressions(proj.expressions_, proj.table_index_); - proj.expressions_ = Move(filtered_expressions); + proj.expressions_ = std::move(filtered_expressions); if (proj.expressions_.empty()) { // nothing references the projected expressions // this happens in the case of e.g. EXISTS(SELECT * FROM ...) @@ -148,7 +148,7 @@ void RemoveUnusedColumns::VisitNode(LogicalNode &op) { // TODO: Scan does not currently support Filter Pushdown // remove the original columns of scan with the filtered columns - scan.base_table_ref_->RetainColumnByIndices(Move(project_indices)); + scan.base_table_ref_->RetainColumnByIndices(std::move(project_indices)); // TODO: Scan does not currently support Filter Prune @@ -162,7 +162,7 @@ void RemoveUnusedColumns::VisitNode(LogicalNode &op) { return; } Vector project_indices = ClearUnusedExpressions(scan.base_table_ref_->column_ids_, scan.TableIndex()); - scan.base_table_ref_->RetainColumnByIndices(Move(project_indices)); + scan.base_table_ref_->RetainColumnByIndices(std::move(project_indices)); return; } case LogicalNodeType::kViewScan: diff --git a/src/planner/optimizer/column_remapper.cpp b/src/planner/optimizer/column_remapper.cpp index f05cfef35e..bcf9febcd4 100644 --- a/src/planner/optimizer/column_remapper.cpp +++ b/src/planner/optimizer/column_remapper.cpp @@ -75,7 +75,7 @@ SharedPtr BindingRemapper::VisitReplace(const SharedPtrsize() - 2); } default: { - LOG_ERROR(Format("Unknown special function: {}", expression->Name())); + LOG_ERROR(fmt::format("Unknown special function: {}", expression->Name())); } } } @@ -86,7 +86,7 @@ SharedPtr BindingRemapper::VisitReplace(const SharedPtrType(), expression->table_name(), expression->column_name(), expression->alias_, idx); } } - LOG_ERROR(Format("Can't bind column expression: {} [{}.{}]", + LOG_ERROR(fmt::format("Can't bind column expression: {} [{}.{}]", expression->table_name(), expression->binding().table_idx, expression->binding().column_idx)); diff --git a/src/planner/optimizer/lazy_load.cpp b/src/planner/optimizer/lazy_load.cpp index cdc58f1207..840ca6c713 100644 --- a/src/planner/optimizer/lazy_load.cpp +++ b/src/planner/optimizer/lazy_load.cpp @@ -117,7 +117,7 @@ void CleanScan::VisitNode(LogicalNode &op) { Vector project_idxs = LoadedColumn(last_op_load_metas_.get(), table_scan.base_table_ref_.get()); scan_table_indexes_.push_back(table_scan.base_table_ref_->table_index_); - table_scan.base_table_ref_->RetainColumnByIndices(Move(project_idxs)); + table_scan.base_table_ref_->RetainColumnByIndices(std::move(project_idxs)); table_scan.add_row_id_ = true; break; } @@ -126,7 +126,7 @@ void CleanScan::VisitNode(LogicalNode &op) { Vector project_idxs = LoadedColumn(last_op_load_metas_.get(), knn_scan.base_table_ref_.get()); scan_table_indexes_.push_back(knn_scan.base_table_ref_->table_index_); - knn_scan.base_table_ref_->RetainColumnByIndices(Move(project_idxs)); + knn_scan.base_table_ref_->RetainColumnByIndices(std::move(project_idxs)); break; } case LogicalNodeType::kMatch: { @@ -134,7 +134,7 @@ void CleanScan::VisitNode(LogicalNode &op) { Vector project_idxs = LoadedColumn(last_op_load_metas_.get(), match.base_table_ref_.get()); scan_table_indexes_.push_back(match.base_table_ref_->table_index_); - match.base_table_ref_->RetainColumnByIndices(Move(project_idxs)); + match.base_table_ref_->RetainColumnByIndices(std::move(project_idxs)); break; } case LogicalNodeType::kLimit: diff --git a/src/planner/query_binder.cpp b/src/planner/query_binder.cpp index 551d34bae0..575072517c 100644 --- a/src/planner/query_binder.cpp +++ b/src/planner/query_binder.cpp @@ -140,13 +140,13 @@ UniquePtr QueryBinder::BindSelect(const SelectStatement &s String select_expr_name = select_expr->ToString(); if (bind_context_ptr_->select_expr_name2index_.contains(select_expr_name)) { - LOG_TRACE(Format("Same expression: {} had already been found in select list index: {}", + LOG_TRACE(fmt::format("Same expression: {} had already been found in select list index: {}", select_expr_name, bind_context_ptr_->select_expr_name2index_[select_expr_name])); // TODO: create an map from secondary expression to the primary one. } else { if (bind_context_ptr_->binding_names_by_column_.contains(select_expr_name)) { - select_expr_name = Format("{}.{}", bind_context_ptr_->binding_names_by_column_[select_expr_name][0], select_expr_name); + select_expr_name = fmt::format("{}.{}", bind_context_ptr_->binding_names_by_column_[select_expr_name][0], select_expr_name); } bind_context_ptr_->select_expr_name2index_[select_expr_name] = column_index; } @@ -314,7 +314,7 @@ SharedPtr QueryBinder::BuildSubquery(QueryContext *, const SubqueryRef String binding_name; if (subquery_ref->alias_ == nullptr) { - binding_name = "subquery" + ToStr(subquery_table_index); + binding_name = "subquery" + std::to_string(subquery_table_index); } else { binding_name = subquery_ref->alias_->alias_; if (subquery_ref->alias_->column_alias_array_ != nullptr) { @@ -330,7 +330,7 @@ SharedPtr QueryBinder::BuildSubquery(QueryContext *, const SubqueryRef this->bind_context_ptr_->AddSubqueryBinding(binding_name, subquery_table_index, bound_statement_ptr->types_ptr_, bound_statement_ptr->names_ptr_); // Use binding name as the subquery table reference name - auto subquery_table_ref_ptr = MakeShared(Move(bound_statement_ptr), subquery_table_index, binding_name); + auto subquery_table_ref_ptr = MakeShared(std::move(bound_statement_ptr), subquery_table_index, binding_name); // TODO: Not care about the correlated expression @@ -365,7 +365,7 @@ SharedPtr QueryBinder::BuildCTE(QueryContext *, const String &name) { this->bind_context_ptr_->AddCTEBinding(name, cte_table_index, bound_statement_ptr->types_ptr_, bound_statement_ptr->names_ptr_); // Use CTE name as the subquery table reference name - auto cte_table_ref_ptr = MakeShared(Move(bound_statement_ptr), cte_table_index, name); + auto cte_table_ref_ptr = MakeShared(std::move(bound_statement_ptr), cte_table_index, name); // TODO: Not care about the correlated expression @@ -411,7 +411,7 @@ SharedPtr QueryBinder::BuildBaseTable(QueryContext *query_context, con SharedPtr block_index = table_entry->GetBlockIndex(txn_id, begin_ts); u64 table_index = bind_context_ptr_->GenerateTableIndex(); - auto table_ref = MakeShared(table_entry, columns, Move(block_index), alias, table_index, names_ptr, types_ptr); + auto table_ref = MakeShared(table_entry, columns, std::move(block_index), alias, table_index, names_ptr, types_ptr); // Insert the table in the binding context this->bind_context_ptr_->AddTableBinding(alias, table_index, table_entry, types_ptr, names_ptr, block_index); @@ -451,7 +451,7 @@ SharedPtr QueryBinder::BuildView(QueryContext *query_context, const Ta // Use view name as the subquery table reference name auto subquery_table_ref_ptr = - MakeShared(Move(bound_statement_ptr), bind_context_ptr_->GenerateTableIndex(), from_table->table_name_); + MakeShared(std::move(bound_statement_ptr), bind_context_ptr_->GenerateTableIndex(), from_table->table_name_); // TODO: Not care about the correlated expression @@ -506,7 +506,7 @@ SharedPtr QueryBinder::BuildCrossProduct(QueryContext *query_context, cross_product_table_ref->right_table_ref_ = right_table_ref; left_bind_context = cross_product_bind_context; - left_query_binder = Move(cross_product_query_binder); + left_query_binder = std::move(cross_product_query_binder); left_table_ref = cross_product_table_ref; } @@ -755,7 +755,7 @@ void QueryBinder::BuildGroupBy(QueryContext *query_context, UniquePtr &select_statement) { u64 table_index = bind_context_ptr_->GenerateTableIndex(); bind_context_ptr_->group_by_table_index_ = table_index; - bind_context_ptr_->group_by_table_name_ = "groupby" + ToStr(table_index); + bind_context_ptr_->group_by_table_name_ = "groupby" + std::to_string(table_index); if (select.group_by_list_ != nullptr) { // Start to bind GROUP BY clause @@ -784,7 +784,7 @@ void QueryBinder::BuildHaving(QueryContext *query_context, UniquePtr &select_statement) { u64 table_index = bind_context_ptr_->GenerateTableIndex(); bind_context_ptr_->aggregate_table_index_ = table_index; - bind_context_ptr_->aggregate_table_name_ = "aggregate" + ToStr(table_index); + bind_context_ptr_->aggregate_table_name_ = "aggregate" + std::to_string(table_index); // All having expr must appear in group by list or aggregate function list. if (select.group_by_list_ != nullptr && select.having_expr_ != nullptr) { @@ -809,7 +809,7 @@ void QueryBinder::PushOrderByToProject(QueryContext *, const SelectStatement &st void QueryBinder::BuildSelectList(QueryContext *, UniquePtr &bound_select_statement) { u64 table_index = bind_context_ptr_->GenerateTableIndex(); bind_context_ptr_->project_table_index_ = table_index; - bind_context_ptr_->project_table_name_ = "project" + ToStr(table_index); + bind_context_ptr_->project_table_name_ = "project" + std::to_string(table_index); auto project_binder = MakeShared(query_context_ptr_); @@ -925,7 +925,7 @@ UniquePtr QueryBinder::BindDelete(const DeleteStatement &s bound_delete_statement->table_ref_ptr_ = base_table_ref; if (base_table_ref.get() == nullptr) { - Error(Format("Cannot bind {}.{} to a table", statement.schema_name_, statement.table_name_)); + Error(fmt::format("Cannot bind {}.{} to a table", statement.schema_name_, statement.table_name_)); } SharedPtr bind_alias_proxy = MakeShared(); @@ -944,7 +944,7 @@ UniquePtr QueryBinder::BindUpdate(const UpdateStatement &s bound_update_statement->table_ref_ptr_ = base_table_ref; if (base_table_ref.get() == nullptr) { - Error(Format("Cannot bind {}.{} to a table", statement.schema_name_, statement.table_name_)); + Error(fmt::format("Cannot bind {}.{} to a table", statement.schema_name_, statement.table_name_)); } SharedPtr bind_alias_proxy = MakeShared(); @@ -954,7 +954,7 @@ UniquePtr QueryBinder::BindUpdate(const UpdateStatement &s bound_update_statement->where_conditions_ = SplitExpressionByDelimiter(where_expr, ConjunctionType::kAnd); } if (statement.update_expr_array_ == nullptr) { - Error(Format("Update expr array is empty")); + Error(fmt::format("Update expr array is empty")); } const Vector &column_names = *std::static_pointer_cast(base_table_ref)->column_names_; @@ -966,7 +966,7 @@ UniquePtr QueryBinder::BindUpdate(const UpdateStatement &s ParsedExpr *expr = upd_expr->value; auto it = std::find(column_names.begin(), column_names.end(), column_name); if (it == column_names.end()) { - Error(Format("Column {} doesn't exist in table {}.{}", column_name, statement.schema_name_, statement.table_name_)); + Error(fmt::format("Column {} doesn't exist in table {}.{}", column_name, statement.schema_name_, statement.table_name_)); } SizeT column_id = std::distance(column_names.begin(), it); SharedPtr update_expr = project_binder->Bind(*expr, this->bind_context_ptr_.get(), 0, true); diff --git a/src/planner/query_binder.cppm b/src/planner/query_binder.cppm index c586913d84..d148c61648 100644 --- a/src/planner/query_binder.cppm +++ b/src/planner/query_binder.cppm @@ -33,7 +33,7 @@ namespace infinity { export class QueryBinder { public: explicit QueryBinder(QueryContext *query_context, SharedPtr bind_context_ptr) - : query_context_ptr_(Move(query_context)), bind_context_ptr_(Move(bind_context_ptr)) {} + : query_context_ptr_(std::move(query_context)), bind_context_ptr_(std::move(bind_context_ptr)) {} UniquePtr BindSelect(const SelectStatement &statement); diff --git a/src/planner/subquery/dependent_join_flattener.cpp b/src/planner/subquery/dependent_join_flattener.cpp index 1567f861be..3da0065cad 100644 --- a/src/planner/subquery/dependent_join_flattener.cpp +++ b/src/planner/subquery/dependent_join_flattener.cpp @@ -77,7 +77,7 @@ SharedPtr DependentJoinFlattener::PushDependentJoin(const SharedPtr SharedPtr DependentJoinFlattener::PushDependentJoinInternal(const SharedPtr &subquery_plan) { // 1. Validates if the logical node was checked in operator2correlated_expression_map_ before. if (!operator2correlated_expression_map_.contains(subquery_plan->node_id())) { - Error(Format("Logical node {} wasn't detected before.", subquery_plan->node_id())); + Error(fmt::format("Logical node {} wasn't detected before.", subquery_plan->node_id())); } // 2. if no correlated expression in this operator. which means all correlated expressions are unnested @@ -188,7 +188,7 @@ SharedPtr DependentJoinFlattener::PushDependentJoinInternal(const S u64 logical_node_id = bind_context_ptr_->GetNewLogicalNodeId(); String alias = "logical_join"; - alias += ToStr(logical_node_id); + alias += std::to_string(logical_node_id); SharedPtr logical_join = MakeShared(logical_node_id, JoinType::kInner, alias, @@ -272,7 +272,7 @@ SharedPtr DependentJoinFlattener::PushDependentJoinInternal(const S case LogicalNodeType::kShow: case LogicalNodeType::kExplain: case LogicalNodeType::kPrepare: { - Error(Format("Logical node {} should be involved in subquery.", subquery_plan->name())); + Error(fmt::format("Logical node {} should be involved in subquery.", subquery_plan->name())); } case LogicalNodeType::kInvalid: { Error("Invalid logical operator node"); @@ -304,7 +304,7 @@ SharedPtr DependentJoinFlattener::BuildNoCorrelatedInternal(const S column_ids.emplace_back(correlated_columns[0]->binding().column_idx); for (SizeT idx = 1; idx < column_count; ++idx) { if (correlated_columns[idx]->binding().table_idx != table_index) { - Error(Format("Correlated column are from different table.")); + Error(fmt::format("Correlated column are from different table.")); } column_names->emplace_back(correlated_columns[idx]->column_name()); column_types->emplace_back(MakeShared(correlated_columns[idx]->Type())); @@ -313,7 +313,7 @@ SharedPtr DependentJoinFlattener::BuildNoCorrelatedInternal(const S const Binding *table_binding_ptr = bind_context_ptr_->GetBindingFromCurrentOrParentByName(correlated_columns[0]->table_name()); if (table_binding_ptr == nullptr) { - Error(Format("Can't find table: {} in binding context.", correlated_columns[0]->table_name())); + Error(fmt::format("Can't find table: {} in binding context.", correlated_columns[0]->table_name())); } // NewCatalog *catalog = query_context_->storage()->catalog(); @@ -331,7 +331,7 @@ SharedPtr DependentJoinFlattener::BuildNoCorrelatedInternal(const S // Generate cross product u64 logical_node_id = bind_context_ptr_->GetNewLogicalNodeId(); String alias = "cross_product"; - alias += ToStr(logical_node_id); + alias += std::to_string(logical_node_id); SharedPtr cross_product_node = MakeShared(logical_node_id, alias, subquery_plan, logical_table_scan); this->base_binding_.table_idx = table_index; diff --git a/src/planner/subquery/subquery_unnest.cpp b/src/planner/subquery/subquery_unnest.cpp index 482703853a..82308a3362 100644 --- a/src/planner/subquery/subquery_unnest.cpp +++ b/src/planner/subquery/subquery_unnest.cpp @@ -134,7 +134,7 @@ SharedPtr SubqueryUnnest::UnnestUncorrelated(SubqueryExpression // Step3 Generate cross product on the root and subquery plan u64 logical_node_id = bind_context->GetNewLogicalNodeId(); - String alias = "cross_product" + ToStr(logical_node_id); + String alias = "cross_product" + std::to_string(logical_node_id); SharedPtr cross_product_node = MakeShared(logical_node_id, alias, root, aggregate_node); root = cross_product_node; @@ -194,7 +194,7 @@ SharedPtr SubqueryUnnest::UnnestUncorrelated(SubqueryExpression // 3. Generate mark join u64 logical_node_id = bind_context->GetNewLogicalNodeId(); - String alias = "logical_join" + ToStr(logical_node_id); + String alias = "logical_join" + std::to_string(logical_node_id); SharedPtr join_node = MakeShared(logical_node_id, JoinType::kMark, alias, conditions, root, subquery_plan); join_node->mark_index_ = bind_context->GenerateTableIndex(); root = join_node; @@ -254,7 +254,7 @@ SharedPtr SubqueryUnnest::UnnestCorrelated(SubqueryExpression *e GenerateJoinConditions(query_context, join_conditions, correlated_columns, subplan_column_bindings, correlated_base_index); u64 logical_node_id = bind_context->GetNewLogicalNodeId(); - String alias = "logical_join" + ToStr(logical_node_id); + String alias = "logical_join" + std::to_string(logical_node_id); SharedPtr logical_join = MakeShared(logical_node_id, JoinType::kMark, alias, join_conditions, root, dependent_join); logical_join->mark_index_ = bind_context->GenerateTableIndex(); @@ -281,7 +281,7 @@ SharedPtr SubqueryUnnest::UnnestCorrelated(SubqueryExpression *e GenerateJoinConditions(query_context, join_conditions, correlated_columns, subplan_column_bindings, correlated_base_index); u64 logical_node_id = bind_context->GetNewLogicalNodeId(); - String alias = "logical_join" + ToStr(logical_node_id); + String alias = "logical_join" + std::to_string(logical_node_id); SharedPtr logical_join = MakeShared(logical_node_id, JoinType::kMark, alias, join_conditions, root, dependent_join); logical_join->mark_index_ = bind_context->GenerateTableIndex(); @@ -347,7 +347,7 @@ SharedPtr SubqueryUnnest::UnnestCorrelated(SubqueryExpression *e join_conditions.emplace_back(in_expression_ptr); u64 logical_node_id = bind_context->GetNewLogicalNodeId(); - String alias = "logical_join" + ToStr(logical_node_id); + String alias = "logical_join" + std::to_string(logical_node_id); SharedPtr logical_join = MakeShared(logical_node_id, JoinType::kMark, alias, join_conditions, root, dependent_join); logical_join->mark_index_ = bind_context->GenerateTableIndex(); @@ -374,7 +374,7 @@ SharedPtr SubqueryUnnest::UnnestCorrelated(SubqueryExpression *e GenerateJoinConditions(query_context, join_conditions, correlated_columns, subplan_column_bindings, correlated_base_index); u64 logical_node_id = bind_context->GetNewLogicalNodeId(); - String alias = "logical_join" + ToStr(logical_node_id); + String alias = "logical_join" + std::to_string(logical_node_id); SharedPtr logical_join = MakeShared(logical_node_id, JoinType::kInner, alias, join_conditions, root, dependent_join); root = logical_join; @@ -410,7 +410,7 @@ void SubqueryUnnest::GenerateJoinConditions(QueryContext *query_context, auto &left_column_expr = correlated_columns[idx]; SizeT correlated_column_index = correlated_base_index + idx; if (correlated_column_index >= subplan_column_bindings.size()) { - Error(Format("Column index is out of range.{}/{}", correlated_column_index, subplan_column_bindings.size())); + Error(fmt::format("Column index is out of range.{}/{}", correlated_column_index, subplan_column_bindings.size())); } // Generate new correlated column expression diff --git a/src/scheduler/fragment_context.cpp b/src/scheduler/fragment_context.cpp index bc32b77ade..52345abd17 100644 --- a/src/scheduler/fragment_context.cpp +++ b/src/scheduler/fragment_context.cpp @@ -289,7 +289,7 @@ MakeTaskState(SizeT operator_id, const Vector &physical_ops, case PhysicalOperatorType::kAlter: case PhysicalOperatorType::kSink: case PhysicalOperatorType::kSource: { - Error(Format("Not support {} now", PhysicalOperatorToString(physical_ops[operator_id]->operator_type()))); + Error(fmt::format("Not support {} now", PhysicalOperatorToString(physical_ops[operator_id]->operator_type()))); break; } } @@ -305,15 +305,15 @@ void CollectTasks(Vector> &result, PlanFragment *fragment_ptr) { String fragment_header = "Fragment #"; - fragment_header += ToStr(fragment_ptr->FragmentID()); + fragment_header += std::to_string(fragment_ptr->FragmentID()); fragment_header += " * "; - fragment_header += ToStr(tasks->size()); + fragment_header += std::to_string(tasks->size()); fragment_header += " Task"; result.emplace_back(MakeShared(fragment_header)); } for (const auto &task : *tasks) { - result.emplace_back(MakeShared("-> Task #" + ToStr(task->TaskID()))); + result.emplace_back(MakeShared("-> Task #" + std::to_string(task->TaskID()))); } // NOTE: Insert blank elements after each Fragment for alignment result.emplace_back(MakeShared()); @@ -412,7 +412,7 @@ void FragmentContext::BuildTask(QueryContext *query_context, } } - task->operator_states_[operator_id] = Move(operator_state); + task->operator_states_[operator_id] = std::move(operator_state); } } @@ -442,7 +442,7 @@ void FragmentContext::BuildTask(QueryContext *query_context, task_array.emplace_back(task.get()); } - fragment_ptr->SetContext(Move(fragment_context)); + fragment_ptr->SetContext(std::move(fragment_context)); } FragmentContext::FragmentContext(PlanFragment *fragment_ptr, QueryContext *query_context) @@ -453,10 +453,10 @@ void FragmentContext::FinishTask() { auto sink_op = GetSinkOperator(); if (unfinished_task == 1 && sink_op->sink_type() == SinkType::kResult) { - LOG_TRACE(Format("All tasks in fragment: {} are completed", fragment_ptr_->FragmentID())); + LOG_TRACE(fmt::format("All tasks in fragment: {} are completed", fragment_ptr_->FragmentID())); Complete(); } else { - LOG_TRACE(Format("Not all tasks in fragment: {} are completed", fragment_ptr_->FragmentID())); + LOG_TRACE(fmt::format("Not all tasks in fragment: {} are completed", fragment_ptr_->FragmentID())); } } @@ -475,9 +475,9 @@ SizeT InitKnnScanFragmentContext(PhysicalKnnScan *knn_scan_operator, FragmentCon SerialMaterializedFragmentCtx *serial_materialize_fragment_ctx = static_cast(fragment_context); serial_materialize_fragment_ctx->knn_scan_shared_data_ = MakeUnique(knn_scan_operator->base_table_ref_, knn_scan_operator->filter_expression_, - Move(knn_scan_operator->block_column_entries_), - Move(knn_scan_operator->index_entries_), - Move(knn_expr->opt_params_), + std::move(knn_scan_operator->block_column_entries_), + std::move(knn_scan_operator->index_entries_), + std::move(knn_expr->opt_params_), knn_expr->topn_, knn_expr->dimension_, 1, @@ -490,9 +490,9 @@ SizeT InitKnnScanFragmentContext(PhysicalKnnScan *knn_scan_operator, FragmentCon ParallelMaterializedFragmentCtx *parallel_materialize_fragment_ctx = static_cast(fragment_context); parallel_materialize_fragment_ctx->knn_scan_shared_data_ = MakeUnique(knn_scan_operator->base_table_ref_, knn_scan_operator->filter_expression_, - Move(knn_scan_operator->block_column_entries_), - Move(knn_scan_operator->index_entries_), - Move(knn_expr->opt_params_), + std::move(knn_scan_operator->block_column_entries_), + std::move(knn_scan_operator->index_entries_), + std::move(knn_expr->opt_params_), knn_expr->topn_, knn_expr->dimension_, 1, @@ -528,11 +528,11 @@ void FragmentContext::MakeSourceState(i64 parallel_count) { case PhysicalOperatorType::kAggregate: { if (fragment_type_ != FragmentType::kParallelMaterialize) { Error( - Format("{} should in parallel materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); + fmt::format("{} should in parallel materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); } if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); } // Partition the hash range to each source state @@ -553,7 +553,7 @@ void FragmentContext::MakeSourceState(i64 parallel_count) { case PhysicalOperatorType::kUpdate: case PhysicalOperatorType::kDelete: { Error( - Format("{} shouldn't be the first operator of the fragment", PhysicalOperatorToString(first_operator->operator_type()))); + fmt::format("{} shouldn't be the first operator of the fragment", PhysicalOperatorToString(first_operator->operator_type()))); } case PhysicalOperatorType::kMergeAggregate: case PhysicalOperatorType::kMergeHash: @@ -565,11 +565,11 @@ void FragmentContext::MakeSourceState(i64 parallel_count) { case PhysicalOperatorType::kCreateIndexFinish: { if (fragment_type_ != FragmentType::kSerialMaterialize) { Error( - Format("{} should be serial materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); + fmt::format("{} should be serial materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); } if (tasks_.size() != 1) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); } tasks_[0]->source_state_ = MakeUnique(); @@ -578,7 +578,7 @@ void FragmentContext::MakeSourceState(i64 parallel_count) { case PhysicalOperatorType::kCreateIndexDo: { if (fragment_type_ != FragmentType::kParallelMaterialize) { Error( - Format("{} should in parallel materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); + fmt::format("{} should in parallel materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); } for (auto &task : tasks_) { task->source_state_ = MakeUnique(); @@ -596,11 +596,11 @@ void FragmentContext::MakeSourceState(i64 parallel_count) { case PhysicalOperatorType::kJoinIndex: case PhysicalOperatorType::kCrossProduct: case PhysicalOperatorType::kPreparedPlan: { - Error(Format("Not support {} now", PhysicalOperatorToString(first_operator->operator_type()))); + Error(fmt::format("Not support {} now", PhysicalOperatorToString(first_operator->operator_type()))); } case PhysicalOperatorType::kTableScan: { if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); } // Partition the hash range to each source state @@ -614,11 +614,11 @@ void FragmentContext::MakeSourceState(i64 parallel_count) { case PhysicalOperatorType::kKnnScan: { if (fragment_type_ != FragmentType::kParallelMaterialize && fragment_type_ != FragmentType::kSerialMaterialize) { Error( - Format("{} should in parallel/serial materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); + fmt::format("{} should in parallel/serial materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); } if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); } for (SizeT task_id = 0; (i64)task_id < parallel_count; ++task_id) { @@ -649,11 +649,11 @@ void FragmentContext::MakeSourceState(i64 parallel_count) { case PhysicalOperatorType::kFlush: { if (fragment_type_ != FragmentType::kSerialMaterialize) { Error( - Format("{} should in serial materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); + fmt::format("{} should in serial materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); } if (tasks_.size() != 1) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(first_operator->operator_type()))); } tasks_[0]->source_state_ = MakeUnique(); @@ -661,7 +661,7 @@ void FragmentContext::MakeSourceState(i64 parallel_count) { } default: { - Error(Format("Unexpected operator type: {}", PhysicalOperatorToString(first_operator->operator_type()))); + Error(fmt::format("Unexpected operator type: {}", PhysicalOperatorToString(first_operator->operator_type()))); } } } @@ -676,17 +676,17 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { } case PhysicalOperatorType::kAggregate: { if (fragment_type_ != FragmentType::kParallelStream) { - Error(Format("{} should in parallel stream fragment", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} should in parallel stream fragment", PhysicalOperatorToString(last_operator->operator_type()))); } if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } for (u64 task_id = 0; (i64)task_id < parallel_count; ++task_id) { auto sink_state = MakeUnique(fragment_ptr_->FragmentID(), task_id); - tasks_[task_id]->sink_state_ = Move(sink_state); + tasks_[task_id]->sink_state_ = std::move(sink_state); } break; } @@ -694,11 +694,11 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { case PhysicalOperatorType::kHash: case PhysicalOperatorType::kTop: { if (fragment_type_ != FragmentType::kParallelStream) { - Error(Format("{} should in parallel stream fragment", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} should in parallel stream fragment", PhysicalOperatorToString(last_operator->operator_type()))); } if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } for (u64 task_id = 0; (i64)task_id < parallel_count; ++task_id) { @@ -706,23 +706,23 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { sink_state->column_types_ = last_operator->GetOutputTypes(); sink_state->column_names_ = last_operator->GetOutputNames(); - tasks_[task_id]->sink_state_ = Move(sink_state); + tasks_[task_id]->sink_state_ = std::move(sink_state); } break; } case PhysicalOperatorType::kLimit: { if (fragment_type_ != FragmentType::kParallelStream) { - Error(Format("{} should in parallel stream fragment", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} should in parallel stream fragment", PhysicalOperatorToString(last_operator->operator_type()))); } if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } for (u64 task_id = 0; (i64)task_id < parallel_count; ++task_id) { auto sink_state = MakeUnique(fragment_ptr_->FragmentID(), task_id); - tasks_[task_id]->sink_state_ = Move(sink_state); + tasks_[task_id]->sink_state_ = std::move(sink_state); } break; } @@ -735,11 +735,11 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { case PhysicalOperatorType::kMergeKnn: { if (fragment_type_ != FragmentType::kSerialMaterialize) { Error( - Format("{} should in serial materialized fragment", PhysicalOperatorToString(last_operator->operator_type()))); + fmt::format("{} should in serial materialized fragment", PhysicalOperatorToString(last_operator->operator_type()))); } if (tasks_.size() != 1) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } tasks_[0]->sink_state_ = MakeUnique(fragment_ptr_->FragmentID(), 0); @@ -750,11 +750,11 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { case PhysicalOperatorType::kShow: { if (fragment_type_ != FragmentType::kSerialMaterialize) { Error( - Format("{} should in serial materialized fragment", PhysicalOperatorToString(last_operator->operator_type()))); + fmt::format("{} should in serial materialized fragment", PhysicalOperatorToString(last_operator->operator_type()))); } if (tasks_.size() != 1) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } tasks_[0]->sink_state_ = MakeUnique(fragment_ptr_->FragmentID(), 0); @@ -775,11 +775,11 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { case PhysicalOperatorType::kCreateIndexDo: { if (fragment_type_ != FragmentType::kParallelMaterialize && fragment_type_ != FragmentType::kSerialMaterialize) { Error( - Format("{} should in parallel/serial materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); + fmt::format("{} should in parallel/serial materialized fragment", PhysicalOperatorToString(first_operator->operator_type()))); } if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } for (u64 task_id = 0; (i64)task_id < parallel_count; ++task_id) { @@ -792,11 +792,11 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { case PhysicalOperatorType::kIndexScan: { if (fragment_type_ == FragmentType::kSerialMaterialize) { Error( - Format("{} should in parallel materialized/stream fragment", PhysicalOperatorToString(last_operator->operator_type()))); + fmt::format("{} should in parallel materialized/stream fragment", PhysicalOperatorToString(last_operator->operator_type()))); } if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } for (u64 task_id = 0; (i64)task_id < parallel_count; ++task_id) { @@ -819,7 +819,7 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { sink_state_ptr->column_names_ = last_operator->GetOutputNames(); } else { if ((i64)tasks_.size() != parallel_count) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } for (u64 task_id = 0; (i64)task_id < parallel_count; ++task_id) { @@ -842,7 +842,7 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { case PhysicalOperatorType::kCrossProduct: case PhysicalOperatorType::kAlter: case PhysicalOperatorType::kPreparedPlan: { - Error(Format("Not support {} now", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("Not support {} now", PhysicalOperatorToString(last_operator->operator_type()))); } case PhysicalOperatorType::kDelete: case PhysicalOperatorType::kUpdate: { @@ -856,11 +856,11 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { case PhysicalOperatorType::kExport: { if (fragment_type_ != FragmentType::kSerialMaterialize) { Error( - Format("{} should in serial materialized fragment", PhysicalOperatorToString(last_operator->operator_type()))); + fmt::format("{} should in serial materialized fragment", PhysicalOperatorToString(last_operator->operator_type()))); } if (tasks_.size() != 1) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } tasks_[0]->sink_state_ = MakeUnique(); @@ -882,18 +882,18 @@ void FragmentContext::MakeSinkState(i64 parallel_count) { case PhysicalOperatorType::kFlush: { if (fragment_type_ != FragmentType::kSerialMaterialize) { Error( - Format("{} should in serial materialized fragment", PhysicalOperatorToString(last_operator->operator_type()))); + fmt::format("{} should in serial materialized fragment", PhysicalOperatorToString(last_operator->operator_type()))); } if (tasks_.size() != 1) { - Error(Format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("{} task count isn't correct.", PhysicalOperatorToString(last_operator->operator_type()))); } tasks_[0]->sink_state_ = MakeUnique(); break; } default: { - Error(Format("Unexpected operator type: {}", PhysicalOperatorToString(last_operator->operator_type()))); + Error(fmt::format("Unexpected operator type: {}", PhysicalOperatorToString(last_operator->operator_type()))); } } } @@ -905,7 +905,7 @@ void FragmentContext::CreateTasks(i64 cpu_count, i64 operator_count) { switch (first_operator->operator_type()) { case PhysicalOperatorType::kTableScan: { auto *table_scan_operator = static_cast(first_operator); - parallel_count = Min(parallel_count, (i64)(table_scan_operator->TaskletCount())); + parallel_count = std::min(parallel_count, (i64)(table_scan_operator->TaskletCount())); if (parallel_count == 0) { parallel_count = 1; } @@ -914,7 +914,7 @@ void FragmentContext::CreateTasks(i64 cpu_count, i64 operator_count) { case PhysicalOperatorType::kKnnScan: { auto *knn_scan_operator = static_cast(first_operator); SizeT task_n = InitKnnScanFragmentContext(knn_scan_operator, this, query_context_); - parallel_count = Min(parallel_count, (i64)task_n); + parallel_count = std::min(parallel_count, (i64)task_n); if (parallel_count == 0) { parallel_count = 1; } @@ -929,8 +929,8 @@ void FragmentContext::CreateTasks(i64 cpu_count, i64 operator_count) { } case PhysicalOperatorType::kCreateIndexDo: { const auto *create_index_do_operator = static_cast(first_operator); - SizeT segment_n = InitCreateIndexDoFragmentContext(create_index_do_operator, this); - parallel_count = Max(parallel_count, 1l); + auto _ = InitCreateIndexDoFragmentContext(create_index_do_operator, this); + parallel_count = std::max(parallel_count, 1l); break; } default: { @@ -943,7 +943,7 @@ void FragmentContext::CreateTasks(i64 cpu_count, i64 operator_count) { Error("Invalid fragment type"); } case FragmentType::kSerialMaterialize: { - UniqueLock locker(locker_); + std::unique_lock locker(locker_); parallel_count = 1; tasks_.reserve(parallel_count); tasks_.emplace_back(MakeUnique(this, 0, operator_count)); @@ -952,7 +952,7 @@ void FragmentContext::CreateTasks(i64 cpu_count, i64 operator_count) { } case FragmentType::kParallelMaterialize: case FragmentType::kParallelStream: { - UniqueLock locker(locker_); + std::unique_lock locker(locker_); tasks_.reserve(parallel_count); for (i64 task_id = 0; task_id < parallel_count; ++task_id) { tasks_.emplace_back(MakeUnique(this, task_id, operator_count)); @@ -1000,9 +1000,9 @@ SharedPtr SerialMaterializedFragmentCtx::GetResultInternal() { SharedPtr result_table = DataTable::MakeResultTable(column_defs); for (auto &data_block : materialize_sink_state->data_block_array_) { result_table->UpdateRowCount(data_block->row_count()); - result_table->data_blocks_.emplace_back(Move(data_block)); + result_table->data_blocks_.emplace_back(std::move(data_block)); } - // result_table->data_blocks_ = Move(materialize_sink_state->data_block_array_); + // result_table->data_blocks_ = std::move(materialize_sink_state->data_block_array_); return result_table; } case SinkStateType::kResult: { @@ -1017,7 +1017,7 @@ SharedPtr SerialMaterializedFragmentCtx::GetResultInternal() { } SharedPtr result_table = DataTable::MakeEmptyResultTable(); - result_table->SetResultMsg(Move(message_sink_state->message_)); + result_table->SetResultMsg(std::move(message_sink_state->message_)); return result_table; } case SinkStateType::kSummary: { @@ -1078,7 +1078,7 @@ SharedPtr ParallelMaterializedFragmentCtx::GetResultInternal() { } for (auto &result_data_block : materialize_sink_state->data_block_array_) { - result_table->Append(Move(result_data_block)); + result_table->Append(std::move(result_data_block)); } } @@ -1126,7 +1126,7 @@ SharedPtr ParallelStreamFragmentCtx::GetResultInternal() { } for (auto &result_data_block : materialize_sink_state->data_block_array_) { - result_table->Append(Move(result_data_block)); + result_table->Append(std::move(result_data_block)); } } diff --git a/src/scheduler/fragment_context.cppm b/src/scheduler/fragment_context.cppm index 9b928ba572..3996741329 100644 --- a/src/scheduler/fragment_context.cppm +++ b/src/scheduler/fragment_context.cppm @@ -55,7 +55,7 @@ public: if(!query_context_->is_enable_profiling()) { return ; } - query_context_->FlushProfiler(Move(profiler)); + query_context_->FlushProfiler(std::move(profiler)); } void FinishTask(); @@ -74,14 +74,14 @@ public: inline SharedPtr GetResult() { - UniqueLock lk(locker_); + std::unique_lock lk(locker_); cv_.wait(lk, [&] { return completed_; }); return GetResultInternal(); } inline void Complete() { - UniqueLock lk(locker_); + std::unique_lock lk(locker_); completed_ = true; cv_.notify_one(); } @@ -103,8 +103,8 @@ protected: protected: atomic_u64 task_n_{0}; - Mutex locker_{}; - CondVar cv_{}; + std::mutex locker_{}; + std::condition_variable cv_{}; PlanFragment *fragment_ptr_{}; // HashMap> tasks_; diff --git a/src/scheduler/fragment_data.cppm b/src/scheduler/fragment_data.cppm index bbda608f7a..981be42e2c 100644 --- a/src/scheduler/fragment_data.cppm +++ b/src/scheduler/fragment_data.cppm @@ -30,7 +30,7 @@ export enum class FragmentDataType { export struct FragmentDataBase { FragmentDataType type_{FragmentDataType::kInvalid}; - u64 fragment_id_{u64_max}; + u64 fragment_id_{std::numeric_limits::max()}; FragmentDataBase(FragmentDataType type, u64 fragment_id) : type_(type), fragment_id_(fragment_id) {} }; @@ -39,17 +39,17 @@ export struct FragmentError : public FragmentDataBase { UniquePtr error_message_{}; FragmentError(u64 fragment_id, UniquePtr error_message) - : FragmentDataBase(FragmentDataType::kError, fragment_id), error_message_(Move(error_message)) {} + : FragmentDataBase(FragmentDataType::kError, fragment_id), error_message_(std::move(error_message)) {} }; export struct FragmentData : public FragmentDataBase { UniquePtr data_block_{}; i64 task_id_{-1}; Optional data_idx_{}; - SizeT data_count_{u64_max}; + SizeT data_count_{std::numeric_limits::max()}; FragmentData(u64 fragment_id, UniquePtr data_block, i64 task_id, SizeT data_idx, SizeT data_count) - : FragmentDataBase(FragmentDataType::kData, fragment_id), data_block_(Move(data_block)), task_id_(task_id), data_idx_(data_idx), + : FragmentDataBase(FragmentDataType::kData, fragment_id), data_block_(std::move(data_block)), task_id_(task_id), data_idx_(data_idx), data_count_(data_count) {} }; diff --git a/src/scheduler/fragment_task.cpp b/src/scheduler/fragment_task.cpp index a7e544d2bd..8c7ba084c1 100644 --- a/src/scheduler/fragment_task.cpp +++ b/src/scheduler/fragment_task.cpp @@ -88,13 +88,13 @@ void FragmentTask::OnExecute(i64) { fragment_context->FlushProfiler(profiler); if (err_msg.get() != nullptr) { - sink_state_->error_message_ = Move(err_msg); + sink_state_->error_message_ = std::move(err_msg); this->set_status(FragmentTaskStatus::kError); } } if(source_complete && source_state_->error_message_.get() != nullptr) { - sink_state_->error_message_ = Move(source_state_->error_message_); + sink_state_->error_message_ = std::move(source_state_->error_message_); this->set_status(FragmentTaskStatus::kError); } @@ -123,7 +123,7 @@ TaskBinding FragmentTask::TaskBinding() const { void FragmentTask::TryCompleteFragment() { FragmentContext *fragment_context = (FragmentContext *)fragment_context_; - LOG_TRACE(Format("Task: {} of Fragment: {} is completed", task_id_, fragment_context->fragment_ptr()->FragmentID())); + LOG_TRACE(fmt::format("Task: {} of Fragment: {} is completed", task_id_, fragment_context->fragment_ptr()->FragmentID())); fragment_context->FinishTask(); } diff --git a/src/scheduler/task_scheduler.cpp b/src/scheduler/task_scheduler.cpp index 47b6edf2b1..afffa36da4 100644 --- a/src/scheduler/task_scheduler.cpp +++ b/src/scheduler/task_scheduler.cpp @@ -51,7 +51,7 @@ void TaskScheduler::Init(const Config *config_ptr) { // Pin the thread to specific cpu ThreadUtil::pin(*worker_thread, cpu_id % cpu_count); - worker_array_.emplace_back(cpu_id, Move(worker_queue), Move(worker_thread)); + worker_array_.emplace_back(cpu_id, std::move(worker_queue), std::move(worker_thread)); worker_workloads_[cpu_id] = 0; } @@ -111,7 +111,7 @@ void TaskScheduler::Schedule(QueryContext *query_context, const Vector &tasks, PlanFragment *plan_fragment) { - LOG_TRACE(Format("Schedule {} tasks of query id: {} into scheduler with OneWorkerPerQuery policy", tasks.size(), query_context->query_id())); + LOG_TRACE(fmt::format("Schedule {} tasks of query id: {} into scheduler with OneWorkerPerQuery policy", tasks.size(), query_context->query_id())); u64 worker_id = ProposedWorkerID(query_context->GetTxn()->TxnID()); for (const auto &fragment_task : tasks) { ScheduleTask(fragment_task, worker_id); @@ -120,9 +120,9 @@ void TaskScheduler::ScheduleOneWorkerPerQuery(QueryContext *query_context, const void TaskScheduler::ScheduleOneWorkerIfPossible(QueryContext *query_context, const Vector &tasks, PlanFragment *plan_fragment) { // Schedule worker 0 if possible - u64 scheduled_worker = u64_max; + u64 scheduled_worker = std::numeric_limits::max();; u64 min_load_worker{0}; - u64 min_work_load{u64_max}; + u64 min_work_load{std::numeric_limits::max()}; for(u64 proposed_worker = 0; proposed_worker < worker_count_; ++ proposed_worker) { u64 current_work_load = worker_workloads_[proposed_worker]; if(current_work_load < 1) { @@ -136,12 +136,12 @@ void TaskScheduler::ScheduleOneWorkerIfPossible(QueryContext *query_context, con } } - if(scheduled_worker == u64_max) { + if(scheduled_worker == std::numeric_limits::max()) { scheduled_worker = min_load_worker; } worker_workloads_[scheduled_worker] += tasks.size(); - LOG_TRACE(Format("Schedule {} tasks of query id: {} into worker: {} with ScheduleOneWorkerIfPossible policy", + LOG_TRACE(fmt::format("Schedule {} tasks of query id: {} into worker: {} with ScheduleOneWorkerIfPossible policy", tasks.size(), query_context->query_id(), scheduled_worker)); @@ -151,7 +151,7 @@ void TaskScheduler::ScheduleOneWorkerIfPossible(QueryContext *query_context, con } void TaskScheduler::ScheduleRoundRobin(QueryContext *query_context, const Vector &tasks, PlanFragment *plan_fragment) { - LOG_TRACE(Format("Schedule {} tasks of query id: {} into scheduler with RR policy", tasks.size(), query_context->query_id())); + LOG_TRACE(fmt::format("Schedule {} tasks of query id: {} into scheduler with RR policy", tasks.size(), query_context->query_id())); u64 worker_id = 0; for (const auto &fragment_task : tasks) { ScheduleTask(fragment_task, worker_id); diff --git a/src/scheduler/task_scheduler.cppm b/src/scheduler/task_scheduler.cppm index e4781551d6..96936b192d 100644 --- a/src/scheduler/task_scheduler.cppm +++ b/src/scheduler/task_scheduler.cppm @@ -30,7 +30,7 @@ using FragmentTaskBlockQueue = BlockingQueue; struct Worker { Worker(u64 cpu_id, UniquePtr queue, UniquePtr thread) - : cpu_id_(cpu_id), queue_(Move(queue)), thread_(Move(thread)) {} + : cpu_id_(cpu_id), queue_(std::move(queue)), thread_(std::move(thread)) {} u64 cpu_id_{0}; UniquePtr queue_{}; UniquePtr thread_{}; diff --git a/src/storage/background_process.cpp b/src/storage/background_process.cpp index 4093deab4c..2718c1c34a 100644 --- a/src/storage/background_process.cpp +++ b/src/storage/background_process.cpp @@ -38,7 +38,7 @@ void BGTaskProcessor::Stop() { LOG_INFO("Shutdown the background processor."); } -void BGTaskProcessor::Submit(SharedPtr bg_task) { task_queue_.Enqueue(Move(bg_task)); } +void BGTaskProcessor::Submit(SharedPtr bg_task) { task_queue_.Enqueue(std::move(bg_task)); } void BGTaskProcessor::Process() { bool running{true}; diff --git a/src/storage/base_table.cppm b/src/storage/base_table.cppm index 07358d8808..fde33596c6 100644 --- a/src/storage/base_table.cppm +++ b/src/storage/base_table.cppm @@ -48,7 +48,7 @@ inline String ToString(BaseTableType type) { export class BaseTable { public: explicit BaseTable(TableEntryType kind, SharedPtr schema_name, SharedPtr table_name) - : kind_(kind), schema_name_(Move(schema_name)), table_name_(Move(table_name)) {} + : kind_(kind), schema_name_(std::move(schema_name)), table_name_(std::move(table_name)) {} [[nodiscard]] inline TableEntryType kind() const { return kind_; } diff --git a/src/storage/bg_task.cppm b/src/storage/bg_task.cppm index daf8397e80..691c537eb6 100644 --- a/src/storage/bg_task.cppm +++ b/src/storage/bg_task.cppm @@ -35,14 +35,14 @@ export struct BGTask { bool async_{false}; bool complete_{false}; - Mutex mutex_{}; - CondVar cv_{}; + std::mutex mutex_{}; + std::condition_variable cv_{}; void Wait() { if (async_) { return; } - UniqueLock locker(mutex_); + std::unique_lock locker(mutex_); cv_.wait(locker, [this] { return complete_; }); } @@ -50,7 +50,7 @@ export struct BGTask { if (async_) { return; } - UniqueLock locker(mutex_); + std::unique_lock locker(mutex_); complete_ = true; cv_.notify_one(); } diff --git a/src/storage/buffer/buffer_manager.cpp b/src/storage/buffer/buffer_manager.cpp index a6ef9ce1b6..1c4b6d8690 100644 --- a/src/storage/buffer/buffer_manager.cpp +++ b/src/storage/buffer/buffer_manager.cpp @@ -27,7 +27,7 @@ module buffer_manager; namespace infinity { BufferManager::BufferManager(u64 memory_limit, SharedPtr base_dir, SharedPtr temp_dir) - : base_dir_(Move(base_dir)), temp_dir_(Move(temp_dir)), memory_limit_(memory_limit), current_memory_size_(0) { + : base_dir_(std::move(base_dir)), temp_dir_(std::move(temp_dir)), memory_limit_(memory_limit), current_memory_size_(0) { LocalFileSystem fs; if (!fs.Exists(*base_dir_)) { fs.CreateDirectory(*base_dir_); @@ -39,16 +39,16 @@ BufferManager::BufferManager(u64 memory_limit, SharedPtr base_dir, Share BufferObj *BufferManager::Allocate(UniquePtr file_worker) { String file_path = file_worker->GetFilePath(); - auto buffer_obj = MakeUnique(this, true, Move(file_worker)); + auto buffer_obj = MakeUnique(this, true, std::move(file_worker)); auto res = buffer_obj.get(); - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); if (auto iter = buffer_map_.find(file_path); iter != buffer_map_.end()) { - UniquePtr err_msg = MakeUnique(Format("BufferManager::Allocate: file %s already exists.", file_path.c_str())); + UniquePtr err_msg = MakeUnique(fmt::format("BufferManager::Allocate: file %s already exists.", file_path.c_str())); LOG_ERROR(*err_msg); Error(*err_msg); } - buffer_map_.emplace(file_path, Move(buffer_obj)); + buffer_map_.emplace(file_path, std::move(buffer_obj)); return res; } @@ -64,10 +64,10 @@ BufferObj *BufferManager::Get(UniquePtr file_worker) { } // Cannot find BufferHandle in buffer_map, read from disk - auto buffer_obj = MakeUnique(this, false, Move(file_worker)); + auto buffer_obj = MakeUnique(this, false, std::move(file_worker)); rw_locker_.lock(); - auto [iter2, insert_ok] = buffer_map_.emplace(Move(file_path), Move(buffer_obj)); + auto [iter2, insert_ok] = buffer_map_.emplace(std::move(file_path), std::move(buffer_obj)); // If insert_ok is false, it means another thread has inserted the same buffer handle. Return it. rw_locker_.unlock(); diff --git a/src/storage/buffer/buffer_manager.cppm b/src/storage/buffer/buffer_manager.cppm index 7db8507e6f..4ccbdb2dee 100644 --- a/src/storage/buffer/buffer_manager.cppm +++ b/src/storage/buffer/buffer_manager.cppm @@ -60,7 +60,7 @@ private: void PushGCQueue(BufferObj *buffer_handle); private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; SharedPtr base_dir_; SharedPtr temp_dir_; diff --git a/src/storage/buffer/buffer_obj.cpp b/src/storage/buffer/buffer_obj.cpp index 1c7233aba9..5af4548f20 100644 --- a/src/storage/buffer/buffer_obj.cpp +++ b/src/storage/buffer/buffer_obj.cpp @@ -29,7 +29,7 @@ module buffer_obj; namespace infinity { BufferObj::BufferObj(BufferManager *buffer_mgr, bool is_ephemeral, UniquePtr file_worker) - : buffer_mgr_(buffer_mgr), file_worker_(Move(file_worker)) { + : buffer_mgr_(buffer_mgr), file_worker_(std::move(file_worker)) { // Init other info file_worker_->SetBaseTempDir(buffer_mgr->BaseDir(), buffer_mgr->GetTempDir()); @@ -45,7 +45,7 @@ BufferObj::BufferObj(BufferManager *buffer_mgr, bool is_ephemeral, UniquePtr w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); switch (status_) { case BufferStatus::kLoaded: { break; @@ -74,12 +74,12 @@ BufferHandle BufferObj::Load() { } void BufferObj::GetMutPointer() { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); type_ = BufferType::kEphemeral; } void BufferObj::UnloadInner() { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); switch (status_) { case BufferStatus::kLoaded: { --rc_; @@ -96,7 +96,7 @@ void BufferObj::UnloadInner() { } bool BufferObj::Free() { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); switch (status_) { case BufferStatus::kFreed: case BufferStatus::kLoaded: { diff --git a/src/storage/buffer/buffer_obj.cppm b/src/storage/buffer/buffer_obj.cppm index dcb12aa035..bfb50cd4d8 100644 --- a/src/storage/buffer/buffer_obj.cppm +++ b/src/storage/buffer/buffer_obj.cppm @@ -86,7 +86,7 @@ public: u64 rc() const { return rc_; } protected: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; BufferManager *buffer_mgr_; diff --git a/src/storage/buffer/column_buffer.cpp b/src/storage/buffer/column_buffer.cpp index b23242124b..fdf00e91ee 100644 --- a/src/storage/buffer/column_buffer.cpp +++ b/src/storage/buffer/column_buffer.cpp @@ -52,7 +52,7 @@ Pair ColumnBuffer::GetVarcharAt(SizeT row_idx) { auto filename = BlockColumnEntry::OutlineFilename(column_id_, long_info.file_idx_); auto base_dir = outline_buffer_->base_dir_; auto file_worker = MakeUnique(base_dir, filename, DEFAULT_OUTLINE_FILE_MAX_SIZE); - auto buffer_obj = outline_buffer_->buffer_mgr_->Get(Move(file_worker)); + auto buffer_obj = outline_buffer_->buffer_mgr_->Get(std::move(file_worker)); outline_buffer_->outline_ele_ = buffer_obj->Load(); outline_buffer_->current_file_idx_ = long_info.file_idx_; } @@ -122,7 +122,7 @@ Pair ColumnBuffer::GetVarcharAtPrefixMut(SizeT row_idx) { auto filename = BlockColumnEntry::OutlineFilename(column_id_, long_info.file_idx_); auto base_dir = outline_buffer_->base_dir_; auto file_worker = MakeUnique(base_dir, filename, DEFAULT_OUTLINE_FILE_MAX_SIZE); - auto buffer_obj = outline_buffer_->buffer_mgr_->Get(Move(file_worker)); + auto buffer_obj = outline_buffer_->buffer_mgr_->Get(std::move(file_worker)); outline_buffer_->outline_ele_ = buffer_obj->Load(); outline_buffer_->current_file_idx_ = long_info.file_idx_; } diff --git a/src/storage/buffer/column_buffer.cppm b/src/storage/buffer/column_buffer.cppm index 62c8b13316..ed8b47a45b 100644 --- a/src/storage/buffer/column_buffer.cppm +++ b/src/storage/buffer/column_buffer.cppm @@ -27,7 +27,7 @@ namespace infinity { struct OutlineBuffer { BufferManager *buffer_mgr_{}; - SizeT current_file_idx_{u64_max}; + SizeT current_file_idx_{std::numeric_limits::max()}; SharedPtr base_dir_{}; diff --git a/src/storage/buffer/file_worker/data_file_worker.cpp b/src/storage/buffer/file_worker/data_file_worker.cpp index f84a9cee9c..a7e87921bc 100644 --- a/src/storage/buffer/file_worker/data_file_worker.cpp +++ b/src/storage/buffer/file_worker/data_file_worker.cpp @@ -25,7 +25,7 @@ module data_file_worker; namespace infinity { DataFileWorker::DataFileWorker(SharedPtr file_dir, SharedPtr file_name, SizeT buffer_size) - : FileWorker(Move(file_dir), Move(file_name)), buffer_size_(buffer_size) {} + : FileWorker(std::move(file_dir), std::move(file_name)), buffer_size_(buffer_size) {} DataFileWorker::~DataFileWorker() { if (data_ != nullptr) { @@ -63,23 +63,23 @@ void DataFileWorker::WriteToFileImpl(bool &prepare_success) { u64 magic_number = 0x00dd3344; u64 nbytes = fs.Write(*file_handler_, &magic_number, sizeof(magic_number)); if (nbytes != sizeof(magic_number)) { - Error(Format("Write magic number which length is {}.", nbytes)); + Error(fmt::format("Write magic number which length is {}.", nbytes)); } nbytes = fs.Write(*file_handler_, const_cast(&buffer_size_), sizeof(buffer_size_)); if (nbytes != sizeof(buffer_size_)) { - Error(Format("Write buffer length field which length is {}.", nbytes)); + Error(fmt::format("Write buffer length field which length is {}.", nbytes)); } nbytes = fs.Write(*file_handler_, data_, buffer_size_); if (nbytes != buffer_size_) { - Error(Format("Expect to write buffer with size: {}, but {} bytes is written", buffer_size_, nbytes)); + Error(fmt::format("Expect to write buffer with size: {}, but {} bytes is written", buffer_size_, nbytes)); } u64 checksum{}; nbytes = fs.Write(*file_handler_, &checksum, sizeof(checksum)); if (nbytes != sizeof(checksum)) { - Error(Format("Write buffer length field which length is {}.", nbytes)); + Error(fmt::format("Write buffer length field which length is {}.", nbytes)); } prepare_success = true; // Not run defer_fn } @@ -89,40 +89,40 @@ void DataFileWorker::ReadFromFileImpl() { SizeT file_size = fs.GetFileSize(*file_handler_); if (file_size < sizeof(u64) * 3) { - Error(Format("Incorrect file length {}.", file_size)); + Error(fmt::format("Incorrect file length {}.", file_size)); } // file header: magic number, buffer_size u64 magic_number{0}; u64 nbytes = fs.Read(*file_handler_, &magic_number, sizeof(magic_number)); if (nbytes != sizeof(magic_number)) { - Error(Format("Read magic number which length isn't {}.", nbytes)); + Error(fmt::format("Read magic number which length isn't {}.", nbytes)); } if (magic_number != 0x00dd3344) { - Error(Format("Incorrect file header magic number: {}.", magic_number)); + Error(fmt::format("Incorrect file header magic number: {}.", magic_number)); } u64 buffer_size_{}; nbytes = fs.Read(*file_handler_, &buffer_size_, sizeof(buffer_size_)); if (nbytes != sizeof(buffer_size_)) { - Error(Format("Unmatched buffer length: {} / {}", nbytes, buffer_size_)); + Error(fmt::format("Unmatched buffer length: {} / {}", nbytes, buffer_size_)); } if (file_size != buffer_size_ + 3 * sizeof(u64)) { - Error(Format("File size: {} isn't matched with {}.", file_size, buffer_size_ + 3 * sizeof(u64))); + Error(fmt::format("File size: {} isn't matched with {}.", file_size, buffer_size_ + 3 * sizeof(u64))); } // file body data_ = static_cast(new char[buffer_size_]{}); nbytes = fs.Read(*file_handler_, data_, buffer_size_); if (nbytes != buffer_size_) { - Error(Format("Expect to read buffer with size: {}, but {} bytes is read", buffer_size_, nbytes)); + Error(fmt::format("Expect to read buffer with size: {}, but {} bytes is read", buffer_size_, nbytes)); } // file footer: checksum u64 checksum{0}; nbytes = fs.Read(*file_handler_, &checksum, sizeof(checksum)); if (nbytes != sizeof(checksum)) { - Error(Format("Incorrect file checksum length: {}.", nbytes)); + Error(fmt::format("Incorrect file checksum length: {}.", nbytes)); } } diff --git a/src/storage/buffer/file_worker/file_worker.cpp b/src/storage/buffer/file_worker/file_worker.cpp index dfdba6724a..969e1f4f70 100644 --- a/src/storage/buffer/file_worker/file_worker.cpp +++ b/src/storage/buffer/file_worker/file_worker.cpp @@ -51,18 +51,18 @@ void FileWorker::WriteToFile(bool to_spill) { if (!fs.Exists(write_dir)) { fs.CreateDirectory(write_dir); } - String write_path = Format("{}/{}", write_dir, *file_name_); + String write_path = fmt::format("{}/{}", write_dir, *file_name_); u8 flags = FileFlags::WRITE_FLAG | FileFlags::CREATE_FLAG; file_handler_ = fs.OpenFile(write_path, flags, FileLockType::kWriteLock); if (to_spill) { auto local_file_handle_ = static_cast(file_handler_.get()); - LOG_WARN(Format("Open spill file: {}, fd: {}", write_path, local_file_handle_->fd_)); + LOG_WARN(fmt::format("Open spill file: {}, fd: {}", write_path, local_file_handle_->fd_)); } bool prepare_success = false; DeferFn defer_fn([&]() { if (to_spill) { - LOG_WARN(Format("Write to spill file {} finished. success {}", write_path, prepare_success)); + LOG_WARN(fmt::format("Write to spill file {} finished. success {}", write_path, prepare_success)); } if (!prepare_success) { file_handler_->Close(); @@ -75,7 +75,7 @@ void FileWorker::WriteToFile(bool to_spill) { void FileWorker::ReadFromFile(bool from_spill) { LocalFileSystem fs; - String read_path = Format("{}/{}", ChooseFileDir(from_spill), *file_name_); + String read_path = fmt::format("{}/{}", ChooseFileDir(from_spill), *file_name_); u8 flags = FileFlags::READ_FLAG; file_handler_ = fs.OpenFile(read_path, flags, FileLockType::kReadLock); DeferFn defer_fn([&]() { @@ -88,17 +88,17 @@ void FileWorker::ReadFromFile(bool from_spill) { void FileWorker::MoveFile() { LocalFileSystem fs; - String src_path = Format("{}/{}", ChooseFileDir(true), *file_name_); + String src_path = fmt::format("{}/{}", ChooseFileDir(true), *file_name_); String dest_dir = ChooseFileDir(false); - String dest_path = Format("{}/{}", dest_dir, *file_name_); + String dest_path = fmt::format("{}/{}", dest_dir, *file_name_); if (!fs.Exists(src_path)) { - Error(Format("File {} doesn't exist.", src_path)); + Error(fmt::format("File {} doesn't exist.", src_path)); } if (!fs.Exists(dest_dir)) { fs.CreateDirectory(dest_dir); } // if (fs.Exists(dest_path)) { - // Error(Format("File {} was already been created before.", dest_path)); + // Error(fmt::format("File {} was already been created before.", dest_path)); // } fs.Rename(src_path, dest_path); } diff --git a/src/storage/buffer/file_worker/file_worker.cppm b/src/storage/buffer/file_worker/file_worker.cppm index a6c016bf10..676eb07e67 100644 --- a/src/storage/buffer/file_worker/file_worker.cppm +++ b/src/storage/buffer/file_worker/file_worker.cppm @@ -14,18 +14,18 @@ module; +export module file_worker; + import stl; import file_system; import third_party; -export module file_worker; - namespace infinity { export class FileWorker { public: // spill_dir_ is not init here - explicit FileWorker(SharedPtr file_dir, SharedPtr file_name) : file_dir_(Move(file_dir)), file_name_(Move(file_name)) {} + explicit FileWorker(SharedPtr file_dir, SharedPtr file_name) : file_dir_(std::move(file_dir)), file_name_(std::move(file_name)) {} // No destruct here virtual ~FileWorker(); @@ -46,12 +46,12 @@ public: void *GetData() { return data_; } void SetBaseTempDir(SharedPtr base_dir, SharedPtr temp_dir) { - base_dir_ = Move(base_dir); - temp_dir_ = Move(temp_dir); + base_dir_ = std::move(base_dir); + temp_dir_ = std::move(temp_dir); } // Get file path. As key of buffer handle. - String GetFilePath() const { return Format("{}/{}", *file_dir_, *file_name_); } + String GetFilePath() const { return fmt::format("{}/{}", *file_dir_, *file_name_); } void Sync(); @@ -63,7 +63,7 @@ protected: virtual void ReadFromFileImpl() = 0; private: - String ChooseFileDir(bool spill) const { return spill ? Format("{}{}", *temp_dir_, *file_dir_) : *file_dir_; } + String ChooseFileDir(bool spill) const { return spill ? fmt::format("{}{}", *temp_dir_, *file_dir_) : *file_dir_; } public: const SharedPtr file_dir_{}; diff --git a/src/storage/buffer/file_worker/hnsw_file_worker.cpp b/src/storage/buffer/file_worker/hnsw_file_worker.cpp index 1d0099d94c..76cfe22adf 100644 --- a/src/storage/buffer/file_worker/hnsw_file_worker.cpp +++ b/src/storage/buffer/file_worker/hnsw_file_worker.cpp @@ -161,7 +161,7 @@ void HnswFileWorker::FreeInMemory() { break; } default: { - Error(Format("Index should be created on float embedding column now, type: {}", EmbeddingDataType2String(embedding_type))); + Error(fmt::format("Index should be created on float embedding column now, type: {}", EmbeddingDataType2String(embedding_type))); } } data_ = nullptr; diff --git a/src/storage/buffer/file_worker/index_file_worker.cppm b/src/storage/buffer/file_worker/index_file_worker.cppm index 5aa1db495b..2372f7962e 100644 --- a/src/storage/buffer/file_worker/index_file_worker.cppm +++ b/src/storage/buffer/file_worker/index_file_worker.cppm @@ -14,13 +14,13 @@ module; +export module index_file_worker; + import parser; import index_base; import file_worker; import stl; -export module index_file_worker; - namespace infinity { export struct CreateIndexParam { diff --git a/src/storage/column_vector/bitmask.cpp b/src/storage/column_vector/bitmask.cpp index 41c95e539a..813c938825 100644 --- a/src/storage/column_vector/bitmask.cpp +++ b/src/storage/column_vector/bitmask.cpp @@ -86,10 +86,10 @@ void Bitmask::Resize(SizeT new_count) { SharedPtr new_buffer_ptr = BitmaskBuffer::Make(new_count); u64 *new_data_ptr = new_buffer_ptr->data_ptr_.get(); - // TODO: use Memcpy but not assignment + // TODO: use std::memcpy but not assignment void *source_ptr = (void *)data_ptr_; void *target_ptr = (void *)new_data_ptr; - Memcpy(target_ptr, source_ptr, count_ / BitmaskBuffer::BYTE_BITS); + std::memcpy(target_ptr, source_ptr, count_ / BitmaskBuffer::BYTE_BITS); // Reset part of new buffer was already initialized as true in BitmaskBuffer::Initialize before. buffer_ptr = new_buffer_ptr; @@ -268,7 +268,7 @@ void Bitmask::WriteAdv(char *&ptr) const { WriteBufAdv(ptr, (i8)all_true); if (!all_true) { i32 bytes = BitmaskBuffer::UnitCount(count_) * sizeof(u64); - Memcpy(ptr, data_ptr_, bytes); + std::memcpy(ptr, data_ptr_, bytes); ptr += bytes; } } @@ -280,7 +280,7 @@ SharedPtr Bitmask::ReadAdv(char *&ptr, i32) { if (!all_true) { i32 bytes = BitmaskBuffer::UnitCount(count) * sizeof(u64); bitmask->SetAllFalse(); - Memcpy(bitmask->data_ptr_, ptr, bytes); + std::memcpy(bitmask->data_ptr_, ptr, bytes); ptr += bytes; } return bitmask; diff --git a/src/storage/column_vector/bitmask_buffer.cpp b/src/storage/column_vector/bitmask_buffer.cpp index 4b1b3b597b..135f7fed3d 100644 --- a/src/storage/column_vector/bitmask_buffer.cpp +++ b/src/storage/column_vector/bitmask_buffer.cpp @@ -61,7 +61,7 @@ void BitmaskBuffer::Initialize(const u64 *input_ptr, SizeT count) { void *target_ptr = data_ptr_.get(); void *source_ptr = (void *)input_ptr; - Memcpy(target_ptr, source_ptr, unit_count * sizeof(u64)); + std::memcpy(target_ptr, source_ptr, unit_count * sizeof(u64)); } } // namespace infinity \ No newline at end of file diff --git a/src/storage/column_vector/bitmask_buffer.cppm b/src/storage/column_vector/bitmask_buffer.cppm index 02905a7093..5304b1d93a 100644 --- a/src/storage/column_vector/bitmask_buffer.cppm +++ b/src/storage/column_vector/bitmask_buffer.cppm @@ -28,7 +28,7 @@ public: static constexpr const u64 UNIT_BITS = 64; // i64 bits count static constexpr const u64 BYTE_BITS = 8; // one byte bit count - static constexpr const u64 UNIT_MAX = u64_max; + static constexpr const u64 UNIT_MAX = std::numeric_limits::max();; static constexpr const u64 UNIT_MIN = 0; public: diff --git a/src/storage/column_vector/column_vector.cpp b/src/storage/column_vector/column_vector.cpp index d28b564711..a72e9e0e92 100644 --- a/src/storage/column_vector/column_vector.cpp +++ b/src/storage/column_vector/column_vector.cpp @@ -671,25 +671,25 @@ String ColumnVector::ToString(SizeT row_index) const { return buffer_->GetCompactBit(row_index) ? "true" : "false"; } case kTinyInt: { - return ToStr(((TinyIntT *)data_ptr_)[row_index]); + return std::to_string(((TinyIntT *)data_ptr_)[row_index]); } case kSmallInt: { - return ToStr(((SmallIntT *)data_ptr_)[row_index]); + return std::to_string(((SmallIntT *)data_ptr_)[row_index]); } case kInteger: { - return ToStr(((IntegerT *)data_ptr_)[row_index]); + return std::to_string(((IntegerT *)data_ptr_)[row_index]); } case kBigInt: { - return ToStr(((BigIntT *)data_ptr_)[row_index]); + return std::to_string(((BigIntT *)data_ptr_)[row_index]); } case kHugeInt: { Error("Not implemented"); } case kFloat: { - return ToStr(((FloatT *)data_ptr_)[row_index]); + return std::to_string(((FloatT *)data_ptr_)[row_index]); } case kDouble: { - return ToStr(((DoubleT *)data_ptr_)[row_index]); + return std::to_string(((DoubleT *)data_ptr_)[row_index]); } case kDecimal: { Error("Not implemented"); @@ -787,7 +787,7 @@ Value ColumnVector::GetValue(SizeT index) const { Error("Column vector isn't initialized."); } if (index >= tail_index_) { - Error(Format("Attempt to access an invalid index of column vector: {}", ToStr(index))); + Error(fmt::format("Attempt to access an invalid index of column vector: {}", std::to_string(index))); } // Not valid, make a same data type with null indicator @@ -900,16 +900,16 @@ void ColumnVector::SetValue(SizeT index, const Value &value) { Error("Column vector isn't initialized."); } if (index > tail_index_) { - Error(Format("Attempt to store value into unavailable row of column vector: {}, current column tail index: {}, capacity: {}", - ToStr(index), - ToStr(tail_index_), - ToStr(capacity_))); + Error(fmt::format("Attempt to store value into unavailable row of column vector: {}, current column tail index: {}, capacity: {}", + std::to_string(index), + std::to_string(tail_index_), + std::to_string(capacity_))); } // TODO: Check if the value type is same as column vector type // TODO: if not, try to cast if (value.type() != *data_type_) { - Error(Format("Attempt to store a different type value into column vector: {}, column vector type: {}", + Error(fmt::format("Attempt to store a different type value into column vector: {}, column vector type: {}", value.type().ToString(), data_type_->ToString())); } @@ -1025,9 +1025,9 @@ void ColumnVector::SetValue(SizeT index, const Value &value) { target_ref.length_ = varchar_len; if (varchar_len <= VARCHAR_INLINE_LENGTH) { // Only prefix is enough to contain all string data. - Memcpy(target_ref.short_.data_, src_str.c_str(), varchar_len); + std::memcpy(target_ref.short_.data_, src_str.c_str(), varchar_len); } else { - Memcpy(target_ref.vector_.prefix_, src_str.c_str(), VARCHAR_PREFIX_LEN); + std::memcpy(target_ref.vector_.prefix_, src_str.c_str(), VARCHAR_PREFIX_LEN); auto [chunk_id, chunk_offset] = this->buffer_->fix_heap_mgr_->AppendToHeap(src_str.c_str(), varchar_len); target_ref.vector_.chunk_id_ = chunk_id; target_ref.vector_.chunk_offset_ = chunk_offset; @@ -1040,10 +1040,10 @@ void ColumnVector::SetValue(SizeT index, const Value &value) { std::tie(src_ptr, src_size) = value.GetEmbedding(); if (src_size != data_type_->Size()) { Error( - Format("Attempt to store a value with different size than column vector type, want {}, got {}", data_type_->Size(), src_size)); + fmt::format("Attempt to store a value with different size than column vector type, want {}, got {}", data_type_->Size(), src_size)); } ptr_t dst_ptr = data_ptr_ + index * data_type_->Size(); - Memcpy(dst_ptr, src_ptr, src_size); + std::memcpy(dst_ptr, src_ptr, src_size); break; } default: { @@ -1055,7 +1055,7 @@ void ColumnVector::SetValue(SizeT index, const Value &value) { void ColumnVector::Finalize(SizeT index) { if (index > capacity_) { - Error(Format("Attempt to set column vector tail index to {}, capacity: {}", index, capacity_)); + Error(fmt::format("Attempt to set column vector tail index to {}, capacity: {}", index, capacity_)); } tail_index_ = index; } @@ -1065,13 +1065,13 @@ void ColumnVector::SetByRawPtr(SizeT index, const_ptr_t raw_ptr) { Error("Column vector isn't initialized."); } if (index > capacity_) { - Error(Format("Attempt to set column vector tail index to {}, capacity: {}", index, capacity_)); + Error(fmt::format("Attempt to set column vector tail index to {}, capacity: {}", index, capacity_)); } if (index > tail_index_) { - Error(Format("Attempt to store value into unavailable row of column vector: {}, current column tail index: {}, capacity: {}", - ToStr(index), - ToStr(tail_index_), - ToStr(capacity_))); + Error(fmt::format("Attempt to store value into unavailable row of column vector: {}, current column tail index: {}, capacity: {}", + std::to_string(index), + std::to_string(tail_index_), + std::to_string(capacity_))); } // We assume the value_ptr point to the same type data. @@ -1126,9 +1126,9 @@ void ColumnVector::SetByRawPtr(SizeT index, const_ptr_t raw_ptr) { target_ref.length_ = varchar_len; if (src_ref.IsInlined()) { // Only prefix is enough to contain all string data. - Memcpy(target_ref.short_.data_, src_ref.short_.data_, varchar_len); + std::memcpy(target_ref.short_.data_, src_ref.short_.data_, varchar_len); } else { - Memcpy(target_ref.vector_.prefix_, src_ref.value_.prefix_, VARCHAR_PREFIX_LEN); + std::memcpy(target_ref.vector_.prefix_, src_ref.value_.prefix_, VARCHAR_PREFIX_LEN); auto [chunk_id, chunk_offset] = this->buffer_->fix_heap_mgr_->AppendToHeap(src_ref.value_.ptr_, varchar_len); target_ref.vector_.chunk_id_ = chunk_id; target_ref.vector_.chunk_offset_ = chunk_offset; @@ -1197,7 +1197,7 @@ void ColumnVector::SetByRawPtr(SizeT index, const_ptr_t raw_ptr) { case kEmbedding: { // auto *embedding_ptr = (EmbeddingT *)(value_ptr); ptr_t ptr = data_ptr_ + index * data_type_->Size(); - Memcpy(ptr, raw_ptr, data_type_->Size()); + std::memcpy(ptr, raw_ptr, data_type_->Size()); break; } case kRowID: { @@ -1235,7 +1235,7 @@ void ColumnVector::AppendByPtr(const_ptr_t value_ptr) { } } if (tail_index_ >= capacity_) { - Error(Format("Exceed the column vector capacity.({}/{})", tail_index_, capacity_)); + Error(fmt::format("Exceed the column vector capacity.({}/{})", tail_index_, capacity_)); } if (data_type_->type() == LogicalType::kEmbedding) { SetByRawPtr(tail_index_++, value_ptr); @@ -1251,12 +1251,12 @@ void ColumnVector::AppendWith(const ColumnVector &other, SizeT from, SizeT count if (*this->data_type_ != *other.data_type_) { Error( - Format("Attempt to append column vector{} to column vector{}", other.data_type_->ToString(), data_type_->ToString())); + fmt::format("Attempt to append column vector{} to column vector{}", other.data_type_->ToString(), data_type_->ToString())); } if (this->tail_index_ + count > this->capacity_) { Error( - Format("Attempt to append {} rows data to {} rows data, which exceeds {} limit.", count, this->tail_index_, this->capacity_)); + fmt::format("Attempt to append {} rows data to {} rows data, which exceeds {} limit.", count, this->tail_index_, this->capacity_)); } switch (data_type_->type()) { @@ -1307,10 +1307,10 @@ void ColumnVector::AppendWith(const ColumnVector &other, SizeT from, SizeT count dst_ref.length_ = src_ref.length_; dst_ref.is_value_ = src_ref.is_value_; if (src_ref.IsInlined()) { - Memcpy(&dst_ref.short_, &src_ref.short_, src_ref.length_); + std::memcpy(&dst_ref.short_, &src_ref.short_, src_ref.length_); } else { // Assume the source must be column vector type. - Memcpy(dst_ref.vector_.prefix_, src_ref.vector_.prefix_, VARCHAR_PREFIX_LEN); + std::memcpy(dst_ref.vector_.prefix_, src_ref.vector_.prefix_, VARCHAR_PREFIX_LEN); auto [chunk_id, chunk_offset] = this->buffer_->fix_heap_mgr_->AppendToHeap(other.buffer_->fix_heap_mgr_.get(), src_ref.vector_.chunk_id_, src_ref.vector_.chunk_offset_, @@ -1385,7 +1385,7 @@ void ColumnVector::AppendWith(const ColumnVector &other, SizeT from, SizeT count for (SizeT idx = 0; idx < count; ++idx) { ptr_t src_ptr = base_src_ptr + (from + idx) * data_type_->Size(); ptr_t dst_ptr = base_dst_ptr + idx * data_type_->Size(); - Memcpy(dst_ptr, src_ptr, data_type_->Size()); + std::memcpy(dst_ptr, src_ptr, data_type_->Size()); } break; } @@ -1456,7 +1456,7 @@ SizeT ColumnVector::AppendWith(ColumnBuffer &column_buffer, SizeT start_row, Siz const_ptr_t ptr = column_buffer.GetAll(); const_ptr_t src_ptr = ptr + start_row * data_type_size_; ptr_t dst_ptr = data_ptr_ + tail_index_ * data_type_size_; - Memcpy(dst_ptr, src_ptr, appended_rows * data_type_size_); + std::memcpy(dst_ptr, src_ptr, appended_rows * data_type_size_); this->tail_index_ += appended_rows; break; } @@ -1469,9 +1469,9 @@ SizeT ColumnVector::AppendWith(ColumnBuffer &column_buffer, SizeT start_row, Siz auto varchar_dst = reinterpret_cast(data_ptr_) + tail_index_; varchar_dst->is_value_ = false; if(src_size <= VARCHAR_INLINE_LEN) { - Memcpy(varchar_dst->short_.data_, src_ptr, src_size); + std::memcpy(varchar_dst->short_.data_, src_ptr, src_size); } else { - Memcpy(varchar_dst->vector_.prefix_, src_ptr, VARCHAR_PREFIX_LEN); + std::memcpy(varchar_dst->vector_.prefix_, src_ptr, VARCHAR_PREFIX_LEN); auto [chunk_id, chunk_offset] = this->buffer_->fix_heap_mgr_->AppendToHeap(src_ptr, src_size); varchar_dst->vector_.chunk_id_ = chunk_id; varchar_dst->vector_.chunk_offset_ = chunk_offset; @@ -1488,12 +1488,12 @@ SizeT ColumnVector::AppendWith(ColumnBuffer &column_buffer, SizeT start_row, Siz // case kBlob: case kMixed: case kNull: { - LOG_ERROR(Format("{} isn't supported", data_type_->ToString())); + LOG_ERROR(fmt::format("{} isn't supported", data_type_->ToString())); Error("Not supported now in append data in column"); } case kMissing: case kInvalid: { - LOG_ERROR(Format("Invalid data type {}", data_type_->ToString())); + LOG_ERROR(fmt::format("Invalid data type {}", data_type_->ToString())); Error("Invalid data type"); } default: { @@ -1506,7 +1506,7 @@ SizeT ColumnVector::AppendWith(ColumnBuffer &column_buffer, SizeT start_row, Siz SizeT ColumnVector::AppendWith(RowID from, SizeT row_count) { if (data_type_->type() != LogicalType::kRowID) { - Error(Format("Only RowID column vector supports this method, current data type: {}", data_type_->ToString())); + Error(fmt::format("Only RowID column vector supports this method, current data type: {}", data_type_->ToString())); } if (row_count == 0) { return 0; @@ -1529,9 +1529,9 @@ SizeT ColumnVector::AppendWith(RowID from, SizeT row_count) { void ColumnVector::ShallowCopy(const ColumnVector &other) { if (*this->data_type_ != *other.data_type_) { - LOG_ERROR(Format("{} isn't supported", data_type_->ToString())); + LOG_ERROR(fmt::format("{} isn't supported", data_type_->ToString())); Error( - Format("Attempt to shallow copy: {} column vector to: {}", other.data_type_->ToString(), this->data_type_->ToString())); + fmt::format("Attempt to shallow copy: {} column vector to: {}", other.data_type_->ToString(), this->data_type_->ToString())); ; } if (this->buffer_.get() != other.buffer_.get()) { @@ -1619,7 +1619,7 @@ bool ColumnVector::operator==(const ColumnVector &other) const { return other.data_type_->type() == LogicalType::kBoolean && VectorBuffer::CompactBitIsSame(this->buffer_, this->tail_index_, other.buffer_, other.tail_index_); } else { - return 0 == Memcmp(this->data_ptr_, other.data_ptr_, this->tail_index_ * this->data_type_size_); + return 0 == std::memcmp(this->data_ptr_, other.data_ptr_, this->tail_index_ * this->data_type_size_); } return true; } @@ -1629,7 +1629,7 @@ i32 ColumnVector::GetSizeInBytes() const { Error("Column vector isn't initialized."); } if (vector_type_ != ColumnVectorType::kFlat && vector_type_ != ColumnVectorType::kConstant && vector_type_ != ColumnVectorType::kCompactBit) { - Error(Format("Not supported vector_type {}", int(vector_type_))); + Error(fmt::format("Not supported vector_type {}", int(vector_type_))); } i32 size = this->data_type_->GetSizeInBytes() + sizeof(ColumnVectorType); size += sizeof(i32); @@ -1650,7 +1650,7 @@ void ColumnVector::WriteAdv(char *&ptr) const { Error("Column vector isn't initialized."); } if (vector_type_ != ColumnVectorType::kFlat && vector_type_ != ColumnVectorType::kConstant && vector_type_ != ColumnVectorType::kCompactBit) { - Error(Format("Not supported vector_type {}", int(vector_type_))); + Error(fmt::format("Not supported vector_type {}", int(vector_type_))); } this->data_type_->WriteAdv(ptr); WriteBufAdv(ptr, this->vector_type_); @@ -1658,10 +1658,10 @@ void ColumnVector::WriteAdv(char *&ptr) const { WriteBufAdv(ptr, tail_index_); if (vector_type_ == ColumnVectorType::kCompactBit) { SizeT byte_size = (this->tail_index_ + 7) / 8; - Memcpy(ptr, this->data_ptr_, byte_size); + std::memcpy(ptr, this->data_ptr_, byte_size); ptr += byte_size; } else { - Memcpy(ptr, this->data_ptr_, this->tail_index_ * this->data_type_size_); + std::memcpy(ptr, this->data_ptr_, this->tail_index_ * this->data_type_size_); ptr += this->tail_index_ * this->data_type_size_; } // write variable part @@ -1686,11 +1686,11 @@ SharedPtr ColumnVector::ReadAdv(char *&ptr, i32 maxbytes) { column_vector->tail_index_ = tail_index; if (vector_type == ColumnVectorType::kCompactBit) { SizeT byte_size = (tail_index + 7) / 8; - Memcpy((void *)column_vector->data_ptr_, ptr, byte_size); + std::memcpy((void *)column_vector->data_ptr_, ptr, byte_size); ptr += byte_size; } else { i32 data_type_size = data_type->Size(); - Memcpy((void *)column_vector->data_ptr_, ptr, tail_index * data_type_size); + std::memcpy((void *)column_vector->data_ptr_, ptr, tail_index * data_type_size); ptr += tail_index * data_type_size; } // read variable part diff --git a/src/storage/column_vector/column_vector.cppm b/src/storage/column_vector/column_vector.cppm index 37409ddfb4..a643950588 100644 --- a/src/storage/column_vector/column_vector.cppm +++ b/src/storage/column_vector/column_vector.cppm @@ -50,7 +50,7 @@ export enum class ColumnVectorType : i8 { // Basic unit of column data vector export struct ColumnVector { public: - static inline SharedPtr Make(SharedPtr data_type) { return MakeShared(Move(data_type)); } + static inline SharedPtr Make(SharedPtr data_type) { return MakeShared(std::move(data_type)); } public: SizeT data_type_size_{0}; @@ -77,7 +77,7 @@ private: public: // Construct a column vector without initialization; - explicit ColumnVector(SharedPtr data_type) : vector_type_(ColumnVectorType::kInvalid), data_type_(Move(data_type)) { + explicit ColumnVector(SharedPtr data_type) : vector_type_(ColumnVectorType::kInvalid), data_type_(std::move(data_type)) { GlobalResourceUsage::IncrObjectCount(); } @@ -109,7 +109,7 @@ public: } if (tail_index_ >= capacity_) { - Error(Format("Exceed the column vector capacity.({}/{})", tail_index_, capacity_)); + Error(fmt::format("Exceed the column vector capacity.({}/{})", tail_index_, capacity_)); } SetValue(tail_index_++, value); } @@ -200,7 +200,7 @@ private: SizeT dst_byte_offset = dst_tail / 8; SizeT src_byte_offset = from / 8; SizeT byte_count = (count + 7) / 8; // copy to tail - Memcpy(dst_buffer->GetData() + dst_byte_offset, src_buffer->GetData() + src_byte_offset, byte_count); + std::memcpy(dst_buffer->GetData() + dst_byte_offset, src_buffer->GetData() + src_byte_offset, byte_count); } else { for (SizeT idx = 0; idx < count; ++idx) { dst_buffer->SetCompactBit(dst_tail + idx, src_buffer->GetCompactBit(from + idx)); @@ -277,9 +277,9 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_ u32 varchar_len = src_ptr->length_; if (src_ptr->IsInlined()) { // Only prefix is enough to contain all string data. - Memcpy(dst_ptr->short_.data_, src_ptr->short_.data_, varchar_len); + std::memcpy(dst_ptr->short_.data_, src_ptr->short_.data_, varchar_len); } else { - Memcpy(dst_ptr->vector_.prefix_, src_ptr->value_.prefix_, VARCHAR_PREFIX_LEN); + std::memcpy(dst_ptr->vector_.prefix_, src_ptr->value_.prefix_, VARCHAR_PREFIX_LEN); auto [chunk_id, chunk_offset] = this->buffer_->fix_heap_mgr_->AppendToHeap(dst_buf->fix_heap_mgr_.get(), src_ptr->vector_.chunk_id_, src_ptr->vector_.chunk_offset_, @@ -308,7 +308,7 @@ ColumnVector::CopyFrom(const VectorBuffer *__restrict src_buf, VectorBuff SizeT point_area_size = point_count * sizeof(PointT); ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(point_area_size); - Memcpy(ptr, src_ptr->ptr, point_area_size); + std::memcpy(ptr, src_ptr->ptr, point_area_size); dst_ptr->ptr = ptr; dst_ptr->point_count = point_count; @@ -331,7 +331,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_ SizeT point_area_size = point_count * sizeof(PointT); ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(point_area_size); - Memcpy(ptr, src_ptr->ptr, point_area_size); + std::memcpy(ptr, src_ptr->ptr, point_area_size); dst_ptr->ptr = ptr; dst_ptr->point_count = point_count; @@ -355,7 +355,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_b SizeT bit_area_size = unit_count * BitmapT::UNIT_BYTES; ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(bit_area_size); - Memcpy(ptr, (void *)(src_ptr->ptr), bit_area_size); + std::memcpy(ptr, (void *)(src_ptr->ptr), bit_area_size); dst_ptr->ptr = (u64 *)ptr; dst_ptr->count = bit_count; @@ -373,7 +373,7 @@ ColumnVector::CopyFrom(const VectorBuffer *__restrict src_buf, VectorBuff u64 blob_size = src_ptr->size; ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(blob_size); - Memcpy(ptr, (void *)(src_ptr->ptr), blob_size); + std::memcpy(ptr, (void *)(src_ptr->ptr), blob_size); dst_ptr->ptr = ptr; dst_ptr->size = blob_size; @@ -395,7 +395,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict sr const_ptr_t src_ptr = src + row_id * data_type_size_; ptr_t dst_ptr = dst + idx * data_type_size_; - Memcpy(dst_ptr, src_ptr, data_type_size_); + std::memcpy(dst_ptr, src_ptr, data_type_size_); } } @@ -410,7 +410,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_buf, SizeT source_end_idx = source_start_idx + count; - std::copy(((const DataT *)(src)) + source_start_idx, ((const DataT *)(src)) + source_end_idx, ((DataT *)(dst)) + dest_start_idx); + Copy(((const DataT *)(src)) + source_start_idx, ((const DataT *)(src)) + source_end_idx, ((DataT *)(dst)) + dest_start_idx); } template <> @@ -443,9 +443,9 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_ u32 varchar_len = src_ptr->length_; if (src_ptr->IsInlined()) { // Only prefix is enough to contain all string data. - Memcpy(dst_ptr->short_.data_, src_ptr->short_.data_, varchar_len); + std::memcpy(dst_ptr->short_.data_, src_ptr->short_.data_, varchar_len); } else { - Memcpy(dst_ptr->vector_.prefix_, src_ptr->value_.prefix_, VARCHAR_PREFIX_LEN); + std::memcpy(dst_ptr->vector_.prefix_, src_ptr->value_.prefix_, VARCHAR_PREFIX_LEN); auto [chunk_id, chunk_offset] = this->buffer_->fix_heap_mgr_->AppendToHeap(dst_buf->fix_heap_mgr_.get(), src_ptr->vector_.chunk_id_, src_ptr->vector_.chunk_offset_, @@ -475,7 +475,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_buf SizeT point_area_size = point_count * sizeof(PointT); ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(point_area_size); - Memcpy(ptr, src_ptr->ptr, point_area_size); + std::memcpy(ptr, src_ptr->ptr, point_area_size); dst_ptr->ptr = ptr; dst_ptr->point_count = point_count; @@ -500,7 +500,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_ SizeT point_area_size = point_count * sizeof(PointT); ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(point_area_size); - Memcpy(ptr, src_ptr->ptr, point_area_size); + std::memcpy(ptr, src_ptr->ptr, point_area_size); dst_ptr->ptr = ptr; dst_ptr->point_count = point_count; @@ -526,7 +526,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_b SizeT bit_area_size = unit_count * BitmapT::UNIT_BYTES; ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(bit_area_size); - Memcpy(ptr, (void *)(src_ptr->ptr), bit_area_size); + std::memcpy(ptr, (void *)(src_ptr->ptr), bit_area_size); dst_ptr->ptr = (u64 *)ptr; dst_ptr->count = bit_count; @@ -549,7 +549,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict src_buf u64 blob_size = src_ptr->size; ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(blob_size); - Memcpy(ptr, (void *)(src_ptr->ptr), blob_size); + std::memcpy(ptr, (void *)(src_ptr->ptr), blob_size); dst_ptr->ptr = ptr; dst_ptr->size = blob_size; @@ -574,7 +574,7 @@ inline void ColumnVector::CopyFrom(const VectorBuffer *__restrict sr const_ptr_t src_ptr = src + idx * data_type_size_; ptr_t dst_ptr = dst + dest_start_idx * data_type_size_; - Memcpy(dst_ptr, src_ptr, data_type_size_); + std::memcpy(dst_ptr, src_ptr, data_type_size_); ++dest_start_idx; } @@ -607,9 +607,9 @@ ColumnVector::CopyRowFrom(const VectorBuffer *__restrict src_buf, Size u32 varchar_len = src_ptr->length_; if (src_ptr->IsInlined()) { // Only prefix is enough to contain all string data. - Memcpy(dst_ptr->short_.data_, src_ptr->short_.data_, varchar_len); + std::memcpy(dst_ptr->short_.data_, src_ptr->short_.data_, varchar_len); } else { - Memcpy(dst_ptr->vector_.prefix_, src_ptr->value_.prefix_, VARCHAR_PREFIX_LEN); + std::memcpy(dst_ptr->vector_.prefix_, src_ptr->value_.prefix_, VARCHAR_PREFIX_LEN); auto [chunk_id, chunk_offset] = this->buffer_->fix_heap_mgr_->AppendToHeap(src_buf->fix_heap_mgr_.get(), src_ptr->vector_.chunk_id_, src_ptr->vector_.chunk_offset_, @@ -632,7 +632,7 @@ inline void ColumnVector::CopyRowFrom(const VectorBuffer *__restrict src_ SizeT point_area_size = point_count * sizeof(PointT); ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(point_area_size); - Memcpy(ptr, src_ptr->ptr, point_area_size); + std::memcpy(ptr, src_ptr->ptr, point_area_size); dst_ptr->ptr = ptr; dst_ptr->point_count = point_count; @@ -649,7 +649,7 @@ ColumnVector::CopyRowFrom(const VectorBuffer *__restrict src_buf, Size SizeT point_area_size = point_count * sizeof(PointT); ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(point_area_size); - Memcpy(ptr, src_ptr->ptr, point_area_size); + std::memcpy(ptr, src_ptr->ptr, point_area_size); dst_ptr->ptr = ptr; dst_ptr->point_count = point_count; @@ -667,7 +667,7 @@ ColumnVector::CopyRowFrom(const VectorBuffer *__restrict src_buf, SizeT SizeT bit_area_size = unit_count * BitmapT::UNIT_BYTES; ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(bit_area_size); - Memcpy(ptr, (void *)(src_ptr->ptr), bit_area_size); + std::memcpy(ptr, (void *)(src_ptr->ptr), bit_area_size); dst_ptr->ptr = (u64 *)ptr; dst_ptr->count = bit_count; @@ -680,7 +680,7 @@ inline void ColumnVector::CopyRowFrom(const VectorBuffer *__restrict src_ u64 blob_size = src_ptr->size; ptr_t ptr = this->buffer_->fix_heap_mgr_->Allocate(blob_size); - Memcpy(ptr, (void *)(src_ptr->ptr), blob_size); + std::memcpy(ptr, (void *)(src_ptr->ptr), blob_size); dst_ptr->ptr = ptr; dst_ptr->size = blob_size; @@ -695,7 +695,7 @@ ColumnVector::CopyRowFrom(const VectorBuffer *__restrict src_buf, Si ptr_t dst = dst_buf->GetData(); const_ptr_t src_ptr = src + src_idx * data_type_size_; ptr_t dst_ptr = dst + dst_idx * data_type_size_; - Memcpy(dst_ptr, src_ptr, data_type_size_); + std::memcpy(dst_ptr, src_ptr, data_type_size_); } } // namespace infinity diff --git a/src/storage/column_vector/fix_heap.cpp b/src/storage/column_vector/fix_heap.cpp index f5e919df9b..191d5bae0b 100644 --- a/src/storage/column_vector/fix_heap.cpp +++ b/src/storage/column_vector/fix_heap.cpp @@ -28,7 +28,7 @@ namespace infinity { Pair FixHeapManager::Allocate(SizeT nbytes) { if (nbytes == 0) { - Error(Format("Attempt to allocate memory with size: {} as the string heap", nbytes)); + Error(fmt::format("Attempt to allocate memory with size: {} as the string heap", nbytes)); } SizeT rest_nbytes = nbytes; @@ -68,10 +68,10 @@ Pair FixHeapManager::AppendToHeap(const char *data_ptr, SizeT nbytes) SizeT current_chunk_remain_size = current_chunk_size_ - chunk_offset; if (nbytes <= current_chunk_remain_size) { // Current chunk can hold the data - Memcpy(start_ptr, data_ptr, nbytes); + std::memcpy(start_ptr, data_ptr, nbytes); nbytes = 0; } else { - Memcpy(start_ptr, data_ptr, current_chunk_remain_size); + std::memcpy(start_ptr, data_ptr, current_chunk_remain_size); data_ptr += current_chunk_remain_size; nbytes -= current_chunk_remain_size; ++chunk_id; @@ -95,14 +95,14 @@ Pair FixHeapManager::AppendToHeap(const FixHeapManager *src_heap_mgr, SizeT copy_size{0}; if (nbytes > src_chunk_remain_size) { // not all data will be copied in this chunk - copy_size = Min(current_chunk_remain_size, src_chunk_remain_size); + copy_size = std::min(current_chunk_remain_size, src_chunk_remain_size); } else { - copy_size = Min(current_chunk_remain_size, nbytes); + copy_size = std::min(current_chunk_remain_size, nbytes); } char *src_ptr = src_heap_mgr->chunks_[src_chunk_id]->ptr_ + src_chunk_offset; - Memcpy(start_ptr, src_ptr, copy_size); + std::memcpy(start_ptr, src_ptr, copy_size); current_chunk_remain_size -= copy_size; src_chunk_remain_size -= copy_size; @@ -133,10 +133,10 @@ void FixHeapManager::ReadFromHeap(char *buffer, u64 chunk_id, u64 chunk_offset, char *start_ptr = chunks_[chunk_id]->ptr_ + chunk_offset; SizeT current_chunk_remain_size = current_chunk_size_ - chunk_offset; if (nbytes <= current_chunk_remain_size) { - Memcpy(buffer, start_ptr, nbytes); + std::memcpy(buffer, start_ptr, nbytes); nbytes = 0; } else { - Memcpy(buffer, start_ptr, current_chunk_remain_size); + std::memcpy(buffer, start_ptr, current_chunk_remain_size); buffer += current_chunk_remain_size; nbytes -= current_chunk_remain_size; ++chunk_id; diff --git a/src/storage/column_vector/fix_heap.cppm b/src/storage/column_vector/fix_heap.cppm index 045c6d8e29..c4d638b7b7 100644 --- a/src/storage/column_vector/fix_heap.cppm +++ b/src/storage/column_vector/fix_heap.cppm @@ -25,7 +25,7 @@ namespace infinity { export struct FixHeapManager { // Use to store string. - static constexpr u64 INVALID_CHUNK_OFFSET = u64_max; + static constexpr u64 INVALID_CHUNK_OFFSET = std::numeric_limits::max();; public: inline explicit FixHeapManager(u64 chunk_size = DEFAULT_FIXLEN_CHUNK_SIZE) : current_chunk_size_(chunk_size) { diff --git a/src/storage/column_vector/heap_chunk.cpp b/src/storage/column_vector/heap_chunk.cpp index bec2b45253..20168cc944 100644 --- a/src/storage/column_vector/heap_chunk.cpp +++ b/src/storage/column_vector/heap_chunk.cpp @@ -27,7 +27,7 @@ ptr_t StringHeapMgr::Allocate(SizeT nbytes) { if (nbytes == 0) { Error("Attempt to allocate zero size memory."); } - if (current_chunk_idx_ == u64_max) { + if (current_chunk_idx_ == std::numeric_limits::max()) { // First chunk while (current_chunk_size_ < nbytes) { current_chunk_size_ *= 2; diff --git a/src/storage/column_vector/heap_chunk.cppm b/src/storage/column_vector/heap_chunk.cppm index 685de26756..43662776b6 100644 --- a/src/storage/column_vector/heap_chunk.cppm +++ b/src/storage/column_vector/heap_chunk.cppm @@ -69,7 +69,7 @@ public: private: Vector> chunks_; u64 current_chunk_size_{CHUNK_SIZE}; - u64 current_chunk_idx_{u64_max}; + u64 current_chunk_idx_{std::numeric_limits::max()}; }; } // namespace infinity diff --git a/src/storage/column_vector/null_value.cppm b/src/storage/column_vector/null_value.cppm index c5f23f1fee..9e7ef54e59 100644 --- a/src/storage/column_vector/null_value.cppm +++ b/src/storage/column_vector/null_value.cppm @@ -25,6 +25,7 @@ export namespace infinity { template inline ValueType NullValue() { TypeException(DataType::TypeToString() + " doesn't have null value."); + return ValueType(); } template <> @@ -34,45 +35,45 @@ inline BooleanT NullValue() { template <> inline TinyIntT NullValue() { - return i8_inf; + return std::numeric_limits::infinity(); } template <> inline SmallIntT NullValue() { - return i16_inf; + return std::numeric_limits::infinity(); } template <> inline IntegerT NullValue() { - return i32_inf; + return std::numeric_limits::infinity(); } template <> inline BigIntT NullValue() { - return i64_inf; + return std::numeric_limits::infinity(); } template <> inline HugeIntT NullValue() { HugeIntT value; - value.lower = i64_inf; - value.upper = i64_inf; + value.lower = std::numeric_limits::infinity(); + value.upper = std::numeric_limits::infinity(); return value; } template <> inline FloatT NullValue() { - return f32_inf; + return std::numeric_limits::infinity(); } template <> inline DoubleT NullValue() { - return f64_inf; + return std::numeric_limits::infinity(); } template <> inline DecimalT NullValue() { - return DecimalT(i64_inf, i64_inf); + return DecimalT(std::numeric_limits::infinity(), std::numeric_limits::infinity()); } template <> @@ -82,79 +83,79 @@ inline VarcharT NullValue() { template <> inline DateT NullValue() { - return DateT(i32_inf); + return DateT(std::numeric_limits::infinity()); } template <> inline TimeT NullValue() { - return TimeT(i32_inf); + return TimeT(std::numeric_limits::infinity()); } template <> inline DateTimeT NullValue() { - return DateTimeT(i32_inf, i32_inf); + return DateTimeT(std::numeric_limits::infinity(), std::numeric_limits::infinity()); } template <> inline TimestampT NullValue() { - return TimestampT(i32_inf, i32_inf); + return TimestampT(std::numeric_limits::infinity(), std::numeric_limits::infinity()); } template <> inline IntervalT NullValue() { IntervalT interval; - interval.value = i32_inf; + interval.value = std::numeric_limits::infinity(); interval.unit = TimeUnit::kInvalidUnit; return interval; } template <> inline PointT NullValue() { - return PointT(f64_inf, f64_inf); + return PointT(std::numeric_limits::infinity(), std::numeric_limits::infinity()); } template <> inline LineT NullValue() { - return LineT(f64_inf, f64_inf, f64_inf); + return LineT(std::numeric_limits::infinity(), std::numeric_limits::infinity(), std::numeric_limits::infinity()); } template <> inline LineSegT NullValue() { - PointT p1(f64_inf, f64_inf); - PointT p2(f64_inf, f64_inf); + PointT p1(std::numeric_limits::infinity(), std::numeric_limits::infinity()); + PointT p2(std::numeric_limits::infinity(), std::numeric_limits::infinity()); return LineSegT(p1, p2); } template <> inline BoxT NullValue() { - PointT p1(f64_inf, f64_inf); - PointT p2(f64_inf, f64_inf); + PointT p1(std::numeric_limits::infinity(), std::numeric_limits::infinity()); + PointT p2(std::numeric_limits::infinity(), std::numeric_limits::infinity()); return BoxT(p1, p2); } //template <> //inline PathT NullValue() { -// PathT path(u32_inf, i32_inf); -// path.ptr = ptr_inf; +// PathT path(std::numeric_limits::infinity(), std::numeric_limits::infinity()); +// path.ptr = std::numeric_limits::infinity(); // return path; //} // //template <> //inline PolygonT NullValue() { // PolygonT polygon; -// polygon.ptr = ptr_inf; +// polygon.ptr = std::numeric_limits::infinity(); // polygon.point_count = u64_inf; -// PointT null_point = PointT(f64_inf, f64_inf); -// polygon.bounding_box.upper_left.x = f64_inf; -// polygon.bounding_box.upper_left.y = f64_inf; -// polygon.bounding_box.lower_right.x = f64_inf; -// polygon.bounding_box.lower_right.y = f64_inf; +// PointT null_point = PointT(std::numeric_limits::infinity(), std::numeric_limits::infinity()); +// polygon.bounding_box.upper_left.x = std::numeric_limits::infinity(); +// polygon.bounding_box.upper_left.y = std::numeric_limits::infinity(); +// polygon.bounding_box.lower_right.x = std::numeric_limits::infinity(); +// polygon.bounding_box.lower_right.y = std::numeric_limits::infinity(); // return polygon; //} template <> inline CircleT NullValue() { - return CircleT(PointT(f64_inf, f64_inf), f64_inf); + return CircleT(PointT(std::numeric_limits::infinity(), std::numeric_limits::infinity()), std::numeric_limits::infinity()); } //template <> @@ -175,22 +176,22 @@ inline UuidT NullValue() { //inline BlobT NullValue() { // BlobT blob; // blob.size = u64_inf; -// blob.ptr = ptr_inf; +// blob.ptr = std::numeric_limits::infinity(); // return blob; //} template <> inline EmbeddingT NullValue() { - ptr_t ptr = ptr_inf; - EmbeddingT embedding(Move(ptr), false); + ptr_t ptr = std::numeric_limits::infinity(); + EmbeddingT embedding(std::move(ptr), false); return embedding; } template <> inline RowID NullValue() { RowID row_id; - row_id.segment_id_ = u32_inf; - row_id.segment_offset_ = u32_inf; + row_id.segment_id_ = std::numeric_limits::infinity(); + row_id.segment_offset_ = std::numeric_limits::infinity(); return row_id; } diff --git a/src/storage/column_vector/operator/binary_operator.cppm b/src/storage/column_vector/operator/binary_operator.cppm index 9ae52c2cce..e73a9afc7b 100644 --- a/src/storage/column_vector/operator/binary_operator.cppm +++ b/src/storage/column_vector/operator/binary_operator.cppm @@ -108,6 +108,9 @@ private: case ColumnVectorType::kHeterogeneous: { return ExecuteFlatHeterogeneous(left, right, result, count, state_ptr, nullable); } + case ColumnVectorType::kCompactBit: { + Error("CompactBit isn't implemented."); + } } } @@ -131,6 +134,9 @@ private: case ColumnVectorType::kHeterogeneous: { return ExecuteConstantHeterogeneous(left, right, result, count, state_ptr, nullable); } + case ColumnVectorType::kCompactBit: { + Error("CompactBit isn't implemented."); + } } } @@ -154,6 +160,9 @@ private: case ColumnVectorType::kHeterogeneous: { return ExecuteHeterogeneousHeterogeneous(left, right, result, count, state_ptr, nullable); } + case ColumnVectorType::kCompactBit: { + Error("CompactBit isn't implemented."); + } } } @@ -611,7 +620,7 @@ private: auto result_u8 = reinterpret_cast(result->data()); static_assert(BitmaskBuffer::UNIT_BITS % 8 == 0, "static_assert: BitmaskBuffer::UNIT_BITS % 8 == 0"); for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; ++i, end_index += BitmaskBuffer::UNIT_BITS) { - end_index = Min(end_index, count); + end_index = std::min(end_index, count); if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null const SizeT e = end_index / 8, tail = end_index % 8; @@ -663,7 +672,7 @@ private: auto result_u8 = reinterpret_cast(result->data()); static_assert(BitmaskBuffer::UNIT_BITS % 8 == 0, "static_assert: BitmaskBuffer::UNIT_BITS % 8 == 0"); for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; ++i, end_index += BitmaskBuffer::UNIT_BITS) { - end_index = Min(end_index, count); + end_index = std::min(end_index, count); if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null const SizeT e = end_index / 8, tail = end_index % 8; @@ -715,7 +724,7 @@ private: auto result_u8 = reinterpret_cast(result->data()); static_assert(BitmaskBuffer::UNIT_BITS % 8 == 0, "static_assert: BitmaskBuffer::UNIT_BITS % 8 == 0"); for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; ++i, end_index += BitmaskBuffer::UNIT_BITS) { - end_index = Min(end_index, count); + end_index = std::min(end_index, count); if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null const SizeT e = end_index / 8, tail = end_index % 8; @@ -881,7 +890,7 @@ private: BooleanPointer result_ptr(result->buffer_.get()); static_assert(BitmaskBuffer::UNIT_BITS % 8 == 0, "static_assert: BitmaskBuffer::UNIT_BITS % 8 == 0"); for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; ++i, end_index += BitmaskBuffer::UNIT_BITS) { - end_index = Min(end_index, count); + end_index = std::min(end_index, count); if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null for (SizeT b = start_index; b < end_index; ++b) { @@ -922,7 +931,7 @@ private: BooleanPointer result_ptr(result->buffer_.get()); static_assert(BitmaskBuffer::UNIT_BITS % 8 == 0, "static_assert: BitmaskBuffer::UNIT_BITS % 8 == 0"); for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; ++i, end_index += BitmaskBuffer::UNIT_BITS) { - end_index = Min(end_index, count); + end_index = std::min(end_index, count); if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null for (SizeT b = start_index; b < end_index; ++b) { @@ -963,7 +972,7 @@ private: BooleanPointer result_ptr(result->buffer_.get()); static_assert(BitmaskBuffer::UNIT_BITS % 8 == 0, "static_assert: BitmaskBuffer::UNIT_BITS % 8 == 0"); for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; ++i, end_index += BitmaskBuffer::UNIT_BITS) { - end_index = Min(end_index, count); + end_index = std::min(end_index, count); if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null for (SizeT b = start_index; b < end_index; ++b) { diff --git a/src/storage/column_vector/operator/embedding_unary_operator.cppm b/src/storage/column_vector/operator/embedding_unary_operator.cppm index 243d4dd122..e1a26814c7 100644 --- a/src/storage/column_vector/operator/embedding_unary_operator.cppm +++ b/src/storage/column_vector/operator/embedding_unary_operator.cppm @@ -78,6 +78,10 @@ public: Error("Heterogeneous embedding is not implemented yet."); // return ExecuteHeterogeneous(input, result, count, state_ptr, nullable); } + case ColumnVectorType::kCompactBit: { + Error("Compact Bit embedding is not implemented yet."); + // return ExecuteHeterogeneous(input, result, count, state_ptr, nullable); + } } } diff --git a/src/storage/column_vector/operator/unary_operator.cppm b/src/storage/column_vector/operator/unary_operator.cppm index 001b3cd6d9..4a328b35c3 100644 --- a/src/storage/column_vector/operator/unary_operator.cppm +++ b/src/storage/column_vector/operator/unary_operator.cppm @@ -209,7 +209,7 @@ private: auto result_u8 = reinterpret_cast(result->data()); static_assert(BitmaskBuffer::UNIT_BITS % 8 == 0, "static_assert: BitmaskBuffer::UNIT_BITS % 8 == 0"); for (SizeT i = 0, start_index = 0, end_index = BitmaskBuffer::UNIT_BITS; i < unit_count; ++i, end_index += BitmaskBuffer::UNIT_BITS) { - end_index = Min(end_index, count); + end_index = std::min(end_index, count); if (result_null_data[i] == BitmaskBuffer::UNIT_MAX) { // all data of 64 rows are not null const SizeT e = end_index / 8, tail = end_index % 8; diff --git a/src/storage/column_vector/selection.cppm b/src/storage/column_vector/selection.cppm index 57684c573f..41666648a6 100644 --- a/src/storage/column_vector/selection.cppm +++ b/src/storage/column_vector/selection.cppm @@ -25,7 +25,7 @@ namespace infinity { struct SelectionData { explicit SelectionData(SizeT count) : capacity_(count) { - if (count > u16_max) { + if (count > std::numeric_limits::max()) { Error("Too large size for selection data."); } data_ = MakeUnique(count); diff --git a/src/storage/column_vector/value.cpp b/src/storage/column_vector/value.cpp index f187567063..a74cf59f0c 100644 --- a/src/storage/column_vector/value.cpp +++ b/src/storage/column_vector/value.cpp @@ -164,7 +164,7 @@ Value Value::MakeCircle(CircleT input) { Value Value::MakeUuid(UuidT input) { Value value(LogicalType::kUuid); - value.value_.uuid = Move(input); + value.value_.uuid = std::move(input); return value; } @@ -191,10 +191,10 @@ Value Value::MakeVarchar(const VarcharT &input) { Value value(LogicalType::kVarchar); if (input.IsInlined()) { String tmp_str(input.short_.data_, input.length_); - value.value_info_ = MakeShared(Move(tmp_str)); + value.value_info_ = MakeShared(std::move(tmp_str)); } else if (input.IsValue()) { String tmp_str(input.value_.ptr_, input.length_); - value.value_info_ = MakeShared(Move(tmp_str)); + value.value_info_ = MakeShared(std::move(tmp_str)); } else { throw TypeException("Value::MakeVarchar(VectorVarchar) is unsupported!"); } @@ -203,13 +203,13 @@ Value Value::MakeVarchar(const VarcharT &input) { Value Value::MakeEmbedding(ptr_t ptr, SharedPtr type_info_ptr) { if (type_info_ptr->type() != TypeInfoType::kEmbedding) { - throw TypeException(Format("Value::MakeEmbedding(type_info_ptr={}) is not unsupported!", type_info_ptr->ToString())); + throw TypeException(fmt::format("Value::MakeEmbedding(type_info_ptr={}) is not unsupported!", type_info_ptr->ToString())); } EmbeddingInfo *embedding_info = static_cast(type_info_ptr.get()); SizeT len = embedding_info->Size(); SharedPtr embedding_value_info = MakeShared(); embedding_value_info->data_.resize(len); - Memcpy(embedding_value_info->data_.data(), ptr, len); + std::memcpy(embedding_value_info->data_.data(), ptr, len); Value value(LogicalType::kEmbedding, type_info_ptr); value.value_info_ = embedding_value_info; return value; @@ -219,7 +219,7 @@ Value Value::MakeEmbedding(ptr_t ptr, SharedPtr type_info_ptr) { template <> BooleanT Value::GetValue() const { if (type_.type() != LogicalType::kBoolean) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.boolean; } @@ -227,7 +227,7 @@ BooleanT Value::GetValue() const { template <> TinyIntT Value::GetValue() const { if (type_.type() != LogicalType::kTinyInt) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.tiny_int; } @@ -235,7 +235,7 @@ TinyIntT Value::GetValue() const { template <> SmallIntT Value::GetValue() const { if (type_.type() != LogicalType::kSmallInt) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.small_int; } @@ -243,7 +243,7 @@ SmallIntT Value::GetValue() const { template <> IntegerT Value::GetValue() const { if (type_.type() != LogicalType::kInteger) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.integer; } @@ -251,7 +251,7 @@ IntegerT Value::GetValue() const { template <> BigIntT Value::GetValue() const { if (type_.type() != LogicalType::kBigInt) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.big_int; } @@ -259,7 +259,7 @@ BigIntT Value::GetValue() const { template <> HugeIntT Value::GetValue() const { if (type_.type() != LogicalType::kHugeInt) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.huge_int; } @@ -267,7 +267,7 @@ HugeIntT Value::GetValue() const { template <> FloatT Value::GetValue() const { if (type_.type() != LogicalType::kFloat) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.float32; } @@ -275,7 +275,7 @@ FloatT Value::GetValue() const { template <> DoubleT Value::GetValue() const { if (type_.type() != LogicalType::kDouble) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.float64; } @@ -283,7 +283,7 @@ DoubleT Value::GetValue() const { template <> DecimalT Value::GetValue() const { if (type_.type() != LogicalType::kDecimal) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.decimal; } @@ -291,7 +291,7 @@ DecimalT Value::GetValue() const { template <> DateT Value::GetValue() const { if (type_.type() != LogicalType::kDate) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.date; } @@ -299,7 +299,7 @@ DateT Value::GetValue() const { template <> TimeT Value::GetValue() const { if (type_.type() != LogicalType::kTime) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.time; } @@ -307,7 +307,7 @@ TimeT Value::GetValue() const { template <> DateTimeT Value::GetValue() const { if (type_.type() != LogicalType::kDateTime) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.datetime; } @@ -315,7 +315,7 @@ DateTimeT Value::GetValue() const { template <> TimestampT Value::GetValue() const { if (type_.type() != LogicalType::kTimestamp) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.timestamp; } @@ -323,7 +323,7 @@ TimestampT Value::GetValue() const { template <> IntervalT Value::GetValue() const { if (type_.type() != LogicalType::kInterval) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.interval; } @@ -331,7 +331,7 @@ IntervalT Value::GetValue() const { template <> PointT Value::GetValue() const { if (type_.type() != LogicalType::kPoint) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.point; } @@ -339,7 +339,7 @@ PointT Value::GetValue() const { template <> LineT Value::GetValue() const { if (type_.type() != LogicalType::kLine) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.line; } @@ -347,7 +347,7 @@ LineT Value::GetValue() const { template <> LineSegT Value::GetValue() const { if (type_.type() != LogicalType::kLineSeg) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.line_segment; } @@ -355,7 +355,7 @@ LineSegT Value::GetValue() const { template <> BoxT Value::GetValue() const { if (type_.type() != LogicalType::kBox) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.box; } @@ -363,7 +363,7 @@ BoxT Value::GetValue() const { template <> CircleT Value::GetValue() const { if (type_.type() != LogicalType::kCircle) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.circle; } @@ -371,7 +371,7 @@ CircleT Value::GetValue() const { template <> UuidT Value::GetValue() const { if (type_.type() != LogicalType::kUuid) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.uuid; } @@ -379,7 +379,7 @@ UuidT Value::GetValue() const { template <> RowID Value::GetValue() const { if (type_.type() != LogicalType::kRowID) { - Error(Format("Not matched type: {}", type_.ToString())); + Error(fmt::format("Not matched type: {}", type_.ToString())); } return value_.row; } @@ -388,7 +388,7 @@ Value::~Value() { GlobalResourceUsage::DecrObjectCount(); } Value::Value(const DataType &data_type) : type_(data_type) { GlobalResourceUsage::IncrObjectCount(); } -Value::Value(LogicalType type, SharedPtr typeinfo_ptr) : type_(type, Move(typeinfo_ptr)) { +Value::Value(LogicalType type, SharedPtr typeinfo_ptr) : type_(type, std::move(typeinfo_ptr)) { GlobalResourceUsage::IncrObjectCount(); } @@ -399,7 +399,7 @@ Value::Value(const Value &other) : type_(other.type_) { Value::Value(Value &&other) noexcept : type_(other.type_) { GlobalResourceUsage::IncrObjectCount(); - MoveUnionValue(Forward(other)); + MoveUnionValue(std::forward(other)); } Value &Value::operator=(const Value &other) { @@ -412,7 +412,7 @@ Value &Value::operator=(const Value &other) { Value &Value::operator=(Value &&other) noexcept { this->Reset(); - MoveUnionValue(Forward(other)); + MoveUnionValue(std::forward(other)); return *this; } @@ -599,7 +599,7 @@ void Value::CopyUnionValue(const Value &other) { } void Value::MoveUnionValue(Value &&other) noexcept { - this->type_ = Move(other.type_); + this->type_ = std::move(other.type_); switch (this->type_.type()) { case kBoolean: { this->value_.boolean = other.value_.boolean; @@ -678,7 +678,7 @@ void Value::MoveUnionValue(Value &&other) noexcept { break; } case kUuid: { - this->value_.uuid = Move(other.value_.uuid); + this->value_.uuid = std::move(other.value_.uuid); break; } case kRowID: { @@ -691,7 +691,7 @@ void Value::MoveUnionValue(Value &&other) noexcept { } case kVarchar: case kEmbedding: { - this->value_info_ = Move(other.value_info_); + this->value_info_ = std::move(other.value_info_); break; } case kMissing: @@ -714,25 +714,25 @@ String Value::ToString() const { return value_.boolean ? "true" : "false"; } case kTinyInt: { - return ToStr(value_.tiny_int); + return std::to_string(value_.tiny_int); } case kSmallInt: { - return ToStr(value_.small_int); + return std::to_string(value_.small_int); } case kInteger: { - return ToStr(value_.integer); + return std::to_string(value_.integer); } case kBigInt: { - return ToStr(value_.big_int); + return std::to_string(value_.big_int); } case kHugeInt: { return value_.huge_int.ToString(); } case kFloat: { - return ToStr(value_.float32); + return std::to_string(value_.float32); } case kDouble: { - return ToStr(value_.float64); + return std::to_string(value_.float64); } case kDate: { return value_.date.ToString(); @@ -747,7 +747,7 @@ String Value::ToString() const { return value_info_->Get().GetString(); } default: { - Error(Format("Value::ToString() not implemented for type {}", type_.ToString())); + Error(fmt::format("Value::ToString() not implemented for type {}", type_.ToString())); return {}; } } diff --git a/src/storage/column_vector/value.cppm b/src/storage/column_vector/value.cppm index 6ecb31bef8..340c7622bd 100644 --- a/src/storage/column_vector/value.cppm +++ b/src/storage/column_vector/value.cppm @@ -66,7 +66,7 @@ struct StringValueInfo : public ExtraValueInfo { public: explicit StringValueInfo(const String &str_p) : ExtraValueInfo(ExtraValueInfoType::STRING_VALUE_INFO), str_(str_p) {} - explicit StringValueInfo(String &&str_p) : ExtraValueInfo(ExtraValueInfoType::STRING_VALUE_INFO), str_(Move(str_p)) {} + explicit StringValueInfo(String &&str_p) : ExtraValueInfo(ExtraValueInfoType::STRING_VALUE_INFO), str_(std::move(str_p)) {} const String &GetString() { return str_; } @@ -90,7 +90,7 @@ public: explicit EmbeddingValueInfo(const Vector &values_p) : ExtraValueInfo(ExtraValueInfoType::EMBEDDING_VALUE_INFO) { SizeT len = values_p.size() * sizeof(T); data_.resize(len); - Memcpy(data_.data(), values_p.data(), len); + std::memcpy(data_.data(), values_p.data(), len); } Pair GetData() const { return MakePair(data_.data(), data_.size()); } diff --git a/src/storage/column_vector/var_heap.cpp b/src/storage/column_vector/var_heap.cpp index af953f0335..d6a7b125c6 100644 --- a/src/storage/column_vector/var_heap.cpp +++ b/src/storage/column_vector/var_heap.cpp @@ -28,7 +28,7 @@ namespace infinity { Pair VarHeapManager::Allocate(SizeT nbytes) { if (nbytes == 0) { - Error(Format("Attempt to allocate memory with size: {} as the string heap", nbytes)); + Error(fmt::format("Attempt to allocate memory with size: {} as the string heap", nbytes)); } u64 start_chunk_id = INITIAL_VECTOR_CHUNK_ID; @@ -72,8 +72,8 @@ Pair VarHeapManager::Allocate(SizeT nbytes) { if (current_chunk_size_ > chunks_[current_chunk_idx_]->capacity_) { UniquePtr new_chunk = MakeUnique(current_chunk_size_); - Memcpy(new_chunk->ptr_, chunks_[current_chunk_idx_]->ptr_, current_chunk_offset_); - chunks_[current_chunk_idx_] = Move(new_chunk); + std::memcpy(new_chunk->ptr_, chunks_[current_chunk_idx_]->ptr_, current_chunk_offset_); + chunks_[current_chunk_idx_] = std::move(new_chunk); } if(current_chunk_offset_ + nbytes < current_chunk_size_) { @@ -135,10 +135,10 @@ Pair VarHeapManager::AppendToHeap(const char *data_ptr, SizeT nbytes) SizeT current_chunk_remain_size = current_chunk_size_ - chunk_offset; if (nbytes <= current_chunk_remain_size) { // Current chunk can hold the data - Memcpy(start_ptr, data_ptr, nbytes); + std::memcpy(start_ptr, data_ptr, nbytes); nbytes = 0; } else { - Memcpy(start_ptr, data_ptr, current_chunk_remain_size); + std::memcpy(start_ptr, data_ptr, current_chunk_remain_size); data_ptr += current_chunk_remain_size; nbytes -= current_chunk_remain_size; ++chunk_id; @@ -157,10 +157,10 @@ void VarHeapManager::ReadFromHeap(char *buffer, u64 chunk_id, u64 chunk_offset, char *start_ptr = chunks_[chunk_id]->ptr_ + chunk_offset; SizeT current_chunk_remain_size = current_chunk_size_ - chunk_offset; if (nbytes <= current_chunk_remain_size) { - Memcpy(buffer, start_ptr, nbytes); + std::memcpy(buffer, start_ptr, nbytes); nbytes = 0; } else { - Memcpy(buffer, start_ptr, current_chunk_remain_size); + std::memcpy(buffer, start_ptr, current_chunk_remain_size); buffer += current_chunk_remain_size; nbytes -= current_chunk_remain_size; ++chunk_id; diff --git a/src/storage/column_vector/var_heap.cppm b/src/storage/column_vector/var_heap.cppm index 606deafdac..c17f039728 100644 --- a/src/storage/column_vector/var_heap.cppm +++ b/src/storage/column_vector/var_heap.cppm @@ -27,7 +27,7 @@ namespace infinity { export struct VarHeapManager { // Use to store string. static constexpr u64 CHUNK_COUNT_LIMIT = MAX_VECTOR_CHUNK_COUNT; - static constexpr u64 INVALID_CHUNK_OFFSET = u64_max; + static constexpr u64 INVALID_CHUNK_OFFSET = std::numeric_limits::max();; public: inline explicit VarHeapManager(u64 chunk_size = MIN_VECTOR_CHUNK_SIZE) : current_chunk_size_(chunk_size) { diff --git a/src/storage/column_vector/vector_buffer.cpp b/src/storage/column_vector/vector_buffer.cpp index 774d25b66a..42750bcb3f 100644 --- a/src/storage/column_vector/vector_buffer.cpp +++ b/src/storage/column_vector/vector_buffer.cpp @@ -80,8 +80,8 @@ void VectorBuffer::Copy(ptr_t input, SizeT size) { if (data_size_ < size) { Error("Attempt to copy an amount of data that cannot currently be accommodated"); } - // Memcpy(data_.get(), input, size); - Memcpy(data_, input, size); + // std::memcpy(data_.get(), input, size); + std::memcpy(data_, input, size); } bool VectorBuffer::RawPointerGetCompactBit(const u8 *src_ptr_u8, SizeT idx) { @@ -148,7 +148,7 @@ void VectorBuffer::CopyCompactBits(u8 *dst_ptr_u8, const u8 *src_ptr_u8, SizeT d SizeT extra; if (start_offset == 0) { // Copy by byte when the start index is aligned. - Memcpy(dst_ptr_u8 + dest_start_idx / 8, src_ptr_u8 + source_start_idx / 8, count / 8); + std::memcpy(dst_ptr_u8 + dest_start_idx / 8, src_ptr_u8 + source_start_idx / 8, count / 8); // Copy the last bits. extra = count % 8; } else { @@ -161,7 +161,7 @@ void VectorBuffer::CopyCompactBits(u8 *dst_ptr_u8, const u8 *src_ptr_u8, SizeT d } else { u8 source_mask = u8(0xff) << start_offset; dst_1 = (dst_1 & (~source_mask)) | (src_1 & source_mask); - Memcpy(dst_ptr_u8 + (dest_start_idx / 8) + 1, src_ptr_u8 + (source_start_idx / 8) + 1, (count - start_todo) / 8); + std::memcpy(dst_ptr_u8 + (dest_start_idx / 8) + 1, src_ptr_u8 + (source_start_idx / 8) + 1, (count - start_todo) / 8); extra = (count - start_todo) % 8; } } @@ -174,7 +174,7 @@ void VectorBuffer::CopyCompactBits(u8 *dst_ptr_u8, const u8 *src_ptr_u8, SizeT d } else { if (SizeT start_offset = dest_start_idx % 8; start_offset != 0) { // head part - SizeT start_todo = Min(count, 8 - start_offset); + SizeT start_todo = std::min(count, 8 - start_offset); for (SizeT i = 0; i < start_todo; ++i) { RawPointerSetCompactBit(dst_ptr_u8, dest_start_idx++, RawPointerGetCompactBit(src_ptr_u8, source_start_idx++)); } diff --git a/src/storage/data_block.cpp b/src/storage/data_block.cpp index 00043fa8ac..896188591b 100644 --- a/src/storage/data_block.cpp +++ b/src/storage/data_block.cpp @@ -170,14 +170,14 @@ Value DataBlock::GetValue(SizeT column_index, SizeT row_index) const { return co void DataBlock::SetValue(SizeT column_index, SizeT row_index, const Value &val) { if (column_index >= column_count_) { - Error(Format("Attempt to access invalid column index: {} in column count: {}", column_index, column_count_)); + Error(fmt::format("Attempt to access invalid column index: {} in column count: {}", column_index, column_count_)); } column_vectors[column_index]->SetValue(row_index, val); } void DataBlock::AppendValue(SizeT column_index, const Value &value) { if (column_index >= column_count_) { - Error(Format("Attempt to access invalid column index: {} in column count: {}", column_index, column_count_)); + Error(fmt::format("Attempt to access invalid column index: {} in column count: {}", column_index, column_count_)); } column_vectors[column_index]->AppendValue(value); finalized = false; @@ -185,7 +185,7 @@ void DataBlock::AppendValue(SizeT column_index, const Value &value) { void DataBlock::AppendValueByPtr(SizeT column_index, const_ptr_t value_ptr) { if (column_index >= column_count_) { - Error(Format("Attempt to access invalid column index: {} in column count: {}", column_index, column_count_)); + Error(fmt::format("Attempt to access invalid column index: {} in column count: {}", column_index, column_count_)); } column_vectors[column_index]->AppendByPtr(value_ptr); finalized = false; @@ -257,11 +257,11 @@ void DataBlock::AppendWith(const SharedPtr &other) { AppendWith(other void DataBlock::AppendWith(const DataBlock *other) { if (other->column_count() != this->column_count()) { Error( - Format("Attempt merge block with column count {} into block with column count {}", other->column_count(), this->column_count())); + fmt::format("Attempt merge block with column count {} into block with column count {}", other->column_count(), this->column_count())); ; } if (this->row_count_ + other->row_count_ > this->capacity_) { - Error(Format("Attempt append block with row count {} into block with row count {}, " + Error(fmt::format("Attempt append block with row count {} into block with row count {}, " "which exceeds the capacity {}", other->row_count(), this->row_count(), @@ -277,11 +277,11 @@ void DataBlock::AppendWith(const DataBlock *other) { void DataBlock::AppendWith(const DataBlock *other, SizeT from, SizeT count) { if (other->column_count() != this->column_count()) { Error( - Format("Attempt merge block with column count {} into block with column count {}", other->column_count(), this->column_count())); + fmt::format("Attempt merge block with column count {} into block with column count {}", other->column_count(), this->column_count())); ; } if (this->row_count_ + count > this->capacity_) { - Error(Format("Attempt append block with row count {} into block with row count{}, " + Error(fmt::format("Attempt append block with row count {} into block with row count{}, " "which exceeds the capacity {}", count, this->row_count(), diff --git a/src/storage/data_table.cpp b/src/storage/data_table.cpp index f69517c413..a2ada2003e 100644 --- a/src/storage/data_table.cpp +++ b/src/storage/data_table.cpp @@ -77,10 +77,10 @@ SharedPtr> DataTable::GetRowIDVector() const { void DataTable::UnionWith(const SharedPtr &other) { if (this->row_count_ != other->row_count_) { - Error(Format("Can't union two table with different row count {}:{}.", this->row_count_, other->row_count_)); + Error(fmt::format("Can't union two table with different row count {}:{}.", this->row_count_, other->row_count_)); } if (this->data_blocks_.size() != other->data_blocks_.size()) { - Error(Format("Can't union two table with different block count {}:{}.", this->data_blocks_.size(), other->data_blocks_.size())); + Error(fmt::format("Can't union two table with different block count {}:{}.", this->data_blocks_.size(), other->data_blocks_.size())); } SizeT block_count = this->data_blocks_.size(); for (SizeT idx = 0; idx < block_count; ++idx) { @@ -95,7 +95,7 @@ void DataTable::Append(const SharedPtr &data_block) { UpdateRowCount(data_block->row_count()); } -SharedPtr DataTable::Make(SharedPtr table_def_ptr, TableType type) { return MakeShared(Move(table_def_ptr), type); } +SharedPtr DataTable::Make(SharedPtr table_def_ptr, TableType type) { return MakeShared(std::move(table_def_ptr), type); } SharedPtr DataTable::MakeResultTable(const Vector> &column_defs) { SharedPtr result_table_def_ptr = TableDef::Make(nullptr, nullptr, column_defs); @@ -127,7 +127,7 @@ SharedPtr DataTable::MakeSummaryResultTable(u64 count, u64 sum) { } DataTable::DataTable(SharedPtr table_def_ptr, TableType type) - : BaseTable(TableEntryType::kTableEntry, table_def_ptr->schema_name(), table_def_ptr->table_name()), definition_ptr_(Move(table_def_ptr)), + : BaseTable(TableEntryType::kTableEntry, table_def_ptr->schema_name(), table_def_ptr->table_name()), definition_ptr_(std::move(table_def_ptr)), row_count_(0), type_(type) {} SizeT DataTable::ColumnCount() const { return definition_ptr_->column_count(); } diff --git a/src/storage/data_table.cppm b/src/storage/data_table.cppm index cc73faa44c..105c43cab1 100644 --- a/src/storage/data_table.cppm +++ b/src/storage/data_table.cppm @@ -69,7 +69,7 @@ public: [[nodiscard]] SharedPtr &GetDataBlockById(SizeT idx) { if (idx >= data_blocks_.size()) { - Error(Format("Attempt to access invalid index: {}/{}", idx, DataBlockCount())); + Error(fmt::format("Attempt to access invalid index: {}/{}", idx, DataBlockCount())); } return data_blocks_[idx]; } @@ -82,7 +82,7 @@ public: inline void UpdateRowCount(SizeT row_count) { row_count_ += row_count; } - inline void SetResultMsg(UniquePtr result_msg) { result_msg_ = Move(result_msg); } + inline void SetResultMsg(UniquePtr result_msg) { result_msg_ = std::move(result_msg); } [[nodiscard]] inline String *result_msg() const { return result_msg_.get(); } diff --git a/src/storage/definition/index_base.cpp b/src/storage/definition/index_base.cpp index 20784f9be7..534555f9f6 100644 --- a/src/storage/definition/index_base.cpp +++ b/src/storage/definition/index_base.cpp @@ -145,15 +145,15 @@ String IndexBase::ToString() const { return ss.str(); } -Json IndexBase::Serialize() const { - Json res; +nlohmann::json IndexBase::Serialize() const { + nlohmann::json res; res["file_name"] = file_name_; res["index_type"] = IndexInfo::IndexTypeToString(index_type_); res["column_names"] = column_names_; return res; } -SharedPtr IndexBase::Deserialize(const Json &index_def_json) { +SharedPtr IndexBase::Deserialize(const nlohmann::json &index_def_json) { SharedPtr res = nullptr; String index_type_name = index_def_json["index_type"]; IndexType index_type = IndexInfo::StringToIndexType(index_type_name); @@ -163,7 +163,7 @@ SharedPtr IndexBase::Deserialize(const Json &index_def_json) { case IndexType::kIVFFlat: { size_t centroids_count = index_def_json["centroids_count"]; MetricType metric_type = StringToMetricType(index_def_json["metric_type"]); - auto ptr = MakeShared(file_name, Move(column_names), centroids_count, metric_type); + auto ptr = MakeShared(file_name, std::move(column_names), centroids_count, metric_type); res = std::static_pointer_cast(ptr); break; } @@ -173,13 +173,13 @@ SharedPtr IndexBase::Deserialize(const Json &index_def_json) { SizeT ef = index_def_json["ef"]; MetricType metric_type = StringToMetricType(index_def_json["metric_type"]); HnswEncodeType encode_type = StringToHnswEncodeType(index_def_json["encode_type"]); - auto ptr = MakeShared(file_name, Move(column_names), metric_type, encode_type, M, ef_construction, ef); + auto ptr = MakeShared(file_name, std::move(column_names), metric_type, encode_type, M, ef_construction, ef); res = std::static_pointer_cast(ptr); break; } case IndexType::kIRSFullText: { String analyzer = index_def_json["analyzer"]; - auto ptr = MakeShared(file_name, Move(column_names), analyzer); + auto ptr = MakeShared(file_name, std::move(column_names), analyzer); res = std::static_pointer_cast(ptr); break; } diff --git a/src/storage/definition/index_base.cppm b/src/storage/definition/index_base.cppm index 4f2b7b3562..1b99e169f0 100644 --- a/src/storage/definition/index_base.cppm +++ b/src/storage/definition/index_base.cppm @@ -36,7 +36,7 @@ export MetricType StringToMetricType(const String &str); export class IndexBase { protected: explicit IndexBase(String file_name, IndexType index_type, Vector column_names) - : index_type_(index_type), file_name_(Move(file_name)), column_names_(Move(column_names)){}; + : index_type_(index_type), file_name_(std::move(file_name)), column_names_(std::move(column_names)){}; public: virtual ~IndexBase() = default; @@ -57,9 +57,9 @@ public: virtual String ToString() const; - virtual Json Serialize() const; + virtual nlohmann::json Serialize() const; - static SharedPtr Deserialize(const Json &index_def_json); + static SharedPtr Deserialize(const nlohmann::json &index_def_json); inline String column_name() { return column_names_[0]; } diff --git a/src/storage/definition/index_def.cpp b/src/storage/definition/index_def.cpp index acfcf7eff2..44891145d9 100644 --- a/src/storage/definition/index_def.cpp +++ b/src/storage/definition/index_def.cpp @@ -105,8 +105,8 @@ String IndexDef::ToString() const { return ss.str(); } -Json IndexDef::Serialize() const { - Json res; +nlohmann::json IndexDef::Serialize() const { + nlohmann::json res; res["index_name"] = *index_name_; for (const auto &index : index_array_) { res["indexes"].emplace_back(index->Serialize()); @@ -114,12 +114,12 @@ Json IndexDef::Serialize() const { return res; } -SharedPtr IndexDef::Deserialize(const Json &index_def_json) { +SharedPtr IndexDef::Deserialize(const nlohmann::json &index_def_json) { SharedPtr index_name = MakeShared(index_def_json["index_name"]); SharedPtr res = MakeShared(index_name); for (const auto &index : index_def_json["indexes"]) { SharedPtr index_base = IndexBase::Deserialize(index); - res->index_array_.emplace_back(Move(index_base)); + res->index_array_.emplace_back(std::move(index_base)); } return res; } diff --git a/src/storage/definition/index_def.cppm b/src/storage/definition/index_def.cppm index de53a41154..f71d201d11 100644 --- a/src/storage/definition/index_def.cppm +++ b/src/storage/definition/index_def.cppm @@ -24,7 +24,7 @@ namespace infinity { export class IndexDef { public: - explicit IndexDef(SharedPtr index_name): index_name_(Move(index_name)) {} + explicit IndexDef(SharedPtr index_name): index_name_(std::move(index_name)) {} virtual ~IndexDef() = default; @@ -44,9 +44,9 @@ public: String ToString() const; - Json Serialize() const; + nlohmann::json Serialize() const; - static SharedPtr Deserialize(const Json &index_def_json); + static SharedPtr Deserialize(const nlohmann::json &index_def_json); public: SharedPtr index_name_{}; diff --git a/src/storage/definition/index_full_text.cpp b/src/storage/definition/index_full_text.cpp index a77d28f3a1..3a96bbb016 100644 --- a/src/storage/definition/index_full_text.cpp +++ b/src/storage/definition/index_full_text.cpp @@ -42,7 +42,7 @@ SharedPtr IndexFullText::Make(String file_name, Vector column analyzer = parameter->param_value_; } } - return MakeShared(file_name, Move(column_names), analyzer); + return MakeShared(file_name, std::move(column_names), analyzer); } bool IndexFullText::operator==(const IndexFullText &other) const { @@ -79,13 +79,13 @@ String IndexFullText::ToString() const { return output_str; } -Json IndexFullText::Serialize() const { - Json res = IndexBase::Serialize(); +nlohmann::json IndexFullText::Serialize() const { + nlohmann::json res = IndexBase::Serialize(); res["analyzer"] = analyzer_; return res; } -SharedPtr IndexFullText::Deserialize(const Json &) { +SharedPtr IndexFullText::Deserialize(const nlohmann::json &) { Error("Not implemented"); return nullptr; } diff --git a/src/storage/definition/index_full_text.cppm b/src/storage/definition/index_full_text.cppm index 8b6dca5e0c..d6e581cb3d 100644 --- a/src/storage/definition/index_full_text.cppm +++ b/src/storage/definition/index_full_text.cppm @@ -29,7 +29,7 @@ public: static SharedPtr Make(String file_name, Vector column_names, const Vector &index_param_list); IndexFullText(String file_name, Vector column_names, String analyzer) - : IndexBase(file_name, IndexType::kIRSFullText, Move(column_names)), analyzer_(Move(analyzer)) {} + : IndexBase(file_name, IndexType::kIRSFullText, std::move(column_names)), analyzer_(std::move(analyzer)) {} ~IndexFullText() final = default; @@ -46,9 +46,9 @@ public: virtual String ToString() const override; - virtual Json Serialize() const override; + virtual nlohmann::json Serialize() const override; - static SharedPtr Deserialize(const Json &index_def_json); + static SharedPtr Deserialize(const nlohmann::json &index_def_json); public: String analyzer_{}; diff --git a/src/storage/definition/index_hnsw.cpp b/src/storage/definition/index_hnsw.cpp index 091cb2dff6..d702d46ecc 100644 --- a/src/storage/definition/index_hnsw.cpp +++ b/src/storage/definition/index_hnsw.cpp @@ -76,7 +76,7 @@ SharedPtr IndexHnsw::Make(String file_name, Vector column_nam if (metric_type == MetricType::kInvalid || encode_type == HnswEncodeType::kInvalid) { Error("Lack index parameters"); } - return MakeShared(file_name, Move(column_names), metric_type, encode_type, M, ef_construction, ef); + return MakeShared(file_name, std::move(column_names), metric_type, encode_type, M, ef_construction, ef); } bool IndexHnsw::operator==(const IndexHnsw &other) const { @@ -114,8 +114,8 @@ String IndexHnsw::ToString() const { return ss.str(); } -Json IndexHnsw::Serialize() const { - Json res = IndexBase::Serialize(); +nlohmann::json IndexHnsw::Serialize() const { + nlohmann::json res = IndexBase::Serialize(); res["metric_type"] = MetricTypeToString(metric_type_); res["encode_type"] = HnswEncodeTypeToString(encode_type_); res["M"] = M_; diff --git a/src/storage/definition/index_hnsw.cppm b/src/storage/definition/index_hnsw.cppm index a778fccfa8..02c9bd7787 100644 --- a/src/storage/definition/index_hnsw.cppm +++ b/src/storage/definition/index_hnsw.cppm @@ -45,7 +45,7 @@ public: SizeT M, SizeT ef_construction, SizeT ef) - : IndexBase(file_name, IndexType::kHnsw, Move(column_names)), metric_type_(metric_type), encode_type_(encode_type), M_(M), + : IndexBase(file_name, IndexType::kHnsw, std::move(column_names)), metric_type_(metric_type), encode_type_(encode_type), M_(M), ef_construction_(ef_construction), ef_(ef) {} ~IndexHnsw() final = default; @@ -61,7 +61,7 @@ public: virtual String ToString() const override; - virtual Json Serialize() const override; + virtual nlohmann::json Serialize() const override; public: const MetricType metric_type_{MetricType::kInvalid}; diff --git a/src/storage/definition/index_ivfflat.cpp b/src/storage/definition/index_ivfflat.cpp index fe13c6896b..89a421f4b0 100644 --- a/src/storage/definition/index_ivfflat.cpp +++ b/src/storage/definition/index_ivfflat.cpp @@ -44,7 +44,7 @@ SharedPtr IndexIVFFlat::Make(String file_name, Vector column_ if (metric_type == MetricType::kInvalid) { Error("Lack index parameter metric_type"); } - return MakeShared(Move(file_name), Move(column_names), centroids_count, metric_type); + return MakeShared(std::move(file_name), std::move(column_names), centroids_count, metric_type); } bool IndexIVFFlat::operator==(const IndexIVFFlat &other) const { @@ -80,14 +80,14 @@ String IndexIVFFlat::ToString() const { return ss.str(); } -Json IndexIVFFlat::Serialize() const { - Json res = IndexBase::Serialize(); +nlohmann::json IndexIVFFlat::Serialize() const { + nlohmann::json res = IndexBase::Serialize(); res["centroids_count"] = centroids_count_; res["metric_type"] = MetricTypeToString(metric_type_); return res; } -SharedPtr IndexIVFFlat::Deserialize(const Json &) { +SharedPtr IndexIVFFlat::Deserialize(const nlohmann::json &) { Error("Not implemented"); return nullptr; } diff --git a/src/storage/definition/index_ivfflat.cppm b/src/storage/definition/index_ivfflat.cppm index 8c07600673..33ba31dacc 100644 --- a/src/storage/definition/index_ivfflat.cppm +++ b/src/storage/definition/index_ivfflat.cppm @@ -28,7 +28,7 @@ public: static SharedPtr Make(String file_name, Vector column_names, const Vector &index_param_list); IndexIVFFlat(String file_name, Vector column_names, SizeT centroids_count, MetricType metric_type) - : IndexBase(file_name, IndexType::kIVFFlat, Move(column_names)), centroids_count_(centroids_count), metric_type_(metric_type) {} + : IndexBase(file_name, IndexType::kIVFFlat, std::move(column_names)), centroids_count_(centroids_count), metric_type_(metric_type) {} ~IndexIVFFlat() final = default; @@ -45,9 +45,9 @@ public: virtual String ToString() const override; - virtual Json Serialize() const override; + virtual nlohmann::json Serialize() const override; - static SharedPtr Deserialize(const Json &index_def_json); + static SharedPtr Deserialize(const nlohmann::json &index_def_json); public: const SizeT centroids_count_{}; diff --git a/src/storage/definition/table_def.cppm b/src/storage/definition/table_def.cppm index 7c594a972d..72eb2d404a 100644 --- a/src/storage/definition/table_def.cppm +++ b/src/storage/definition/table_def.cppm @@ -26,12 +26,12 @@ export class TableDef { public: static inline SharedPtr Make(SharedPtr schema, SharedPtr table_name, Vector> columns) { - return MakeShared(Move(schema), Move(table_name), Move(columns)); + return MakeShared(std::move(schema), std::move(table_name), std::move(columns)); } public: explicit TableDef(SharedPtr schema, SharedPtr table_name, Vector> columns) - : schema_name_(Move(schema)), table_name_(Move(table_name)), columns_(Move(columns)) { + : schema_name_(std::move(schema)), table_name_(std::move(table_name)), columns_(std::move(columns)) { SizeT column_count = columns_.size(); for (SizeT idx = 0; idx < column_count; ++idx) { column_name2id_[columns_[idx]->name()] = idx; diff --git a/src/storage/invertedindex/codec.cpp b/src/storage/invertedindex/codec.cpp index fbe19c1fa2..61e834e029 100644 --- a/src/storage/invertedindex/codec.cpp +++ b/src/storage/invertedindex/codec.cpp @@ -35,13 +35,13 @@ void Codec::RemoveFixed8(String &key, u8 &i) { void Codec::RemoveFixed64(String &key, u64 &i) { key.erase(0, sizeof(i)); } void Codec::RemoveBuffer(String &key, char *buffer, u32 size) { - Memcpy(buffer, key.data(), size); + std::memcpy(buffer, key.data(), size); key.erase(size); } void Codec::AddInt(String &buf, u32 value) { u8 working[sizeof(value)]; - Memcpy(working, &value, sizeof(value)); + std::memcpy(working, &value, sizeof(value)); buf.append(buf, sizeof(working)); } @@ -53,7 +53,7 @@ void Codec::AddVInt(String &buf, u32 value) { void Codec::AddLong(String &buf, u64 value) { u8 working[sizeof(value)]; - Memcpy(working, &value, sizeof(value)); + std::memcpy(working, &value, sizeof(value)); buf.append(buf, sizeof(working)); } @@ -65,7 +65,7 @@ void Codec::AddVLong(String &buf, u64 value) { u32 DecodeInt(const u8 *ptr) { u32 result; - Memcpy(&result, ptr, sizeof(result)); + std::memcpy(&result, ptr, sizeof(result)); return result; } diff --git a/src/storage/invertedindex/common/bitmap.cpp b/src/storage/invertedindex/common/bitmap.cpp index 8f5588c14c..43cb733a75 100644 --- a/src/storage/invertedindex/common/bitmap.cpp +++ b/src/storage/invertedindex/common/bitmap.cpp @@ -37,7 +37,7 @@ Bitmap::Bitmap(u32 item_count, bool set, MemoryPool *pool) { data_ = pool_ ? (u32 *)pool_->Allocate(slot_count_ * sizeof(u32)) : new u32[slot_count_]; item_count_ = item_count; - Memset(data_, set ? 0xFF : 0x0, slot_count_ * sizeof(u32)); + std::memset(data_, set ? 0xFF : 0x0, slot_count_ * sizeof(u32)); set_count_ = set ? item_count : 0; mount_ = false; init_set_ = set; @@ -52,7 +52,7 @@ Bitmap::Bitmap(const Bitmap &rhs) { if (rhs.GetData() != nullptr) { data_ = pool_ ? (u32 *)pool_->Allocate(slot_count_ * sizeof(u32)) : new u32[slot_count_]; - Memcpy(data_, rhs.data_, slot_count_ * sizeof(u32)); + std::memcpy(data_, rhs.data_, slot_count_ * sizeof(u32)); } else { data_ = nullptr; } @@ -77,7 +77,7 @@ Bitmap &Bitmap::operator=(const Bitmap &rhs) { if (rhs.GetData() != nullptr) { data_ = pool_ ? (u32 *)pool_->Allocate(slot_count_ * sizeof(u32)) : new u32[slot_count_]; - Memcpy(data_, rhs.data_, slot_count_ * sizeof(u32)); + std::memcpy(data_, rhs.data_, slot_count_ * sizeof(u32)); } else { data_ = nullptr; } @@ -97,7 +97,7 @@ bool Bitmap::Alloc(u32 item_count, bool set) { data_ = pool_ ? (u32 *)pool_->Allocate(slot_count_ * sizeof(u32)) : new u32[slot_count_]; item_count_ = item_count; - Memset(data_, set ? 0xFF : 0x0, slot_count_ * sizeof(u32)); + std::memset(data_, set ? 0xFF : 0x0, slot_count_ * sizeof(u32)); set_count_ = set ? item_count : 0; return true; @@ -223,7 +223,7 @@ bool Bitmap::Reset(u32 index) { } void Bitmap::ResetAll() { - Memset(data_, 0x0, slot_count_ * sizeof(u32)); + std::memset(data_, 0x0, slot_count_ * sizeof(u32)); set_count_ = 0; } @@ -239,7 +239,7 @@ void Bitmap::ResetAllAfter(u32 index) { if (quot < slot_count_ - 1) { u32 siz = slot_count_ - quot - 1; - Memset(((char *)data_) + (quot + 1) * sizeof(u32), 0, siz * sizeof(u32)); + std::memset(((char *)data_) + (quot + 1) * sizeof(u32), 0, siz * sizeof(u32)); } RefreshSetCountByScanning(); @@ -422,7 +422,7 @@ bool Bitmap::operator==(Bitmap &bitmap) { if (data_ == bitmap.data_) { return true; } - return Memcmp(data_, bitmap.data_, slot_count_ * sizeof(u32)) == 0; + return std::memcmp(data_, bitmap.data_, slot_count_ * sizeof(u32)) == 0; } bool Bitmap::operator!=(Bitmap &bitmap) { return !(*this == bitmap); } diff --git a/src/storage/invertedindex/common/dynamic_bitmap.cpp b/src/storage/invertedindex/common/dynamic_bitmap.cpp index 42348b4c97..efac4d83e3 100644 --- a/src/storage/invertedindex/common/dynamic_bitmap.cpp +++ b/src/storage/invertedindex/common/dynamic_bitmap.cpp @@ -50,10 +50,10 @@ void DynamicBitmap::Expand(u32 index) { u32 *data = pool_ ? (u32 *)pool_->Allocate(sizeof(u32) * alloc_slot_count) : new u32[alloc_slot_count]; if (data_ != nullptr) { - Memcpy(data, data_, slot_count_ * sizeof(u32)); + std::memcpy(data, data_, slot_count_ * sizeof(u32)); u8 initValue = init_set_ ? 0xFF : 0; - Memset(data + slot_count_, initValue, (alloc_slot_count - slot_count_) * sizeof(u32)); + std::memset(data + slot_count_, initValue, (alloc_slot_count - slot_count_) * sizeof(u32)); if (pool_) { pool_->Deallocate((void *)data_, sizeof(u32) * slot_count_); @@ -66,7 +66,7 @@ void DynamicBitmap::Expand(u32 index) { item_count_ = slot_count_ * SLOT_SIZE; } else { u8 initValue = init_set_ ? 0xFF : 0; - Memset(data + slot_count_, initValue, (alloc_slot_count - slot_count_) * sizeof(u32)); + std::memset(data + slot_count_, initValue, (alloc_slot_count - slot_count_) * sizeof(u32)); data_ = data; slot_count_ = alloc_slot_count; @@ -86,7 +86,7 @@ DynamicBitmap *DynamicBitmap::CloneWithOnlyValidData() const { if (GetData() != nullptr) { new_bitmap->data_ = new_bitmap->pool_ ? (u32 *)new_bitmap->pool_->Allocate(sizeof(u32) * new_bitmap->slot_count_) : new u32[new_bitmap->slot_count_]; - Memcpy(new_bitmap->data_, data_, new_bitmap->slot_count_ * sizeof(u32)); + std::memcpy(new_bitmap->data_, data_, new_bitmap->slot_count_ * sizeof(u32)); } else { new_bitmap->data_ = nullptr; } diff --git a/src/storage/invertedindex/format/buffered_byte_slice_reader.cppm b/src/storage/invertedindex/format/buffered_byte_slice_reader.cppm index 98697d5453..88c3e96dbf 100644 --- a/src/storage/invertedindex/format/buffered_byte_slice_reader.cppm +++ b/src/storage/invertedindex/format/buffered_byte_slice_reader.cppm @@ -82,7 +82,7 @@ bool BufferedByteSliceReader::Decode(T *buffer, SizeT count, SizeT &decode_count const ShortBuffer &shortBuffer = buffered_byte_slice_->GetBuffer(); const T *src = shortBuffer.GetRowTyped(current_value->location_); - Memcpy((void *)buffer, (const void *)src, buffer_size * sizeof(T)); + std::memcpy((void *)buffer, (const void *)src, buffer_size * sizeof(T)); decode_count = buffer_size; short_buffer_cursor_++; diff --git a/src/storage/invertedindex/format/short_buffer.cpp b/src/storage/invertedindex/format/short_buffer.cpp index 743b652bad..b726cdeb9e 100644 --- a/src/storage/invertedindex/format/short_buffer.cpp +++ b/src/storage/invertedindex/format/short_buffer.cpp @@ -68,7 +68,7 @@ void ShortBuffer::BufferMemoryCopy(u8 *dst, u8 dst_col_count, u8 *src, u8 src_co } for (u8 i = 0; i < posting_values->GetSize(); ++i) { const PostingValue *value = posting_values->GetValue(i); - Memcpy(GetRow(dst, dst_col_count, value), GetRow(src, src_col_count, value), src_size * value->GetSize()); + std::memcpy(GetRow(dst, dst_col_count, value), GetRow(src, src_col_count, value), src_size * value->GetSize()); } } diff --git a/src/storage/invertedindex/index_defines.cppm b/src/storage/invertedindex/index_defines.cppm index 3a2a594d45..05852d3d50 100644 --- a/src/storage/invertedindex/index_defines.cppm +++ b/src/storage/invertedindex/index_defines.cppm @@ -55,7 +55,7 @@ export { constexpr optionflag_t NO_TERM_FREQUENCY = of_doc_payload | of_term_payload; constexpr optionflag_t OPTION_FLAG_NONE = of_none; constexpr docid_t INVALID_DOCID = -1; - constexpr pos_t INVALID_POSITION = u32_max; + constexpr pos_t INVALID_POSITION = std::numeric_limits::max(); constexpr segmentid_t INVALID_SEGMENTID = -1; constexpr u32 MAX_DOC_PER_RECORD = 128; constexpr u32 MAX_DOC_PER_RECORD_BIT_NUM = 7; diff --git a/src/storage/invertedindex/indexer.cpp b/src/storage/invertedindex/indexer.cpp index 0ec383615d..512293de4f 100644 --- a/src/storage/invertedindex/indexer.cpp +++ b/src/storage/invertedindex/indexer.cpp @@ -49,7 +49,7 @@ void Indexer::Add(DataBlock *data_block) { SharedPtr column_vector = data_block->column_vectors[i]; if (column_vector->data_type()->type() == LogicalType::kRowID) { row_ids.resize(column_vector->Size()); - Memcpy(row_ids.data(), column_vector->data(), column_vector->Size() * sizeof(RowID)); + std::memcpy(row_ids.data(), column_vector->data(), column_vector->Size() * sizeof(RowID)); break; } else { column_vectors.push_back(column_vector); diff --git a/src/storage/invertedindex/iresearch/analyzer.cpp b/src/storage/invertedindex/iresearch/analyzer.cpp index 09324cee28..c445df721a 100644 --- a/src/storage/invertedindex/iresearch/analyzer.cpp +++ b/src/storage/invertedindex/iresearch/analyzer.cpp @@ -35,14 +35,14 @@ void AnalyzerPool::Set(const StringView &name) { case Str2Int(JIEBA.data()): { IRSJiebaAnalyzer::options_t opt; opt.path_ = InfinityContext::instance().config()->resource_dict_path(); - UniquePtr analyzer = MakeUnique(Move(opt)); + UniquePtr analyzer = MakeUnique(std::move(opt)); if (analyzer->load()) - cache_[JIEBA] = Move(analyzer); + cache_[JIEBA] = std::move(analyzer); } break; case Str2Int(SEGMENT.data()): { IRSSegmentationAnalyzer::options_t opt; - UniquePtr analyzer = MakeUnique(Move(opt)); - cache_[SEGMENT] = Move(analyzer); + UniquePtr analyzer = MakeUnique(std::move(opt)); + cache_[SEGMENT] = std::move(analyzer); } break; default: break; diff --git a/src/storage/invertedindex/iresearch/datastore.cpp b/src/storage/invertedindex/iresearch/datastore.cpp index 3b1e5d4566..d9e5e04877 100644 --- a/src/storage/invertedindex/iresearch/datastore.cpp +++ b/src/storage/invertedindex/iresearch/datastore.cpp @@ -74,11 +74,11 @@ constexpr SizeT DEFAULT_CONSOLIDATION_INTERVAL_MSEC = 1000; template void IRSAsync::Queue(SizeT id, T &&fn) { - T t = Move(fn); + T t = std::move(fn); if (0 == id) - pool_0_.push(Move(t)); + pool_0_.push(std::move(t)); else if (1 == id) - pool_1_.push(Move(t)); + pool_1_.push(std::move(t)); } void IRSAsync::ClearQueue() { @@ -125,14 +125,14 @@ struct ConsolidationTask : Task { }; void ConsolidationTask::operator()(int id) { - LOG_INFO(Format("ConsolidationTask id {}", id)); - if ((true == state_->cancel_.load(MemoryOrderRelease)) && (false == optimize_)) + LOG_INFO(fmt::format("ConsolidationTask id {}", id)); + if ((true == state_->cancel_.load(std::memory_order::release)) && (false == optimize_)) return; std::this_thread::sleep_for(std::chrono::milliseconds(consolidation_interval_)); - state_->pending_consolidations_.fetch_sub(1, MemoryOrderRelease); + state_->pending_consolidations_.fetch_sub(1, std::memory_order::release); if (optimize_) { - LOG_INFO(Format("ConsolidationTask optimize {}", id)); + LOG_INFO(fmt::format("ConsolidationTask optimize {}", id)); store_->GetWriter()->Consolidate(irs::index_utils::MakePolicy(irs::index_utils::ConsolidateCount())); store_->GetWriter()->Commit(); } else { @@ -141,11 +141,11 @@ void ConsolidationTask::operator()(int id) { if (consolidation_interval_ != std::chrono::milliseconds::zero()) { // reschedule - auto count = state_->pending_consolidations_.load(MemoryOrderAcquire); + auto count = state_->pending_consolidations_.load(std::memory_order::acquire); if (count > 0) { - if (state_->pending_consolidations_.compare_exchange_weak(count, count + 1, MemoryOrderAcqrel)) { + if (state_->pending_consolidations_.compare_exchange_weak(count, count + 1, std::memory_order::acq_rel)) { ConsolidationTask task(*this); - async_->Queue(1, Move(task)); + async_->Queue(1, std::move(task)); } } } @@ -169,11 +169,11 @@ struct CommitTask : Task { }; void CommitTask::operator()(int id) { - if (true == state_->cancel_.load(MemoryOrderRelease)) + if (true == state_->cancel_.load(std::memory_order::release)) return; - LOG_INFO(Format("CommitTask id {}", id)); + LOG_INFO(fmt::format("CommitTask id {}", id)); std::this_thread::sleep_for(std::chrono::milliseconds(commit_interval_)); - state_->pending_commits_.fetch_sub(1, MemoryOrderRelease); + state_->pending_commits_.fetch_sub(1, std::memory_order::release); Finalize(); store_->Commit(); } @@ -181,9 +181,9 @@ void CommitTask::operator()(int id) { void CommitTask::Finalize() { constexpr size_t kMaxPendingConsolidations = 3; CommitTask task(*this); - state_->pending_commits_.fetch_add(1, MemoryOrderRelease); - async_->Queue(0, Move(task)); - if (state_->pending_consolidations_.load(MemoryOrderRelease) < kMaxPendingConsolidations) { + state_->pending_commits_.fetch_add(1, std::memory_order::release); + async_->Queue(0, std::move(task)); + if (state_->pending_consolidations_.load(std::memory_order::release) < kMaxPendingConsolidations) { store_->ScheduleConsolidation(); } } @@ -224,9 +224,9 @@ IRSDataStore::IRSDataStore(const String &table_name, const String &directory) { return std::make_pair(info, irs::FeatureWriterFactory{}); }; - index_writer_ = IRSIndexWriter::Make(*(irs_directory_), Move(format), OpenMode(open_mode), options); + index_writer_ = IRSIndexWriter::Make(*(irs_directory_), std::move(format), OpenMode(open_mode), options); auto reader = index_writer_->GetSnapshot(); - auto data = MakeShared(Move(reader)); + auto data = MakeShared(std::move(reader)); AnalyzerPool::instance().Set(SEGMENT); AnalyzerPool::instance().Set(JIEBA); @@ -236,16 +236,16 @@ IRSDataStore::IRSDataStore(const String &table_name, const String &directory) { IRSDataStore::~IRSDataStore() { StopSchedule(); } -void IRSDataStore::StoreSnapshot(DataSnapshotPtr snapshot) { std::atomic_store_explicit(&snapshot_, Move(snapshot), MemoryOrderRelease); } +void IRSDataStore::StoreSnapshot(DataSnapshotPtr snapshot) { std::atomic_store_explicit(&snapshot_, std::move(snapshot), std::memory_order::release); } -IRSDataStore::DataSnapshotPtr IRSDataStore::LoadSnapshot() const { return std::atomic_load_explicit(&snapshot_, MemoryOrderAcquire); } +IRSDataStore::DataSnapshotPtr IRSDataStore::LoadSnapshot() const { return std::atomic_load_explicit(&snapshot_, std::memory_order::acquire); } void IRSDataStore::Commit() { - UniqueLock lk(commit_mutex_); + std::unique_lock lk(commit_mutex_); index_writer_->Commit(); auto reader = index_writer_->GetSnapshot(); reader->Reopen(); - auto data = MakeShared(Move(reader)); + auto data = MakeShared(std::move(reader)); StoreSnapshot(data); } @@ -255,8 +255,8 @@ void IRSDataStore::ScheduleCommit() { task.async_ = async_.get(); task.store_ = this; task.commit_interval_ = std::chrono::milliseconds(DEFAULT_COMMIT_INTERVAL); - maintenance_state_->pending_commits_.fetch_add(1, MemoryOrderRelease); - async_->Queue(0, Move(task)); + maintenance_state_->pending_commits_.fetch_add(1, std::memory_order::release); + async_->Queue(0, std::move(task)); } void IRSDataStore::ScheduleConsolidation() { @@ -266,8 +266,8 @@ void IRSDataStore::ScheduleConsolidation() { task.store_ = this; task.optimize_ = false; task.consolidation_interval_ = std::chrono::milliseconds{DEFAULT_CONSOLIDATION_INTERVAL_MSEC}; - maintenance_state_->pending_consolidations_.fetch_add(1, MemoryOrderRelease); - async_->Queue(1, Move(task)); + maintenance_state_->pending_consolidations_.fetch_add(1, std::memory_order::release); + async_->Queue(1, std::move(task)); } void IRSDataStore::ScheduleOptimize() { @@ -276,13 +276,13 @@ void IRSDataStore::ScheduleOptimize() { task.async_ = async_.get(); task.store_ = this; task.optimize_ = true; - maintenance_state_->pending_consolidations_.fetch_add(1, MemoryOrderRelease); - async_->Queue(1, Move(task)); + maintenance_state_->pending_consolidations_.fetch_add(1, std::memory_order::release); + async_->Queue(1, std::move(task)); } void IRSDataStore::StopSchedule() { async_->ClearQueue(); - maintenance_state_->cancel_.store(true, MemoryOrderRelease); + maintenance_state_->cancel_.store(true, std::memory_order::release); } void IRSDataStore::BatchInsert(TableEntry *table_entry, const IndexDef *index_def, SegmentEntry *segment_entry, BufferManager *buffer_mgr) { @@ -302,14 +302,14 @@ void IRSDataStore::BatchInsert(TableEntry *table_entry, const IndexDef *index_de if (!stream.get()) { throw StorageException("Dict path of Jieba analyzer is not valid"); } - analyzers.push_back(Move(stream)); + analyzers.push_back(std::move(stream)); } else if (index_base->analyzer_ == SEGMENT) { UniquePtr stream = AnalyzerPool::instance().Get(SEGMENT); - analyzers.push_back(Move(stream)); + analyzers.push_back(std::move(stream)); } else if (index_base->analyzer_.empty()) { // TODO use segmentation analyzer if analyzer is not set UniquePtr stream = AnalyzerPool::instance().Get(SEGMENT); - analyzers.push_back(Move(stream)); + analyzers.push_back(std::move(stream)); } else { throw StorageException("Non existing analyzer"); } @@ -438,7 +438,7 @@ ViewSnapshot *IRSDataStore::GetViewSnapshot() { ViewSnapshot::ViewSnapshot(IRSDirectoryReader *reader) : reader_(reader) { segments_.reserve(reader_->size()); for (auto &subreader : *reader_) { - segments_.emplace_back(Move(ViewSegment(subreader))); + segments_.emplace_back(ViewSegment(subreader)); } } @@ -462,12 +462,12 @@ int IRSDataStore::Search(IrsFilter *flt, const Map &options, Sco auto arg_format = irs::type::get(); auto scr = irs::scorers::get(scorer, arg_format, scorer_arg); if (!scr) { - LOG_ERROR(Format("Unable to instantiate scorer '{}' with argument format csv with arguments '{}'", scorer, scorer_arg)); + LOG_ERROR(fmt::format("Unable to instantiate scorer '{}' with argument format csv with arguments '{}'", scorer, scorer_arg)); return -1; } const IRSDirectoryReader &reader = GetDirectoryReader(); - LOG_INFO(Format("Index stats: segments={}, docs={},live-docs={}", reader->size(), reader->docs_count(), reader->live_docs_count())); + LOG_INFO(fmt::format("Index stats: segments={}, docs={},live-docs={}", reader->size(), reader->docs_count(), reader->live_docs_count())); irs::Scorers order = irs::Scorers::Prepare(scr.get()); irs::filter::prepared::ptr filter = flt->prepare({ @@ -477,7 +477,7 @@ int IRSDataStore::Search(IrsFilter *flt, const Map &options, Sco SizeT topn(DEFAULT_TOPN); if (auto it = options.find("topn"); it != options.end()) { - topn = StrToInt(it->second); + topn = std::stoi(it->second); } sorted.reserve(topn); diff --git a/src/storage/invertedindex/iresearch/datastore.cppm b/src/storage/invertedindex/iresearch/datastore.cppm index 7058ddd2fe..59c2524b3c 100644 --- a/src/storage/invertedindex/iresearch/datastore.cppm +++ b/src/storage/invertedindex/iresearch/datastore.cppm @@ -99,10 +99,10 @@ public: explicit IRSDataStore(const String &table_name, const String &directory); ~IRSDataStore(); struct DataSnapshot { - DataSnapshot(IRSDirectoryReader &&reader) : reader_(Move(reader)) {} + DataSnapshot(IRSDirectoryReader &&reader) : reader_(std::move(reader)) {} DataSnapshot &operator=(DataSnapshot &&rhs) noexcept { if (this != &rhs) { - reader_ = Move(rhs.reader_); + reader_ = std::move(rhs.reader_); } return *this; } @@ -143,7 +143,7 @@ private: IRSDirectory::ptr irs_directory_; IRSIndexWriter::ptr index_writer_; IRSIndexWriter::Transaction recovery_txn_; - Mutex commit_mutex_; + std::mutex commit_mutex_; DataSnapshotPtr snapshot_; UniquePtr async_; SharedPtr maintenance_state_; diff --git a/src/storage/invertedindex/iresearch/document.cppm b/src/storage/invertedindex/iresearch/document.cppm index 46ad5523e1..145d1bfff0 100644 --- a/src/storage/invertedindex/iresearch/document.cppm +++ b/src/storage/invertedindex/iresearch/document.cppm @@ -68,7 +68,7 @@ export struct TextField : public IndexField { mutable IRSAnalyzer *stream_; TextField(const String &name, IndexFeatures index_features, const Features &flags, IRSAnalyzer *stream) - : IndexField(name, index_features, flags), stream_(Move(stream)) {} + : IndexField(name, index_features, flags), stream_(std::move(stream)) {} TokenStream &get_tokens() const override { stream_->reset(f_); diff --git a/src/storage/invertedindex/multi_posting_decoder.cpp b/src/storage/invertedindex/multi_posting_decoder.cpp index 5dc2a7cf6a..569378d480 100644 --- a/src/storage/invertedindex/multi_posting_decoder.cpp +++ b/src/storage/invertedindex/multi_posting_decoder.cpp @@ -84,7 +84,7 @@ bool MultiPostingDecoder::DecodeDocBufferInOneSegment(docid_t start_doc_id, return false; } - docid_t cur_seg_doc_id = Max(docid_t(0), start_doc_id - base_doc_id_); + docid_t cur_seg_doc_id = std::max(docid_t(0), start_doc_id - base_doc_id_); if (!index_decoder_->DecodeDocBuffer(cur_seg_doc_id, doc_buffer, first_doc_id, last_doc_id, current_ttf)) { return false; } diff --git a/src/storage/invertedindex/posting_iterator.cpp b/src/storage/invertedindex/posting_iterator.cpp index f354e8180b..935e1baf55 100644 --- a/src/storage/invertedindex/posting_iterator.cpp +++ b/src/storage/invertedindex/posting_iterator.cpp @@ -46,7 +46,7 @@ bool PostingIterator::Init(const SharedPtr> &seg_postings docid_t PostingIterator::SeekDoc(docid_t doc_id) { docid_t ret = INVALID_DOCID; docid_t cur_doc_id = current_doc_id_; - doc_id = Max(cur_doc_id + 1, doc_id); + doc_id = std::max(cur_doc_id + 1, doc_id); if (unlikely(doc_id > last_doc_id_in_buffer_)) { if (!posting_decoder_->DecodeDocBuffer(doc_id, doc_buffer_, cur_doc_id, last_doc_id_in_buffer_, current_ttf_)) return ret; diff --git a/src/storage/io/byte_slice_reader.cpp b/src/storage/io/byte_slice_reader.cpp index af35188a4d..807f5963e4 100644 --- a/src/storage/io/byte_slice_reader.cpp +++ b/src/storage/io/byte_slice_reader.cpp @@ -55,7 +55,7 @@ SizeT ByteSliceReader::Read(void *value, SizeT len) { } if (current_slice_offset_ + len <= GetSliceDataSize(current_slice_)) { - Memcpy(value, current_slice_->data_ + current_slice_offset_, len); + std::memcpy(value, current_slice_->data_ + current_slice_offset_, len); current_slice_offset_ += len; global_offset_ += len; return len; @@ -68,7 +68,7 @@ SizeT ByteSliceReader::Read(void *value, SizeT len) { while (total_len > 0) { leftLen = GetSliceDataSize(current_slice_) - offset; if (leftLen < total_len) { - Memcpy(dest, current_slice_->data_ + offset, leftLen); + std::memcpy(dest, current_slice_->data_ + offset, leftLen); total_len -= leftLen; dest += leftLen; @@ -78,7 +78,7 @@ SizeT ByteSliceReader::Read(void *value, SizeT len) { break; } } else { - Memcpy(dest, current_slice_->data_ + offset, total_len); + std::memcpy(dest, current_slice_->data_ + offset, total_len); dest += total_len; offset += (SizeT)total_len; total_len = 0; diff --git a/src/storage/io/byte_slice_writer.cpp b/src/storage/io/byte_slice_writer.cpp index 72ccce2514..979618f566 100644 --- a/src/storage/io/byte_slice_writer.cpp +++ b/src/storage/io/byte_slice_writer.cpp @@ -65,7 +65,7 @@ void ByteSliceWriter::Write(const void *value, SizeT len) { slice_list_->Add(slice); } u32 copy_len = (last_slice_size_ - slice->size_) > left ? left : (last_slice_size_ - slice->size_); - Memcpy(slice->data_ + slice->size_, data, copy_len); + std::memcpy(slice->data_ + slice->size_, data, copy_len); data += copy_len; left -= copy_len; slice->size_ = slice->size_ + copy_len; diff --git a/src/storage/io/file_reader.cpp b/src/storage/io/file_reader.cpp index 2545023c0c..7ff6d48d26 100644 --- a/src/storage/io/file_reader.cpp +++ b/src/storage/io/file_reader.cpp @@ -16,6 +16,8 @@ module; #include +module file_reader; + import stl; import file_system; import file_system_type; @@ -23,8 +25,6 @@ import file_system_type; import infinity_exception; import third_party; -module file_reader; - namespace infinity { FileReader::FileReader(FileSystem &fs, const String &path, SizeT buffer_size) @@ -41,7 +41,7 @@ u8 FileReader::ReadByte() { if (buffer_offset_ >= buffer_size_) { already_read_size_ = fs_.Read(*file_handler_, data_.get(), buffer_size_); if (already_read_size_ == 0) { - Error(Format("No enough data from file: {}", file_handler_->path_.string())); + Error(fmt::format("No enough data from file: {}", file_handler_->path_.string())); } buffer_offset_ = 0; buffer_start_ += already_read_size_; @@ -89,9 +89,9 @@ void FileReader::Read(char_t *buffer, SizeT read_size) { while (true) { i64 byte_count1 = end_pos - buffer; i64 byte_count2 = already_read_size_ - buffer_offset_; - i64 to_read = Min(byte_count1, byte_count2); + i64 to_read = std::min(byte_count1, byte_count2); if (to_read > 0) { - Memcpy(buffer, data_.get() + buffer_offset_, to_read); + std::memcpy(buffer, data_.get() + buffer_offset_, to_read); buffer_offset_ += to_read; start_pos += to_read; } @@ -103,7 +103,7 @@ void FileReader::Read(char_t *buffer, SizeT read_size) { buffer_offset_ = 0; already_read_size_ = fs_.Read(*file_handler_, data_.get(), buffer_size_); if (already_read_size_ == 0) { - Error(Format("No enough data from file: {}", file_handler_->path_.string())); + Error(fmt::format("No enough data from file: {}", file_handler_->path_.string())); } } else { return; diff --git a/src/storage/io/file_system.cppm b/src/storage/io/file_system.cppm index 215bf103ea..5d7bc6272e 100644 --- a/src/storage/io/file_system.cppm +++ b/src/storage/io/file_system.cppm @@ -25,7 +25,7 @@ export class FileSystem; export class FileHandler { public: - FileHandler(FileSystem &file_system, String path) : file_system_(file_system), path_(Move(path)) {} + FileHandler(FileSystem &file_system, String path) : file_system_(file_system), path_(std::move(path)) {} FileHandler(const FileHandler &) = delete; diff --git a/src/storage/io/file_writer.cpp b/src/storage/io/file_writer.cpp index df5570a30f..bb899b0df5 100644 --- a/src/storage/io/file_writer.cpp +++ b/src/storage/io/file_writer.cpp @@ -70,8 +70,8 @@ void FileWriter::Write(const char_t *buffer, SizeT bytes_count) { while (start_pos < end_pos) { i64 byte_count1 = end_pos - start_pos; i64 byte_count2 = buffer_size_ - offset_; - i64 to_write = Min(byte_count1, byte_count2); - Memcpy(data_.get() + offset_, start_pos, to_write); + i64 to_write = std::min(byte_count1, byte_count2); + std::memcpy(data_.get() + offset_, start_pos, to_write); offset_ += to_write; start_pos += to_write; if (offset_ == buffer_size_) { diff --git a/src/storage/io/local_file_system.cpp b/src/storage/io/local_file_system.cpp index 01b18bd780..fd00b55200 100644 --- a/src/storage/io/local_file_system.cpp +++ b/src/storage/io/local_file_system.cpp @@ -38,7 +38,7 @@ LocalFileHandler::~LocalFileHandler() { if (fd_ != -1) { int ret = close(fd_); if (ret != 0) { - Error(Format("Close file failed: {}", strerror(errno))); + Error(fmt::format("Close file failed: {}", strerror(errno))); } fd_ = -1; } @@ -78,7 +78,7 @@ UniquePtr LocalFileSystem::OpenFile(const String &path, u8 flags, F i32 fd = open(path.c_str(), file_flags, 0666); if (fd == -1) { - Error(Format("Can't open file: {}: {}", path, strerror(errno))); + Error(fmt::format("Can't open file: {}: {}", path, strerror(errno))); } if (lock_type != FileLockType::kNoLock) { @@ -93,7 +93,7 @@ UniquePtr LocalFileSystem::OpenFile(const String &path, u8 flags, F file_lock.l_start = 0; file_lock.l_len = 0; if (fcntl(fd, F_SETLK, &file_lock) == -1) { - Error(Format("Can't lock file: {}: {}", path, strerror(errno))); + Error(fmt::format("Can't lock file: {}: {}", path, strerror(errno))); } } return MakeUnique(*this, path, fd); @@ -105,13 +105,13 @@ void LocalFileSystem::Close(FileHandler &file_handler) { // set fd to -1 so that destructor of `LocalFileHandler` will not close the file. local_file_handler->fd_ = -1; if (close(fd) != 0) { - Error(Format("Can't close file: {}: {}", file_handler.path_.string(), strerror(errno))); + Error(fmt::format("Can't close file: {}: {}", file_handler.path_.string(), strerror(errno))); } } void LocalFileSystem::Rename(const String &old_path, const String &new_path) { if (rename(old_path.c_str(), new_path.c_str()) != 0) { - Error(Format("Can't rename file: {}, {}", old_path, strerror(errno))); + Error(fmt::format("Can't rename file: {}, {}", old_path, strerror(errno))); } } @@ -119,7 +119,7 @@ i64 LocalFileSystem::Read(FileHandler &file_handler, void *data, u64 nbytes) { i32 fd = ((LocalFileHandler &)file_handler).fd_; i64 read_count = read(fd, data, nbytes); if (read_count == -1) { - Error(Format("Can't read file: {}: {}", file_handler.path_.string(), strerror(errno))); + Error(fmt::format("Can't read file: {}: {}", file_handler.path_.string(), strerror(errno))); } return read_count; } @@ -128,7 +128,7 @@ i64 LocalFileSystem::Write(FileHandler &file_handler, const void *data, u64 nbyt i32 fd = ((LocalFileHandler &)file_handler).fd_; i64 write_count = write(fd, data, nbytes); if (write_count == -1) { - Error(Format("Can't write file: {}: {}. fd: {}", file_handler.path_.string(), strerror(errno), fd)); + Error(fmt::format("Can't write file: {}: {}. fd: {}", file_handler.path_.string(), strerror(errno), fd)); } return write_count; } @@ -136,7 +136,7 @@ i64 LocalFileSystem::Write(FileHandler &file_handler, const void *data, u64 nbyt void LocalFileSystem::Seek(FileHandler &file_handler, i64 pos) { i32 fd = ((LocalFileHandler &)file_handler).fd_; if (0 != lseek(fd, pos, SEEK_SET)) { - Error(Format("Can't seek file: {}: {}", file_handler.path_.string(), strerror(errno))); + Error(fmt::format("Can't seek file: {}: {}", file_handler.path_.string(), strerror(errno))); } } @@ -155,17 +155,17 @@ void LocalFileSystem::DeleteFile(const String &file_name) { bool is_deleted = std::filesystem::remove(p, error_code); if (error_code.value() == 0) { if (!is_deleted) { - Error(Format("Can't delete file: {}: {}", file_name, strerror(errno))); + Error(fmt::format("Can't delete file: {}: {}", file_name, strerror(errno))); } } else { - Error(Format("Delete file {} exception: {}", file_name, strerror(errno))); + Error(fmt::format("Delete file {} exception: {}", file_name, strerror(errno))); } } void LocalFileSystem::SyncFile(FileHandler &file_handler) { i32 fd = ((LocalFileHandler &)file_handler).fd_; if (fsync(fd) != 0) { - Error(Format("fsync failed: {}, {}", file_handler.path_.string(), strerror(errno))); + Error(fmt::format("fsync failed: {}, {}", file_handler.path_.string(), strerror(errno))); } } @@ -177,7 +177,7 @@ bool LocalFileSystem::Exists(const String &path) { if (error_code.value() == 0) { return is_exists; } else { - Error(Format("{} exists exception: {}", path, strerror(errno))); + Error(fmt::format("{} exists exception: {}", path, strerror(errno))); } return false; } @@ -193,7 +193,7 @@ void LocalFileSystem::CreateDirectory(const String &path) { Path p{path}; std::filesystem::create_directories(p, error_code); if (error_code.value() != 0) { - Error(Format("{} create exception: {}", path, strerror(errno))); + Error(fmt::format("{} create exception: {}", path, strerror(errno))); } } @@ -202,7 +202,7 @@ u64 LocalFileSystem::DeleteDirectory(const String &path) { Path p{path}; u64 removed_count = std::filesystem::remove_all(p, error_code); if (error_code.value() != 0) { - Error(Format("Delete directory {} exception: {}", path, error_code.message())); + Error(fmt::format("Delete directory {} exception: {}", path, error_code.message())); } return removed_count; } @@ -210,7 +210,7 @@ u64 LocalFileSystem::DeleteDirectory(const String &path) { Vector> LocalFileSystem::ListDirectory(const String &path) { Path dir_path(path); if (!is_directory(dir_path)) { - Error(Format("{} isn't a directory", path)); + Error(fmt::format("{} isn't a directory", path)); } Vector> file_array; diff --git a/src/storage/io/local_file_system.cppm b/src/storage/io/local_file_system.cppm index 80fe7f99fc..f3999e4b0b 100644 --- a/src/storage/io/local_file_system.cppm +++ b/src/storage/io/local_file_system.cppm @@ -24,7 +24,7 @@ namespace infinity { export class LocalFileHandler : public FileHandler { public: - LocalFileHandler(FileSystem &file_system, String path, i32 fd) : FileHandler(file_system, Move(path)), fd_(fd) {} + LocalFileHandler(FileSystem &file_system, String path, i32 fd) : FileHandler(file_system, std::move(path)), fd_(fd) {} ~LocalFileHandler() override; diff --git a/src/storage/io/write_buffer.cpp b/src/storage/io/write_buffer.cpp index 16fc828a27..ff2bfeb4fd 100644 --- a/src/storage/io/write_buffer.cpp +++ b/src/storage/io/write_buffer.cpp @@ -25,14 +25,14 @@ module write_buffer; namespace infinity { SizeT WriteBuffer::WriteTo(char *to, SizeT n) { - n = Min(n, Count()); + n = std::min(n, Count()); SizeT bytes_copied = 0; Buffer working_buffer = Buffer(0, 0); Container::iterator chunk = chunk_list_.begin(); while (bytes_copied < n) { working_buffer = *chunk; - SizeT bytes_to_copy = Min(static_cast(working_buffer.Size()), n - bytes_copied); - Memcpy(to + bytes_copied, working_buffer.Begin(), bytes_to_copy); + SizeT bytes_to_copy = std::min(static_cast(working_buffer.Size()), n - bytes_copied); + std::memcpy(to + bytes_copied, working_buffer.Begin(), bytes_to_copy); bytes_copied += bytes_to_copy; chunk = std::next(chunk); } @@ -49,8 +49,8 @@ void WriteBuffer::Write(const char *from, SizeT n) { while (bytes_copied < n) { NextIfAtEnd(); - SizeT bytes_to_copy = Min(static_cast(working_buffer_.End() - pos_), n - bytes_copied); - Memcpy(pos_, from + bytes_copied, bytes_to_copy); + SizeT bytes_to_copy = std::min(static_cast(working_buffer_.End() - pos_), n - bytes_copied); + std::memcpy(pos_, from + bytes_copied, bytes_to_copy); pos_ += bytes_to_copy; bytes_copied += bytes_to_copy; } diff --git a/src/storage/io/write_buffer.cppm b/src/storage/io/write_buffer.cppm index 143c82d4ca..e7cf6fbdb4 100644 --- a/src/storage/io/write_buffer.cppm +++ b/src/storage/io/write_buffer.cppm @@ -31,7 +31,7 @@ export class WriteBuffer : public BufferBase { const double growth_rate_; const SizeT max_chunk_size_; - using Container = ForwardList; + using Container = std::forward_list; Container chunk_list_; Container::iterator chunk_tail_; @@ -158,8 +158,8 @@ private: chunk_tail_ = chunk_list_.before_begin(); next_chunk_size = initial_chunk_size_; } else { - next_chunk_size = Max(1ul, static_cast(chunk_tail_->Size() * growth_rate_)); - next_chunk_size = Min(next_chunk_size, max_chunk_size_); + next_chunk_size = std::max(1ul, static_cast(chunk_tail_->Size() * growth_rate_)); + next_chunk_size = std::min(next_chunk_size, max_chunk_size_); } if (max_total_size_) { diff --git a/src/storage/knnindex/ann_ivf/ann_ivf_flat.cppm b/src/storage/knnindex/ann_ivf/ann_ivf_flat.cppm index 4ccf3ecc16..b017609047 100644 --- a/src/storage/knnindex/ann_ivf/ann_ivf_flat.cppm +++ b/src/storage/knnindex/ann_ivf/ann_ivf_flat.cppm @@ -93,7 +93,7 @@ public: if (!begin_) { Error("IVFFlat isn't begin"); } - n_probes = Min(n_probes, base_ivf->partition_num_); + n_probes = std::min(n_probes, base_ivf->partition_num_); if ((n_probes == 0) || (base_ivf->data_num_ == 0)) { return; } @@ -155,7 +155,7 @@ public: if (!begin_) { Error("IVFFlat isn't begin"); } - n_probes = Min(n_probes, base_ivf->partition_num_); + n_probes = std::min(n_probes, base_ivf->partition_num_); if ((n_probes == 0) || (base_ivf->data_num_ == 0)) { return; } diff --git a/src/storage/knnindex/ann_ivf/search_top_1_sgemm.cppm b/src/storage/knnindex/ann_ivf/search_top_1_sgemm.cppm index dc4ca5ce6c..39cdb4ff2b 100644 --- a/src/storage/knnindex/ann_ivf/search_top_1_sgemm.cppm +++ b/src/storage/knnindex/ann_ivf/search_top_1_sgemm.cppm @@ -41,7 +41,7 @@ void search_top_1_with_sgemm(u32 dimension, distances_holder = MakeUniqueForOverwrite(nx); distances = distances_holder.get(); } - std::fill_n(distances, nx, LimitMax()); + std::fill_n(distances, nx, std::numeric_limits::max()); auto square_x = MakeUniqueForOverwrite(nx); auto square_y = MakeUniqueForOverwrite(ny); auto x_y_inner_product_buffer = MakeUniqueForOverwrite(block_size_x * block_size_y); diff --git a/src/storage/knnindex/ann_ivf/search_top_k.cppm b/src/storage/knnindex/ann_ivf/search_top_k.cppm index 7abe2723cd..7c95876467 100644 --- a/src/storage/knnindex/ann_ivf/search_top_k.cppm +++ b/src/storage/knnindex/ann_ivf/search_top_k.cppm @@ -32,7 +32,7 @@ namespace infinity { template void search_top_1_simple_with_dis(u32 dimension, u32 nx, const TypeX *x, u32 ny, const TypeY *y, ID *labels, DistType *distances) { for (u32 i = 0; i < nx; ++i) { - DistType min_dist = LimitMax(); + DistType min_dist = std::numeric_limits::max(); u32 min_idx = 0; for (u32 j = 0; j < ny; ++j) { DistType dist = L2Distance(x + i * dimension, y + j * dimension, dimension); @@ -58,7 +58,7 @@ void search_top_1_with_dis(u32 dimension, u32 nx, const TypeX *x, u32 ny, const template void search_top_1_simple_without_dis(u32 dimension, u32 nx, const TypeX *x, u32 ny, const TypeY *y, ID *labels) { for (u32 i = 0; i < nx; ++i) { - DistType min_dist = LimitMax(); + DistType min_dist = std::numeric_limits::max(); u32 min_idx = 0; for (u32 j = 0; j < ny; ++j) { DistType dist = L2Distance(x + i * dimension, y + j * dimension, dimension); diff --git a/src/storage/knnindex/knn_flat/knn_flat_l2_blas.cppm b/src/storage/knnindex/knn_flat/knn_flat_l2_blas.cppm index efd0b0d327..7c14143aa6 100644 --- a/src/storage/knnindex/knn_flat/knn_flat_l2_blas.cppm +++ b/src/storage/knnindex/knn_flat/knn_flat_l2_blas.cppm @@ -176,7 +176,7 @@ public: *ip_line = dis; } else { - *ip_line = LimitMax(); + *ip_line = std::numeric_limits::max(); } ip_line++; } diff --git a/src/storage/knnindex/knn_flat/knn_flat_l2_blas_reservoir.cppm b/src/storage/knnindex/knn_flat/knn_flat_l2_blas_reservoir.cppm index fbe040d531..e0915a3d0c 100644 --- a/src/storage/knnindex/knn_flat/knn_flat_l2_blas_reservoir.cppm +++ b/src/storage/knnindex/knn_flat/knn_flat_l2_blas_reservoir.cppm @@ -176,7 +176,7 @@ public: *ip_line = dis; } else { - *ip_line = LimitMax(); + *ip_line = std::numeric_limits::max(); } ip_line++; } diff --git a/src/storage/knnindex/knn_flat/knn_flat_l2_top1_blas.cppm b/src/storage/knnindex/knn_flat/knn_flat_l2_top1_blas.cppm index 36e3c3f765..f10de46444 100644 --- a/src/storage/knnindex/knn_flat/knn_flat_l2_top1_blas.cppm +++ b/src/storage/knnindex/knn_flat/knn_flat_l2_top1_blas.cppm @@ -177,7 +177,7 @@ public: *ip_line = dis; } else { - *ip_line = LimitMax(); + *ip_line = std::numeric_limits::max(); } ip_line++; } diff --git a/src/storage/knnindex/knn_hnsw/graph_store.cppm b/src/storage/knnindex/knn_hnsw/graph_store.cppm index 712d3b794a..f4e6a35ff5 100644 --- a/src/storage/knnindex/knn_hnsw/graph_store.cppm +++ b/src/storage/knnindex/knn_hnsw/graph_store.cppm @@ -109,7 +109,7 @@ private: void Init() { max_layer_ = -1; enterpoint_ = -1; - Fill(graph_, graph_ + max_vertex_num_ * level0_size_, 0); + std::fill(graph_, graph_ + max_vertex_num_ * level0_size_, 0); // for (VertexType vertex_i = 0; vertex_i < max_vertex_num_; ++vertex_i) { // VertexL0Mut vertex = GetLevel0Mut(vertex_i); // *vertex.GetNeighbors().second = 0; @@ -246,7 +246,7 @@ public: for (VertexType vertex_i = 0; vertex_i < cur_vertex_n; ++vertex_i) { VertexL0 vertex = GetLevel0(vertex_i); int cur_max_layer = vertex.GetLayers().second; - max_layer = Max(cur_max_layer, max_layer); + max_layer = std::max(cur_max_layer, max_layer); assert(cur_max_layer >= 0 && cur_max_layer <= max_layer_); auto [neighbors, neighbor_n] = vertex.GetNeighbors(); assert(neighbor_n <= int(Mmax0)); diff --git a/src/storage/knnindex/knn_hnsw/hnsw_alg.cppm b/src/storage/knnindex/knn_hnsw/hnsw_alg.cppm index 9f3d63a7a1..fa0c0d6823 100644 --- a/src/storage/knnindex/knn_hnsw/hnsw_alg.cppm +++ b/src/storage/knnindex/knn_hnsw/hnsw_alg.cppm @@ -72,8 +72,8 @@ private: Distance distance_; const UniquePtr labels_; - Mutex global_mutex_; - mutable Vector vertex_mutex_; + std::mutex global_mutex_; + mutable Vector vertex_mutex_; private: KnnHnsw(SizeT M, @@ -86,12 +86,12 @@ private: UniquePtr labels, SizeT ef, SizeT random_seed) - : M_(M), Mmax_(Mmax), Mmax0_(Mmax0), ef_construction_(Max(M_, ef_construction)), // + : M_(M), Mmax_(Mmax), Mmax0_(Mmax0), ef_construction_(std::max(M_, ef_construction)), // mult_(1 / std::log(1.0 * M_)), // - data_store_(Move(data_store)), // - graph_store_(Move(graph_store)), // - distance_(Move(distance)), // - labels_(Move(labels)), // + data_store_(std::move(data_store)), // + graph_store_(std::move(graph_store)), // + distance_(std::move(distance)), // + labels_(std::move(labels)), // vertex_mutex_(data_store_.max_vec_num()) { if (ef == 0) { ef = ef_construction_; @@ -105,16 +105,16 @@ private: public: static UniquePtr Make(SizeT max_vertex, SizeT dim, SizeT M, SizeT ef_construction, DataStore::InitArgs args) { auto [Mmax, Mmax0] = This::GetMmax(M); - auto data_store = DataStore::Make(max_vertex, dim, Move(args)); + auto data_store = DataStore::Make(max_vertex, dim, std::move(args)); auto graph_store = GraphStore::Make(max_vertex, Mmax, Mmax0); Distance distance(data_store.dim()); return UniquePtr(new This(M, Mmax, Mmax0, ef_construction, - Move(data_store), - Move(graph_store), - Move(distance), + std::move(data_store), + std::move(graph_store), + std::move(distance), MakeUnique(max_vertex), 0, 0)); @@ -159,9 +159,9 @@ private: break; } - SharedLock lock; + std::shared_lock lock; if constexpr (WithLock) { - lock = SharedLock(vertex_mutex_[c_idx]); + lock = std::shared_lock(vertex_mutex_[c_idx]); } const auto [neighbors_p, neighbor_size] = graph_store_.GetNeighbors(c_idx, layer_idx); @@ -173,7 +173,7 @@ private: } visited[n_idx] = true; if (prefetch_start >= 0) { - int lower = Max(0, prefetch_start - prefetch_step_); + int lower = std::max(0, prefetch_start - prefetch_step_); for (int i = prefetch_start; i >= lower; --i) { data_store_.Prefetch(neighbors_p[i]); } @@ -189,7 +189,7 @@ private: } } result_handler.EndWithoutSort(); - return {result_handler.GetSize(0), Move(d_ptr), Move(i_ptr)}; + return {result_handler.GetSize(0), std::move(d_ptr), std::move(i_ptr)}; } template @@ -200,9 +200,9 @@ private: while (check) { check = false; - SharedLock lock; + std::shared_lock lock; if constexpr (WithLock) { - lock = SharedLock(vertex_mutex_[cur_p]); + lock = std::shared_lock(vertex_mutex_[cur_p]); } const auto [neighbors_p, neighbor_size] = graph_store_.GetNeighbors(cur_p, layer_idx); @@ -257,9 +257,9 @@ private: for (int i = 0; i < q_neighbor_size; ++i) { VertexType n_idx = q_neighbors_p[i]; - UniqueLock lock; + std::unique_lock lock; if constexpr (WithLock) { - lock = UniqueLock(vertex_mutex_[n_idx]); + lock = std::unique_lock(vertex_mutex_[n_idx]); } auto [n_neighbors_p, n_neighbor_size_p] = graph_store_.GetNeighborsMut(n_idx, layer_idx); @@ -280,7 +280,7 @@ private: candidates.emplace_back(distance_(n_data, data_store_.GetVec(n_neighbors_p[i]), data_store_), n_neighbors_p[i]); } - SelectNeighborsHeuristic(Move(candidates), Mmax, n_neighbors_p, n_neighbor_size_p); // write in memory + SelectNeighborsHeuristic(std::move(candidates), Mmax, n_neighbors_p, n_neighbor_size_p); // write in memory } } @@ -310,7 +310,7 @@ public: if (ret == DataStore::ERR_IDX) { Error("Data index is not enough."); } - std::copy(labels, labels + insert_n, labels_.get() + ret); + Copy(labels, labels + insert_n, labels_.get() + ret); return ret; } @@ -322,9 +322,9 @@ public: template void Build(VertexType vertex_i) { - UniqueLock global_lock; + std::unique_lock global_lock; if constexpr (WithLock) { - global_lock = UniqueLock(global_mutex_); + global_lock = std::unique_lock(global_mutex_); } i32 q_layer = GenerateRandomLayer(); @@ -335,9 +335,9 @@ public: } } - UniqueLock lock; + std::unique_lock lock; if constexpr (WithLock) { - lock = UniqueLock(vertex_mutex_[vertex_i]); + lock = std::unique_lock(vertex_mutex_[vertex_i]); } StoreType query = data_store_.GetVec(vertex_i); @@ -347,7 +347,7 @@ public: for (i32 cur_layer = max_layer; cur_layer > q_layer; --cur_layer) { ep = SearchLayerNearest(ep, query, cur_layer); } - for (i32 cur_layer = Min(q_layer, max_layer); cur_layer >= 0; --cur_layer) { + for (i32 cur_layer = std::min(q_layer, max_layer); cur_layer >= 0; --cur_layer) { auto [result_n, d_ptr, v_ptr] = SearchLayer(ep, query, cur_layer, ef_construction_, None); auto search_result = Vector(result_n); for (SizeT i = 0; i < result_n; ++i) { @@ -355,7 +355,7 @@ public: } const auto [q_neighbors_p, q_neighbor_size_p] = graph_store_.GetNeighborsMut(vertex_i, cur_layer); - SelectNeighborsHeuristic(Move(search_result), M_, q_neighbors_p, q_neighbor_size_p); + SelectNeighborsHeuristic(std::move(search_result), M_, q_neighbors_p, q_neighbor_size_p); ep = q_neighbors_p[0]; ConnectNeighbors(vertex_i, q_neighbors_p, *q_neighbor_size_p, cur_layer); } @@ -368,7 +368,7 @@ public: for (i32 cur_layer = graph_store_.max_layer(); cur_layer > 0; --cur_layer) { ep = SearchLayerNearest(ep, query, cur_layer); } - return SearchLayer(ep, query, 0, Max(k, ef_), bitmask); + return SearchLayer(ep, query, 0, std::max(k, ef_), bitmask); } // function for test @@ -410,7 +410,7 @@ public: auto labels = MakeUnique(data_store.cur_vec_num()); file_handler.Read(labels.get(), sizeof(LabelType) * data_store.cur_vec_num()); - return UniquePtr(new This(M, Mmax, Mmax0, ef_construction, Move(data_store), Move(graph_store), Move(distance), Move(labels), 0, 0)); + return UniquePtr(new This(M, Mmax, Mmax0, ef_construction, std::move(data_store), std::move(graph_store), std::move(distance), std::move(labels), 0, 0)); } //---------------------------------------------- Following is the tmp debug function. ---------------------------------------------- diff --git a/src/storage/knnindex/knn_hnsw/lvq_store.cppm b/src/storage/knnindex/knn_hnsw/lvq_store.cppm index c76548b693..79c4f4c910 100644 --- a/src/storage/knnindex/knn_hnsw/lvq_store.cppm +++ b/src/storage/knnindex/knn_hnsw/lvq_store.cppm @@ -45,7 +45,7 @@ public: static constexpr SizeT PADDING_SIZE = 32; private: - constexpr static SizeT max_bucket_idx_ = LimitMax() - LimitMin(); // 255 for i8 + constexpr static SizeT max_bucket_idx_ = std::numeric_limits::max() - std::numeric_limits::min(); // 255 for i8 // Decompress: Q = scale * C + bias + Mean using ScalarType = DataType; // type for scale and bias @@ -114,7 +114,7 @@ public: private: LVQStore(DataStoreMeta meta, This::InitArgs init_args) - : meta_(Move(meta)), // + : meta_(std::move(meta)), // compress_data_offset_(AlignTo(mean_offset_ + dim() * sizeof(MeanType), PADDING_SIZE)), // compress_data_size_(AlignTo(compress_vec_offset_ + sizeof(CompressType) * dim(), PADDING_SIZE)), // ptr_(static_cast(operator new[](compress_data_offset_ + compress_data_size_ * max_vec_num(), std::align_val_t(PADDING_SIZE)))), // @@ -124,14 +124,14 @@ private: void Init() { // MeanType *mean = GetMeanMut(); - // Fill(mean, mean + dim(), 0); - Fill(ptr_, ptr_ + compress_data_offset_ + compress_data_size_ * max_vec_num(), 0); + // std::fill(mean, mean + dim(), 0); + std::fill(ptr_, ptr_ + compress_data_offset_ + compress_data_size_ * max_vec_num(), 0); } public: static This Make(SizeT max_vec_num, SizeT dim, This::InitArgs init_args) { DataStoreMeta meta(max_vec_num, dim); - auto ret = This(Move(meta), Move(init_args)); + auto ret = This(std::move(meta), std::move(init_args)); ret.Init(); return ret; } @@ -141,12 +141,12 @@ public: LVQStore &operator=(This &&other) = delete; LVQStore(This &&other) - : meta_(Move(other.meta_)), // + : meta_(std::move(other.meta_)), // compress_data_offset_(other.compress_data_size_), // compress_data_size_(other.compress_data_offset_), // ptr_(other.ptr_), // buffer_plain_size_(other.buffer_plain_size_), // - plain_data_(Move(other.plain_data_)) // + plain_data_(std::move(other.plain_data_)) // { const_cast(other.ptr_) = nullptr; } @@ -165,7 +165,7 @@ public: static This Load(FileHandler &file_handler, SizeT max_vec_num, This::InitArgs init_args) { DataStoreMeta meta = DataStoreMeta::Load(file_handler, max_vec_num); - auto ret = This(Move(meta), Move(init_args)); + auto ret = This(std::move(meta), std::move(init_args)); file_handler.Read(ret.ptr_, ret.compress_data_offset_ + ret.compress_data_size_ * ret.cur_vec_num()); return ret; } @@ -187,22 +187,22 @@ private: auto [scale_p, bias_p] = lvq.GetScalarMut(); CompressType *compress = lvq.GetCompressVecMut(); - ScalarType lower = LimitMax(); - ScalarType upper = -LimitMax(); + ScalarType lower = std::numeric_limits::max(); + ScalarType upper = -std::numeric_limits::max(); for (SizeT j = 0; j < dim(); ++j) { auto x = static_cast(vec[j] - mean[j]); - lower = Min(lower, x); - upper = Max(upper, x); + lower = std::min(lower, x); + upper = std::max(upper, x); } ScalarType scale = (upper - lower) / max_bucket_idx_; - ScalarType bias = lower - LimitMin() * scale; + ScalarType bias = lower - std::numeric_limits::min() * scale; if (scale == 0) { - Fill(compress, compress + dim(), 0); + std::fill(compress, compress + dim(), 0); } else { ScalarType scale_inv = 1 / scale; for (SizeT j = 0; j < dim(); ++j) { auto c = std::floor((vec[j] - mean[j] - bias) * scale_inv + 0.5); - if(!(c <= LimitMax() && c >= LimitMin())) { + if(!(c <= std::numeric_limits::max() && c >= std::numeric_limits::min())) { Error("CompressVec error"); } compress[j] = c; @@ -262,7 +262,7 @@ private: ++vec_i; } *GetGlobalCacheMut() = LVQCache::MakeGlobalCache(GetMean(), dim()); - plain_data_ = PlainStore::Make(Min(buffer_plain_size_, max_vec_num() - cur_vec_num()), dim()); + plain_data_ = PlainStore::Make(std::min(buffer_plain_size_, max_vec_num() - cur_vec_num()), dim()); return cur_vec_num() - vec_num; } @@ -274,7 +274,7 @@ public: SizeT AddVec(Iterator query_iter, SizeT vec_num) { if (SizeT idx = plain_data_.AddVec(query_iter, vec_num); idx != DataStoreMeta::ERR_IDX) { return meta_.cur_vec_num() + idx; - } else if (SizeT idx = MergeCompress(Move(query_iter), vec_num); idx != DataStoreMeta::ERR_IDX) { + } else if (SizeT idx = MergeCompress(std::move(query_iter), vec_num); idx != DataStoreMeta::ERR_IDX) { return idx; } else { return ERR_IDX; @@ -299,7 +299,7 @@ public: QueryType MakeQuery(const DataType *vec) const { auto ptr = MakeUnique(compress_data_size_); CompressVec(vec, LVQData(ptr.get())); - return QueryType{Move(ptr)}; + return QueryType{std::move(ptr)}; } void Compress() { diff --git a/src/storage/knnindex/knn_hnsw/memory_pool.cppm b/src/storage/knnindex/knn_hnsw/memory_pool.cppm index 61d87b2e65..d1f307c26b 100644 --- a/src/storage/knnindex/knn_hnsw/memory_pool.cppm +++ b/src/storage/knnindex/knn_hnsw/memory_pool.cppm @@ -49,7 +49,7 @@ class PooledType { public: PooledType(MemPoolT *pool, Args... args) : pool_(pool), functor_(F(args...)) {} - PooledType(PooledType &&other) : pool_(other.pool_), data_(Move(other.data_)), functor_(Move(other.functor_)) { other.pool_ = nullptr; } + PooledType(PooledType &&other) : pool_(other.pool_), data_(std::move(other.data_)), functor_(std::move(other.functor_)) { other.pool_ = nullptr; } PooledType(const PooledType &) = delete; PooledType &operator=(const PooledType &) = delete; @@ -58,7 +58,7 @@ public: ~PooledType() { if (pool_) { functor_.Release(data_); - pool_->Release(Move(data_)); + pool_->Release(std::move(data_)); } } @@ -87,7 +87,7 @@ public: private: friend class PooledType; - void Release(typename F::DataT data) { pool_.Enqueue(Move(data)); } + void Release(typename F::DataT data) { pool_.Enqueue(std::move(data)); } }; // -------------- implement concept below ---------------- diff --git a/src/storage/knnindex/knn_hnsw/plain_store.cppm b/src/storage/knnindex/knn_hnsw/plain_store.cppm index e768be65fe..1999e92179 100644 --- a/src/storage/knnindex/knn_hnsw/plain_store.cppm +++ b/src/storage/knnindex/knn_hnsw/plain_store.cppm @@ -40,15 +40,15 @@ private: public: static This Make(SizeT max_vec_num, SizeT dim, This::InitArgs = {}) { DataStoreMeta data_store(max_vec_num, dim); - return This(Move(data_store)); + return This(std::move(data_store)); } - PlainStore(DataStoreMeta meta) : meta_(Move(meta)), ptr_(MakeUnique(meta_.max_vec_num_ * meta_.dim_)) {} + PlainStore(DataStoreMeta meta) : meta_(std::move(meta)), ptr_(MakeUnique(meta_.max_vec_num_ * meta_.dim_)) {} - PlainStore(This &&other) : meta_(Move(other.meta_)), ptr_(Move(const_cast &>(other.ptr_))) {} + PlainStore(This &&other) : meta_(std::move(other.meta_)), ptr_(std::move(const_cast &>(other.ptr_))) {} PlainStore &operator=(This &&other) { - meta_ = Move(other.meta_); - const_cast &>(ptr_) = Move(const_cast &>(other.ptr_)); + meta_ = std::move(other.meta_); + const_cast &>(ptr_) = std::move(const_cast &>(other.ptr_)); return *this; } @@ -61,7 +61,7 @@ public: static This Load(FileHandler &file_handler, SizeT max_vec_num, This::InitArgs = {}) { DataStoreMeta meta = DataStoreMeta::Load(file_handler, max_vec_num); - This ret(Move(meta)); + This ret(std::move(meta)); file_handler.Read(ret.ptr_.get(), sizeof(DataType) * ret.cur_vec_num() * ret.dim()); return ret; } diff --git a/src/storage/knnindex/result_handler.cppm b/src/storage/knnindex/result_handler.cppm index 0eb34b5852..c6726bed38 100644 --- a/src/storage/knnindex/result_handler.cppm +++ b/src/storage/knnindex/result_handler.cppm @@ -34,7 +34,7 @@ struct CompareMin { using CompareReverse = CompareMax; static bool Compare(DistanceType a, DistanceType b) { return a < b; } static bool Compare(DistanceType a, DistanceType b, IDType i, IDType j) { return (a < b) || ((a == b) && (i > j)); } - static constexpr DistanceType InitialValue() { return LimitLowest(); } + static constexpr DistanceType InitialValue() { return std::numeric_limits::lowest(); } static constexpr bool IsMax = false; }; @@ -45,7 +45,7 @@ struct CompareMax { using CompareReverse = CompareMin; static bool Compare(DistanceType a, DistanceType b) { return a > b; } static bool Compare(DistanceType a, DistanceType b, IDType i, IDType j) { return (a > b) || ((a == b) && (i > j)); } - static constexpr DistanceType InitialValue() { return LimitMax(); } + static constexpr DistanceType InitialValue() { return std::numeric_limits::max(); } static constexpr bool IsMax = true; }; @@ -110,7 +110,7 @@ public: [[nodiscard]] u32 GetSize(SizeT q_id) const { return sizes[q_id]; } - void ReInitialize() { Fill(sizes.begin(), sizes.end(), 0); } + void ReInitialize() { std::fill(sizes.begin(), sizes.end(), 0); } void AddResult(SizeT q_id, DistType d, ID i) { u32 &size = sizes[q_id]; @@ -277,14 +277,14 @@ public: auto &min_distance = this->distance_ptr[i]; auto &min_index = this->id_ptr[i]; auto tmp_min_distance = min_distance; - auto tmp_min_j = LimitMax(); + auto tmp_min_j = std::numeric_limits::max(); for (u32 j = j0; j < j1; ++j) { if (const DistType distance = dis_tab_i[j]; Compare::Compare(tmp_min_distance, distance)) { tmp_min_distance = distance; tmp_min_j = j; } } - if (tmp_min_j != LimitMax()) { + if (tmp_min_j != std::numeric_limits::max()) { min_distance = tmp_min_distance; min_index = RowID(segment_id, segment_offset_start + tmp_min_j); } @@ -443,8 +443,8 @@ public: void Begin() {} void ReInitialize() { - Fill(sizes.begin(), sizes.end(), 0); - Fill(thresholds.begin(), thresholds.end(), Compare::InitialValue()); + std::fill(sizes.begin(), sizes.end(), 0); + std::fill(thresholds.begin(), thresholds.end(), Compare::InitialValue()); } [[nodiscard]] DistType GetThreshold(SizeT q_id) const { return thresholds[q_id]; } diff --git a/src/storage/meta/base_meta.cpp b/src/storage/meta/base_meta.cpp index 5e5fb5565c..ae2607874b 100644 --- a/src/storage/meta/base_meta.cpp +++ b/src/storage/meta/base_meta.cpp @@ -86,7 +86,7 @@ BaseMeta::EntryStatus BaseMeta::AddEntryInternal(u64 txn_id, TxnTimeStamp begin_ } void BaseMeta::DeleteNewEntry(BaseMeta *meta, u64 txn_id, TxnManager *txn_mgr) { - UniqueLock w_locker(meta->rw_locker_); + std::unique_lock w_locker(meta->rw_locker_); if (meta->entry_list_.empty()) { LOG_TRACE("Attempt to delete not existed entry."); return; @@ -101,12 +101,12 @@ void BaseMeta::DeleteNewEntry(BaseMeta *meta, u64 txn_id, TxnManager *txn_mgr) { } Status BaseMeta::GetEntry(BaseMeta *meta, u64 txn_id, TxnTimeStamp begin_ts, BaseEntry*& base_entry) { - SharedLock r_locker(meta->rw_locker_); + std::shared_lock r_locker(meta->rw_locker_); for (const auto &entry : meta->entry_list_) { if (entry->entry_type_ == EntryType::kDummy) { UniquePtr err_msg = MakeUnique("No valid entry"); LOG_ERROR(*err_msg); - return Status(ErrorCode::kNotFound, Move(err_msg)); + return Status(ErrorCode::kNotFound, std::move(err_msg)); } if (entry->commit_ts_ < UNCOMMIT_TS) { @@ -115,7 +115,7 @@ Status BaseMeta::GetEntry(BaseMeta *meta, u64 txn_id, TxnTimeStamp begin_ts, Bas if (entry->deleted_) { UniquePtr err_msg = MakeUnique("No valid entry"); LOG_ERROR(*err_msg); - return Status(ErrorCode::kNotFound, Move(err_msg)); + return Status(ErrorCode::kNotFound, std::move(err_msg)); } else { base_entry = entry.get(); return Status::OK(); @@ -129,7 +129,7 @@ Status BaseMeta::GetEntry(BaseMeta *meta, u64 txn_id, TxnTimeStamp begin_ts, Bas } UniquePtr err_msg = MakeUnique("No valid entry"); LOG_ERROR(*err_msg); - return Status(ErrorCode::kNotFound, Move(err_msg)); + return Status(ErrorCode::kNotFound, std::move(err_msg)); } } // namespace infinity diff --git a/src/storage/meta/catalog.cpp b/src/storage/meta/catalog.cpp index b8e81f02cf..64b41c60ad 100644 --- a/src/storage/meta/catalog.cpp +++ b/src/storage/meta/catalog.cpp @@ -42,7 +42,7 @@ import data_access_state; namespace infinity { -NewCatalog::NewCatalog(SharedPtr dir, bool create_default_db) : current_dir_(Move(dir)) { +NewCatalog::NewCatalog(SharedPtr dir, bool create_default_db) : current_dir_(std::move(dir)) { if (create_default_db) { // db current dir is same level as catalog Path catalog_path(*this->current_dir_); @@ -51,10 +51,10 @@ NewCatalog::NewCatalog(SharedPtr dir, bool create_default_db) : current_ UniquePtr db_meta = MakeUnique(data_dir, MakeShared("default")); UniquePtr db_entry = MakeUnique(db_meta->data_dir(), db_meta->db_name(), 0, 0); db_entry->commit_ts_ = 0; - DBMeta::AddEntry(db_meta.get(), Move(db_entry)); + DBMeta::AddEntry(db_meta.get(), std::move(db_entry)); this->rw_locker_.lock(); - this->databases_["default"] = Move(db_meta); + this->databases_["default"] = std::move(db_meta); this->rw_locker_.unlock(); } } @@ -78,7 +78,7 @@ NewCatalog::CreateDatabase(const String &db_name, u64 txn_id, TxnTimeStamp begin } else { this->rw_locker_.unlock_shared(); - LOG_TRACE(Format("Create new database: {}", db_name)); + LOG_TRACE(fmt::format("Create new database: {}", db_name)); // Not find the db and create new db meta Path catalog_path(*this->current_dir_); Path parent_path = catalog_path.parent_path(); @@ -89,14 +89,14 @@ NewCatalog::CreateDatabase(const String &db_name, u64 txn_id, TxnTimeStamp begin this->rw_locker_.lock(); auto db_iter2 = this->databases_.find(db_name); if (db_iter2 == this->databases_.end()) { - this->databases_[db_name] = Move(new_db_meta); + this->databases_[db_name] = std::move(new_db_meta); } else { db_meta = db_iter2->second.get(); } this->rw_locker_.unlock(); } - LOG_TRACE(Format("Add new database entry: {}", db_name)); + LOG_TRACE(fmt::format("Add new database entry: {}", db_name)); return db_meta->CreateNewEntry(txn_id, begin_ts, txn_mgr, conflict_type); } @@ -114,12 +114,12 @@ Tuple NewCatalog::DropDatabase(const String &db_name, u64 txn } this->rw_locker_.unlock_shared(); if (db_meta == nullptr) { - UniquePtr err_msg = MakeUnique(Format("Attempt to drop not existed database entry {}", db_name)); + UniquePtr err_msg = MakeUnique(fmt::format("Attempt to drop not existed database entry {}", db_name)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } - LOG_TRACE(Format("Drop a database entry {}", db_name)); + LOG_TRACE(fmt::format("Drop a database entry {}", db_name)); return db_meta->DropNewEntry(txn_id, begin_ts, txn_mgr); } @@ -133,9 +133,9 @@ Tuple NewCatalog::GetDatabase(const String &db_name, u64 txn_ } this->rw_locker_.unlock_shared(); if (db_meta == nullptr) { - UniquePtr err_msg = MakeUnique(Format("Attempt to get not existed database {}", db_name)); + UniquePtr err_msg = MakeUnique(fmt::format("Attempt to get not existed database {}", db_name)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } return db_meta->GetEntry(txn_id, begin_ts); } @@ -149,7 +149,7 @@ void NewCatalog::RemoveDBEntry(const String &db_name, u64 txn_id, TxnManager *tx } this->rw_locker_.unlock_shared(); - LOG_TRACE(Format("Remove a database entry {}", db_name)); + LOG_TRACE(fmt::format("Remove a database entry {}", db_name)); db_meta->DeleteNewEntry(txn_id, txn_mgr); } @@ -178,7 +178,7 @@ Tuple NewCatalog::CreateTable(const String &db_name, auto [db_entry, status] = this->GetDatabase(db_name, txn_id, begin_ts); if (!status.ok()) { // Error - LOG_ERROR(Format("Database: {} is invalid.", db_name)); + LOG_ERROR(fmt::format("Database: {} is invalid.", db_name)); return {nullptr, status}; } @@ -194,7 +194,7 @@ Tuple NewCatalog::DropTableByName(const String &db_name, auto [db_entry, status] = this->GetDatabase(db_name, txn_id, begin_ts); if (!status.ok()) { // Error - LOG_ERROR(Format("Database: {} is invalid.", db_name)); + LOG_ERROR(fmt::format("Database: {} is invalid.", db_name)); return {nullptr, status}; } return db_entry->DropTable(table_name, conflict_type, txn_id, begin_ts, txn_mgr); @@ -205,7 +205,7 @@ Status NewCatalog::GetTables(const String &db_name, Vector &output_ auto [db_entry, status] = this->GetDatabase(db_name, txn_id, begin_ts); if (!status.ok()) { // Error - LOG_ERROR(Format("Database: {} is invalid.", db_name)); + LOG_ERROR(fmt::format("Database: {} is invalid.", db_name)); return status; } return db_entry->GetTablesDetail(txn_id, begin_ts, output_table_array); @@ -216,7 +216,7 @@ Tuple NewCatalog::GetTableByName(const String &db_name, co auto [db_entry, status] = this->GetDatabase(db_name, txn_id, begin_ts); if (!status.ok()) { // Error - LOG_ERROR(Format("Database: {} is invalid.", db_name)); + LOG_ERROR(fmt::format("Database: {} is invalid.", db_name)); return {nullptr, status}; } @@ -225,7 +225,7 @@ Tuple NewCatalog::GetTableByName(const String &db_name, co Status NewCatalog::RemoveTableEntry(TableEntry *table_entry, u64 txn_id, TxnManager *txn_mgr) { TableMeta *table_meta = table_entry->GetTableMeta(); - LOG_TRACE(Format("Remove a table/collection entry: {}", *table_entry->GetTableName())); + LOG_TRACE(fmt::format("Remove a table/collection entry: {}", *table_entry->GetTableName())); table_meta->DeleteNewEntry(txn_id, txn_mgr); return Status::OK(); @@ -240,7 +240,7 @@ Tuple NewCatalog::CreateIndex(const Str TxnManager *txn_mgr) { auto [table_entry, table_status] = GetTableByName(db_name, table_name, txn_id, begin_ts); if (!table_status.ok()) { - LOG_ERROR(Format("Database: {}, Table: {} is invalid", db_name, table_name)); + LOG_ERROR(fmt::format("Database: {}, Table: {} is invalid", db_name, table_name)); return {nullptr, nullptr, table_status}; } @@ -258,7 +258,7 @@ Tuple NewCatalog::DropIndex(const String &db_name, TxnManager *txn_mgr) { auto [table_entry, table_status] = GetTableByName(db_name, table_name, txn_id, begin_ts); if (!table_status.ok()) { - LOG_ERROR(Format("Database: {}, Table: {} is invalid", db_name, table_name)); + LOG_ERROR(fmt::format("Database: {}, Table: {} is invalid", db_name, table_name)); return {nullptr, table_status}; } @@ -316,7 +316,7 @@ u32 NewCatalog::GetNextSegmentID(TableEntry *table_entry) { return TableEntry::G u32 NewCatalog::GetMaxSegmentID(const TableEntry *table_entry) { return TableEntry::GetMaxSegmentID(table_entry); } void NewCatalog::ImportSegment(TableEntry *table_entry, u32 segment_id, SharedPtr &segment_entry) { - table_entry->segment_map_.emplace(segment_id, Move(segment_entry)); + table_entry->segment_map_.emplace(segment_id, std::move(segment_entry)); // ATTENTION: focusing on the segment id table_entry->next_segment_id_++; } @@ -328,7 +328,7 @@ SharedPtr NewCatalog::GetFunctionSetByName(NewCatalog *catalog, Str StringToLower(function_name); if (!catalog->function_sets_.contains(function_name)) { - Error(Format("No function name: {}", function_name)); + Error(fmt::format("No function name: {}", function_name)); } return catalog->function_sets_[function_name]; } @@ -337,7 +337,7 @@ void NewCatalog::AddFunctionSet(NewCatalog *catalog, const SharedPtrname(); StringToLower(name); if (catalog->function_sets_.contains(name)) { - Error(Format("Trying to add duplicated function table_name into catalog: {}", name)); + Error(fmt::format("Trying to add duplicated function table_name into catalog: {}", name)); } catalog->function_sets_.emplace(name, function_set); } @@ -346,7 +346,7 @@ void NewCatalog::DeleteFunctionSet(NewCatalog *catalog, String function_name) { // Unused now. StringToLower(function_name); if (!catalog->function_sets_.contains(function_name)) { - Error(Format("Delete not exist function: {}", function_name)); + Error(fmt::format("Delete not exist function: {}", function_name)); } catalog->function_sets_.erase(function_name); } @@ -355,7 +355,7 @@ void NewCatalog::DeleteFunctionSet(NewCatalog *catalog, String function_name) { SharedPtr NewCatalog::GetTableFunctionByName(NewCatalog *catalog, String function_name) { StringToLower(function_name); if (!catalog->table_functions_.contains(function_name)) { - Error(Format("No table function table_name: {}", function_name)); + Error(fmt::format("No table function table_name: {}", function_name)); } return catalog->table_functions_[function_name]; } @@ -364,7 +364,7 @@ void NewCatalog::AddTableFunction(NewCatalog *catalog, const SharedPtrname(); StringToLower(name); if (catalog->table_functions_.contains(name)) { - Error(Format("Trying to add duplicated table function into catalog: {}", name)); + Error(fmt::format("Trying to add duplicated table function into catalog: {}", name)); } catalog->table_functions_.emplace(name, table_function); } @@ -373,7 +373,7 @@ void NewCatalog::AddSpecialFunction(NewCatalog *catalog, const SharedPtrname(); StringToLower(name); if (catalog->table_functions_.contains(name)) { - Error(Format("Trying to add duplicated special function into catalog: {}", name)); + Error(fmt::format("Trying to add duplicated special function into catalog: {}", name)); } catalog->special_functions_.emplace(name, special_function); } @@ -390,16 +390,16 @@ void NewCatalog::DeleteTableFunction(NewCatalog *catalog, String function_name) // Unused now. StringToLower(function_name); if (!catalog->table_functions_.contains(function_name)) { - Error(Format("Delete not exist table function: {}", function_name)); + Error(fmt::format("Delete not exist table function: {}", function_name)); } catalog->table_functions_.erase(function_name); } -Json NewCatalog::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { - Json json_res; +nlohmann::json NewCatalog::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { + nlohmann::json json_res; Vector databases; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json_res["current_dir"] = *this->current_dir_; json_res["next_txn_id"] = this->next_txn_id_; json_res["catalog_version"] = this->catalog_version_; @@ -443,12 +443,12 @@ UniquePtr NewCatalog::LoadFromFiles(const Vector &catalog_pa Error("Catalog paths is empty"); } // Load the latest full checkpoint. - LOG_INFO(Format("Load base catalog1 from: {}", catalog_paths[0])); + LOG_INFO(fmt::format("Load base catalog1 from: {}", catalog_paths[0])); catalog1 = NewCatalog::LoadFromFile(catalog_paths[0], buffer_mgr); // Load catalogs delta checkpoints and merge. for (SizeT i = 1; i < catalog_paths.size(); i++) { - LOG_INFO(Format("Load delta catalog1 from: {}", catalog_paths[i])); + LOG_INFO(fmt::format("Load delta catalog1 from: {}", catalog_paths[i])); UniquePtr catalog2 = NewCatalog::LoadFromFile(catalog_paths[i], buffer_mgr); catalog1->MergeFrom(*catalog2); } @@ -461,7 +461,7 @@ void NewCatalog::MergeFrom(NewCatalog &other) { for (auto &[db_name, db_meta2] : other.databases_) { auto it = this->databases_.find(db_name); if (it == this->databases_.end()) { - this->databases_.emplace(db_name, Move(db_meta2)); + this->databases_.emplace(db_name, std::move(db_meta2)); } else { it->second->MergeFrom(*db_meta2.get()); } @@ -476,15 +476,15 @@ UniquePtr NewCatalog::LoadFromFile(const String &catalog_path, Buffe String json_str(file_size, 0); SizeT nbytes = catalog_file_handler->Read(json_str.data(), file_size); if (file_size != nbytes) { - Error(Format("Catalog file {}, read error.", catalog_path)); + Error(fmt::format("Catalog file {}, read error.", catalog_path)); } - Json catalog_json = Json::parse(json_str); + nlohmann::json catalog_json = nlohmann::json::parse(json_str); Deserialize(catalog_json, buffer_mgr, catalog); return catalog; } -void NewCatalog::Deserialize(const Json &catalog_json, BufferManager *buffer_mgr, UniquePtr &catalog) { +void NewCatalog::Deserialize(const nlohmann::json &catalog_json, BufferManager *buffer_mgr, UniquePtr &catalog) { SharedPtr current_dir = MakeShared(catalog_json["current_dir"]); // FIXME: new catalog need a scheduler, current we use nullptr to represent it. @@ -494,13 +494,13 @@ void NewCatalog::Deserialize(const Json &catalog_json, BufferManager *buffer_mgr if (catalog_json.contains("databases")) { for (const auto &db_json : catalog_json["databases"]) { UniquePtr db_meta = DBMeta::Deserialize(db_json, buffer_mgr); - catalog->databases_.emplace(*db_meta->db_name(), Move(db_meta)); + catalog->databases_.emplace(*db_meta->db_name(), std::move(db_meta)); } } } String NewCatalog::SaveAsFile(const String &dir, TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { - Json catalog_json = Serialize(max_commit_ts, is_full_checkpoint); + nlohmann::json catalog_json = Serialize(max_commit_ts, is_full_checkpoint); String catalog_str = catalog_json.dump(); // FIXME: Temp implementation, will be replaced by async task. @@ -510,12 +510,12 @@ String NewCatalog::SaveAsFile(const String &dir, TxnTimeStamp max_commit_ts, boo fs.CreateDirectory(dir); } - String file_name = Format("META_{}", max_commit_ts); + String file_name = fmt::format("META_{}", max_commit_ts); if (is_full_checkpoint) file_name += ".full.json"; else file_name += ".delta.json"; - String file_path = Format("{}/{}", dir, file_name); + String file_path = fmt::format("{}/{}", dir, file_name); u8 fileflags = FileFlags::WRITE_FLAG; if (!fs.Exists(file_path)) { @@ -527,12 +527,12 @@ String NewCatalog::SaveAsFile(const String &dir, TxnTimeStamp max_commit_ts, boo // TODO: Save as a temp filename, then rename it to the real filename. SizeT nbytes = catalog_file_handler->Write(catalog_str.data(), catalog_str.size()); if (nbytes != catalog_str.size()) { - Error(Format("Catalog file {}, saving error.", file_path)); + Error(fmt::format("Catalog file {}, saving error.", file_path)); } catalog_file_handler->Sync(); catalog_file_handler->Close(); - LOG_INFO(Format("Saved catalog to: {}", file_path)); + LOG_INFO(fmt::format("Saved catalog to: {}", file_path)); return file_path; } diff --git a/src/storage/meta/catalog.cppm b/src/storage/meta/catalog.cppm index cb039ab910..d4d4686ee5 100644 --- a/src/storage/meta/catalog.cppm +++ b/src/storage/meta/catalog.cppm @@ -54,7 +54,7 @@ namespace infinity { class ProfileHistory { private: - Mutex lock_{}; + std::mutex lock_{}; Vector> queue{}; SizeT front{}; SizeT rear{}; @@ -69,7 +69,7 @@ public: } void Enqueue(SharedPtr &&profiler) { - UniqueLock lk(lock_); + std::unique_lock lk(lock_); if ((rear + 1) % max_size == front) { return; } @@ -78,7 +78,7 @@ public: } QueryProfiler *GetElement(SizeT index) { - UniqueLock lk(lock_); + std::unique_lock lk(lock_); // FIXME: Bug, unsigned integer: index will always >= 0 if (index < 0 || index >= (rear - front + max_size) % max_size) { @@ -92,7 +92,7 @@ public: Vector> elements; elements.reserve(max_size); - UniqueLock lk(lock_); + std::unique_lock lk(lock_); for (SizeT i = 0; i < queue.size(); ++i) { if (queue[i].get() != nullptr) { elements.push_back(queue[i]); @@ -213,13 +213,13 @@ public: public: // Serialization and Deserialization - Json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); String SaveAsFile(const String &dir, TxnTimeStamp max_commit_ts, bool is_full_checkpoint); void MergeFrom(NewCatalog &other); - static void Deserialize(const Json &catalog_json, BufferManager *buffer_mgr, UniquePtr &catalog); + static void Deserialize(const nlohmann::json &catalog_json, BufferManager *buffer_mgr, UniquePtr &catalog); static UniquePtr LoadFromFiles(const Vector &catalog_paths, BufferManager *buffer_mgr); @@ -228,7 +228,7 @@ public: public: // Profile related methods - void AppendProfilerRecord(SharedPtr profiler) { history.Enqueue(Move(profiler)); } + void AppendProfilerRecord(SharedPtr profiler) { history.Enqueue(std::move(profiler)); } const QueryProfiler *GetProfilerRecord(SizeT index) { return history.GetElement(index); } @@ -239,7 +239,7 @@ public: HashMap> databases_{}; u64 next_txn_id_{}; u64 catalog_version_{}; - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; // Currently, these function or function set can't be changed and also will not be persistent. HashMap> function_sets_{}; diff --git a/src/storage/meta/db_meta.cpp b/src/storage/meta/db_meta.cpp index bef12df3a9..24a4fe2720 100644 --- a/src/storage/meta/db_meta.cpp +++ b/src/storage/meta/db_meta.cpp @@ -33,19 +33,19 @@ import infinity_exception; namespace infinity { Tuple DBMeta::CreateNewEntry(u64 txn_id, TxnTimeStamp begin_ts, TxnManager *txn_mgr, ConflictType conflic_type) { - UniqueLock rw_locker(this->rw_locker_); + std::unique_lock rw_locker(this->rw_locker_); DBEntry *db_entry_ptr{nullptr}; // rw_locker_.lock(); if (this->entry_list_.empty()) { // Insert a dummy entry. UniquePtr dummy_entry = MakeUnique(EntryType::kDummy); dummy_entry->deleted_ = true; - this->entry_list_.emplace_back(Move(dummy_entry)); + this->entry_list_.emplace_back(std::move(dummy_entry)); // Insert the new db entry UniquePtr db_entry = MakeUnique(this->data_dir_, this->db_name_, txn_id, begin_ts); db_entry_ptr = db_entry.get(); - this->entry_list_.emplace_front(Move(db_entry)); + this->entry_list_.emplace_front(std::move(db_entry)); LOG_TRACE("New database entry is added."); return {db_entry_ptr, Status::OK()}; @@ -55,7 +55,7 @@ Tuple DBMeta::CreateNewEntry(u64 txn_id, TxnTimeStamp begin_t if (header_base_entry->entry_type_ == EntryType::kDummy) { UniquePtr db_entry = MakeUnique(this->data_dir_, this->db_name_, txn_id, begin_ts); db_entry_ptr = db_entry.get(); - this->entry_list_.emplace_front(Move(db_entry)); + this->entry_list_.emplace_front(std::move(db_entry)); return {db_entry_ptr, Status::OK()}; } @@ -66,7 +66,7 @@ Tuple DBMeta::CreateNewEntry(u64 txn_id, TxnTimeStamp begin_t // No conflict UniquePtr db_entry = MakeUnique(this->data_dir_, this->db_name_, txn_id, begin_ts); db_entry_ptr = db_entry.get(); - this->entry_list_.emplace_front(Move(db_entry)); + this->entry_list_.emplace_front(std::move(db_entry)); return {db_entry_ptr, Status::OK()}; } else { switch (conflic_type) { @@ -76,18 +76,18 @@ Tuple DBMeta::CreateNewEntry(u64 txn_id, TxnTimeStamp begin_t } default: { // Duplicated database - UniquePtr err_msg = MakeUnique(Format("Duplicated database name: {}.", *this->db_name_)); + UniquePtr err_msg = MakeUnique(fmt::format("Duplicated database name: {}.", *this->db_name_)); LOG_ERROR(*err_msg); - return {db_entry_ptr, Status(ErrorCode::kDuplicate, Move(err_msg))}; + return {db_entry_ptr, Status(ErrorCode::kDuplicate, std::move(err_msg))}; } } } } else { // Write-Write conflict UniquePtr err_msg = - MakeUnique(Format("Write-write conflict: There is a committed database which is later than current transaction.")); + MakeUnique(fmt::format("Write-write conflict: There is a committed database which is later than current transaction.")); LOG_ERROR(*err_msg); - return {db_entry_ptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {db_entry_ptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } else { @@ -101,26 +101,26 @@ Tuple DBMeta::CreateNewEntry(u64 txn_id, TxnTimeStamp begin_t if (header_db_entry->deleted_) { UniquePtr db_entry = MakeUnique(this->data_dir_, this->db_name_, txn_id, begin_ts); db_entry_ptr = db_entry.get(); - this->entry_list_.emplace_front(Move(db_entry)); + this->entry_list_.emplace_front(std::move(db_entry)); return {db_entry_ptr, Status::OK()}; } else { - UniquePtr err_msg = MakeUnique(Format("Duplicated database name: {}.", *this->db_name_)); + UniquePtr err_msg = MakeUnique(fmt::format("Duplicated database name: {}.", *this->db_name_)); LOG_ERROR(*err_msg); - return {db_entry_ptr, Status(ErrorCode::kDuplicate, Move(err_msg))}; + return {db_entry_ptr, Status(ErrorCode::kDuplicate, std::move(err_msg))}; } } else { - UniquePtr err_msg = MakeUnique(Format("Write-write conflict: There is a uncommitted transaction.")); + UniquePtr err_msg = MakeUnique(fmt::format("Write-write conflict: There is a uncommitted transaction.")); LOG_ERROR(*err_msg); - return {db_entry_ptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {db_entry_ptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } case TxnState::kCommitting: case TxnState::kCommitted: { // Committing / Committed, report WW conflict and rollback current txn UniquePtr err_msg = MakeUnique( - Format("Write-write conflict: There is a committing/committed database which is later than current transaction.")); + fmt::format("Write-write conflict: There is a committing/committed database which is later than current transaction.")); LOG_ERROR(*err_msg); - return {db_entry_ptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {db_entry_ptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } case TxnState::kRollbacking: case TxnState::kRollbacked: { @@ -130,13 +130,13 @@ Tuple DBMeta::CreateNewEntry(u64 txn_id, TxnTimeStamp begin_t // Append new one UniquePtr db_entry = MakeUnique(this->data_dir_, this->db_name_, txn_id, begin_ts); db_entry_ptr = db_entry.get(); - this->entry_list_.emplace_front(Move(db_entry)); + this->entry_list_.emplace_front(std::move(db_entry)); return {db_entry_ptr, Status::OK()}; } default: { UniquePtr err_msg = MakeUnique("Invalid db entry txn state"); LOG_ERROR(*err_msg); - return {db_entry_ptr, Status(ErrorCode::kUndefined, Move(err_msg))}; + return {db_entry_ptr, Status(ErrorCode::kUndefined, std::move(err_msg))}; } } } @@ -146,18 +146,18 @@ Tuple DBMeta::CreateNewEntry(u64 txn_id, TxnTimeStamp begin_t Tuple DBMeta::DropNewEntry(u64 txn_id, TxnTimeStamp begin_ts, TxnManager *) { DBEntry *db_entry_ptr{nullptr}; - UniqueLock rw_locker(this->rw_locker_); + std::unique_lock rw_locker(this->rw_locker_); if (this->entry_list_.empty()) { UniquePtr err_msg = MakeUnique("Empty db entry list."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } BaseEntry *header_base_entry = this->entry_list_.front().get(); if (header_base_entry->entry_type_ == EntryType::kDummy) { UniquePtr err_msg = MakeUnique("No valid db entry."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } DBEntry *header_db_entry = (DBEntry *)header_base_entry; @@ -167,13 +167,13 @@ Tuple DBMeta::DropNewEntry(u64 txn_id, TxnTimeStamp begin_ts, if (header_db_entry->deleted_) { UniquePtr err_msg = MakeUnique("DB is dropped before."); LOG_TRACE(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } UniquePtr db_entry = MakeUnique(this->data_dir_, this->db_name_, txn_id, begin_ts); db_entry_ptr = db_entry.get(); db_entry_ptr->deleted_ = true; - this->entry_list_.emplace_front(Move(db_entry)); + this->entry_list_.emplace_front(std::move(db_entry)); return {db_entry_ptr, Status::OK()}; } else { @@ -181,7 +181,7 @@ Tuple DBMeta::DropNewEntry(u64 txn_id, TxnTimeStamp begin_ts, UniquePtr err_msg = MakeUnique("Write-write conflict: There is a committed database which is later than current transaction."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } else { // Uncommitted, check if the same txn @@ -195,18 +195,18 @@ Tuple DBMeta::DropNewEntry(u64 txn_id, TxnTimeStamp begin_ts, // Not same txn, issue WW conflict UniquePtr err_msg = MakeUnique("Write-write conflict: There is another uncommitted db entry."); LOG_ERROR(*err_msg); - return {db_entry_ptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {db_entry_ptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } } void DBMeta::AddEntry(DBMeta *db_meta, UniquePtr db_entry) { - UniqueLock rw_locker(db_meta->rw_locker_); - db_meta->entry_list_.emplace_front(Move(db_entry)); + std::unique_lock rw_locker(db_meta->rw_locker_); + db_meta->entry_list_.emplace_front(std::move(db_entry)); } void DBMeta::DeleteNewEntry(u64 txn_id, TxnManager *) { - UniqueLock rw_locker(this->rw_locker_); + std::unique_lock rw_locker(this->rw_locker_); if (this->entry_list_.empty()) { LOG_TRACE("Empty db entry list."); return; @@ -219,18 +219,18 @@ void DBMeta::DeleteNewEntry(u64 txn_id, TxnManager *) { } Tuple DBMeta::GetEntry(u64 txn_id, TxnTimeStamp begin_ts) { - SharedLock r_locker(this->rw_locker_); + std::shared_lock r_locker(this->rw_locker_); if (this->entry_list_.empty()) { UniquePtr err_msg = MakeUnique("Empty db entry list."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } for (const auto &db_entry : this->entry_list_) { if (db_entry->entry_type_ == EntryType::kDummy) { UniquePtr err_msg = MakeUnique("No valid db entry."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } if (db_entry->Committed()) { @@ -238,7 +238,7 @@ Tuple DBMeta::GetEntry(u64 txn_id, TxnTimeStamp begin_ts) { if (db_entry->deleted_) { UniquePtr err_msg = MakeUnique("DB is dropped."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } else { // check the tables meta return {(DBEntry*)(db_entry.get()), Status::OK()}; @@ -251,7 +251,7 @@ Tuple DBMeta::GetEntry(u64 txn_id, TxnTimeStamp begin_ts) { if (db_entry->deleted_) { UniquePtr err_msg = MakeUnique("DB is dropped."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } else { return {(DBEntry*)(db_entry.get()), Status::OK()}; } @@ -260,21 +260,21 @@ Tuple DBMeta::GetEntry(u64 txn_id, TxnTimeStamp begin_ts) { } UniquePtr err_msg = MakeUnique("No db entry found."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } SharedPtr DBMeta::ToString() { - SharedLock r_locker(this->rw_locker_); + std::shared_lock r_locker(this->rw_locker_); SharedPtr res = MakeShared( - Format("DBMeta, data_dir: {}, db name: {}, entry count: ", *this->data_dir_, *this->db_name_, this->entry_list_.size())); + fmt::format("DBMeta, data_dir: {}, db name: {}, entry count: ", *this->data_dir_, *this->db_name_, this->entry_list_.size())); return res; } -Json DBMeta::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { - Json json_res; +nlohmann::json DBMeta::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { + nlohmann::json json_res; Vector db_candidates; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json_res["data_dir"] = *this->data_dir_; json_res["db_name"] = *this->db_name_; // Need to find the full history of the entry till given timestamp. Note that GetEntry returns at most one valid entry at given timestamp. @@ -292,7 +292,7 @@ Json DBMeta::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { return json_res; } -UniquePtr DBMeta::Deserialize(const Json &db_meta_json, BufferManager *buffer_mgr) { +UniquePtr DBMeta::Deserialize(const nlohmann::json &db_meta_json, BufferManager *buffer_mgr) { SharedPtr data_dir = MakeShared(db_meta_json["data_dir"]); SharedPtr db_name = MakeShared(db_meta_json["db_name"]); UniquePtr res = MakeUnique(data_dir, db_name); diff --git a/src/storage/meta/db_meta.cppm b/src/storage/meta/db_meta.cppm index 7284af1cea..3f2912d39f 100644 --- a/src/storage/meta/db_meta.cppm +++ b/src/storage/meta/db_meta.cppm @@ -31,13 +31,13 @@ export struct DBMeta { friend struct NewCatalog; public: - explicit DBMeta(const SharedPtr &data_dir, SharedPtr name) : db_name_(Move(name)), data_dir_(data_dir) {} + explicit DBMeta(const SharedPtr &data_dir, SharedPtr name) : db_name_(std::move(name)), data_dir_(data_dir) {} SharedPtr ToString(); - Json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); - static UniquePtr Deserialize(const Json &db_meta_json, BufferManager *buffer_mgr); + static UniquePtr Deserialize(const nlohmann::json &db_meta_json, BufferManager *buffer_mgr); void MergeFrom(DBMeta &other); @@ -65,7 +65,7 @@ private: SharedPtr db_name_{}; SharedPtr data_dir_{}; - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; // Ordered by commit_ts from latest to oldest. List> entry_list_{}; }; diff --git a/src/storage/meta/entry/base_entry.cpp b/src/storage/meta/entry/base_entry.cpp index b0dc2355cc..e595ac1e1d 100644 --- a/src/storage/meta/entry/base_entry.cpp +++ b/src/storage/meta/entry/base_entry.cpp @@ -39,7 +39,7 @@ void MergeLists(List> &list1, List> &l if ((*it1)->commit_ts_ > (*it2)->commit_ts_) { ++it1; } else if ((*it1)->commit_ts_ < (*it2)->commit_ts_) { - list1.insert(it1, Move(*it2)); + list1.insert(it1, std::move(*it2)); ++it2; } else { (*it1)->MergeFrom(**it2); @@ -51,7 +51,7 @@ void MergeLists(List> &list1, List> &l while(it2 != list2.end()) { if ((*it2)->entry_type_ != EntryType::kDummy) { - list1.insert(it1, Move(*it2)); + list1.insert(it1, std::move(*it2)); } ++it2; } diff --git a/src/storage/meta/entry/block_column_entry.cpp b/src/storage/meta/entry/block_column_entry.cpp index 29130dbb7e..fdbaa8be6a 100644 --- a/src/storage/meta/entry/block_column_entry.cpp +++ b/src/storage/meta/entry/block_column_entry.cpp @@ -41,7 +41,7 @@ UniquePtr BlockColumnEntry::MakeNewBlockColumnEntry(const BlockEntry *block_entry, u64 column_id, BufferManager *buffer_manager, bool is_replay) { UniquePtr block_column_entry = MakeUnique(block_entry, column_id, block_entry->base_dir()); - block_column_entry->file_name_ = MakeShared(ToStr(column_id) + ".col"); + block_column_entry->file_name_ = MakeShared(std::to_string(column_id) + ".col"); block_column_entry->column_type_ = block_entry->GetColumnType(column_id); DataType *column_type = block_column_entry->column_type_.get(); @@ -51,9 +51,9 @@ BlockColumnEntry::MakeNewBlockColumnEntry(const BlockEntry *block_entry, u64 col auto file_worker = MakeUnique(block_column_entry->base_dir_, block_column_entry->file_name_, total_data_size); if (!is_replay) { - block_column_entry->buffer_ = buffer_manager->Allocate(Move(file_worker)); + block_column_entry->buffer_ = buffer_manager->Allocate(std::move(file_worker)); } else { - block_column_entry->buffer_ = buffer_manager->Get(Move(file_worker)); + block_column_entry->buffer_ = buffer_manager->Get(std::move(file_worker)); } if (block_column_entry->column_type_->type() == kVarchar) { @@ -67,7 +67,7 @@ ColumnBuffer BlockColumnEntry::GetColumnData(BufferManager *buffer_manager) { if (this->buffer_ == nullptr) { // Get buffer handle from buffer manager auto file_worker = MakeUnique(this->base_dir_, this->file_name_, 0); - this->buffer_ = buffer_manager->Get(Move(file_worker)); + this->buffer_ = buffer_manager->Get(std::move(file_worker)); } bool outline = this->column_type_->type() == kVarchar; @@ -126,7 +126,7 @@ void BlockColumnEntry::AppendRaw(SizeT dst_offset, const_ptr_t src_p, SizeT data case kFloat: case kDouble: case kEmbedding: { - Memcpy(dst_p, src_p, data_size); + std::memcpy(dst_p, src_p, data_size); break; } case kVarchar: { @@ -139,12 +139,12 @@ void BlockColumnEntry::AppendRaw(SizeT dst_offset, const_ptr_t src_p, SizeT data if (varchar_type->IsInlined()) { auto &short_info = varchar_layout->u.short_info_; varchar_layout->length_ = varchar_type->length_; - Memcpy(short_info.data.data(), varchar_type->short_.data_, varchar_type->length_); + std::memcpy(short_info.data.data(), varchar_type->short_.data_, varchar_type->length_); } else { auto &long_info = varchar_layout->u.long_info_; auto outline_info = this->outline_info_.get(); - auto base_file_size = - Min(DEFAULT_BASE_FILE_SIZE * Pow(DEFAULT_BASE_NUM, outline_info->next_file_idx), DEFAULT_OUTLINE_FILE_MAX_SIZE); + auto base_file_size = std::min(SizeT(DEFAULT_BASE_FILE_SIZE * std::pow(DEFAULT_BASE_NUM, outline_info->next_file_idx)), + DEFAULT_OUTLINE_FILE_MAX_SIZE); if (outline_info->written_buffers_.empty() || outline_info->written_buffers_.back().second + varchar_type->length_ > base_file_size) { @@ -153,9 +153,9 @@ void BlockColumnEntry::AppendRaw(SizeT dst_offset, const_ptr_t src_p, SizeT data auto file_worker = MakeUnique(this->base_dir_, file_name, - DEFAULT_BASE_NUM * Max(base_file_size, static_cast(varchar_type->length_))); + DEFAULT_BASE_NUM * std::max(base_file_size, static_cast(varchar_type->length_))); - BufferObj *buffer_obj = outline_info->buffer_mgr_->Allocate(Move(file_worker)); + BufferObj *buffer_obj = outline_info->buffer_mgr_->Allocate(std::move(file_worker)); outline_info->written_buffers_.emplace_back(buffer_obj, 0); } auto &[current_buffer_obj, current_buffer_offset] = outline_info->written_buffers_.back(); @@ -164,7 +164,7 @@ void BlockColumnEntry::AppendRaw(SizeT dst_offset, const_ptr_t src_p, SizeT data if (varchar_type->IsValue()) { u32 outline_data_size = varchar_type->length_; ptr_t outline_src_ptr = varchar_type->value_.ptr_; - Memcpy(outline_dst_ptr, outline_src_ptr, outline_data_size); + std::memcpy(outline_dst_ptr, outline_src_ptr, outline_data_size); } else { vector_buffer->fix_heap_mgr_->ReadFromHeap(outline_dst_ptr, varchar_type->vector_.chunk_id_, @@ -173,7 +173,7 @@ void BlockColumnEntry::AppendRaw(SizeT dst_offset, const_ptr_t src_p, SizeT data } varchar_layout->length_ = varchar_type->length_; - Memcpy(long_info.prefix_.data(), varchar_type->value_.prefix_, VARCHAR_PREFIX_LEN); + std::memcpy(long_info.prefix_.data(), varchar_type->value_.prefix_, VARCHAR_PREFIX_LEN); long_info.file_idx_ = outline_info->next_file_idx - 1; long_info.file_offset_ = current_buffer_offset; current_buffer_offset += varchar_type->length_; @@ -248,19 +248,19 @@ void BlockColumnEntry::Flush(BlockColumnEntry *block_column_entry, SizeT) { // case kBlob: case kMixed: case kNull: { - LOG_ERROR(Format("{} isn't supported", column_type->ToString())); + LOG_ERROR(fmt::format("{} isn't supported", column_type->ToString())); Error("Invalid data type."); } case kMissing: case kInvalid: { - LOG_ERROR(Format("Invalid data type {}", column_type->ToString())); + LOG_ERROR(fmt::format("Invalid data type {}", column_type->ToString())); Error("Invalid data type."); } } } -Json BlockColumnEntry::Serialize() { - Json json_res; +nlohmann::json BlockColumnEntry::Serialize() { + nlohmann::json json_res; json_res["column_id"] = this->column_id_; if (this->outline_info_) { auto &outline_info = this->outline_info_; @@ -269,7 +269,8 @@ Json BlockColumnEntry::Serialize() { return json_res; } -UniquePtr BlockColumnEntry::Deserialize(const Json &column_data_json, BlockEntry *block_entry, BufferManager *buffer_mgr) { +UniquePtr +BlockColumnEntry::Deserialize(const nlohmann::json &column_data_json, BlockEntry *block_entry, BufferManager *buffer_mgr) { u64 column_id = column_data_json["column_id"]; UniquePtr block_column_entry = MakeNewBlockColumnEntry(block_entry, column_id, buffer_mgr, true); if (block_column_entry->outline_info_.get() != nullptr) { @@ -286,7 +287,7 @@ Vector BlockColumnEntry::OutlinePaths() const { for (SizeT i = 0; i < outline_info_->next_file_idx; ++i) { auto outline_file = BlockColumnEntry::OutlineFilename(column_id_, i); - outline_paths.push_back(Move(LocalFileSystem::ConcatenateFilePath(*base_dir_, *outline_file))); + outline_paths.push_back(LocalFileSystem::ConcatenateFilePath(*base_dir_, *outline_file)); } } return outline_paths; diff --git a/src/storage/meta/entry/block_column_entry.cppm b/src/storage/meta/entry/block_column_entry.cppm index d4837a8415..aac839acdb 100644 --- a/src/storage/meta/entry/block_column_entry.cppm +++ b/src/storage/meta/entry/block_column_entry.cppm @@ -45,9 +45,9 @@ public: inline explicit BlockColumnEntry(const BlockEntry *block_entry, u64 column_id, const SharedPtr &base_dir_ref) : BaseEntry(EntryType::kBlockColumn), block_entry_(block_entry), column_id_(column_id), base_dir_(base_dir_ref) {} - Json Serialize(); + nlohmann::json Serialize(); - static UniquePtr Deserialize(const Json &column_data_json, BlockEntry *block_entry, BufferManager *buffer_mgr); + static UniquePtr Deserialize(const nlohmann::json &column_data_json, BlockEntry *block_entry, BufferManager *buffer_mgr); public: // Getter @@ -58,7 +58,7 @@ public: inline const BlockEntry *block_entry() const { return block_entry_; } static SharedPtr OutlineFilename(u64 column_id, SizeT file_idx) { - return MakeShared(Format("col_{}_out_{}", column_id, file_idx)); + return MakeShared(fmt::format("col_{}_out_{}", column_id, file_idx)); } String FilePath() { return LocalFileSystem::ConcatenateFilePath(*base_dir_, *file_name_); } diff --git a/src/storage/meta/entry/block_entry.cpp b/src/storage/meta/entry/block_entry.cpp index cf61de7b1a..7b995121e6 100644 --- a/src/storage/meta/entry/block_entry.cpp +++ b/src/storage/meta/entry/block_entry.cpp @@ -62,7 +62,7 @@ i32 BlockVersion::GetRowCount(TxnTimeStamp begin_ts) { void BlockVersion::LoadFromFile(const String &version_path) { std::ifstream ifs(version_path); if (!ifs.is_open()) { - LOG_WARN(Format("Failed to open block_version file: {}", version_path)); + LOG_WARN(fmt::format("Failed to open block_version file: {}", version_path)); // load the block_version file not exist return and create version return; } @@ -75,9 +75,9 @@ void BlockVersion::LoadFromFile(const String &version_path) { int32_t deleted_size = ReadBufAdv(ptr); created_.resize(created_size); deleted_.resize(deleted_size); - Memcpy(created_.data(), ptr, created_size * sizeof(CreateField)); + std::memcpy(created_.data(), ptr, created_size * sizeof(CreateField)); ptr += created_size * sizeof(CreateField); - Memcpy(deleted_.data(), ptr, deleted_size * sizeof(TxnTimeStamp)); + std::memcpy(deleted_.data(), ptr, deleted_size * sizeof(TxnTimeStamp)); ptr += deleted_.size() * sizeof(TxnTimeStamp); if (ptr - buf.data() != buf_len) { Error("Failed to load block_version file: " + version_path); @@ -91,9 +91,9 @@ void BlockVersion::SaveToFile(const String &version_path) { char *ptr = buf.data(); WriteBufAdv(ptr, int32_t(created_.size())); WriteBufAdv(ptr, int32_t(deleted_.size())); - Memcpy(ptr, created_.data(), created_.size() * sizeof(CreateField)); + std::memcpy(ptr, created_.data(), created_.size() * sizeof(CreateField)); ptr += created_.size() * sizeof(CreateField); - Memcpy(ptr, deleted_.data(), deleted_.size() * sizeof(TxnTimeStamp)); + std::memcpy(ptr, deleted_.data(), deleted_.size() * sizeof(TxnTimeStamp)); ptr += deleted_.size() * sizeof(TxnTimeStamp); if (ptr - buf.data() != exp_size) { Error("Failed to save block_version file: " + version_path); @@ -159,10 +159,10 @@ Pair BlockEntry::GetVisibleRange(TxnTimeStamp begin_ts, u16 block_offs } u16 BlockEntry::AppendData(u64 txn_id, DataBlock *input_data_block, u16 input_block_offset, u16 append_rows, BufferManager *) { - UniqueLock lck(this->rw_locker_); + std::unique_lock lck(this->rw_locker_); if (this->using_txn_id_ != 0 && this->using_txn_id_ != txn_id) { Error( - Format("Multiple transactions are changing data of Segment: {}, Block: {}", this->segment_entry_->segment_id(), this->block_id_)); + fmt::format("Multiple transactions are changing data of Segment: {}, Block: {}", this->segment_entry_->segment_id(), this->block_id_)); } this->using_txn_id_ = txn_id; @@ -179,7 +179,7 @@ u16 BlockEntry::AppendData(u64 txn_id, DataBlock *input_data_block, u16 input_bl input_block_offset, actual_copied); - LOG_TRACE(Format("Segment: {}, Block: {}, Column: {} is appended with {} rows", + LOG_TRACE(fmt::format("Segment: {}, Block: {}, Column: {} is appended with {} rows", this->segment_entry_->segment_id(), this->block_id_, column_id, @@ -191,10 +191,10 @@ u16 BlockEntry::AppendData(u64 txn_id, DataBlock *input_data_block, u16 input_bl } void BlockEntry::DeleteData(u64 txn_id, TxnTimeStamp commit_ts, const Vector &rows) { - UniqueLock lck(this->rw_locker_); + std::unique_lock lck(this->rw_locker_); if (this->using_txn_id_ != 0 && this->using_txn_id_ != txn_id) { Error( - Format("Multiple transactions are changing data of Segment: {}, Block: {}", this->segment_entry_->segment_id(), this->block_id_)); + fmt::format("Multiple transactions are changing data of Segment: {}, Block: {}", this->segment_entry_->segment_id(), this->block_id_)); } this->using_txn_id_ = txn_id; @@ -208,31 +208,31 @@ void BlockEntry::DeleteData(u64 txn_id, TxnTimeStamp commit_ts, const Vectordeleted_[block_offset] = commit_ts; } - LOG_TRACE(Format("Segment {} Block {} has deleted {} rows", segment_id, block_id, rows.size())); + LOG_TRACE(fmt::format("Segment {} Block {} has deleted {} rows", segment_id, block_id, rows.size())); } // A txn may invoke AppendData() multiple times, and then invoke CommitAppend() once. void BlockEntry::CommitAppend(u64 txn_id, TxnTimeStamp commit_ts) { - UniqueLock lck(this->rw_locker_); + std::unique_lock lck(this->rw_locker_); if (this->using_txn_id_ != txn_id) { Error( - Format("Multiple transactions are changing data of Segment: {}, Block: {}", this->segment_entry_->segment_id(), this->block_id_)); + fmt::format("Multiple transactions are changing data of Segment: {}, Block: {}", this->segment_entry_->segment_id(), this->block_id_)); } this->using_txn_id_ = 0; if (this->min_row_ts_ == 0) { this->min_row_ts_ = commit_ts; } - this->max_row_ts_ = Max(this->max_row_ts_, commit_ts); + this->max_row_ts_ = std::max(this->max_row_ts_, commit_ts); auto &block_version = this->block_version_; block_version->created_.push_back({commit_ts, int32_t(this->row_count_)}); } void BlockEntry::CommitDelete(u64 txn_id, TxnTimeStamp commit_ts) { - UniqueLock lck(this->rw_locker_); + std::unique_lock lck(this->rw_locker_); if (this->using_txn_id_ != 0 && this->using_txn_id_ != txn_id) { Error( - Format("Multiple transactions are changing data of Segment: {}, Block: {}", this->segment_entry_->segment_id(), this->block_id_)); + fmt::format("Multiple transactions are changing data of Segment: {}, Block: {}", this->segment_entry_->segment_id(), this->block_id_)); } if (this->using_txn_id_ == 0) { @@ -244,7 +244,7 @@ void BlockEntry::CommitDelete(u64 txn_id, TxnTimeStamp commit_ts) { if (this->min_row_ts_ == 0) { this->min_row_ts_ = commit_ts; } - this->max_row_ts_ = Max(this->max_row_ts_, commit_ts); + this->max_row_ts_ = std::max(this->max_row_ts_, commit_ts); } void BlockEntry::FlushData(int64_t checkpoint_row_count) { @@ -253,7 +253,7 @@ void BlockEntry::FlushData(int64_t checkpoint_row_count) { while (column_idx < column_count) { BlockColumnEntry *block_column_entry = this->columns_[column_idx].get(); BlockColumnEntry::Flush(block_column_entry, checkpoint_row_count); - LOG_TRACE(Format("ColumnData {} is flushed", block_column_entry->column_id())); + LOG_TRACE(fmt::format("ColumnData {} is flushed", block_column_entry->column_id())); ++column_idx; } } @@ -261,16 +261,16 @@ void BlockEntry::FlushData(int64_t checkpoint_row_count) { void BlockEntry::FlushVersion(BlockVersion &checkpoint_version) { checkpoint_version.SaveToFile(this->VersionFilePath()); } void BlockEntry::Flush(TxnTimeStamp checkpoint_ts) { - LOG_TRACE(Format("Segment: {}, Block: {} is being flushing", this->segment_entry_->segment_id(), this->block_id_)); + LOG_TRACE(fmt::format("Segment: {}, Block: {} is being flushing", this->segment_entry_->segment_id(), this->block_id_)); if (checkpoint_ts < this->checkpoint_ts_) { Error( - Format("BlockEntry checkpoint_ts skew! checkpoint_ts: {}, this->checkpoint_ts_: {}", checkpoint_ts, this->checkpoint_ts_)); + fmt::format("BlockEntry checkpoint_ts skew! checkpoint_ts: {}, this->checkpoint_ts_: {}", checkpoint_ts, this->checkpoint_ts_)); } int checkpoint_row_count = 0; BlockVersion checkpoint_version(this->block_version_->deleted_.size()); { - SharedLock lock(this->rw_locker_); + std::shared_lock lock(this->rw_locker_); // Skip if entry has been flushed at some previous checkpoint, or is invisible at current checkpoint. if (this->max_row_ts_ <= this->checkpoint_ts_ || this->min_row_ts_ > checkpoint_ts) return; @@ -294,7 +294,7 @@ void BlockEntry::Flush(TxnTimeStamp checkpoint_ts) { } checkpoint_version.created_ = this->block_version_->created_; checkpoint_version.deleted_.reserve(checkpoint_row_count); - Memcpy(checkpoint_version.deleted_.data(), deleted.data(), checkpoint_row_count * sizeof(TxnTimeStamp)); + std::memcpy(checkpoint_version.deleted_.data(), deleted.data(), checkpoint_row_count * sizeof(TxnTimeStamp)); } for (int i = 0; i < checkpoint_row_count; i++) { if (checkpoint_version.deleted_[i] > checkpoint_ts) { @@ -306,14 +306,14 @@ void BlockEntry::Flush(TxnTimeStamp checkpoint_ts) { FlushData(checkpoint_row_count); this->checkpoint_ts_ = checkpoint_ts; this->checkpoint_row_count_ = checkpoint_row_count; - LOG_TRACE(Format("Segment: {}, Block {} is flushed", this->segment_entry_->segment_id(), this->block_id_)); + LOG_TRACE(fmt::format("Segment: {}, Block {} is flushed", this->segment_entry_->segment_id(), this->block_id_)); return; } // TODO: introduce BlockColumnMeta -Json BlockEntry::Serialize(TxnTimeStamp) { - Json json_res; - SharedLock lck(this->rw_locker_); +nlohmann::json BlockEntry::Serialize(TxnTimeStamp) { + nlohmann::json json_res; + std::shared_lock lck(this->rw_locker_); json_res["block_id"] = this->block_id_; json_res["checkpoint_ts"] = this->checkpoint_ts_; @@ -328,7 +328,7 @@ Json BlockEntry::Serialize(TxnTimeStamp) { return json_res; } -UniquePtr BlockEntry::Deserialize(const Json &block_entry_json, SegmentEntry *segment_entry, BufferManager *buffer_mgr) { +UniquePtr BlockEntry::Deserialize(const nlohmann::json &block_entry_json, SegmentEntry *segment_entry, BufferManager *buffer_mgr) { u64 block_id = block_entry_json["block_id"]; TxnTimeStamp checkpoint_ts = block_entry_json["checkpoint_ts"]; UniquePtr block_entry = MakeUnique(segment_entry, block_id, checkpoint_ts, 0, buffer_mgr); @@ -355,14 +355,14 @@ UniquePtr BlockEntry::Deserialize(const Json &block_entry_json, Segm } i32 BlockEntry::GetAvailableCapacity() { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); return this->row_capacity_ - this->row_count_; } SharedPtr BlockEntry::DetermineDir(const String &parent_dir, u64 block_id) { LocalFileSystem fs; SharedPtr base_dir; - base_dir = MakeShared(Format("{}/blk_{}", parent_dir, block_id)); + base_dir = MakeShared(fmt::format("{}/blk_{}", parent_dir, block_id)); fs.CreateDirectoryNoExp(*base_dir); return base_dir; } diff --git a/src/storage/meta/entry/block_entry.cppm b/src/storage/meta/entry/block_entry.cppm index 2209b8ecd6..b23a5cd830 100644 --- a/src/storage/meta/entry/block_entry.cppm +++ b/src/storage/meta/entry/block_entry.cppm @@ -89,9 +89,9 @@ public: // Used in block iterator inline BlockColumnEntry *GetColumnDataByID(u64 column_id) const { return this->columns_[column_id].get(); } - Json Serialize(TxnTimeStamp max_commit_ts); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts); - static UniquePtr Deserialize(const Json &table_entry_json, SegmentEntry *table_entry, BufferManager *buffer_mgr); + static UniquePtr Deserialize(const nlohmann::json &table_entry_json, SegmentEntry *table_entry, BufferManager *buffer_mgr); void MergeFrom(BaseEntry &other) override; @@ -146,7 +146,7 @@ public: inline void IncreaseRowCount(SizeT increased_row_count) { row_count_ += increased_row_count; } protected: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; const SegmentEntry *segment_entry_{}; diff --git a/src/storage/meta/entry/column_index_entry.cpp b/src/storage/meta/entry/column_index_entry.cpp index ae79f2bbba..2e2188436e 100644 --- a/src/storage/meta/entry/column_index_entry.cpp +++ b/src/storage/meta/entry/column_index_entry.cpp @@ -59,19 +59,19 @@ UniquePtr ColumnIndexEntry::NewColumnIndexEntry(SharedPtr index_entry) { - UniqueLock w_locker(this->rw_locker_); - this->index_by_segment_.emplace(segment_id, Move(index_entry)); + std::unique_lock w_locker(this->rw_locker_); + this->index_by_segment_.emplace(segment_id, std::move(index_entry)); } -Json ColumnIndexEntry::Serialize(TxnTimeStamp max_commit_ts) { +nlohmann::json ColumnIndexEntry::Serialize(TxnTimeStamp max_commit_ts) { if (this->deleted_) { Error("Column index entry can't be deleted."); } - Json json; + nlohmann::json json; Vector segment_column_index_entry_candidates; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json["txn_id"] = this->txn_id_.load(); json["begin_ts"] = this->begin_ts_; @@ -94,7 +94,7 @@ Json ColumnIndexEntry::Serialize(TxnTimeStamp max_commit_ts) { return json; } -UniquePtr ColumnIndexEntry::Deserialize(const Json &column_index_entry_json, +UniquePtr ColumnIndexEntry::Deserialize(const nlohmann::json &column_index_entry_json, TableIndexEntry *table_index_entry, BufferManager *buffer_mgr, TableEntry *table_entry) { @@ -118,7 +118,7 @@ UniquePtr ColumnIndexEntry::Deserialize(const Json &column_ind for (const auto &index_by_segment_json : column_index_entry_json["index_by_segment"]) { UniquePtr segment_column_index_entry = SegmentColumnIndexEntry::Deserialize(index_by_segment_json, column_index_entry.get(), buffer_mgr, table_entry); - column_index_entry->index_by_segment_.emplace(segment_column_index_entry->segment_id(), Move(segment_column_index_entry)); + column_index_entry->index_by_segment_.emplace(segment_column_index_entry->segment_id(), std::move(segment_column_index_entry)); } } @@ -167,14 +167,14 @@ UniquePtr ColumnIndexEntry::CreateFileWorker(CreateIndexParam * case IndexType::kIRSFullText: { // auto create_fulltext_param = static_cast(param); UniquePtr err_msg = - MakeUnique(Format("File worker isn't implemented: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); + MakeUnique(fmt::format("File worker isn't implemented: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); LOG_ERROR(*err_msg); Error(*err_msg); break; } default: { UniquePtr err_msg = - MakeUnique(Format("File worker isn't implemented: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); + MakeUnique(fmt::format("File worker isn't implemented: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); LOG_ERROR(*err_msg); Error(*err_msg); } @@ -187,7 +187,7 @@ UniquePtr ColumnIndexEntry::CreateFileWorker(CreateIndexParam * return file_worker; } -String ColumnIndexEntry::IndexFileName(const String &index_name, u32 segment_id) { return Format("seg{}.idx", segment_id, index_name); } +String ColumnIndexEntry::IndexFileName(const String &index_name, u32 segment_id) { return fmt::format("seg{}.idx", segment_id, index_name); } Status ColumnIndexEntry::CreateIndexDo(const ColumnDef *column_def, HashMap &create_index_idxes) { for (auto &[segment_id, segment_column_index_entry] : index_by_segment_) { diff --git a/src/storage/meta/entry/column_index_entry.cppm b/src/storage/meta/entry/column_index_entry.cppm index 5e4bf41a83..837cc59a50 100644 --- a/src/storage/meta/entry/column_index_entry.cppm +++ b/src/storage/meta/entry/column_index_entry.cppm @@ -53,10 +53,10 @@ public: SharedPtr index_dir, TxnTimeStamp begin_ts); - Json Serialize(TxnTimeStamp max_commit_ts); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts); static UniquePtr - Deserialize(const Json &column_index_entry_json, TableIndexEntry *table_index_entry, BufferManager *buffer_mgr, TableEntry *table_entry); + Deserialize(const nlohmann::json &column_index_entry_json, TableIndexEntry *table_index_entry, BufferManager *buffer_mgr, TableEntry *table_entry); public: // Getter @@ -77,7 +77,7 @@ private: static String IndexFileName(const String &index_name, u32 segment_id); private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; TableIndexEntry *table_index_entry_{}; u64 column_id_{}; diff --git a/src/storage/meta/entry/db_entry.cpp b/src/storage/meta/entry/db_entry.cpp index a1746fb7c2..2ac4cfb001 100644 --- a/src/storage/meta/entry/db_entry.cpp +++ b/src/storage/meta/entry/db_entry.cpp @@ -51,12 +51,12 @@ Tuple DBEntry::CreateTable(TableEntryType table_entry_type table_meta = table_iter->second.get(); this->rw_locker_.unlock_shared(); - LOG_TRACE(Format("Add new table entry for {} in existed table meta of db_entry {}", table_name, *this->db_entry_dir_)); + LOG_TRACE(fmt::format("Add new table entry for {} in existed table meta of db_entry {}", table_name, *this->db_entry_dir_)); } else { this->rw_locker_.unlock_shared(); - LOG_TRACE(Format("Create new table/collection: {}", table_name)); + LOG_TRACE(fmt::format("Create new table/collection: {}", table_name)); UniquePtr new_table_meta = MakeUnique(this->db_entry_dir_, table_collection_name, this); table_meta = new_table_meta.get(); @@ -65,11 +65,11 @@ Tuple DBEntry::CreateTable(TableEntryType table_entry_type if (table_iter2 != this->tables_.end()) { table_meta = table_iter2->second.get(); } else { - this->tables_[table_name] = Move(new_table_meta); + this->tables_[table_name] = std::move(new_table_meta); } this->rw_locker_.unlock(); - LOG_TRACE(Format("Add new table entry for {} in new table meta of db_entry {} ", table_name, *this->db_entry_dir_)); + LOG_TRACE(fmt::format("Add new table entry for {} in new table meta of db_entry {} ", table_name, *this->db_entry_dir_)); } return table_meta->CreateNewEntry(table_entry_type, table_collection_name, columns, txn_id, begin_ts, txn_mgr); @@ -86,16 +86,16 @@ DBEntry::DropTable(const String &table_collection_name, ConflictType conflict_ty this->rw_locker_.unlock_shared(); if (table_meta == nullptr) { if (conflict_type == ConflictType::kIgnore) { - LOG_TRACE(Format("Ignore drop a not existed table/collection entry {}", table_collection_name)); + LOG_TRACE(fmt::format("Ignore drop a not existed table/collection entry {}", table_collection_name)); return {nullptr, Status::OK()}; } - UniquePtr err_msg = MakeUnique(Format("Attempt to drop not existed table/collection entry {}", table_collection_name)); + UniquePtr err_msg = MakeUnique(fmt::format("Attempt to drop not existed table/collection entry {}", table_collection_name)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } - LOG_TRACE(Format("Drop a table/collection entry {}", table_collection_name)); + LOG_TRACE(fmt::format("Drop a table/collection entry {}", table_collection_name)); return table_meta->DropNewEntry(txn_id, begin_ts, txn_mgr, table_collection_name, conflict_type); } @@ -112,7 +112,7 @@ Tuple DBEntry::GetTableCollection(const String &table_coll if (table_meta == nullptr) { UniquePtr err_msg = MakeUnique("No valid db meta."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } return table_meta->GetEntry(txn_id, begin_ts); } @@ -126,7 +126,7 @@ void DBEntry::RemoveTableEntry(const String &table_collection_name, u64 txn_id, } this->rw_locker_.unlock_shared(); - LOG_TRACE(Format("Remove a table/collection entry: {}", table_collection_name)); + LOG_TRACE(fmt::format("Remove a table/collection entry: {}", table_collection_name)); table_meta->DeleteNewEntry(txn_id, txn_mgr); } @@ -140,7 +140,7 @@ Vector DBEntry::TableCollections(u64 txn_id, TxnTimeStamp begin_ts TableMeta *table_meta = table_collection_meta_pair.second.get(); auto [table_entry, status] = table_meta->GetEntry(txn_id, begin_ts); if (!status.ok()) { - LOG_TRACE(Format("error when get table/collection entry: {}", status.message())); + LOG_TRACE(fmt::format("error when get table/collection entry: {}", status.message())); } else { results.emplace_back((TableEntry *)table_entry); } @@ -172,18 +172,18 @@ Status DBEntry::GetTablesDetail(u64 txn_id, TxnTimeStamp begin_ts, Vector DBEntry::ToString() { - SharedLock r_locker(rw_locker_); + std::shared_lock r_locker(rw_locker_); SharedPtr res = - MakeShared(Format("DBEntry, db_entry_dir: {}, txn id: {}, table count: ", *db_entry_dir_, txn_id_, tables_.size())); + MakeShared(fmt::format("DBEntry, db_entry_dir: {}, txn id: {}, table count: ", *db_entry_dir_, txn_id_, tables_.size())); return res; } -Json DBEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { - Json json_res; +nlohmann::json DBEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { + nlohmann::json json_res; Vector table_metas; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json_res["db_entry_dir"] = *this->db_entry_dir_; json_res["db_name"] = *this->db_name_; json_res["txn_id"] = this->txn_id_.load(); @@ -202,8 +202,8 @@ Json DBEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { return json_res; } -UniquePtr DBEntry::Deserialize(const Json &db_entry_json, BufferManager *buffer_mgr) { - Json json_res; +UniquePtr DBEntry::Deserialize(const nlohmann::json &db_entry_json, BufferManager *buffer_mgr) { + nlohmann::json json_res; SharedPtr db_entry_dir = MakeShared(db_entry_json["db_entry_dir"]); SharedPtr db_name = MakeShared(db_entry_json["db_name"]); @@ -222,7 +222,7 @@ UniquePtr DBEntry::Deserialize(const Json &db_entry_json, BufferManager if (db_entry_json.contains("tables")) { for (const auto &table_meta_json : db_entry_json["tables"]) { UniquePtr table_meta = TableMeta::Deserialize(table_meta_json, res.get(), buffer_mgr); - res->tables_.emplace(*table_meta->table_name_, Move(table_meta)); + res->tables_.emplace(*table_meta->table_name_, std::move(table_meta)); } } @@ -246,7 +246,7 @@ void DBEntry::MergeFrom(BaseEntry &other) { auto it = this->tables_.find(table_name); if (it == this->tables_.end()) { table_meta2->db_entry_ = this; - this->tables_.emplace(table_name, Move(table_meta2)); + this->tables_.emplace(table_name, std::move(table_meta2)); } else { it->second->MergeFrom(*table_meta2.get()); } diff --git a/src/storage/meta/entry/db_entry.cppm b/src/storage/meta/entry/db_entry.cppm index 3d94498c16..7d5f8d61b2 100644 --- a/src/storage/meta/entry/db_entry.cppm +++ b/src/storage/meta/entry/db_entry.cppm @@ -34,8 +34,8 @@ class DBEntry : public BaseEntry { public: inline explicit DBEntry(const SharedPtr &data_dir, SharedPtr db_name, u64 txn_id, TxnTimeStamp begin_ts) - : BaseEntry(EntryType::kDatabase), db_entry_dir_(MakeShared(Format("{}/{}/txn_{}", *data_dir, *db_name, txn_id))), - db_name_(Move(db_name)) { + : BaseEntry(EntryType::kDatabase), db_entry_dir_(MakeShared(fmt::format("{}/{}/txn_{}", *data_dir, *db_name, txn_id))), + db_name_(std::move(db_name)) { begin_ts_ = begin_ts; txn_id_ = txn_id; } @@ -44,9 +44,9 @@ public: SharedPtr ToString(); - Json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); - static UniquePtr Deserialize(const Json &db_entry_json, BufferManager *buffer_mgr); + static UniquePtr Deserialize(const nlohmann::json &db_entry_json, BufferManager *buffer_mgr); virtual void MergeFrom(BaseEntry &other); @@ -74,7 +74,7 @@ private: Status GetTablesDetail(u64 txn_id, TxnTimeStamp begin_ts, Vector &output_table_array); private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; SharedPtr db_entry_dir_{}; SharedPtr db_name_{}; HashMap> tables_{}; // NOTE : can use SharedPtr as key. diff --git a/src/storage/meta/entry/irs_index_entry.cpp b/src/storage/meta/entry/irs_index_entry.cpp index f7035ca3d3..873c943360 100644 --- a/src/storage/meta/entry/irs_index_entry.cpp +++ b/src/storage/meta/entry/irs_index_entry.cpp @@ -28,13 +28,13 @@ import logger; namespace infinity { IrsIndexEntry::IrsIndexEntry(TableIndexEntry *, SharedPtr index_dir, u64 txn_id, TxnTimeStamp begin_ts) - : BaseEntry(EntryType::kIRSIndex), index_dir_(Move(index_dir)) { + : BaseEntry(EntryType::kIRSIndex), index_dir_(std::move(index_dir)) { txn_id_ = txn_id; begin_ts_ = begin_ts; } -Json IrsIndexEntry::Serialize(TxnTimeStamp) { - Json json; +nlohmann::json IrsIndexEntry::Serialize(TxnTimeStamp) { + nlohmann::json json; json["txn_id"] = this->txn_id_.load(); json["begin_ts"] = this->begin_ts_; json["commit_ts"] = this->commit_ts_.load(); @@ -43,7 +43,7 @@ Json IrsIndexEntry::Serialize(TxnTimeStamp) { return json; } -SharedPtr IrsIndexEntry::Deserialize(const Json &index_def_entry_json, TableIndexEntry *table_index_entry, BufferManager *) { +SharedPtr IrsIndexEntry::Deserialize(const nlohmann::json &index_def_entry_json, TableIndexEntry *table_index_entry, BufferManager *) { u64 txn_id = index_def_entry_json["txn_id"]; TxnTimeStamp begin_ts = index_def_entry_json["begin_ts"]; TxnTimeStamp commit_ts = index_def_entry_json["commit_ts"]; diff --git a/src/storage/meta/entry/irs_index_entry.cppm b/src/storage/meta/entry/irs_index_entry.cppm index 26d44b818d..fcd664d7ec 100644 --- a/src/storage/meta/entry/irs_index_entry.cppm +++ b/src/storage/meta/entry/irs_index_entry.cppm @@ -41,15 +41,15 @@ public: void AddColumn(SharedPtr index_base, u64 column_id); - Json Serialize(TxnTimeStamp max_commit_ts); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts); - static SharedPtr Deserialize(const Json &index_def_entry_json, TableIndexEntry *table_index_entry, BufferManager *buffer_mgr); + static SharedPtr Deserialize(const nlohmann::json &index_def_entry_json, TableIndexEntry *table_index_entry, BufferManager *buffer_mgr); private: static SharedPtr DetermineIndexDir(const String &parent_dir, const String &index_name); public: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; const TableIndexEntry *table_index_entry_{}; SharedPtr index_dir_{}; diff --git a/src/storage/meta/entry/segment_column_index_entry.cpp b/src/storage/meta/entry/segment_column_index_entry.cpp index 52b56f484f..4841a87bb7 100644 --- a/src/storage/meta/entry/segment_column_index_entry.cpp +++ b/src/storage/meta/entry/segment_column_index_entry.cpp @@ -46,7 +46,7 @@ SharedPtr SegmentColumnIndexEntry::NewIndexEntry(Column CreateIndexParam *param) { // FIXME: estimate index size. UniquePtr file_worker = column_index_entry->CreateFileWorker(param, segment_id); - auto buffer = buffer_manager->Allocate(Move(file_worker)); + auto buffer = buffer_manager->Allocate(std::move(file_worker)); auto segment_column_index_entry = SharedPtr(new SegmentColumnIndexEntry(column_index_entry, segment_id, buffer)); segment_column_index_entry->min_ts_ = create_ts; segment_column_index_entry->max_ts_ = create_ts; @@ -58,7 +58,7 @@ UniquePtr SegmentColumnIndexEntry::LoadIndexEntry(Colum BufferManager *buffer_manager, CreateIndexParam *param) { UniquePtr file_worker = column_index_entry->CreateFileWorker(param, segment_id); - auto buffer = buffer_manager->Get(Move(file_worker)); + auto buffer = buffer_manager->Get(std::move(file_worker)); return UniquePtr(new SegmentColumnIndexEntry(column_index_entry, segment_id, buffer)); } @@ -72,7 +72,7 @@ Status SegmentColumnIndexEntry::CreateIndexDo(IndexBase *index_base, const Colum while (true) { SizeT idx = create_index_idx.fetch_add(1); if (idx % 10000 == 0) { - LOG_INFO(Format("Insert index: {}", idx)); + LOG_INFO(fmt::format("Insert index: {}", idx)); } if (idx >= vertex_n) { break; @@ -158,9 +158,9 @@ void SegmentColumnIndexEntry::UpdateIndex(TxnTimeStamp, FaissIndexPtr *, BufferM bool SegmentColumnIndexEntry::Flush(TxnTimeStamp checkpoint_ts) { String &index_name = *this->column_index_entry_->index_dir(); u64 segment_id = this->segment_id_; - LOG_TRACE(Format("Segment: {}, Index: {} is being flushing", segment_id, index_name)); + LOG_TRACE(fmt::format("Segment: {}, Index: {} is being flushing", segment_id, index_name)); if (this->max_ts_ <= this->checkpoint_ts_ || this->min_ts_ > checkpoint_ts) { - LOG_TRACE(Format("Segment: {}, Index: {} has been flushed at some previous checkpoint, or is not visible at current checkpoint.", + LOG_TRACE(fmt::format("Segment: {}, Index: {} has been flushed at some previous checkpoint, or is not visible at current checkpoint.", segment_id, index_name)); return false; @@ -175,18 +175,18 @@ bool SegmentColumnIndexEntry::Flush(TxnTimeStamp checkpoint_ts) { } this->checkpoint_ts_ = checkpoint_ts; - LOG_TRACE(Format("Segment: {}, Index: {} is flushed", segment_id, index_name)); + LOG_TRACE(fmt::format("Segment: {}, Index: {} is flushed", segment_id, index_name)); return true; } -Json SegmentColumnIndexEntry::Serialize() { +nlohmann::json SegmentColumnIndexEntry::Serialize() { if (this->deleted_) { Error("Segment Column index entry can't be deleted."); } - Json index_entry_json; + nlohmann::json index_entry_json; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); index_entry_json["segment_id"] = this->segment_id_; index_entry_json["min_ts"] = this->min_ts_; index_entry_json["max_ts"] = this->max_ts_; @@ -196,7 +196,7 @@ Json SegmentColumnIndexEntry::Serialize() { return index_entry_json; } -UniquePtr SegmentColumnIndexEntry::Deserialize(const Json &index_entry_json, +UniquePtr SegmentColumnIndexEntry::Deserialize(const nlohmann::json &index_entry_json, ColumnIndexEntry *column_index_entry, BufferManager *buffer_mgr, TableEntry *table_entry) { diff --git a/src/storage/meta/entry/segment_column_index_entry.cppm b/src/storage/meta/entry/segment_column_index_entry.cppm index 044bf7dcc6..f300d5d3fe 100644 --- a/src/storage/meta/entry/segment_column_index_entry.cppm +++ b/src/storage/meta/entry/segment_column_index_entry.cppm @@ -49,10 +49,10 @@ public: [[nodiscard]] BufferHandle GetIndex(); - Json Serialize(); + nlohmann::json Serialize(); static UniquePtr - Deserialize(const Json &index_entry_json, ColumnIndexEntry *column_index_entry, BufferManager *buffer_mgr, TableEntry *table_entry); + Deserialize(const nlohmann::json &index_entry_json, ColumnIndexEntry *column_index_entry, BufferManager *buffer_mgr, TableEntry *table_entry); void MergeFrom(BaseEntry &other); @@ -80,7 +80,7 @@ private: BufferObj *const buffer_{}; - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; TxnTimeStamp min_ts_{0}; // Indicate the commit_ts which create this SegmentColumnIndexEntry TxnTimeStamp max_ts_{0}; // Indicate the max commit_ts which update data inside this SegmentColumnIndexEntry diff --git a/src/storage/meta/entry/segment_entry.cpp b/src/storage/meta/entry/segment_entry.cpp index 16329e18ac..a40c1e4e7b 100644 --- a/src/storage/meta/entry/segment_entry.cpp +++ b/src/storage/meta/entry/segment_entry.cpp @@ -87,17 +87,17 @@ SegmentEntry::MakeReplaySegmentEntry(const TableEntry *table_entry, u32 segment_ const auto *table_ptr = (const TableEntry *)table_entry; new_entry->column_count_ = table_ptr->ColumnCount(); - new_entry->segment_dir_ = Move(segment_dir); + new_entry->segment_dir_ = std::move(segment_dir); return new_entry; } int SegmentEntry::Room() { - SharedLock lck(rw_locker_); + std::shared_lock lck(rw_locker_); return this->row_capacity_ - this->row_count_; } u64 SegmentEntry::AppendData(u64 txn_id, AppendState *append_state_ptr, BufferManager *buffer_mgr) { - UniqueLock lck(this->rw_locker_); + std::unique_lock lck(this->rw_locker_); if (this->row_capacity_ - this->row_count_ <= 0) return 0; // SizeT start_row = this->row_count_; @@ -123,7 +123,7 @@ u64 SegmentEntry::AppendData(u64 txn_id, AppendState *append_state_ptr, BufferMa u16 actual_appended = last_block_entry->AppendData(txn_id, input_block, append_state_ptr->current_block_offset_, to_append_rows, buffer_mgr); if (to_append_rows < actual_appended) { - Error(Format("Attempt to append rows: {}, but rows: {} are appended", to_append_rows, actual_appended)); + Error(fmt::format("Attempt to append rows: {}, but rows: {} are appended", to_append_rows, actual_appended)); } append_state_ptr->append_ranges_.emplace_back(range_segment_id, range_block_id, range_block_start_row, actual_appended); @@ -142,13 +142,13 @@ u64 SegmentEntry::AppendData(u64 txn_id, AppendState *append_state_ptr, BufferMa } void SegmentEntry::DeleteData(u64 txn_id, TxnTimeStamp commit_ts, const HashMap> &block_row_hashmap) { - UniqueLock lck(this->rw_locker_); + std::unique_lock lck(this->rw_locker_); for (const auto &row_hash_map : block_row_hashmap) { u16 block_id = row_hash_map.first; BlockEntry *block_entry = this->GetBlockEntryByID(block_id); if (block_entry == nullptr) { - Error(Format("The segment doesn't contain the given block: {}.", block_id)); + Error(fmt::format("The segment doesn't contain the given block: {}.", block_id)); } const Vector &rows = row_hash_map.second; @@ -292,12 +292,12 @@ SharedPtr SegmentEntry::CreateIndexFile(ColumnIndexEntr break; } case IndexType::kIRSFullText: { - UniquePtr err_msg = MakeUnique(Format("Invalid index type: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); + UniquePtr err_msg = MakeUnique(fmt::format("Invalid index type: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); LOG_ERROR(*err_msg); Error(*err_msg); } default: { - UniquePtr err_msg = MakeUnique(Format("Invalid index type: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); + UniquePtr err_msg = MakeUnique(fmt::format("Invalid index type: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); LOG_ERROR(*err_msg); Error(*err_msg); } @@ -309,29 +309,29 @@ SharedPtr SegmentEntry::CreateIndexFile(ColumnIndexEntr void SegmentEntry::CommitAppend(u64 txn_id, TxnTimeStamp commit_ts, u16 block_id, u16, u16) { SharedPtr block_entry; { - UniqueLock lck(this->rw_locker_); + std::unique_lock lck(this->rw_locker_); if (this->min_row_ts_ == 0) { this->min_row_ts_ = commit_ts; } - this->max_row_ts_ = Max(this->max_row_ts_, commit_ts); + this->max_row_ts_ = std::max(this->max_row_ts_, commit_ts); block_entry = this->block_entries_[block_id]; } block_entry->CommitAppend(txn_id, commit_ts); } void SegmentEntry::CommitDelete(u64 txn_id, TxnTimeStamp commit_ts, const HashMap> &block_row_hashmap) { - UniqueLock lck(this->rw_locker_); + std::unique_lock lck(this->rw_locker_); for (const auto &row_hash_map : block_row_hashmap) { u16 block_id = row_hash_map.first; // TODO: block_id is u16, GetBlockEntryByID need to be modified accordingly. BlockEntry *block_entry = this->GetBlockEntryByID(block_id); if (block_entry == nullptr) { - Error(Format("The segment doesn't contain the given block: {}.", block_id)); + Error(fmt::format("The segment doesn't contain the given block: {}.", block_id)); } block_entry->CommitDelete(txn_id, commit_ts); - this->max_row_ts_ = Max(this->max_row_ts_, commit_ts); + this->max_row_ts_ = std::max(this->max_row_ts_, commit_ts); } } @@ -343,11 +343,11 @@ BlockEntry *SegmentEntry::GetBlockEntryByID(u16 block_id) const { } } -Json SegmentEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { - Json json_res; +nlohmann::json SegmentEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { + nlohmann::json json_res; Vector block_entries; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json_res["segment_dir"] = *this->segment_dir_; json_res["row_capacity"] = this->row_capacity_; json_res["segment_id"] = this->segment_id_; @@ -363,13 +363,13 @@ Json SegmentEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint } } for (BlockEntry *block_entry : block_entries) { - LOG_TRACE(Format("Before Flush: block_entry checkpoint ts: {}, min_row_ts: {}, max_row_ts: {} || max_commit_ts: {}", + LOG_TRACE(fmt::format("Before Flush: block_entry checkpoint ts: {}, min_row_ts: {}, max_row_ts: {} || max_commit_ts: {}", block_entry->checkpoint_ts(), block_entry->min_row_ts(), block_entry->max_row_ts(), max_commit_ts)); block_entry->Flush(max_commit_ts); - LOG_TRACE(Format("Finish Flush: block_entry checkpoint ts: {}, min_row_ts: {}, max_row_ts: {} || max_commit_ts: {}", + LOG_TRACE(fmt::format("Finish Flush: block_entry checkpoint ts: {}, min_row_ts: {}, max_row_ts: {} || max_commit_ts: {}", block_entry->checkpoint_ts(), block_entry->min_row_ts(), block_entry->max_row_ts(), @@ -383,7 +383,7 @@ Json SegmentEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint return json_res; } -SharedPtr SegmentEntry::Deserialize(const Json &segment_entry_json, TableEntry *table_entry, BufferManager *buffer_mgr) { +SharedPtr SegmentEntry::Deserialize(const nlohmann::json &segment_entry_json, TableEntry *table_entry, BufferManager *buffer_mgr) { SharedPtr segment_entry = MakeShared(table_entry); segment_entry->segment_dir_ = MakeShared(segment_entry_json["segment_dir"]); @@ -401,11 +401,11 @@ SharedPtr SegmentEntry::Deserialize(const Json &segment_entry_json for (const auto &block_json : segment_entry_json["block_entries"]) { UniquePtr block_entry = BlockEntry::Deserialize(block_json, segment_entry.get(), buffer_mgr); auto block_entries_size = segment_entry->block_entries_.size(); - segment_entry->block_entries_.resize(Max(block_entries_size, static_cast(block_entry->block_id() + 1))); - segment_entry->block_entries_[block_entry->block_id()] = Move(block_entry); + segment_entry->block_entries_.resize(std::max(block_entries_size, static_cast(block_entry->block_id() + 1))); + segment_entry->block_entries_[block_entry->block_id()] = std::move(block_entry); } } - LOG_TRACE(Format("Segment: {}, Block count: {}", segment_entry->segment_id_, segment_entry->block_entries_.size())); + LOG_TRACE(fmt::format("Segment: {}, Block count: {}", segment_entry->segment_id_, segment_entry->block_entries_.size())); return segment_entry; } @@ -415,7 +415,7 @@ SharedPtr SegmentEntry::DetermineSegmentDir(const String &parent_dir, u3 SharedPtr segment_dir; do { u32 seed = time(nullptr); - segment_dir = MakeShared(parent_dir + '/' + RandomString(DEFAULT_RANDOM_NAME_LEN, seed) + "_seg_" + ToStr(seg_id)); + segment_dir = MakeShared(parent_dir + '/' + RandomString(DEFAULT_RANDOM_NAME_LEN, seed) + "_seg_" + std::to_string(seg_id)); } while (!fs.CreateDirectoryNoExp(*segment_dir)); return segment_dir; } @@ -444,9 +444,9 @@ void SegmentEntry::MergeFrom(BaseEntry &other) { Error("SegmentEntry::MergeFrom requires source segment entry blocks not more than segment entry blocks"); } - this->row_count_ = Max(this->row_count_, segment_entry2->row_count_); - this->max_row_ts_ = Max(this->max_row_ts_, segment_entry2->max_row_ts_); - this->row_capacity_ = Max(this->row_capacity_, segment_entry2->row_capacity_); + this->row_count_ = std::max(this->row_count_, segment_entry2->row_count_); + this->max_row_ts_ = std::max(this->max_row_ts_, segment_entry2->max_row_ts_); + this->row_capacity_ = std::max(this->row_capacity_, segment_entry2->row_capacity_); SizeT block_count = this->block_entries_.size(); SizeT idx = 0; @@ -487,7 +487,7 @@ UniquePtr SegmentEntry::GetCreateIndexParam(SizeT seg_row_coun return MakeUnique(index_base, column_def); } default: { - UniquePtr err_msg = MakeUnique(Format("Invalid index type: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); + UniquePtr err_msg = MakeUnique(fmt::format("Invalid index type: {}", IndexInfo::IndexTypeToString(index_base->index_type_))); LOG_ERROR(*err_msg); Error(*err_msg); } diff --git a/src/storage/meta/entry/segment_entry.cppm b/src/storage/meta/entry/segment_entry.cppm index b73231f900..080bf3cf72 100644 --- a/src/storage/meta/entry/segment_entry.cppm +++ b/src/storage/meta/entry/segment_entry.cppm @@ -49,9 +49,9 @@ public: static UniquePtr GetCreateIndexParam(SizeT seg_row_count, const IndexBase *index_base, const ColumnDef *column_def); - Json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); - static SharedPtr Deserialize(const Json &table_entry_json, TableEntry *table_entry, BufferManager *buffer_mgr); + static SharedPtr Deserialize(const nlohmann::json &table_entry_json, TableEntry *table_entry, BufferManager *buffer_mgr); void MergeFrom(infinity::BaseEntry &other) override; @@ -76,7 +76,7 @@ public: public: // Used in WAL replay & Physical Import - inline void AppendBlockEntry(UniquePtr block_entry) { block_entries_.emplace_back(Move(block_entry)); } + inline void AppendBlockEntry(UniquePtr block_entry) { block_entries_.emplace_back(std::move(block_entry)); } inline void IncreaseRowCount(SizeT increased_row_count) { row_count_ += increased_row_count; } @@ -109,7 +109,7 @@ private: static SharedPtr DetermineSegmentDir(const String &parent_dir, u32 seg_id); protected: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; const TableEntry *table_entry_{}; diff --git a/src/storage/meta/entry/table_entry.cpp b/src/storage/meta/entry/table_entry.cpp index aa24f5a3f0..30674ad2f7 100644 --- a/src/storage/meta/entry/table_entry.cpp +++ b/src/storage/meta/entry/table_entry.cpp @@ -49,8 +49,8 @@ TableEntry::TableEntry(const SharedPtr &db_entry_dir, TableMeta *table_meta, u64 txn_id, TxnTimeStamp begin_ts) - : BaseEntry(EntryType::kTable), table_entry_dir_(MakeShared(Format("{}/{}/txn_{}", *db_entry_dir, *table_collection_name, txn_id))), - table_name_(Move(table_collection_name)), columns_(columns), table_entry_type_(table_entry_type), table_meta_(table_meta) { + : BaseEntry(EntryType::kTable), table_entry_dir_(MakeShared(fmt::format("{}/{}/txn_{}", *db_entry_dir, *table_collection_name, txn_id))), + table_name_(std::move(table_collection_name)), columns_(columns), table_entry_type_(table_entry_type), table_meta_(table_meta) { SizeT column_count = columns.size(); for (SizeT idx = 0; idx < column_count; ++idx) { column_name2column_id_[columns[idx]->name()] = idx; @@ -87,12 +87,12 @@ TableEntry::CreateIndex(const SharedPtr &index_def, ConflictType confl table_index_meta = iter->second.get(); } else { - this->index_meta_map_[*index_def->index_name_] = Move(new_table_index_meta); + this->index_meta_map_[*index_def->index_name_] = std::move(new_table_index_meta); } this->rw_locker_.unlock(); } - LOG_TRACE(Format("Creating new index: {}", *index_def->index_name_)); + LOG_TRACE(fmt::format("Creating new index: {}", *index_def->index_name_)); return table_index_meta->CreateTableIndexEntry(index_def, conflict_type, txn_id, begin_ts, txn_mgr); } @@ -112,7 +112,7 @@ TableEntry::DropIndex(const String &index_name, ConflictType conflict_type, u64 return {nullptr, Status::OK()}; } case ConflictType::kError: { - String error_message = Format("Attempt to drop not existed index entry {}", index_name); + String error_message = fmt::format("Attempt to drop not existed index entry {}", index_name); LOG_TRACE(error_message); return {nullptr, Status(ErrorCode::kNotFound, error_message.c_str())}; } @@ -122,7 +122,7 @@ TableEntry::DropIndex(const String &index_name, ConflictType conflict_type, u64 } Error("Should not reach here."); } - LOG_TRACE(Format("Drop index entry {}", index_name)); + LOG_TRACE(fmt::format("Drop index entry {}", index_name)); return index_meta->DropTableIndexEntry(conflict_type, txn_id, begin_ts, txn_mgr); } @@ -132,7 +132,7 @@ Tuple TableEntry::GetIndex(const String &index_name, } UniquePtr err_msg = MakeUnique("Cannot find index def"); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } void TableEntry::RemoveIndexEntry(const String &index_name, u64 txn_id, TxnManager *txn_mgr) { @@ -144,7 +144,7 @@ void TableEntry::RemoveIndexEntry(const String &index_name, u64 txn_id, TxnManag } this->rw_locker_.unlock_shared(); - LOG_TRACE(Format("Remove index entry: {}", index_name)); + LOG_TRACE(fmt::format("Remove index entry: {}", index_name)); table_index_meta->DeleteNewEntry(txn_id, txn_mgr); } @@ -187,19 +187,19 @@ void TableEntry::Append(u64 txn_id, void *txn_store, BufferManager *buffer_mgr) while (!append_state_ptr->Finished()) { { - UniqueLock rw_locker(this->rw_locker_); // prevent another read conflict with this append operation + std::unique_lock rw_locker(this->rw_locker_); // prevent another read conflict with this append operation if (this->unsealed_segment_ == nullptr || unsealed_segment_->Room() <= 0) { // unsealed_segment_ is unpopulated or full u32 new_segment_id = this->next_segment_id_++; SharedPtr new_segment = SegmentEntry::MakeNewSegmentEntry(this, new_segment_id, buffer_mgr); this->segment_map_.emplace(new_segment_id, new_segment); this->unsealed_segment_ = new_segment.get(); - LOG_TRACE(Format("Created a new segment {}", new_segment_id)); + LOG_TRACE(fmt::format("Created a new segment {}", new_segment_id)); } } // Append data from app_state_ptr to the buffer in segment. If append all data, then set finish. u64 actual_appended = unsealed_segment_->AppendData(txn_id, append_state_ptr, buffer_mgr); - LOG_TRACE(Format("Segment {} is appended with {} rows", this->unsealed_segment_->segment_id_, actual_appended)); + LOG_TRACE(fmt::format("Segment {} is appended with {} rows", this->unsealed_segment_->segment_id_, actual_appended)); } } @@ -256,9 +256,9 @@ Status TableEntry::Delete(u64 txn_id, TxnTimeStamp commit_ts, DeleteState &delet u32 segment_id = to_delete_seg_rows.first; SegmentEntry *segment_entry = TableEntry::GetSegmentByID(this, segment_id); if (segment_entry == nullptr) { - UniquePtr err_msg = MakeUnique(Format("Going to delete data in non-exist segment: {}", segment_id)); + UniquePtr err_msg = MakeUnique(fmt::format("Going to delete data in non-exist segment: {}", segment_id)); Error(*err_msg); - return Status(ErrorCode::kNotFound, Move(err_msg)); + return Status(ErrorCode::kNotFound, std::move(err_msg)); } const HashMap> &block_row_hashmap = to_delete_seg_rows.second; segment_entry->DeleteData(txn_id, commit_ts, block_row_hashmap); @@ -269,7 +269,7 @@ Status TableEntry::Delete(u64 txn_id, TxnTimeStamp commit_ts, DeleteState &delet void TableEntry::CommitAppend(u64 txn_id, TxnTimeStamp commit_ts, const AppendState *append_state_ptr) { SizeT row_count = 0; for (const auto &range : append_state_ptr->append_ranges_) { - LOG_TRACE(Format("Commit, segment: {}, block: {} start offset: {}, count: {}", + LOG_TRACE(fmt::format("Commit, segment: {}, block: {} start offset: {}, count: {}", range.segment_id_, range.block_id_, range.start_offset_, @@ -293,7 +293,7 @@ void TableEntry::CommitDelete(u64 txn_id, TxnTimeStamp commit_ts, const DeleteSt u32 segment_id = to_delete_seg_rows.first; SegmentEntry *segment = TableEntry::GetSegmentByID(this, segment_id); if (segment == nullptr) { - Error(Format("Going to commit delete data in non-exist segment: {}", segment_id)); + Error(fmt::format("Going to commit delete data in non-exist segment: {}", segment_id)); } const HashMap> &block_row_hashmap = to_delete_seg_rows.second; segment->CommitDelete(txn_id, commit_ts, block_row_hashmap); @@ -309,9 +309,9 @@ Status TableEntry::RollbackDelete(u64 txn_id, DeleteState &, BufferManager *) { Status TableEntry::ImportSegment(TxnTimeStamp commit_ts, SharedPtr segment) { if (this->deleted_) { - UniquePtr err_msg = MakeUnique(Format("Table {} is deleted.", *this->GetTableName())); + UniquePtr err_msg = MakeUnique(fmt::format("Table {} is deleted.", *this->GetTableName())); Error(*err_msg); - return Status(ErrorCode::kNotFound, Move(err_msg)); + return Status(ErrorCode::kNotFound, std::move(err_msg)); } segment->min_row_ts_ = commit_ts; @@ -326,9 +326,9 @@ Status TableEntry::ImportSegment(TxnTimeStamp commit_ts, SharedPtr block_entry->block_version_->created_.emplace_back(commit_ts, block_entry->row_count()); } - UniqueLock rw_locker(this->rw_locker_); + std::unique_lock rw_locker(this->rw_locker_); this->row_count_ = row_count; - this->segment_map_.emplace(segment->segment_id_, Move(segment)); + this->segment_map_.emplace(segment->segment_id_, std::move(segment)); return Status::OK(); } @@ -344,12 +344,12 @@ SegmentEntry *TableEntry::GetSegmentByID(const TableEntry *table_entry, u32 segm const BlockEntry *TableEntry::GetBlockEntryByID(u32 seg_id, u16 block_id) const { SegmentEntry *segment_entry = TableEntry::GetSegmentByID(this, seg_id); if (segment_entry == nullptr) { - throw ExecutorException(Format("Cannot find segment, segment id: {}", seg_id)); + throw ExecutorException(fmt::format("Cannot find segment, segment id: {}", seg_id)); } BlockEntry *block_entry = segment_entry->GetBlockEntryByID(block_id); if (block_entry == nullptr) { - throw ExecutorException(Format("Cannot find block, segment id: {}, block id: {}", seg_id, block_id)); + throw ExecutorException(fmt::format("Cannot find block, segment id: {}, block id: {}", seg_id, block_id)); } return block_entry; } @@ -359,9 +359,9 @@ Pair TableEntry::GetSegmentRowCountBySegmentID(u32 seg_id) { if (iter != this->segment_map_.end()) { return {iter->second->row_count(), Status::OK()}; } else { - UniquePtr err_msg = MakeUnique(Format("No segment id: {}.", seg_id)); + UniquePtr err_msg = MakeUnique(fmt::format("No segment id: {}.", seg_id)); LOG_ERROR(*err_msg); - return {0, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {0, Status(ErrorCode::kNotFound, std::move(err_msg))}; } } @@ -375,7 +375,7 @@ const SharedPtr &TableEntry::GetDBName() const { return table_meta_->db_ SharedPtr TableEntry::GetBlockIndex(u64, TxnTimeStamp begin_ts) { // SharedPtr> result = MakeShared>(); SharedPtr result = MakeShared(); - SharedLock rw_locker(this->rw_locker_); + std::shared_lock rw_locker(this->rw_locker_); result->Reserve(this->segment_map_.size()); for (const auto &segment_pair : this->segment_map_) { @@ -385,14 +385,14 @@ SharedPtr TableEntry::GetBlockIndex(u64, TxnTimeStamp begin_ts) { return result; } -Json TableEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { - Json json_res; +nlohmann::json TableEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { + nlohmann::json json_res; Vector segment_candidates; Vector table_index_meta_candidates; Vector table_index_name_candidates; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json_res["table_entry_dir"] = *this->table_entry_dir_; json_res["table_name"] = *this->GetTableName(); json_res["table_entry_type"] = this->table_entry_type_; @@ -402,7 +402,7 @@ Json TableEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) json_res["txn_id"] = this->txn_id_.load(); json_res["deleted"] = this->deleted_; for (const auto &column_def : this->columns_) { - Json column_def_json; + nlohmann::json column_def_json; column_def_json["column_type"] = column_def->type()->Serialize(); column_def_json["column_id"] = column_def->id(); column_def_json["column_name"] = column_def->name(); @@ -440,7 +440,7 @@ Json TableEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) SizeT table_index_count = table_index_meta_candidates.size(); for (SizeT idx = 0; idx < table_index_count; ++idx) { TableIndexMeta *table_index_meta = table_index_meta_candidates[idx]; - Json index_def_meta_json = table_index_meta->Serialize(max_commit_ts); + nlohmann::json index_def_meta_json = table_index_meta->Serialize(max_commit_ts); index_def_meta_json["index_name"] = table_index_name_candidates[idx]; json_res["table_indexes"].emplace_back(index_def_meta_json); } @@ -448,7 +448,7 @@ Json TableEntry::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) return json_res; } -UniquePtr TableEntry::Deserialize(const Json &table_entry_json, TableMeta *table_meta, BufferManager *buffer_mgr) { +UniquePtr TableEntry::Deserialize(const nlohmann::json &table_entry_json, TableMeta *table_meta, BufferManager *buffer_mgr) { SharedPtr table_entry_dir = MakeShared(table_entry_json["table_entry_dir"]); SharedPtr table_name = MakeShared(table_entry_json["table_name"]); TableEntryType table_entry_type = table_entry_json["table_entry_type"]; @@ -490,7 +490,7 @@ UniquePtr TableEntry::Deserialize(const Json &table_entry_json, Tabl for (const auto &segment_json : table_entry_json["segments"]) { SharedPtr segment_entry = SegmentEntry::Deserialize(segment_json, table_entry.get(), buffer_mgr); table_entry->segment_map_.emplace(segment_entry->segment_id_, segment_entry); - max_segment_id = Max(max_segment_id, segment_entry->segment_id_); + max_segment_id = std::max(max_segment_id, segment_entry->segment_id_); } table_entry->unsealed_segment_ = table_entry->segment_map_[max_segment_id].get(); } @@ -511,7 +511,7 @@ UniquePtr TableEntry::Deserialize(const Json &table_entry_json, Tabl UniquePtr table_index_meta = TableIndexMeta::Deserialize(index_def_meta_json, table_entry.get(), buffer_mgr); String index_name = index_def_meta_json["index_name"]; - table_entry->index_meta_map_.emplace(Move(index_name), Move(table_index_meta)); + table_entry->index_meta_map_.emplace(std::move(index_name), std::move(table_index_meta)); } } @@ -521,7 +521,7 @@ UniquePtr TableEntry::Deserialize(const Json &table_entry_json, Tabl u64 TableEntry::GetColumnIdByName(const String &column_name) const { auto it = column_name2column_id_.find(column_name); if (it == column_name2column_id_.end()) { - Error(Format("No column name: {}", column_name)); + Error(fmt::format("No column name: {}", column_name)); } return it->second; } @@ -542,14 +542,14 @@ void TableEntry::MergeFrom(BaseEntry &other) { Error("DBEntry::MergeFrom requires table_entry_dir_ match"); } - this->next_segment_id_.store(Max(this->next_segment_id_, table_entry2->next_segment_id_)); - this->row_count_.store(Max(this->row_count_, table_entry2->row_count_)); + this->next_segment_id_.store(std::max(this->next_segment_id_, table_entry2->next_segment_id_)); + this->row_count_.store(std::max(this->row_count_, table_entry2->row_count_)); u32 max_segment_id = 0; for (auto &[seg_id, sgement_entry] : this->segment_map_) { - max_segment_id = Max(max_segment_id, seg_id); + max_segment_id = std::max(max_segment_id, seg_id); } for (auto &[seg_id, sgement_entry2] : table_entry2->segment_map_) { - max_segment_id = Max(max_segment_id, seg_id); + max_segment_id = std::max(max_segment_id, seg_id); auto it = this->segment_map_.find(seg_id); if (it == this->segment_map_.end()) { sgement_entry2->table_entry_ = this; @@ -561,7 +561,7 @@ void TableEntry::MergeFrom(BaseEntry &other) { if (this->unsealed_segment_ == nullptr && !this->segment_map_.empty()) { auto seg_it = this->segment_map_.find(max_segment_id); if (seg_it == this->segment_map_.end()) { - Error(Format("max_segment_id {} is invalid", max_segment_id)); + Error(fmt::format("max_segment_id {} is invalid", max_segment_id)); } this->unsealed_segment_ = seg_it->second.get(); } @@ -569,7 +569,7 @@ void TableEntry::MergeFrom(BaseEntry &other) { for (auto &[index_name, table_index_meta] : table_entry2->index_meta_map_) { auto it = this->index_meta_map_.find(index_name); if (it == this->index_meta_map_.end()) { - this->index_meta_map_.emplace(index_name, Move(table_index_meta)); + this->index_meta_map_.emplace(index_name, std::move(table_index_meta)); } else { it->second->MergeFrom(*table_index_meta.get()); } diff --git a/src/storage/meta/entry/table_entry.cppm b/src/storage/meta/entry/table_entry.cppm index ae4865ad5c..1c88a4ba74 100644 --- a/src/storage/meta/entry/table_entry.cppm +++ b/src/storage/meta/entry/table_entry.cppm @@ -117,9 +117,9 @@ public: void GetFullTextAnalyzers(u64 txn_id, TxnTimeStamp begin_ts, SharedPtr &irs_index_entry, Map &column2analyzer); public: - Json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); - static UniquePtr Deserialize(const Json &table_entry_json, TableMeta *table_meta, BufferManager *buffer_mgr); + static UniquePtr Deserialize(const nlohmann::json &table_entry_json, TableMeta *table_meta, BufferManager *buffer_mgr); virtual void MergeFrom(BaseEntry &other); @@ -133,7 +133,7 @@ public: protected: HashMap column_name2column_id_; - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; SharedPtr table_entry_dir_{}; diff --git a/src/storage/meta/entry/table_index_entry.cpp b/src/storage/meta/entry/table_index_entry.cpp index 57811d51f0..9a7cfcf921 100644 --- a/src/storage/meta/entry/table_index_entry.cpp +++ b/src/storage/meta/entry/table_index_entry.cpp @@ -38,7 +38,7 @@ TableIndexEntry::TableIndexEntry(const SharedPtr &index_def, u64 txn_id, TxnTimeStamp begin_ts, bool is_replay) - : BaseEntry(EntryType::kTableIndex), table_index_meta_(table_index_meta), index_def_(Move(index_def)), index_dir_(Move(index_dir)) { + : BaseEntry(EntryType::kTableIndex), table_index_meta_(table_index_meta), index_def_(std::move(index_def)), index_dir_(std::move(index_dir)) { begin_ts_ = begin_ts; // TODO:: begin_ts and txn_id should be const and set in BaseEntry txn_id_ = txn_id; @@ -59,10 +59,10 @@ TableIndexEntry::TableIndexEntry(const SharedPtr &index_def, if (index_base->index_type_ == IndexType::kIRSFullText) { index_info_map.emplace(column_id, std::static_pointer_cast(index_base)); } else { - SharedPtr column_index_path = MakeShared(Format("{}/{}", *index_dir_, index_base->column_names_[0])); + SharedPtr column_index_path = MakeShared(fmt::format("{}/{}", *index_dir_, index_base->column_names_[0])); UniquePtr column_index_entry = ColumnIndexEntry::NewColumnIndexEntry(index_base, column_id, this, txn_id, column_index_path, begin_ts); - column_index_map_[column_id] = Move(column_index_entry); + column_index_map_[column_id] = std::move(column_index_entry); } } if (!index_info_map.empty()) { @@ -87,20 +87,20 @@ UniquePtr TableIndexEntry::NewDropTableIndexEntry(TableIndexMet } void TableIndexEntry::CommitCreateIndex(u64 column_id, u32 segment_id, SharedPtr segment_column_index_entry) { - UniqueLock w_locker(this->rw_locker_); + std::unique_lock w_locker(this->rw_locker_); ColumnIndexEntry *column_index_entry = this->column_index_map_[column_id].get(); column_index_entry->index_by_segment_.emplace(segment_id, segment_column_index_entry); } void TableIndexEntry::CommitCreateIndex(const SharedPtr &irs_index_entry) { this->irs_index_entry_ = irs_index_entry; } -Json TableIndexEntry::Serialize(TxnTimeStamp max_commit_ts) { - Json json; +nlohmann::json TableIndexEntry::Serialize(TxnTimeStamp max_commit_ts) { + nlohmann::json json; Vector column_index_entry_candidates; IrsIndexEntry *irs_index_entry_candidate_{}; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json["txn_id"] = this->txn_id_.load(); json["begin_ts"] = this->begin_ts_; json["commit_ts"] = this->commit_ts_.load(); @@ -131,7 +131,7 @@ Json TableIndexEntry::Serialize(TxnTimeStamp max_commit_ts) { } UniquePtr -TableIndexEntry::Deserialize(const Json &index_def_entry_json, TableIndexMeta *table_index_meta, BufferManager *buffer_mgr, TableEntry *table_entry) { +TableIndexEntry::Deserialize(const nlohmann::json &index_def_entry_json, TableIndexMeta *table_index_meta, BufferManager *buffer_mgr, TableEntry *table_entry) { u64 txn_id = index_def_entry_json["txn_id"]; TxnTimeStamp begin_ts = index_def_entry_json["begin_ts"]; TxnTimeStamp commit_ts = index_def_entry_json["commit_ts"]; @@ -157,7 +157,7 @@ TableIndexEntry::Deserialize(const Json &index_def_entry_json, TableIndexMeta *t UniquePtr column_index_entry = ColumnIndexEntry::Deserialize(column_index_entry_json, table_index_entry.get(), buffer_mgr, table_entry); u64 column_id = column_index_entry->column_id_; - table_index_entry->column_index_map_.emplace(column_id, Move(column_index_entry)); + table_index_entry->column_index_map_.emplace(column_id, std::move(column_index_entry)); } } @@ -173,7 +173,7 @@ SharedPtr TableIndexEntry::DetermineIndexDir(const String &parent_dir, c SharedPtr index_dir; do { u32 seed = time(nullptr); - index_dir = MakeShared(Format("{}/{}_index_{}", parent_dir, RandomString(DEFAULT_RANDOM_NAME_LEN, seed), index_name)); + index_dir = MakeShared(fmt::format("{}/{}_index_{}", parent_dir, RandomString(DEFAULT_RANDOM_NAME_LEN, seed), index_name)); } while (!fs.CreateDirectoryNoExp(*index_dir)); return index_dir; } diff --git a/src/storage/meta/entry/table_index_entry.cppm b/src/storage/meta/entry/table_index_entry.cppm index 57532eb29e..e1e9db3bfb 100644 --- a/src/storage/meta/entry/table_index_entry.cppm +++ b/src/storage/meta/entry/table_index_entry.cppm @@ -51,10 +51,10 @@ public: static UniquePtr NewDropTableIndexEntry(TableIndexMeta *table_index_meta, u64 txn_id, TxnTimeStamp begin_ts); - Json Serialize(TxnTimeStamp max_commit_ts); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts); static UniquePtr - Deserialize(const Json &index_def_entry_json, TableIndexMeta *table_index_meta, BufferManager *buffer_mgr, TableEntry *table_entry); + Deserialize(const nlohmann::json &index_def_entry_json, TableIndexMeta *table_index_meta, BufferManager *buffer_mgr, TableEntry *table_entry); public: // Getter @@ -72,7 +72,7 @@ private: void CommitCreateIndex(const SharedPtr &irs_index_entry); private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; TableIndexMeta *table_index_meta_{}; const SharedPtr index_def_{}; SharedPtr index_dir_{}; diff --git a/src/storage/meta/entry/view_entry.cppm b/src/storage/meta/entry/view_entry.cppm index ca15848a07..e9ee6bf155 100644 --- a/src/storage/meta/entry/view_entry.cppm +++ b/src/storage/meta/entry/view_entry.cppm @@ -39,8 +39,8 @@ public: ViewMeta *view_meta, u64 txn_id, TxnTimeStamp begin_ts) - : BaseEntry(EntryType::kView), create_view_info_(create_view_info), base_dir_(base_dir), view_name_(Move(view_name)), - column_types_(Move(column_types)), column_names_(Move(column_names)), view_meta_(view_meta) { + : BaseEntry(EntryType::kView), create_view_info_(create_view_info), base_dir_(base_dir), view_name_(std::move(view_name)), + column_types_(std::move(column_types)), column_names_(std::move(column_names)), view_meta_(view_meta) { begin_ts_ = begin_ts; txn_id_ = txn_id; } @@ -54,7 +54,7 @@ public: inline const SharedPtr &view_name() const { return view_name_; } private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; SharedPtr create_view_info_; diff --git a/src/storage/meta/table_index_meta.cpp b/src/storage/meta/table_index_meta.cpp index 42a2ecdb1a..340a180d7e 100644 --- a/src/storage/meta/table_index_meta.cpp +++ b/src/storage/meta/table_index_meta.cpp @@ -36,7 +36,7 @@ namespace infinity { struct SegmentEntry; -TableIndexMeta::TableIndexMeta(TableEntry *table_entry, SharedPtr index_name) : index_name_(Move(index_name)), table_entry_(table_entry) {} +TableIndexMeta::TableIndexMeta(TableEntry *table_entry, SharedPtr index_name) : index_name_(std::move(index_name)), table_entry_(table_entry) {} Tuple TableIndexMeta::CreateTableIndexEntry(const SharedPtr &index_def, ConflictType conflict_type, @@ -67,18 +67,18 @@ Tuple TableIndexMeta::CreateTableIndexEntryInternal(const SharedPtr &index_def, u64 txn_id, TxnTimeStamp begin_ts, TxnManager *txn_mgr) { TableIndexEntry *table_index_entry_ptr{nullptr}; - UniqueLock rw_locker(this->rw_locker_); + std::unique_lock rw_locker(this->rw_locker_); if (this->entry_list_.empty()) { // Insert a dummy entry. UniquePtr dummy_entry = MakeUnique(EntryType::kDummy); dummy_entry->deleted_ = true; - this->entry_list_.emplace_back(Move(dummy_entry)); + this->entry_list_.emplace_back(std::move(dummy_entry)); // Create a new table index entry auto table_index_entry = TableIndexEntry::NewTableIndexEntry(index_def, this, txn_id, begin_ts); table_index_entry_ptr = table_index_entry.get(); - this->entry_list_.emplace_front(Move(table_index_entry)); + this->entry_list_.emplace_front(std::move(table_index_entry)); LOG_TRACE("New table index entry is added."); return {table_index_entry_ptr, Status::OK()}; } else { @@ -87,7 +87,7 @@ TableIndexMeta::CreateTableIndexEntryInternal(const SharedPtr &index_d if (header_base_entry->entry_type_ == EntryType::kDummy) { auto table_index_entry = TableIndexEntry::NewTableIndexEntry(index_def, this, txn_id, begin_ts); table_index_entry_ptr = table_index_entry.get(); - this->entry_list_.emplace_front(Move(table_index_entry)); + this->entry_list_.emplace_front(std::move(table_index_entry)); LOG_TRACE("New table index entry is added."); return {table_index_entry_ptr, Status::OK()}; } @@ -99,21 +99,21 @@ TableIndexMeta::CreateTableIndexEntryInternal(const SharedPtr &index_d // No conflict auto table_index_entry = TableIndexEntry::NewTableIndexEntry(index_def, this, txn_id, begin_ts); table_index_entry_ptr = table_index_entry.get(); - this->entry_list_.emplace_front(Move(table_index_entry)); + this->entry_list_.emplace_front(std::move(table_index_entry)); LOG_TRACE("New table index entry is added."); return {table_index_entry_ptr, Status::OK()}; } else { // Duplicated index name - UniquePtr err_msg = MakeUnique(Format("Duplicated index name: {}.", *this->index_name_)); + UniquePtr err_msg = MakeUnique(fmt::format("Duplicated index name: {}.", *this->index_name_)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kDuplicate, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kDuplicate, std::move(err_msg))}; } } else { // Write-Write conflict UniquePtr err_msg = - MakeUnique(Format("Write-write conflict: There is a committed database which is later than current transaction.")); + MakeUnique(fmt::format("Write-write conflict: There is a committed database which is later than current transaction.")); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } else { @@ -128,27 +128,27 @@ TableIndexMeta::CreateTableIndexEntryInternal(const SharedPtr &index_d // No conflict auto table_index_entry = TableIndexEntry::NewTableIndexEntry(index_def, this, txn_id, begin_ts); table_index_entry_ptr = table_index_entry.get(); - this->entry_list_.emplace_front(Move(table_index_entry)); + this->entry_list_.emplace_front(std::move(table_index_entry)); LOG_TRACE("New table index entry is added."); return {table_index_entry_ptr, Status::OK()}; } else { - UniquePtr err_msg = MakeUnique(Format("Duplicated index name: {}.", *this->index_name_)); + UniquePtr err_msg = MakeUnique(fmt::format("Duplicated index name: {}.", *this->index_name_)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kDuplicate, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kDuplicate, std::move(err_msg))}; } } else { - UniquePtr err_msg = MakeUnique(Format("Write-write conflict: There is a uncommitted transaction.")); + UniquePtr err_msg = MakeUnique(fmt::format("Write-write conflict: There is a uncommitted transaction.")); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } case TxnState::kCommitting: case TxnState::kCommitted: { // Committing / Committed, report WW conflict and rollback current txn UniquePtr err_msg = MakeUnique( - Format("Write-write conflict: There is a committing/committed database which is later than current transaction.")); + fmt::format("Write-write conflict: There is a committing/committed database which is later than current transaction.")); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } case TxnState::kRollbacking: case TxnState::kRollbacked: { @@ -158,14 +158,14 @@ TableIndexMeta::CreateTableIndexEntryInternal(const SharedPtr &index_d // Append new one auto table_index_entry = TableIndexEntry::NewTableIndexEntry(index_def, this, txn_id, begin_ts); table_index_entry_ptr = table_index_entry.get(); - this->entry_list_.emplace_front(Move(table_index_entry)); + this->entry_list_.emplace_front(std::move(table_index_entry)); LOG_TRACE("New table index entry is added."); return {table_index_entry_ptr, Status::OK()}; } default: { UniquePtr err_msg = MakeUnique("Invalid db entry txn state"); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kUndefined, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kUndefined, std::move(err_msg))}; } } } @@ -197,19 +197,19 @@ TableIndexMeta::DropTableIndexEntry(ConflictType conflict_type, u64 txn_id, TxnT Tuple TableIndexMeta::DropTableIndexEntryInternal(u64 txn_id, TxnTimeStamp begin_ts, TxnManager *) { TableIndexEntry *table_index_entry_ptr{nullptr}; - UniqueLock w_locker(this->rw_locker_); + std::unique_lock w_locker(this->rw_locker_); if (this->entry_list_.empty()) { UniquePtr err_msg = MakeUnique("Empty index entry list."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } BaseEntry *header_base_entry = this->entry_list_.front().get(); if (header_base_entry->entry_type_ == EntryType::kDummy) { UniquePtr err_msg = MakeUnique("No valid index entry."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } TableIndexEntry *header_index_entry = (TableIndexEntry *)header_base_entry; @@ -219,21 +219,21 @@ Tuple TableIndexMeta::DropTableIndexEntryInternal(u64 if (header_index_entry->deleted_) { UniquePtr err_msg = MakeUnique("DB is dropped before."); LOG_TRACE(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } // Append new one to drop index auto table_index_entry = TableIndexEntry::NewDropTableIndexEntry(this, txn_id, begin_ts); table_index_entry_ptr = table_index_entry.get(); table_index_entry_ptr->deleted_ = true; - this->entry_list_.emplace_front(Move(table_index_entry)); + this->entry_list_.emplace_front(std::move(table_index_entry)); return {table_index_entry_ptr, Status::OK()}; } else { // Write-Write conflict UniquePtr err_msg = MakeUnique("Write-write conflict: There is a committed database which is later than current transaction."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } else { // Uncommitted, check if the same txn @@ -246,19 +246,19 @@ Tuple TableIndexMeta::DropTableIndexEntryInternal(u64 // Not same txn, issue WW conflict UniquePtr err_msg = MakeUnique("Write-write conflict: There is another uncommitted db entry."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } } SharedPtr TableIndexMeta::ToString() { throw StorageException("Not implemented"); } -Json TableIndexMeta::Serialize(TxnTimeStamp max_commit_ts) { - Json json_res; +nlohmann::json TableIndexMeta::Serialize(TxnTimeStamp max_commit_ts) { + nlohmann::json json_res; Vector table_index_entry_candidates; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json_res["index_name"] = *this->index_name_; table_index_entry_candidates.reserve(this->entry_list_.size()); @@ -282,8 +282,8 @@ Json TableIndexMeta::Serialize(TxnTimeStamp max_commit_ts) { return json_res; } -UniquePtr TableIndexMeta::Deserialize(const Json &table_index_meta_json, TableEntry *table_entry, BufferManager *buffer_mgr) { - LOG_TRACE(Format("load index")); +UniquePtr TableIndexMeta::Deserialize(const nlohmann::json &table_index_meta_json, TableEntry *table_entry, BufferManager *buffer_mgr) { + LOG_TRACE(fmt::format("load index")); SharedPtr index_name = MakeShared(table_index_meta_json["index_name"]); auto res = MakeUnique(table_entry, index_name); @@ -292,7 +292,7 @@ UniquePtr TableIndexMeta::Deserialize(const Json &table_index_me // traverse reversely because a dummy head has been inserted for (auto iter = entries.rbegin(); iter != entries.rend(); iter++) { auto entry = TableIndexEntry::Deserialize(*iter, res.get(), buffer_mgr, table_entry); - res->entry_list_.emplace_front(Move(entry)); + res->entry_list_.emplace_front(std::move(entry)); } } return res; @@ -302,12 +302,12 @@ Tuple TableIndexMeta::GetEntry(u64 txn_id, TxnTimeSta TableIndexEntry *table_index_entry{nullptr}; - SharedLock r_locker(this->rw_locker_); + std::shared_lock r_locker(this->rw_locker_); for (const auto &entry : this->entry_list_) { if (entry->entry_type_ == EntryType::kDummy) { UniquePtr err_msg = MakeUnique("No valid entry"); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } if (entry->commit_ts_ < UNCOMMIT_TS) { @@ -316,7 +316,7 @@ Tuple TableIndexMeta::GetEntry(u64 txn_id, TxnTimeSta if (entry->deleted_) { UniquePtr err_msg = MakeUnique("No valid entry"); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } else { table_index_entry = static_cast(entry.get()); return {table_index_entry, Status::OK()}; @@ -331,11 +331,11 @@ Tuple TableIndexMeta::GetEntry(u64 txn_id, TxnTimeSta UniquePtr err_msg = MakeUnique("No valid entry"); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } void TableIndexMeta::DeleteNewEntry(u64 txn_id, TxnManager *) { - UniqueLock w_locker(this->rw_locker_); + std::unique_lock w_locker(this->rw_locker_); if (this->entry_list_.empty()) { LOG_TRACE("Attempt to delete not existed entry."); return; diff --git a/src/storage/meta/table_index_meta.cppm b/src/storage/meta/table_index_meta.cppm index 5cb08cfcb8..4dcb95c2aa 100644 --- a/src/storage/meta/table_index_meta.cppm +++ b/src/storage/meta/table_index_meta.cppm @@ -52,9 +52,9 @@ private: SharedPtr ToString(); - Json Serialize(TxnTimeStamp max_commit_ts); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts); - static UniquePtr Deserialize(const Json &index_def_meta_json, TableEntry *table_entry, BufferManager *buffer_mgr); + static UniquePtr Deserialize(const nlohmann::json &index_def_meta_json, TableEntry *table_entry, BufferManager *buffer_mgr); void DeleteNewEntry(u64 txn_id, TxnManager *txn_mgr); @@ -66,11 +66,11 @@ private: Tuple DropTableIndexEntryInternal(u64 txn_id, TxnTimeStamp begin_ts, TxnManager *txn_mgr); private: - // RWMutex rw_locker_{}; + // std::shared_mutex rw_locker_{}; SharedPtr index_name_{}; TableEntry *table_entry_{}; - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; List> entry_list_{}; }; } // namespace infinity \ No newline at end of file diff --git a/src/storage/meta/table_meta.cpp b/src/storage/meta/table_meta.cpp index aeb22f0337..f60d47cb42 100644 --- a/src/storage/meta/table_meta.cpp +++ b/src/storage/meta/table_meta.cpp @@ -54,7 +54,7 @@ Tuple TableMeta::CreateNewEntry(TableEntryType table_entry u64 txn_id, TxnTimeStamp begin_ts, TxnManager *txn_mgr) { - UniqueLock rw_locker(this->rw_locker_); + std::unique_lock rw_locker(this->rw_locker_); const String &table_collection_name = *table_collection_name_ptr; TableEntry *table_entry_ptr{nullptr}; @@ -63,15 +63,15 @@ Tuple TableMeta::CreateNewEntry(TableEntryType table_entry // Insert a dummy entry. UniquePtr dummy_entry = MakeUnique(EntryType::kDummy); dummy_entry->deleted_ = true; - this->entry_list_.emplace_back(Move(dummy_entry)); + this->entry_list_.emplace_back(std::move(dummy_entry)); // Insert the new table entry UniquePtr table_entry = MakeUnique(this->db_entry_dir_, table_collection_name_ptr, columns, table_entry_type, this, txn_id, begin_ts); table_entry_ptr = table_entry.get(); - this->entry_list_.emplace_front(Move(table_entry)); + this->entry_list_.emplace_front(std::move(table_entry)); - LOG_TRACE(Format("New table entry is added: {}.", table_collection_name)); + LOG_TRACE(fmt::format("New table entry is added: {}.", table_collection_name)); return {table_entry_ptr, Status::OK()}; } else { // Already have a table entry, check if the table entry is valid here. @@ -81,7 +81,7 @@ Tuple TableMeta::CreateNewEntry(TableEntryType table_entry UniquePtr table_entry = MakeUnique(this->db_entry_dir_, table_collection_name_ptr, columns, table_entry_type, this, txn_id, begin_ts); table_entry_ptr = table_entry.get(); - this->entry_list_.emplace_front(Move(table_entry)); + this->entry_list_.emplace_front(std::move(table_entry)); return {table_entry_ptr, Status::OK()}; } @@ -94,20 +94,20 @@ Tuple TableMeta::CreateNewEntry(TableEntryType table_entry UniquePtr table_entry = MakeUnique(this->db_entry_dir_, table_collection_name_ptr, columns, table_entry_type, this, txn_id, begin_ts); table_entry_ptr = table_entry.get(); - this->entry_list_.emplace_front(Move(table_entry)); + this->entry_list_.emplace_front(std::move(table_entry)); return {table_entry_ptr, Status::OK()}; } else { // Duplicated table - UniquePtr err_msg = MakeUnique(Format("Duplicated table: {}.", table_collection_name)); + UniquePtr err_msg = MakeUnique(fmt::format("Duplicated table: {}.", table_collection_name)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kDuplicate, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kDuplicate, std::move(err_msg))}; } } else { // Write-Write conflict UniquePtr err_msg = MakeUnique( - Format("Write-write conflict: There is a committed table: {} which is later than current transaction.", table_collection_name)); + fmt::format("Write-write conflict: There is a committed table: {} which is later than current transaction.", table_collection_name)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } else { @@ -127,26 +127,26 @@ Tuple TableMeta::CreateNewEntry(TableEntryType table_entry txn_id, begin_ts); table_entry_ptr = table_entry.get(); - this->entry_list_.emplace_front(Move(table_entry)); + this->entry_list_.emplace_front(std::move(table_entry)); return {table_entry_ptr, Status::OK()}; } else { - UniquePtr err_msg = MakeUnique(Format("Create a duplicated table {}.", table_collection_name)); + UniquePtr err_msg = MakeUnique(fmt::format("Create a duplicated table {}.", table_collection_name)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kDuplicate, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kDuplicate, std::move(err_msg))}; } } else { - UniquePtr err_msg = MakeUnique(Format("Write-write conflict: There is a uncommitted transaction.")); + UniquePtr err_msg = MakeUnique(fmt::format("Write-write conflict: There is a uncommitted transaction.")); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } case TxnState::kCommitting: case TxnState::kCommitted: { // Committing / Committed, report WW conflict and rollback current txn UniquePtr err_msg = MakeUnique( - Format("Write-write conflict: There is a committing/committed table which is later than current transaction.")); + fmt::format("Write-write conflict: There is a committing/committed table which is later than current transaction.")); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } case TxnState::kRollbacking: case TxnState::kRollbacked: { @@ -157,13 +157,13 @@ Tuple TableMeta::CreateNewEntry(TableEntryType table_entry UniquePtr table_entry = MakeUnique(this->db_entry_dir_, table_collection_name_ptr, columns, table_entry_type, this, txn_id, begin_ts); table_entry_ptr = table_entry.get(); - this->entry_list_.emplace_front(Move(table_entry)); + this->entry_list_.emplace_front(std::move(table_entry)); return {table_entry_ptr, Status::OK()}; } default: { UniquePtr err_msg = MakeUnique("Invalid table entry txn state"); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kUndefined, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kUndefined, std::move(err_msg))}; } } } @@ -175,18 +175,18 @@ TableMeta::DropNewEntry(u64 txn_id, TxnTimeStamp begin_ts, TxnManager *, const S TableEntry *table_entry_ptr{nullptr}; - UniqueLock rw_locker(this->rw_locker_); + std::unique_lock rw_locker(this->rw_locker_); if (this->entry_list_.empty()) { UniquePtr err_msg = MakeUnique("Empty table entry list."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } BaseEntry *header_base_entry = this->entry_list_.front().get(); if (header_base_entry->entry_type_ == EntryType::kDummy) { UniquePtr err_msg = MakeUnique("No valid table entry."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } auto *header_table_entry = (TableEntry *)header_base_entry; @@ -196,12 +196,12 @@ TableMeta::DropNewEntry(u64 txn_id, TxnTimeStamp begin_ts, TxnManager *, const S // No conflict if (header_table_entry->deleted_) { if (conflict_type == ConflictType::kIgnore) { - LOG_TRACE(Format("Ignore drop a not existed table entry {}", table_name)); + LOG_TRACE(fmt::format("Ignore drop a not existed table entry {}", table_name)); return {nullptr, Status::OK()}; } UniquePtr err_msg = MakeUnique("Table was dropped before."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } Vector> dummy_columns; @@ -209,15 +209,15 @@ TableMeta::DropNewEntry(u64 txn_id, TxnTimeStamp begin_ts, TxnManager *, const S MakeUnique(this->db_entry_dir_, this->table_name_, dummy_columns, TableEntryType::kTableEntry, this, txn_id, begin_ts); table_entry_ptr = table_entry.get(); table_entry_ptr->deleted_ = true; - this->entry_list_.emplace_front(Move(table_entry)); + this->entry_list_.emplace_front(std::move(table_entry)); return {table_entry_ptr, Status::OK()}; } else { // Write-Write conflict UniquePtr err_msg = - MakeUnique(Format("Write-write conflict: There is a committed database which is later than current transaction.")); + MakeUnique(fmt::format("Write-write conflict: There is a committed database which is later than current transaction.")); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } else { // Uncommitted, check if the same txn @@ -229,15 +229,15 @@ TableMeta::DropNewEntry(u64 txn_id, TxnTimeStamp begin_ts, TxnManager *, const S return {table_entry_ptr, Status::OK()}; } else { // Not same txn, issue WW conflict - UniquePtr err_msg = MakeUnique(Format("Write-write conflict: There is another uncommitted table entry.")); + UniquePtr err_msg = MakeUnique(fmt::format("Write-write conflict: There is another uncommitted table entry.")); LOG_ERROR(*err_msg); - return {table_entry_ptr, Status(ErrorCode::kWWConflict, Move(err_msg))}; + return {table_entry_ptr, Status(ErrorCode::kWWConflict, std::move(err_msg))}; } } } void TableMeta::DeleteNewEntry(u64 txn_id, TxnManager *) { - UniqueLock rw_locker(this->rw_locker_); + std::unique_lock rw_locker(this->rw_locker_); if (this->entry_list_.empty()) { LOG_TRACE("Empty table entry list."); return; @@ -263,18 +263,18 @@ void TableMeta::DeleteNewEntry(u64 txn_id, TxnManager *) { * @return Status */ Tuple TableMeta::GetEntry(u64 txn_id, TxnTimeStamp begin_ts) { - SharedLock r_locker(this->rw_locker_); + std::shared_lock r_locker(this->rw_locker_); if (this->entry_list_.empty()) { UniquePtr err_msg = MakeUnique("Empty table entry list."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } for (const auto &table_entry : this->entry_list_) { if (table_entry->entry_type_ == EntryType::kDummy) { UniquePtr err_msg = MakeUnique("No valid table entry. dummy entry"); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } u64 table_entry_commit_ts = table_entry->commit_ts_; @@ -284,7 +284,7 @@ Tuple TableMeta::GetEntry(u64 txn_id, TxnTimeStamp begin_t if (table_entry->deleted_) { UniquePtr err_msg = MakeUnique("Table was dropped."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } else { return {static_cast(table_entry.get()), Status::OK()}; } @@ -299,23 +299,23 @@ Tuple TableMeta::GetEntry(u64 txn_id, TxnTimeStamp begin_t } UniquePtr err_msg = MakeUnique("No table entry found."); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } const SharedPtr &TableMeta::db_name_ptr() const { return db_entry_->db_name_ptr(); } SharedPtr TableMeta::ToString() { - SharedLock r_locker(this->rw_locker_); + std::shared_lock r_locker(this->rw_locker_); SharedPtr res = - MakeShared(Format("TableMeta, db_entry_dir: {}, table name: {}, entry count: ", *db_entry_dir_, *table_name_, entry_list_.size())); + MakeShared(fmt::format("TableMeta, db_entry_dir: {}, table name: {}, entry count: ", *db_entry_dir_, *table_name_, entry_list_.size())); return res; } -Json TableMeta::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { - Json json_res; +nlohmann::json TableMeta::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { + nlohmann::json json_res; Vector table_candidates; { - SharedLock lck(this->rw_locker_); + std::shared_lock lck(this->rw_locker_); json_res["db_entry_dir"] = *this->db_entry_dir_; json_res["table_name"] = *this->table_name_; // Need to find the full history of the entry till given timestamp. Note that GetEntry returns at most one valid entry at given timestamp. @@ -345,21 +345,21 @@ Json TableMeta::Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint) { * @param buffer_mgr * @return UniquePtr */ -UniquePtr TableMeta::Deserialize(const Json &table_meta_json, DBEntry *db_entry, BufferManager *buffer_mgr) { +UniquePtr TableMeta::Deserialize(const nlohmann::json &table_meta_json, DBEntry *db_entry, BufferManager *buffer_mgr) { SharedPtr db_entry_dir = MakeShared(table_meta_json["db_entry_dir"]); SharedPtr table_name = MakeShared(table_meta_json["table_name"]); - LOG_TRACE(Format("load table {}", *table_name)); + LOG_TRACE(fmt::format("load table {}", *table_name)); UniquePtr res = MakeUnique(db_entry_dir, table_name, db_entry); if (table_meta_json.contains("table_entries")) { for (const auto &table_entry_json : table_meta_json["table_entries"]) { UniquePtr table_entry = TableEntry::Deserialize(table_entry_json, res.get(), buffer_mgr); - res->entry_list_.emplace_back(Move(table_entry)); + res->entry_list_.emplace_back(std::move(table_entry)); } } res->entry_list_.sort([](const UniquePtr &ent1, const UniquePtr &ent2) { return ent1->commit_ts_ > ent2->commit_ts_; }); UniquePtr dummy_entry = MakeUnique(EntryType::kDummy); dummy_entry->deleted_ = true; - res->entry_list_.emplace_back(Move(dummy_entry)); + res->entry_list_.emplace_back(std::move(dummy_entry)); return res; } diff --git a/src/storage/meta/table_meta.cppm b/src/storage/meta/table_meta.cppm index ccf17aaa6f..690b485493 100644 --- a/src/storage/meta/table_meta.cppm +++ b/src/storage/meta/table_meta.cppm @@ -38,13 +38,13 @@ friend struct NewCatalog; public: inline explicit TableMeta(const SharedPtr &db_entry_dir, SharedPtr name, DBEntry *db_entry) - : db_entry_dir_(db_entry_dir), table_name_(Move(name)), db_entry_(db_entry) {} + : db_entry_dir_(db_entry_dir), table_name_(std::move(name)), db_entry_(db_entry) {} SharedPtr ToString(); - Json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); + nlohmann::json Serialize(TxnTimeStamp max_commit_ts, bool is_full_checkpoint); - static UniquePtr Deserialize(const Json &table_meta_json, DBEntry *db_entry, BufferManager *buffer_mgr); + static UniquePtr Deserialize(const nlohmann::json &table_meta_json, DBEntry *db_entry, BufferManager *buffer_mgr); void MergeFrom(TableMeta &other); @@ -68,7 +68,7 @@ private: Tuple GetEntry(u64 txn_id, TxnTimeStamp begin_ts); private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; SharedPtr db_entry_dir_{}; SharedPtr table_name_{}; diff --git a/src/storage/meta/view_meta.cppm b/src/storage/meta/view_meta.cppm index f9cc95f366..66e9f8bf0d 100644 --- a/src/storage/meta/view_meta.cppm +++ b/src/storage/meta/view_meta.cppm @@ -30,7 +30,7 @@ class DBEntry; export struct ViewMeta { public: - explicit ViewMeta(SharedPtr name, DBEntry *db_entry) : view_name_(Move(name)), db_entry_(db_entry) {} + explicit ViewMeta(SharedPtr name, DBEntry *db_entry) : view_name_(std::move(name)), db_entry_(db_entry) {} public: static Status CreateNewEntry(ViewMeta *table_meta, @@ -54,7 +54,7 @@ private: inline void *GetDBEntry() { return this->db_entry_; } private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; SharedPtr view_name_{}; DBEntry *db_entry_{}; diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 4b40739914..6d29339667 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -80,7 +80,7 @@ void Storage::Init() { } void Storage::UnInit() { - Printf("Shutdown storage ...\n"); + fmt::print("Shutdown storage ...\n"); bg_processor_->Stop(); wal_mgr_->Stop(); @@ -94,7 +94,7 @@ void Storage::UnInit() { new_catalog_.reset(); config_ptr_ = nullptr; - Printf("Shutdown storage successfully\n"); + fmt::print("Shutdown storage successfully\n"); } SharedPtr Storage::GetLatestCatalog(const String &dir) { @@ -109,7 +109,7 @@ SharedPtr Storage::GetLatestCatalog(const String &dir) { int64_t latest_version_number = -1; const std::regex catalog_file_regex("META_[0-9]+\\.full.json"); for (const auto &dir_entry_ptr : dir_array) { - LOG_TRACE(Format("Candidate file name: {}", dir_entry_ptr->path().c_str())); + LOG_TRACE(fmt::format("Candidate file name: {}", dir_entry_ptr->path().c_str())); if (dir_entry_ptr->is_regular_file()) { String current_file_name = dir_entry_ptr->path().filename(); if (std::regex_match(current_file_name, catalog_file_regex)) { @@ -138,9 +138,9 @@ void Storage::InitCatalog(NewCatalog *, TxnManager *txn_mgr) { } void Storage::AttachCatalog(const Vector &catalog_files) { - LOG_INFO(Format("Attach catalogs from {} files", catalog_files.size())); + LOG_INFO(fmt::format("Attach catalogs from {} files", catalog_files.size())); for (const auto &catalog_file : catalog_files) { - LOG_TRACE(Format("Catalog file: {}", catalog_file.c_str())); + LOG_TRACE(fmt::format("Catalog file: {}", catalog_file.c_str())); } new_catalog_ = NewCatalog::LoadFromFiles(catalog_files, buffer_mgr_.get()); } diff --git a/src/storage/txn/txn.cpp b/src/storage/txn/txn.cpp index fe65bf7e15..206904487d 100644 --- a/src/storage/txn/txn.cpp +++ b/src/storage/txn/txn.cpp @@ -53,9 +53,9 @@ Tuple Txn::GetTableEntry(const String &db_name, const Stri db_name_ = db_name; } else { if (!IsEqual(db_name_, db_name)) { - UniquePtr err_msg = MakeUnique(Format("Attempt to get table {} from another database {}", db_name, table_name)); + UniquePtr err_msg = MakeUnique(fmt::format("Attempt to get table {} from another database {}", db_name, table_name)); LOG_ERROR(*err_msg); - return {nullptr, Status(ErrorCode::kNotFound, Move(err_msg))}; + return {nullptr, Status(ErrorCode::kNotFound, std::move(err_msg))}; } } @@ -89,7 +89,7 @@ Status Txn::Append(const String &db_name, const String &table_name, const Shared wal_entry_->cmds.push_back(MakeShared(db_name, table_name, input_block)); UniquePtr err_msg = table_store->Append(input_block); if (err_msg.get() != nullptr) { - return Status(ErrorCode::kError, Move(err_msg)); + return Status(ErrorCode::kError, std::move(err_msg)); } return Status::OK(); } @@ -109,13 +109,13 @@ Status Txn::Delete(const String &db_name, const String &table_name, const Vector wal_entry_->cmds.push_back(MakeShared(db_name, table_name, row_ids)); UniquePtr err_msg = table_store->Delete(row_ids); if (err_msg.get() != nullptr) { - return Status(ErrorCode::kError, Move(err_msg)); + return Status(ErrorCode::kError, std::move(err_msg)); } return Status::OK(); } TxnTableStore *Txn::GetTxnTableStore(TableEntry *table_entry) { - UniqueLock lk(lock_); + std::unique_lock lk(lock_); auto txn_table_iter = txn_tables_store_.find(*table_entry->GetTableName()); if (txn_table_iter != txn_tables_store_.end()) { return txn_table_iter->second.get(); @@ -231,7 +231,7 @@ Status Txn::CreateTable(const String &db_name, const SharedPtr &table_ if (table_status.ok()) { UniquePtr err_msg = MakeUnique("TODO: CreateTableCollectionFailed"); LOG_ERROR(*err_msg); - return Status(ErrorCode::kError, Move(err_msg)); + return Status(ErrorCode::kError, std::move(err_msg)); } else { return table_status; } @@ -412,7 +412,7 @@ TxnTimeStamp Txn::Commit() { txn_mgr_->PutWalEntry(wal_entry_); // Wait until CommitTxnBottom is done. - UniqueLock lk(lock_); + std::unique_lock lk(lock_); cond_var_.wait(lk, [this] { return done_bottom_; }); return commit_ts; } @@ -449,17 +449,17 @@ void Txn::CommitBottom() { for (const auto &[index_name, table_index_entry] : txn_indexes_) { table_index_entry->Commit(commit_ts); } - LOG_TRACE(Format("Txn: {} is committed.", txn_id_)); + LOG_TRACE(fmt::format("Txn: {} is committed.", txn_id_)); // Notify the top half - UniqueLock lk(lock_); + std::unique_lock lk(lock_); done_bottom_ = true; cond_var_.notify_one(); } void Txn::CancelCommitBottom() { txn_context_.SetTxnRollbacked(); - UniqueLock lk(lock_); + std::unique_lock lk(lock_); done_bottom_ = true; cond_var_.notify_one(); } @@ -496,7 +496,7 @@ void Txn::Rollback() { txn_context_.SetTxnRollbacked(); - LOG_TRACE(Format("Txn: {} is dropped.", txn_id_)); + LOG_TRACE(fmt::format("Txn: {} is dropped.", txn_id_)); } void Txn::AddWalCmd(const SharedPtr &cmd) { wal_entry_->cmds.push_back(cmd); } diff --git a/src/storage/txn/txn.cppm b/src/storage/txn/txn.cppm index aa1e5b487b..f683e8f575 100644 --- a/src/storage/txn/txn.cppm +++ b/src/storage/txn/txn.cppm @@ -171,8 +171,8 @@ private: SharedPtr wal_entry_{}; // WalManager notify the commit bottom half is done - Mutex lock_{}; - CondVar cond_var_{}; + std::mutex lock_{}; + std::condition_variable cond_var_{}; bool done_bottom_{false}; }; diff --git a/src/storage/txn/txn_context.cppm b/src/storage/txn/txn_context.cppm index da5f38f964..6ccf5ce13f 100644 --- a/src/storage/txn/txn_context.cppm +++ b/src/storage/txn/txn_context.cppm @@ -30,7 +30,7 @@ public: friend class Txn; inline void BeginCommit(TxnTimeStamp begin_ts) { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); if (state_ != TxnState::kNotStarted) { Error("Transaction isn't in NOT_STARTED status."); } @@ -39,22 +39,22 @@ public: } inline TxnTimeStamp GetBeginTS() { - SharedLock r_locker(rw_locker_); + std::shared_lock r_locker(rw_locker_); return begin_ts_; } inline TxnTimeStamp GetCommitTS() { - SharedLock r_locker(rw_locker_); + std::shared_lock r_locker(rw_locker_); return commit_ts_; } inline TxnState GetTxnState() { - SharedLock r_locker(rw_locker_); + std::shared_lock r_locker(rw_locker_); return state_; } inline void SetTxnRollbacking(TxnTimeStamp rollback_ts) { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); if (state_ != TxnState::kStarted) { Error("Transaction isn't in STARTED status."); } @@ -63,7 +63,7 @@ public: } inline void SetTxnRollbacked() { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); if (state_ != TxnState::kRollbacking && state_!= TxnState::kCommitting) { Error("Transaction isn't in ROLLBACKING status."); } @@ -71,7 +71,7 @@ public: } inline void SetTxnCommitted() { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); if (state_ != TxnState::kCommitting) { Error("Transaction isn't in COMMITTING status."); } @@ -79,7 +79,7 @@ public: } inline void SetTxnCommitting(TxnTimeStamp commit_ts) { - UniqueLock w_locker(rw_locker_); + std::unique_lock w_locker(rw_locker_); if (state_ != TxnState::kStarted) { Error("Transaction isn't in STARTED status."); } @@ -88,7 +88,7 @@ public: } private: - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; TxnTimeStamp begin_ts_{}; TxnTimeStamp commit_ts_{}; TxnState state_{TxnState::kNotStarted}; diff --git a/src/storage/txn/txn_manager.cpp b/src/storage/txn/txn_manager.cpp index 07b1305f24..f2d81e177c 100644 --- a/src/storage/txn/txn_manager.cpp +++ b/src/storage/txn/txn_manager.cpp @@ -42,7 +42,7 @@ Txn *TxnManager::CreateTxn() { u64 new_txn_id = GetNewTxnID(); UniquePtr new_txn = MakeUnique(this, catalog_, new_txn_id); Txn *res = new_txn.get(); - txn_map_[new_txn_id] = Move(new_txn); + txn_map_[new_txn_id] = std::move(new_txn); rw_locker_.unlock(); return res; } @@ -55,7 +55,7 @@ Txn *TxnManager::GetTxn(u64 txn_id) { } TxnState TxnManager::GetTxnState(u64 txn_id) { - SharedLock r_locker(rw_locker_); + std::shared_lock r_locker(rw_locker_); Txn *txn_ptr = txn_map_[txn_id].get(); TxnState res = txn_ptr->GetTxnState(); return res; @@ -67,7 +67,7 @@ u64 TxnManager::GetNewTxnID() { } TxnTimeStamp TxnManager::GetTimestamp(bool prepare_wal) { - LockGuard guard(mutex_); + std::lock_guard guard(mutex_); TxnTimeStamp ts = txn_ts_++; if (prepare_wal && put_wal_entry_ != nullptr) { priority_que_[ts] = nullptr; @@ -80,7 +80,7 @@ void TxnManager::Invalidate(TxnTimeStamp commit_ts) { if (is_running_.load() == false) { Error("TxnManager is not running, cannot invalidate"); } - LockGuard guard(mutex_); + std::lock_guard guard(mutex_); SizeT cnt = priority_que_.erase(commit_ts); if (cnt > 0 && !priority_que_.empty()) { auto it = priority_que_.begin(); @@ -98,7 +98,7 @@ void TxnManager::PutWalEntry(SharedPtr entry) { } if (put_wal_entry_ == nullptr) return; - UniqueLock lk(mutex_); + std::unique_lock lk(mutex_); priority_que_[entry->commit_ts] = entry; auto it = priority_que_.begin(); while (it != priority_que_.end() && it->second.get() != nullptr) { @@ -108,7 +108,7 @@ void TxnManager::PutWalEntry(SharedPtr entry) { return; } -void TxnManager::Start() { is_running_.store(true, MemoryOrderRelax); } +void TxnManager::Start() { is_running_.store(true, std::memory_order::relaxed); } void TxnManager::Stop() { bool expected = true; @@ -119,7 +119,7 @@ void TxnManager::Stop() { } LOG_INFO("TxnManager is stopping..."); - LockGuard guard(mutex_); + std::lock_guard guard(mutex_); auto it = priority_que_.begin(); while (it != priority_que_.end()) { // remove and notify the wal manager condition variable diff --git a/src/storage/txn/txn_manager.cppm b/src/storage/txn/txn_manager.cppm index a2d76ee6da..49417d1b33 100644 --- a/src/storage/txn/txn_manager.cppm +++ b/src/storage/txn/txn_manager.cppm @@ -71,7 +71,7 @@ private: private: NewCatalog *catalog_{}; - RWMutex rw_locker_{}; + std::shared_mutex rw_locker_{}; u64 txn_id_{}; BufferManager *buffer_mgr_{}; HashMap> txn_map_{}; @@ -79,7 +79,7 @@ private: PutWalEntryFn put_wal_entry_{}; // Use a variant of priority queue to ensure entries are putted to WalManager in the same order as commit_ts allocation. - Mutex mutex_; + std::mutex mutex_; TxnTimeStamp txn_ts_{}; Map> priority_que_; // TODO: use C++23 std::flat_map? // For stop the txn manager diff --git a/src/storage/txn/txn_store.cpp b/src/storage/txn/txn_store.cpp index 6939f61d4b..2f64f898e7 100644 --- a/src/storage/txn/txn_store.cpp +++ b/src/storage/txn/txn_store.cpp @@ -37,7 +37,7 @@ TxnIndexStore::TxnIndexStore(TableIndexEntry *table_index_entry) : table_index_e UniquePtr TxnTableStore::Append(const SharedPtr &input_block) { SizeT column_count = table_entry_->ColumnCount(); if (input_block->column_count() != column_count) { - String err_msg = Format("Attempt to insert different column count data block into transaction table store"); + String err_msg = fmt::format("Attempt to insert different column count data block into transaction table store"); LOG_ERROR(err_msg); return MakeUnique(err_msg); } @@ -46,7 +46,7 @@ UniquePtr TxnTableStore::Append(const SharedPtr &input_block) for (SizeT col_id = 0; col_id < column_count; ++col_id) { column_types.emplace_back(table_entry_->GetColumnDefByID(col_id)->type()); if (*column_types.back() != *input_block->column_vectors[col_id]->data_type()) { - String err_msg = Format("Attempt to insert different type data into transaction table store"); + String err_msg = fmt::format("Attempt to insert different type data into transaction table store"); LOG_ERROR(err_msg); return MakeUnique(err_msg); } @@ -99,7 +99,7 @@ TxnTableStore::CreateIndexFile(TableIndexEntry *table_index_entry, u64 column_id } else { TxnIndexStore index_store(table_index_entry); index_store.index_entry_map_[column_id][segment_id] = index; - txn_indexes_store_.emplace(index_name, Move(index_store)); + txn_indexes_store_.emplace(index_name, std::move(index_store)); } return nullptr; } @@ -134,7 +134,7 @@ void TxnTableStore::Rollback() { if (append_state_.get() != nullptr) { // Rollback the data already been appended. NewCatalog::RollbackAppend(table_entry_, txn_->TxnID(), txn_->CommitTS(), this); - LOG_TRACE(Format("Rollback prepare appended data in table: {}", *table_entry_->GetTableName())); + LOG_TRACE(fmt::format("Rollback prepare appended data in table: {}", *table_entry_->GetTableName())); } blocks_.clear(); @@ -145,7 +145,7 @@ void TxnTableStore::PrepareCommit() { append_state_ = MakeUnique(this->blocks_); // Start to append - LOG_TRACE(Format("Transaction local storage table: {}, Start to prepare commit", *table_entry_->GetTableName())); + LOG_TRACE(fmt::format("Transaction local storage table: {}, Start to prepare commit", *table_entry_->GetTableName())); Txn *txn_ptr = (Txn *)txn_; NewCatalog::Append(table_entry_, txn_->TxnID(), this, txn_ptr->GetBufferMgr()); @@ -159,7 +159,7 @@ void TxnTableStore::PrepareCommit() { NewCatalog::Delete(table_entry_, txn_->TxnID(), txn_->CommitTS(), delete_state_); NewCatalog::CommitCreateIndex(txn_indexes_store_); - LOG_TRACE(Format("Transaction local storage table: {}, Complete commit preparing", *table_entry_->GetTableName())); + LOG_TRACE(fmt::format("Transaction local storage table: {}, Complete commit preparing", *table_entry_->GetTableName())); } /** diff --git a/src/storage/view.cppm b/src/storage/view.cppm index 2ec475e3e5..c021eec68e 100644 --- a/src/storage/view.cppm +++ b/src/storage/view.cppm @@ -26,7 +26,7 @@ export class View { public: explicit View(SharedPtr create_view_info, SharedPtr> column_names, SharedPtr>> column_types) - : create_view_info_(Move(create_view_info)), column_names_(Move(column_names)), column_types_(Move(column_types)) {} + : create_view_info_(std::move(create_view_info)), column_names_(std::move(column_names)), column_types_(std::move(column_types)) {} [[nodiscard]] inline const String &schema_name() const { return create_view_info_->schema_name_; } diff --git a/src/storage/wal/wal_entry.cpp b/src/storage/wal/wal_entry.cpp index 572f16f42e..5b93427c80 100644 --- a/src/storage/wal/wal_entry.cpp +++ b/src/storage/wal/wal_entry.cpp @@ -113,7 +113,7 @@ SharedPtr WalCmd::ReadAdv(char *&ptr, i32 max_bytes) { break; } default: - Error(Format("UNIMPLEMENTED ReadAdv for WalCmd command {}", int(cmd_type))); + Error(fmt::format("UNIMPLEMENTED ReadAdv for WalCmd command {}", int(cmd_type))); } max_bytes = ptr_end - ptr; if (max_bytes < 0) { @@ -327,7 +327,7 @@ i32 WalEntry::GetSizeInBytes() const { void WalEntry::WriteAdv(char *&ptr) const { char *const saved_ptr = ptr; - Memcpy(ptr, this, sizeof(WalEntryHeader)); + std::memcpy(ptr, this, sizeof(WalEntryHeader)); ptr += sizeof(WalEntryHeader); WriteBufAdv(ptr, static_cast(cmds.size())); SizeT cmd_count = cmds.size(); @@ -484,13 +484,13 @@ WalEntryIterator WalEntryIterator::Make(const String &wal_path) { ifs.read(buf.data(), wal_size); ifs.close(); - return WalEntryIterator(Move(buf), wal_size); + return WalEntryIterator(std::move(buf), wal_size); } SharedPtr WalEntryIterator::Next() { if (end_ > buf_.data()) { i32 entry_size; - Memcpy(&entry_size, end_ - sizeof(i32), sizeof(entry_size)); + std::memcpy(&entry_size, end_ - sizeof(i32), sizeof(entry_size)); end_ = end_ - entry_size; auto entry = WalEntry::ReadAdv(end_, entry_size); end_ = end_ - entry_size; diff --git a/src/storage/wal/wal_entry.cppm b/src/storage/wal/wal_entry.cppm index f654c3e9e4..1dedb1141b 100644 --- a/src/storage/wal/wal_entry.cppm +++ b/src/storage/wal/wal_entry.cppm @@ -72,7 +72,7 @@ export struct WalCmd { }; export struct WalCmdCreateDatabase : public WalCmd { - explicit WalCmdCreateDatabase(String db_name_) : db_name(Move(db_name_)) {} + explicit WalCmdCreateDatabase(String db_name_) : db_name(std::move(db_name_)) {} WalCommandType GetType() override { return WalCommandType::CREATE_DATABASE; } bool operator==(const WalCmd &other) const override { @@ -86,7 +86,7 @@ export struct WalCmdCreateDatabase : public WalCmd { }; export struct WalCmdDropDatabase : public WalCmd { - explicit WalCmdDropDatabase(String db_name_) : db_name(Move(db_name_)) {} + explicit WalCmdDropDatabase(String db_name_) : db_name(std::move(db_name_)) {} WalCommandType GetType() override { return WalCommandType::DROP_DATABASE; } bool operator==(const WalCmd &other) const override { @@ -100,7 +100,7 @@ export struct WalCmdDropDatabase : public WalCmd { }; export struct WalCmdCreateTable : public WalCmd { - WalCmdCreateTable(String db_name_, const SharedPtr &table_def_) : db_name(Move(db_name_)), table_def(table_def_) {} + WalCmdCreateTable(String db_name_, const SharedPtr &table_def_) : db_name(std::move(db_name_)), table_def(table_def_) {} WalCommandType GetType() override { return WalCommandType::CREATE_TABLE; } bool operator==(const WalCmd &other) const override; @@ -113,7 +113,7 @@ export struct WalCmdCreateTable : public WalCmd { export struct WalCmdCreateIndex : public WalCmd { WalCmdCreateIndex(String db_name, String table_name, SharedPtr index_def) - : db_name_(Move(db_name)), table_name_(Move(table_name)), index_def_(Move(index_def)) {} + : db_name_(std::move(db_name)), table_name_(std::move(table_name)), index_def_(std::move(index_def)) {} WalCommandType GetType() override { return WalCommandType::CREATE_INDEX; } @@ -162,7 +162,7 @@ export struct WalCmdDropIndex : public WalCmd { export struct WalCmdImport : public WalCmd { WalCmdImport(String db_name_, String table_name_, String segment_dir_, u32 segment_id_, u16 block_entries_size_, Vector &row_counts_) - : db_name(Move(db_name_)), table_name(Move(table_name_)), segment_dir(Move(segment_dir_)), segment_id(segment_id_), + : db_name(std::move(db_name_)), table_name(std::move(table_name_)), segment_dir(std::move(segment_dir_)), segment_id(segment_id_), block_entries_size(block_entries_size_), row_counts_(row_counts_) {} WalCommandType GetType() override { return WalCommandType::IMPORT; } @@ -181,7 +181,7 @@ export struct WalCmdImport : public WalCmd { export struct WalCmdAppend : public WalCmd { WalCmdAppend(String db_name_, String table_name_, const SharedPtr &block_) - : db_name(Move(db_name_)), table_name(Move(table_name_)), block(block_) {} + : db_name(std::move(db_name_)), table_name(std::move(table_name_)), block(block_) {} WalCommandType GetType() override { return WalCommandType::APPEND; } bool operator==(const WalCmd &other) const override; @@ -195,7 +195,7 @@ export struct WalCmdAppend : public WalCmd { export struct WalCmdDelete : public WalCmd { WalCmdDelete(String db_name_, String table_name_, const Vector &row_ids_) - : db_name(Move(db_name_)), table_name(Move(table_name_)), row_ids(row_ids_) {} + : db_name(std::move(db_name_)), table_name(std::move(table_name_)), row_ids(row_ids_) {} WalCommandType GetType() override { return WalCommandType::DELETE; } bool operator==(const WalCmd &other) const override; @@ -265,7 +265,7 @@ public: [[nodiscard]] SharedPtr Next(); private: - WalEntryIterator(Vector &&buf, StreamSize wal_size) : buf_(Move(buf)), wal_size_(wal_size) { + WalEntryIterator(Vector &&buf, StreamSize wal_size) : buf_(std::move(buf)), wal_size_(wal_size) { end_ = buf_.data() + wal_size_; } diff --git a/src/storage/wal/wal_manager.cpp b/src/storage/wal/wal_manager.cpp index 47a01c7e37..d7360c83eb 100644 --- a/src/storage/wal/wal_manager.cpp +++ b/src/storage/wal/wal_manager.cpp @@ -88,7 +88,7 @@ WalManager::WalManager(Storage *storage, u64 delta_checkpoint_interval_wal_bytes) : wal_size_threshold_(wal_size_threshold), full_checkpoint_interval_sec_(full_checkpoint_interval_sec), delta_checkpoint_interval_sec_(delta_checkpoint_interval_sec), delta_checkpoint_interval_wal_bytes_(delta_checkpoint_interval_wal_bytes), - wal_path_(Move(wal_path)), storage_(storage), running_(false) {} + wal_path_(std::move(wal_path)), storage_(storage), running_(false) {} WalManager::~WalManager() { Stop(); @@ -108,7 +108,7 @@ void WalManager::Start() { // TODO: recovery from wal checkpoint ofs_ = std::ofstream(wal_path_, std::ios::app | std::ios::binary); if (!ofs_.is_open()) { - Error(Format("Failed to open wal file: {}", wal_path_)); + Error(fmt::format("Failed to open wal file: {}", wal_path_)); } auto seconds_since_epoch = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()); int64_t now = seconds_since_epoch.count(); @@ -207,7 +207,7 @@ void WalManager::Flush() { for (const auto &entry : que2_) { // Empty WalEntry (read-only transactions) shouldn't go into WalManager. if (entry->cmds.empty()) { - Error(Format("WalEntry of txn_id {} commands is empty", entry->txn_id)); + Error(fmt::format("WalEntry of txn_id {} commands is empty", entry->txn_id)); } int32_t exp_size = entry->GetSizeInBytes(); Vector buf(exp_size); @@ -215,12 +215,12 @@ void WalManager::Flush() { entry->WriteAdv(ptr); int32_t act_size = ptr - buf.data(); if (exp_size != act_size) - LOG_ERROR(Format("WalManager::Flush WalEntry estimated size {} differ " + LOG_ERROR(fmt::format("WalManager::Flush WalEntry estimated size {} differ " "with the actual one {}", exp_size, act_size)); ofs_.write(buf.data(), ptr - buf.data()); - LOG_TRACE(Format("WalManager::Flush done writing wal for txn_id {}, commit_ts {}", entry->txn_id, entry->commit_ts)); + LOG_TRACE(fmt::format("WalManager::Flush done writing wal for txn_id {}, commit_ts {}", entry->txn_id, entry->commit_ts)); if (entry->cmds[0]->GetType() != WalCommandType::CHECKPOINT) { max_commit_ts = entry->commit_ts; wal_size += act_size; @@ -286,7 +286,7 @@ void WalManager::Checkpoint() { txn_mgr = storage_->txn_manager(); txn = txn_mgr->CreateTxn(); txn->Begin(); - LOG_INFO(Format("created txn for checkpoint, txn_id: {}, begin_ts: {}, max_commit_ts {}", txn->TxnID(), txn->BeginTS(), max_commit_ts)); + LOG_INFO(fmt::format("created txn for checkpoint, txn_id: {}, begin_ts: {}, max_commit_ts {}", txn->TxnID(), txn->BeginTS(), max_commit_ts)); txn->Checkpoint(max_commit_ts, is_full_checkpoint); txn_mgr->CommitTxn(txn); @@ -299,9 +299,9 @@ void WalManager::Checkpoint() { full_ckp_commit_ts_ = max_commit_ts; RecycleWalFile(full_ckp_commit_ts_); } - LOG_INFO(Format("WalManager::Checkpoint {} done for commit_ts <= {}", is_full_checkpoint ? "full" : "delta", max_commit_ts)); + LOG_INFO(fmt::format("WalManager::Checkpoint {} done for commit_ts <= {}", is_full_checkpoint ? "full" : "delta", max_commit_ts)); } catch (Exception &e) { - LOG_ERROR(Format("WalManager::Checkpoint failed: {}", e.what())); + LOG_ERROR(fmt::format("WalManager::Checkpoint failed: {}", e.what())); } } @@ -314,7 +314,7 @@ void WalManager::Checkpoint(ForceCheckpointTask *ckp_task) { bool is_full_checkpoint = true; - LOG_INFO(Format("Start to full checkpoint, txn_id: {}, begin_ts: {}, max_commit_ts {}", + LOG_INFO(fmt::format("Start to full checkpoint, txn_id: {}, begin_ts: {}, max_commit_ts {}", ckp_task->txn_->TxnID(), ckp_task->txn_->BeginTS(), max_commit_ts)); @@ -323,7 +323,7 @@ void WalManager::Checkpoint(ForceCheckpointTask *ckp_task) { // This function doesn't change the ckp related variable, which won't affect the following checkpoint correctness. - LOG_INFO(Format("Full Checkpoint is done for commit_ts <= {}", max_commit_ts)); + LOG_INFO(fmt::format("Full Checkpoint is done for commit_ts <= {}", max_commit_ts)); } /** @@ -342,8 +342,8 @@ void WalManager::SwapWalFile(const TxnTimeStamp max_commit_ts) { Path old_file_path = Path(wal_path_); - String new_file_path = old_file_path.string() + '.' + ToStr(max_commit_ts); - LOG_INFO(Format("Wal Swap to new path: {}", new_file_path.c_str())); + String new_file_path = old_file_path.string() + '.' + std::to_string(max_commit_ts); + LOG_INFO(fmt::format("Wal Swap to new path: {}", new_file_path.c_str())); // Rename the current wal file to a new one. std::filesystem::rename(wal_path_, new_file_path); @@ -351,7 +351,7 @@ void WalManager::SwapWalFile(const TxnTimeStamp max_commit_ts) { // Create a new wal file with the original name. ofs_ = std::ofstream(wal_path_, std::ios::app | std::ios::binary); if (!ofs_.is_open()) { - Error(Format("Failed to open wal file: {}", wal_path_)); + Error(fmt::format("Failed to open wal file: {}", wal_path_)); } } @@ -434,9 +434,9 @@ i64 WalManager::ReplayWalFile() { LOG_INFO("Start Wal Replay"); // log the wal files. for (const auto &wal_file : wal_list_) { - LOG_TRACE(Format("List wal file: {}", wal_file.c_str())); + LOG_TRACE(fmt::format("List wal file: {}", wal_file.c_str())); } - LOG_INFO(Format("List wal file size: {}", wal_list_.size())); + LOG_INFO(fmt::format("List wal file size: {}", wal_list_.size())); i64 max_commit_ts = 0; String catalog_path; @@ -467,8 +467,8 @@ i64 WalManager::ReplayWalFile() { max_commit_ts = current_max_commit_ts; catalog_path = current_catalog_path; } - LOG_TRACE(Format("Find checkpoint max commit ts: {}", max_commit_ts)); - LOG_TRACE(Format("Find catalog path: {}", catalog_path)); + LOG_TRACE(fmt::format("Find checkpoint max commit ts: {}", max_commit_ts)); + LOG_TRACE(fmt::format("Find catalog path: {}", catalog_path)); break; } else { // delta checkpoint @@ -481,7 +481,7 @@ i64 WalManager::ReplayWalFile() { } } } - LOG_INFO(Format("Find checkpoint max commit ts: {}", max_commit_ts)); + LOG_INFO(fmt::format("Find checkpoint max commit ts: {}", max_commit_ts)); // phase 2: by the max commit ts, find the entries to replay LOG_INFO("Replay phase 2: by the max commit ts, find the entries to replay"); @@ -529,14 +529,14 @@ i64 WalManager::ReplayWalFile() { system_start_ts = replay_entries[replay_count]->commit_ts; last_txn_id = replay_entries[replay_count]->txn_id; if (replay_entries[replay_count]->IsCheckPoint()) { - LOG_TRACE(Format("Replay Skip checkpoint entry: {}", replay_entries[replay_count]->ToString())); + LOG_TRACE(fmt::format("Replay Skip checkpoint entry: {}", replay_entries[replay_count]->ToString())); continue; } ReplayWalEntry(*replay_entries[replay_count]); LOG_TRACE(replay_entries[replay_count]->ToString()); } - LOG_TRACE(Format("System start ts: {}, lastest txn id: {}", system_start_ts, last_txn_id)); + LOG_TRACE(fmt::format("System start ts: {}, lastest txn id: {}", system_start_ts, last_txn_id)); storage_->catalog()->next_txn_id_ = last_txn_id; return system_start_ts; } @@ -559,7 +559,7 @@ void WalManager::RecycleWalFile(TxnTimeStamp full_ckp_ts) { auto suffix = entry.path().string().substr(entry.path().string().find_last_of('.') + 1); if (std::stoll(suffix) < i64(full_ckp_ts)) { std::filesystem::remove(entry.path()); - LOG_TRACE(Format("WalManager::Checkpoint delete wal file: {}", entry.path().string().c_str())); + LOG_TRACE(fmt::format("WalManager::Checkpoint delete wal file: {}", entry.path().string().c_str())); } } } @@ -568,7 +568,7 @@ void WalManager::RecycleWalFile(TxnTimeStamp full_ckp_ts) { } void WalManager::ReplayWalEntry(const WalEntry &entry) { for (const auto &cmd : entry.cmds) { - LOG_TRACE(Format("Replay wal cmd: {}, commit ts: {}", WalManager::WalCommandTypeToString(cmd->GetType()).c_str(), entry.commit_ts)); + LOG_TRACE(fmt::format("Replay wal cmd: {}, commit ts: {}", WalManager::WalCommandTypeToString(cmd->GetType()).c_str(), entry.commit_ts)); switch (cmd->GetType()) { case WalCommandType::CREATE_DATABASE: WalCmdCreateDatabaseReplay(*dynamic_cast(cmd.get()), entry.txn_id, entry.commit_ts); @@ -672,7 +672,7 @@ void WalManager::WalCmdImportReplay(const WalCmdImport &cmd, u64 txn_id, i64 com auto [table_entry, table_status] = storage_->catalog()->GetTableByName(cmd.db_name, cmd.table_name, txn_id, commit_ts); if (!table_status.ok()) { - Error(Format("Wal Replay: Get table failed {}", table_status.message())); + Error(fmt::format("Wal Replay: Get table failed {}", table_status.message())); } auto segment_dir_ptr = MakeShared(cmd.segment_dir); @@ -688,7 +688,7 @@ void WalManager::WalCmdImportReplay(const WalCmdImport &cmd, u64 txn_id, i64 com commit_ts, commit_ts); - segment_entry->AppendBlockEntry(Move(block_entry)); + segment_entry->AppendBlockEntry(std::move(block_entry)); segment_entry->IncreaseRowCount(cmd.row_counts_[id]); } @@ -697,7 +697,7 @@ void WalManager::WalCmdImportReplay(const WalCmdImport &cmd, u64 txn_id, i64 com void WalManager::WalCmdDeleteReplay(const WalCmdDelete &cmd, u64 txn_id, i64 commit_ts) { auto [table_entry, table_status] = storage_->catalog()->GetTableByName(cmd.db_name, cmd.table_name, txn_id, commit_ts); if (!table_status.ok()) { - Error(Format("Wal Replay: Get table failed {}", table_status.message())); + Error(fmt::format("Wal Replay: Get table failed {}", table_status.message())); } auto fake_txn = MakeUnique(storage_->txn_manager(), storage_->catalog(), txn_id); @@ -711,7 +711,7 @@ void WalManager::WalCmdDeleteReplay(const WalCmdDelete &cmd, u64 txn_id, i64 com void WalManager::WalCmdAppendReplay(const WalCmdAppend &cmd, u64 txn_id, i64 commit_ts) { auto [table_entry, table_status] = storage_->catalog()->GetTableByName(cmd.db_name, cmd.table_name, txn_id, commit_ts); if (!table_status.ok()) { - Error(Format("Wal Replay: Get table failed {}", table_status.message())); + Error(fmt::format("Wal Replay: Get table failed {}", table_status.message())); } auto fake_txn = MakeUnique(storage_->txn_manager(), storage_->catalog(), txn_id); @@ -720,7 +720,7 @@ void WalManager::WalCmdAppendReplay(const WalCmdAppend &cmd, u64 txn_id, i64 com table_store->Append(cmd.block); auto append_state = MakeUnique(table_store->blocks_); - table_store->append_state_ = Move(append_state); + table_store->append_state_ = std::move(append_state); fake_txn->FakeCommit(commit_ts); NewCatalog::Append(table_store->table_entry_, table_store->txn_->TxnID(), table_store.get(), storage_->buffer_manager()); diff --git a/src/storage/wal/wal_manager.cppm b/src/storage/wal/wal_manager.cppm index 7837d2068b..bf18e77af2 100644 --- a/src/storage/wal/wal_manager.cppm +++ b/src/storage/wal/wal_manager.cppm @@ -101,7 +101,7 @@ private: Thread checkpoint_thread_{}; // TxnManager and Flush thread access following members - Mutex mutex_{}; + std::mutex mutex_{}; Deque> que_{}; // Only Flush thread access following members @@ -109,7 +109,7 @@ private: StdOfStream ofs_{}; // Flush and Checkpoint threads access following members - Mutex mutex2_{}; + std::mutex mutex2_{}; TxnTimeStamp max_commit_ts_{}; i64 wal_size_{}; diff --git a/src/unit_test/function/aggregate/first_functions.cpp b/src/unit_test/function/aggregate/first_functions.cpp index 88dfe98b42..b45e32709e 100644 --- a/src/unit_test/function/aggregate/first_functions.cpp +++ b/src/unit_test/function/aggregate/first_functions.cpp @@ -287,7 +287,7 @@ TEST_F(FirstFunctionTest, first_func) { data_block.Init(column_types); for (SizeT idx = 0; idx < row_count; ++idx) { - String s = "hello" + ToStr(idx); + String s = "hello" + std::to_string(idx); VarcharT varchar_value; varchar_value.InitAsValue(s); Value v = Value::MakeVarchar(varchar_value); diff --git a/src/unit_test/function/cast/float/double_cast.cpp b/src/unit_test/function/cast/float/double_cast.cpp index 1f373c02af..e549fe2c58 100644 --- a/src/unit_test/function/cast/float/double_cast.cpp +++ b/src/unit_test/function/cast/float/double_cast.cpp @@ -187,49 +187,49 @@ TEST_F(DoubleCastTest, double_cast0) { source = std::numeric_limits::lowest(); EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 47); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = std::numeric_limits::max(); EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 46); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 0; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 8); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 9; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 8); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 10; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 9); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 99; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 9); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = -100; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 11); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 100; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 10); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); @@ -237,7 +237,7 @@ TEST_F(DoubleCastTest, double_cast0) { source = std::numeric_limits::max(); EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 46); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); @@ -399,7 +399,7 @@ TEST_F(DoubleCastTest, double_cast1) { EXPECT_TRUE(result); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { f64 check_value = static_cast(i); - String check_str(ToStr(check_value)); + String check_str(std::to_string(check_value)); Value vx = col_target->GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s2.c_str(), check_str.c_str()); diff --git a/src/unit_test/function/cast/float/float_cast.cpp b/src/unit_test/function/cast/float/float_cast.cpp index 3848a30612..7eb30fa0c7 100644 --- a/src/unit_test/function/cast/float/float_cast.cpp +++ b/src/unit_test/function/cast/float/float_cast.cpp @@ -184,49 +184,49 @@ TEST_F(FloatCastTest, float_cast0) { source = std::numeric_limits::lowest(); EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 47); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = std::numeric_limits::max(); EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 46); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 0; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 8); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 9; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 8); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 10; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 9); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 99; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 9); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = -100; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 11); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 100; EXPECT_TRUE(FloatTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 10); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); } @@ -387,7 +387,7 @@ TEST_F(FloatCastTest, float_cast1) { EXPECT_TRUE(result); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { f32 check_value = static_cast(i); - String check_str(ToStr(check_value)); + String check_str(std::to_string(check_value)); Value vx = col_target->GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s2.c_str(), check_str.c_str()); diff --git a/src/unit_test/function/cast/integer_cast/bigint_cast.cpp b/src/unit_test/function/cast/integer_cast/bigint_cast.cpp index a1b764dc82..c0b56a6119 100644 --- a/src/unit_test/function/cast/integer_cast/bigint_cast.cpp +++ b/src/unit_test/function/cast/integer_cast/bigint_cast.cpp @@ -186,49 +186,49 @@ TEST_F(BigIntCastTest, bigint_cast0) { source = std::numeric_limits::min(); EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 20); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = std::numeric_limits::max(); EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 19); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 0; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 1); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 9; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 1); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 10; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 2); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 99; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 2); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = -100; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 4); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 100; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); -// src_str = ToStr(source); +// src_str = std::to_string(source); // EXPECT_EQ(src_str.size(), 3); // EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); } @@ -406,7 +406,7 @@ TEST_F(BigIntCastTest, bigint_cast1) { EXPECT_TRUE(result); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { i64 check_value = static_cast(i); - String check_str(ToStr(check_value)); + String check_str(std::to_string(check_value)); Value vx = col_target->GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s2.c_str(), check_str.c_str()); diff --git a/src/unit_test/function/cast/integer_cast/integer_cast.cpp b/src/unit_test/function/cast/integer_cast/integer_cast.cpp index b17fc42d04..f33e32d1e1 100644 --- a/src/unit_test/function/cast/integer_cast/integer_cast.cpp +++ b/src/unit_test/function/cast/integer_cast/integer_cast.cpp @@ -176,49 +176,49 @@ TEST_F(IntegerCastTest, integer_cast0) { source = std::numeric_limits::min(); EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 11); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = std::numeric_limits::max(); EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 10); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 0; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 1); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 9; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 1); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 10; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 2); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 99; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 2); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = -100; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 4); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 100; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 3); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); } @@ -395,7 +395,7 @@ TEST_F(IntegerCastTest, integer_cast1) { EXPECT_TRUE(result); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { i32 check_value = static_cast(i); - String check_str(ToStr(check_value)); + String check_str(std::to_string(check_value)); Value vx = col_target->GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s2.c_str(), check_str.c_str()); diff --git a/src/unit_test/function/cast/integer_cast/small_integer_cast.cpp b/src/unit_test/function/cast/integer_cast/small_integer_cast.cpp index 802eb7de64..68fcd55511 100644 --- a/src/unit_test/function/cast/integer_cast/small_integer_cast.cpp +++ b/src/unit_test/function/cast/integer_cast/small_integer_cast.cpp @@ -167,49 +167,49 @@ TEST_F(SmallIntegerCastTest, small_integer_cast0) { source = std::numeric_limits::min(); EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 6); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = std::numeric_limits::max(); EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 5); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 0; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 1); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 9; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 1); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 10; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 2); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 99; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 2); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = -100; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 4); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 100; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 3); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); } @@ -382,7 +382,7 @@ TEST_F(SmallIntegerCastTest, small_integer_cast1) { EXPECT_TRUE(result); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { i16 check_value = static_cast(i); - String check_str(ToStr(check_value)); + String check_str(std::to_string(check_value)); Value vx = col_target->GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s2.c_str(), check_str.c_str()); diff --git a/src/unit_test/function/cast/integer_cast/tiny_integer_cast.cpp b/src/unit_test/function/cast/integer_cast/tiny_integer_cast.cpp index 5dfe7dba40..6a442cbd86 100644 --- a/src/unit_test/function/cast/integer_cast/tiny_integer_cast.cpp +++ b/src/unit_test/function/cast/integer_cast/tiny_integer_cast.cpp @@ -162,49 +162,49 @@ TEST_F(TinyIntegerCastTest, tiny_integer_cast0) { source = std::numeric_limits::min(); EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 4); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = std::numeric_limits::max(); EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 3); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 0; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 1); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 9; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 1); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 10; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 2); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 99; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 2); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = -100; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 4); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); source = 100; EXPECT_TRUE(IntegerTryCastToVarlen::Run(source, target, col_varchar_ptr)); - src_str = ToStr(source); + src_str = std::to_string(source); EXPECT_EQ(src_str.size(), 3); EXPECT_STREQ(src_str.c_str(), target.ToString().c_str()); } @@ -375,7 +375,7 @@ TEST_F(TinyIntegerCastTest, tiny_integer_cast1) { EXPECT_TRUE(result); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { i8 check_value = static_cast(i); - String check_str(ToStr(check_value)); + String check_str(std::to_string(check_value)); Value vx = col_target->GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s2.c_str(), check_str.c_str()); diff --git a/src/unit_test/function/scalar/equals_functions.cpp b/src/unit_test/function/scalar/equals_functions.cpp index 841789e32d..8d8450ac20 100644 --- a/src/unit_test/function/scalar/equals_functions.cpp +++ b/src/unit_test/function/scalar/equals_functions.cpp @@ -579,11 +579,11 @@ TEST_F(EqualsFunctionsTest, equals_func) { for (SizeT i = 0; i < row_count; ++i) { if (i % 2 == 0) { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + std::to_string(i))); } else { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("helloworld" + std::to_string(i))); } } data_block.Finalize(); @@ -594,11 +594,11 @@ TEST_F(EqualsFunctionsTest, equals_func) { EXPECT_EQ(v1.type_.type(), LogicalType::kVarchar); EXPECT_EQ(v2.type_.type(), LogicalType::kVarchar); if (i % 2 == 0) { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); } else { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + std::to_string(i)); } } diff --git a/src/unit_test/function/scalar/greater_equals_functions.cpp b/src/unit_test/function/scalar/greater_equals_functions.cpp index d535686028..9c1f0b8c95 100644 --- a/src/unit_test/function/scalar/greater_equals_functions.cpp +++ b/src/unit_test/function/scalar/greater_equals_functions.cpp @@ -446,11 +446,11 @@ TEST_F(GreaterEqualsFunctionsTest, greater_equals_func) { // // for (SizeT i = 0; i < row_count; ++i) { // if (i % 2 == 0) { -// data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); -// data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + ToStr(i))); +// data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); +// data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + std::to_string(i))); // } else { -// data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); -// data_block.AppendValue(1, Value::MakeVarchar("helloworld" + ToStr(i))); +// data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); +// data_block.AppendValue(1, Value::MakeVarchar("helloworld" + std::to_string(i))); // } // } // data_block.Finalize(); @@ -461,11 +461,11 @@ TEST_F(GreaterEqualsFunctionsTest, greater_equals_func) { // EXPECT_EQ(v1.type_.type(), LogicalType::kVarchar); // EXPECT_EQ(v2.type_.type(), LogicalType::kVarchar); // if (i % 2 == 0) { -// EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); -// EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + ToStr(i)); +// EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); +// EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); // } else { -// EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); -// EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + ToStr(i)); +// EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); +// EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + std::to_string(i)); // } // } // @@ -477,16 +477,16 @@ TEST_F(GreaterEqualsFunctionsTest, greater_equals_func) { // Value v = result->GetValue(i); // EXPECT_EQ(v.type_.type(), LogicalType::kBoolean); // if (i % 2 == 0) { -// String s1 = "Helloworld" + ToStr(i); -// String s2 = "Helloworld" + ToStr(i); +// String s1 = "Helloworld" + std::to_string(i); +// String s2 = "Helloworld" + std::to_string(i); // if (s1 >= s2) { // EXPECT_EQ(v.value_.boolean, true); // } else { // EXPECT_EQ(v.value_.boolean, false); // } // } else { -// String s1 = "Helloworld" + ToStr(i); -// String s2 = "helloworld" + ToStr(i); +// String s1 = "Helloworld" + std::to_string(i); +// String s2 = "helloworld" + std::to_string(i); // if (s1 >= s2) { // EXPECT_EQ(v.value_.boolean, true); // } else { diff --git a/src/unit_test/function/scalar/greater_functions.cpp b/src/unit_test/function/scalar/greater_functions.cpp index 79ee2310d5..e2cc7b06f1 100644 --- a/src/unit_test/function/scalar/greater_functions.cpp +++ b/src/unit_test/function/scalar/greater_functions.cpp @@ -448,11 +448,11 @@ TEST_F(GreaterFunctionsTest, greater_func) { for (SizeT i = 0; i < row_count; ++i) { if (i % 2 == 0) { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + std::to_string(i))); } else { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("helloworld" + std::to_string(i))); } } data_block.Finalize(); @@ -463,11 +463,11 @@ TEST_F(GreaterFunctionsTest, greater_func) { EXPECT_EQ(v1.type_.type(), LogicalType::kVarchar); EXPECT_EQ(v2.type_.type(), LogicalType::kVarchar); if (i % 2 == 0) { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); } else { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + std::to_string(i)); } } @@ -479,16 +479,16 @@ TEST_F(GreaterFunctionsTest, greater_func) { Value v = result->GetValue(i); EXPECT_EQ(v.type_.type(), LogicalType::kBoolean); if (i % 2 == 0) { - String s1 = "Helloworld" + ToStr(i); - String s2 = "Helloworld" + ToStr(i); + String s1 = "Helloworld" + std::to_string(i); + String s2 = "Helloworld" + std::to_string(i); if (s1 > s2) { EXPECT_EQ(v.value_.boolean, true); } else { EXPECT_EQ(v.value_.boolean, false); } } else { - String s1 = "Helloworld" + ToStr(i); - String s2 = "helloworld" + ToStr(i); + String s1 = "Helloworld" + std::to_string(i); + String s2 = "helloworld" + std::to_string(i); if (s1 > s2) { EXPECT_EQ(v.value_.boolean, true); } else { diff --git a/src/unit_test/function/scalar/inequals_functions.cpp b/src/unit_test/function/scalar/inequals_functions.cpp index 4dca286912..f7ae16f0ee 100644 --- a/src/unit_test/function/scalar/inequals_functions.cpp +++ b/src/unit_test/function/scalar/inequals_functions.cpp @@ -576,11 +576,11 @@ TEST_F(InEqualsFunctionsTest, inequals_func) { for (SizeT i = 0; i < row_count; ++i) { if (i % 2 == 0) { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + std::to_string(i))); } else { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("helloworld" + std::to_string(i))); } } data_block.Finalize(); @@ -591,11 +591,11 @@ TEST_F(InEqualsFunctionsTest, inequals_func) { EXPECT_EQ(v1.type_.type(), LogicalType::kVarchar); EXPECT_EQ(v2.type_.type(), LogicalType::kVarchar); if (i % 2 == 0) { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); } else { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + std::to_string(i)); } } diff --git a/src/unit_test/function/scalar/less_equals_functions.cpp b/src/unit_test/function/scalar/less_equals_functions.cpp index d01355c58a..3a2ac7db78 100644 --- a/src/unit_test/function/scalar/less_equals_functions.cpp +++ b/src/unit_test/function/scalar/less_equals_functions.cpp @@ -446,11 +446,11 @@ TEST_F(LessEqualsFunctionsTest, less_equals_func) { for (SizeT i = 0; i < row_count; ++i) { if (i % 2 == 0) { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + std::to_string(i))); } else { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("helloworld" + std::to_string(i))); } } data_block.Finalize(); @@ -461,11 +461,11 @@ TEST_F(LessEqualsFunctionsTest, less_equals_func) { EXPECT_EQ(v1.type_.type(), LogicalType::kVarchar); EXPECT_EQ(v2.type_.type(), LogicalType::kVarchar); if (i % 2 == 0) { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); } else { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + std::to_string(i)); } } @@ -477,16 +477,16 @@ TEST_F(LessEqualsFunctionsTest, less_equals_func) { Value v = result->GetValue(i); EXPECT_EQ(v.type_.type(), LogicalType::kBoolean); if (i % 2 == 0) { - String s1 = "Helloworld" + ToStr(i); - String s2 = "Helloworld" + ToStr(i); + String s1 = "Helloworld" + std::to_string(i); + String s2 = "Helloworld" + std::to_string(i); if (s1 <= s2) { EXPECT_EQ(v.value_.boolean, true); } else { EXPECT_EQ(v.value_.boolean, false); } } else { - String s1 = "Helloworld" + ToStr(i); - String s2 = "helloworld" + ToStr(i); + String s1 = "Helloworld" + std::to_string(i); + String s2 = "helloworld" + std::to_string(i); if (s1 <= s2) { EXPECT_EQ(v.value_.boolean, true); } else { diff --git a/src/unit_test/function/scalar/less_functions.cpp b/src/unit_test/function/scalar/less_functions.cpp index 16351328f5..4ee1fcfb2f 100644 --- a/src/unit_test/function/scalar/less_functions.cpp +++ b/src/unit_test/function/scalar/less_functions.cpp @@ -446,11 +446,11 @@ TEST_F(LessFunctionsTest, less_func) { for (SizeT i = 0; i < row_count; ++i) { if (i % 2 == 0) { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("Helloworld" + std::to_string(i))); } else { - data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + ToStr(i))); - data_block.AppendValue(1, Value::MakeVarchar("helloworld" + ToStr(i))); + data_block.AppendValue(0, Value::MakeVarchar("Helloworld" + std::to_string(i))); + data_block.AppendValue(1, Value::MakeVarchar("helloworld" + std::to_string(i))); } } data_block.Finalize(); @@ -461,11 +461,11 @@ TEST_F(LessFunctionsTest, less_func) { EXPECT_EQ(v1.type_.type(), LogicalType::kVarchar); EXPECT_EQ(v2.type_.type(), LogicalType::kVarchar); if (i % 2 == 0) { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); } else { - EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + ToStr(i)); - EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + ToStr(i)); + EXPECT_EQ(v1.value_.varchar.ToString(), "Helloworld" + std::to_string(i)); + EXPECT_EQ(v2.value_.varchar.ToString(), "helloworld" + std::to_string(i)); } } @@ -477,16 +477,16 @@ TEST_F(LessFunctionsTest, less_func) { Value v = result->GetValue(i); EXPECT_EQ(v.type_.type(), LogicalType::kBoolean); if (i % 2 == 0) { - String s1 = "Helloworld" + ToStr(i); - String s2 = "Helloworld" + ToStr(i); + String s1 = "Helloworld" + std::to_string(i); + String s2 = "Helloworld" + std::to_string(i); if (s1 < s2) { EXPECT_EQ(v.value_.boolean, true); } else { EXPECT_EQ(v.value_.boolean, false); } } else { - String s1 = "Helloworld" + ToStr(i); - String s2 = "helloworld" + ToStr(i); + String s1 = "Helloworld" + std::to_string(i); + String s2 = "helloworld" + std::to_string(i); if (s1 < s2) { EXPECT_EQ(v.value_.boolean, true); } else { diff --git a/src/unit_test/function/scalar/substr_function.cpp b/src/unit_test/function/scalar/substr_function.cpp index c0218b6f00..a095deec7e 100644 --- a/src/unit_test/function/scalar/substr_function.cpp +++ b/src/unit_test/function/scalar/substr_function.cpp @@ -87,7 +87,7 @@ TEST_F(SubstrFunctionTest, varchar_substr) { len_value_expr->AppendToChunk(col2); for (SizeT idx = 0; idx < row_count; ++idx) { - String s = "hello" + ToStr(idx); + String s = "hello" + std::to_string(idx); VarcharT varchar_value; varchar_value.InitAsValue(s); Value v = Value::MakeVarchar(varchar_value); @@ -163,7 +163,7 @@ TEST_F(SubstrFunctionTest, varchar_substr) { len_value_expr->AppendToChunk(col2); for (SizeT idx = 0; idx < row_count; ++idx) { - String s = "hellohellohellohello" + ToStr(idx); + String s = "hellohellohellohello" + std::to_string(idx); VarcharT varchar_value; varchar_value.InitAsValue(s); Value v = Value::MakeVarchar(varchar_value); diff --git a/src/unit_test/parser/type/complex/bitmap_type.cpp b/src/unit_test/parser/type/complex/bitmap_type.cpp index f3ba09d994..3dc7ac415d 100644 --- a/src/unit_test/parser/type/complex/bitmap_type.cpp +++ b/src/unit_test/parser/type/complex/bitmap_type.cpp @@ -98,7 +98,7 @@ TEST_F(BitmapTypeTest, bitmap1) { } } - BitmapT bt4 = Move(bt3); + BitmapT bt4 = std::move(bt3); for (u64 i = 0; i < 100; ++i) { if (i % 2 == 0) { @@ -133,7 +133,7 @@ TEST_F(BitmapTypeTest, bitmap1) { EXPECT_THROW(bt5.GetBit(50), ParserException); EXPECT_THROW(bt5.SetBit(50, false), ParserException); - bt5 = Move(bt2); + bt5 = std::move(bt2); for (u64 i = 0; i < 100; ++i) { if (i % 2 == 0) { @@ -243,7 +243,7 @@ TEST_F(BitmapTypeTest, bitmap2) { } } - BitmapT bt4 = Move(bt3); + BitmapT bt4 = std::move(bt3); for (u64 i = 0; i < 100; ++i) { if (i % 2 == 0) { @@ -278,7 +278,7 @@ TEST_F(BitmapTypeTest, bitmap2) { EXPECT_THROW(bt5.GetBit(50), ParserException); EXPECT_THROW(bt5.SetBit(50, false), ParserException); - bt5 = Move(bt2); + bt5 = std::move(bt2); for (u64 i = 0; i < 100; ++i) { if (i % 2 == 0) { diff --git a/src/unit_test/parser/type/complex/blob_type.cpp b/src/unit_test/parser/type/complex/blob_type.cpp index d28e9146ad..3a148d4e4c 100644 --- a/src/unit_test/parser/type/complex/blob_type.cpp +++ b/src/unit_test/parser/type/complex/blob_type.cpp @@ -52,8 +52,8 @@ TEST_F(BlobTypeTest, blob1) { EXPECT_EQ(b1, b2); EXPECT_FALSE(b1 != b2); - // Move constructor - BlobT b3(Move(b1)); + // std::move constructor + BlobT b3(std::move(b1)); EXPECT_STREQ(b2.ptr, "abcdefghijklmnopqrstuvwxyz"); EXPECT_EQ(b2.size, SIZE); @@ -66,9 +66,9 @@ TEST_F(BlobTypeTest, blob1) { EXPECT_STREQ(b4.ptr, "abcdefghijklmnopqrstuvwxyz"); EXPECT_EQ(b4.size, SIZE); - // Move assignment + // std::move assignment BlobT b5; - b5 = Move(b2); + b5 = std::move(b2); EXPECT_STREQ(b5.ptr, "abcdefghijklmnopqrstuvwxyz"); EXPECT_EQ(b5.size, SIZE); @@ -80,7 +80,7 @@ TEST_F(BlobTypeTest, blob1) { EXPECT_EQ(b5.ptr, nullptr); EXPECT_EQ(b5.size, 0); - // Move from ptr; + // std::move from ptr; blob_ptr = new char[SIZE]{0}; for (i64 i = 0; i < SIZE; ++i) { @@ -88,7 +88,7 @@ TEST_F(BlobTypeTest, blob1) { } blob_ptr[SIZE - 1] = 0; BlobT b6; - b6.Move(blob_ptr, SIZE); + b6.std::move(blob_ptr, SIZE); EXPECT_STREQ(b6.ptr, "abcdefghijklmnopqrstuvwxyz"); EXPECT_EQ(b6.size, SIZE); diff --git a/src/unit_test/parser/type/complex/uuid_type.cpp b/src/unit_test/parser/type/complex/uuid_type.cpp index 2d88612f7b..24d1df85fc 100644 --- a/src/unit_test/parser/type/complex/uuid_type.cpp +++ b/src/unit_test/parser/type/complex/uuid_type.cpp @@ -43,14 +43,14 @@ TEST_F(UuidTypeTest, Uuid) { uuid3 = uuid2; EXPECT_STREQ(uuid3.ToString().c_str(), uuid_str); - // Move assignment + // std::move assignment UuidT uuid4{}; - uuid4 = Move(uuid2); + uuid4 = std::move(uuid2); EXPECT_STREQ(uuid4.ToString().c_str(), uuid_str); EXPECT_STREQ(uuid2.ToString().c_str(), ""); - // Move constructor - UuidT uuid5(Move(uuid3)); + // std::move constructor + UuidT uuid5(std::move(uuid3)); EXPECT_STREQ(uuid5.ToString().c_str(), uuid_str); EXPECT_STREQ(uuid3.ToString().c_str(), ""); diff --git a/src/unit_test/parser/type/complex/varchar_type.cpp b/src/unit_test/parser/type/complex/varchar_type.cpp index 2fd0afee6d..4e369d4ece 100644 --- a/src/unit_test/parser/type/complex/varchar_type.cpp +++ b/src/unit_test/parser/type/complex/varchar_type.cpp @@ -172,24 +172,24 @@ TEST_F(VarcharTypeTest, TestCopy) { // String s1 = "Hello World"; // String s2 = "Hello World, welcome to c++"; // -// // Move constructor 1 +// // std::move constructor 1 // { // // VarcharT v1; // v1.InitAsValue(s1); -// VarcharT v2 = Move(v1); +// VarcharT v2 = std::move(v1); // EXPECT_EQ(v1.length_, 0); // EXPECT_EQ(v1.ToString(), ""); // EXPECT_EQ(v2.length_, s1.length()); // EXPECT_EQ(v2.ToString(), s1); // } // -// // Move constructor 2 +// // std::move constructor 2 // { // // VarcharT v1; // v1.InitAsValue(s2); -// VarcharT v2 = Move(v1); +// VarcharT v2 = std::move(v1); // EXPECT_EQ(v1.length_, 0); // EXPECT_EQ(v1.ptr, nullptr); // EXPECT_EQ(v1.ToString(), ""); @@ -261,26 +261,26 @@ TEST_F(VarcharTypeTest, TestMoveAssignment) { String s2 = "Hello World, welcome to c++"; String s3 = "Hello World, Php is the best programming language in the world"; - // Move constructor 1 + // std::move constructor 1 { VarcharT v1; v1.InitAsValue(s1); VarcharT v2; - v2 = Move(v1); + v2 = std::move(v1); EXPECT_EQ(v1.length_, 0); EXPECT_EQ(v1.ToString(), ""); EXPECT_EQ(v2.length_, s1.length()); EXPECT_EQ(v2.ToString(), s1); } - // Move constructor 2 + // std::move constructor 2 { VarcharT v1; v1.InitAsValue(s2); VarcharT v2; - v2 = Move(v1); + v2 = std::move(v1); EXPECT_EQ(v1.length_, 0); EXPECT_EQ(v1.value_.ptr_, nullptr); EXPECT_EQ(v1.ToString(), ""); @@ -288,7 +288,7 @@ TEST_F(VarcharTypeTest, TestMoveAssignment) { EXPECT_EQ(v2.ToString(), s2); } - // Move Assignment 3 + // std::move Assignment 3 { VarcharT v1; @@ -298,14 +298,14 @@ TEST_F(VarcharTypeTest, TestMoveAssignment) { VarcharT v3; v3.InitAsValue(s3); - v2 = Move(v1); + v2 = std::move(v1); EXPECT_EQ(v1.length_, 0); EXPECT_EQ(v1.ToString(), ""); EXPECT_EQ(v2.length_, s1.length()); EXPECT_EQ(v2.ToString(), s1); - v2 = Move(v3); + v2 = std::move(v3); EXPECT_EQ(v2.length_, s3.length()); EXPECT_EQ(v2.ToString(), s3); EXPECT_EQ(v3.length_, 0); diff --git a/src/unit_test/parser/type/geo/path_type.cpp b/src/unit_test/parser/type/geo/path_type.cpp index 0776ae71c4..1de01d6b48 100644 --- a/src/unit_test/parser/type/geo/path_type.cpp +++ b/src/unit_test/parser/type/geo/path_type.cpp @@ -74,7 +74,7 @@ TEST_F(PathTypeTest, path1) { EXPECT_EQ(path4.GetPoint(1).y, PointT(1.1, 2.2).y); PathT path5(1); - path5 = Move(path2); + path5 = std::move(path2); EXPECT_EQ(path5.PointCount(), 2); EXPECT_EQ(path5.GetPoint(0).x, PointT(1.0, 2.1).x); EXPECT_EQ(path5.GetPoint(0).y, PointT(1.0, 2.1).y); @@ -84,7 +84,7 @@ TEST_F(PathTypeTest, path1) { EXPECT_EQ(path2.PointCount(), 0); EXPECT_EQ(path2.ptr, nullptr); - PathT path6(Move(path4)); + PathT path6(std::move(path4)); EXPECT_EQ(path6.PointCount(), 2); EXPECT_EQ(path6.GetPoint(0).x, PointT(1.0, 2.1).x); EXPECT_EQ(path6.GetPoint(0).y, PointT(1.0, 2.1).y); diff --git a/src/unit_test/parser/type/geo/polygon_type.cpp b/src/unit_test/parser/type/geo/polygon_type.cpp index 5c8d6e6eaf..1b8d217e35 100644 --- a/src/unit_test/parser/type/geo/polygon_type.cpp +++ b/src/unit_test/parser/type/geo/polygon_type.cpp @@ -93,7 +93,7 @@ TEST_F(PolygonTypeTest, polygon1) { EXPECT_EQ(polygon4.bounding_box.lower_right.y, 2.1); PolygonT polygon5(1); - polygon5 = Move(polygon2); + polygon5 = std::move(polygon2); EXPECT_EQ(polygon5.PointCount(), 2); EXPECT_EQ(polygon5.GetPoint(0).x, PointT(1.0, 2.1).x); EXPECT_EQ(polygon5.GetPoint(0).y, PointT(1.0, 2.1).y); @@ -108,7 +108,7 @@ TEST_F(PolygonTypeTest, polygon1) { EXPECT_EQ(polygon2.PointCount(), 0); EXPECT_EQ(polygon2.ptr, nullptr); - PolygonT polygon6(Move(polygon4)); + PolygonT polygon6(std::move(polygon4)); EXPECT_EQ(polygon6.PointCount(), 2); EXPECT_EQ(polygon6.GetPoint(0).x, PointT(1.0, 2.1).x); EXPECT_EQ(polygon6.GetPoint(0).y, PointT(1.0, 2.1).y); diff --git a/src/unit_test/parser/type/heterogeneous/mixed_type.cpp b/src/unit_test/parser/type/heterogeneous/mixed_type.cpp index 1962cb7eb2..cf5090aa01 100644 --- a/src/unit_test/parser/type/heterogeneous/mixed_type.cpp +++ b/src/unit_test/parser/type/heterogeneous/mixed_type.cpp @@ -43,8 +43,8 @@ TEST_F(MixedTypeTest, mixed_integer) { EXPECT_EQ(integer_mixed_ptr->value, 11); EXPECT_EQ(integer_mixed_ptr2->value, 10); - // Move constructor - MixedType mixed_integer3 = Move(mixed_integer2); + // std::move constructor + MixedType mixed_integer3 = std::move(mixed_integer2); EXPECT_EQ(mixed_integer3.type, MixedValueType::kInteger); EXPECT_EQ(mixed_integer2.type, MixedValueType::kInvalid); auto *integer_mixed_ptr3 = (IntegerMixedType *)(&mixed_integer3); @@ -57,9 +57,9 @@ TEST_F(MixedTypeTest, mixed_integer) { auto *integer_mixed_ptr4 = (IntegerMixedType *)(&mixed_integer4); EXPECT_EQ(integer_mixed_ptr4->value, 11); - // Move assignment + // std::move assignment MixedType mixed_integer5; - mixed_integer5 = Move(mixed_integer3); + mixed_integer5 = std::move(mixed_integer3); EXPECT_EQ(mixed_integer5.type, MixedValueType::kInteger); auto *integer_mixed_ptr5 = (IntegerMixedType *)(&mixed_integer5); EXPECT_EQ(integer_mixed_ptr5->value, 10); @@ -84,8 +84,8 @@ TEST_F(MixedTypeTest, mixed_float) { EXPECT_FLOAT_EQ(float_mixed_ptr->value, 2.005); EXPECT_FLOAT_EQ(float_mixed_ptr2->value, 1.005); - // Move constructor - MixedType mixed_float3 = Move(mixed_float2); + // std::move constructor + MixedType mixed_float3 = std::move(mixed_float2); EXPECT_EQ(mixed_float3.type, MixedValueType::kFloat); EXPECT_EQ(mixed_float2.type, MixedValueType::kInvalid); auto *float_mixed_ptr3 = (FloatMixedType *)(&mixed_float3); @@ -98,9 +98,9 @@ TEST_F(MixedTypeTest, mixed_float) { auto *float_mixed_ptr4 = (FloatMixedType *)(&mixed_float4); EXPECT_FLOAT_EQ(float_mixed_ptr4->value, 2.005); - // Move assignment + // std::move assignment MixedType mixed_float5; - mixed_float5 = Move(mixed_float3); + mixed_float5 = std::move(mixed_float3); EXPECT_EQ(mixed_float5.type, MixedValueType::kFloat); auto *float_mixed_ptr5 = (FloatMixedType *)(&mixed_float5); EXPECT_FLOAT_EQ(float_mixed_ptr5->value, 1.005); @@ -145,8 +145,8 @@ TEST_F(MixedTypeTest, mixed_short_str) { EXPECT_STREQ(result.c_str(), "Hello a World!"); EXPECT_EQ(short_string_mixed_ptr->length, 14); - // Move constructor - MixedType mixed_short_string3 = Move(mixed_short_string2); + // std::move constructor + MixedType mixed_short_string3 = std::move(mixed_short_string2); EXPECT_EQ(mixed_short_string3.type, MixedValueType::kShortStr); auto *short_string_mixed_ptr3 = (ShortStrMixedType *)(&mixed_short_string3); result = String(short_string_mixed_ptr3->ptr, short_string_mixed_ptr3->length); @@ -172,9 +172,9 @@ TEST_F(MixedTypeTest, mixed_short_str) { EXPECT_STREQ(result.c_str(), "Hello a World!"); EXPECT_EQ(short_string_mixed_ptr3->length, 14); - // Move assignment + // std::move assignment MixedType mixed_short_string5; - mixed_short_string5 = Move(mixed_short_string3); + mixed_short_string5 = std::move(mixed_short_string3); EXPECT_EQ(mixed_short_string5.type, MixedValueType::kShortStr); auto *short_string_mixed_ptr5 = (ShortStrMixedType *)(&mixed_short_string5); result = String(short_string_mixed_ptr5->ptr, short_string_mixed_ptr5->length); @@ -224,8 +224,8 @@ TEST_F(MixedTypeTest, mixed_long_str) { EXPECT_EQ(long_string_mixed_ptr->ptr, nullptr); EXPECT_EQ(long_string_mixed_ptr->length, 0); - // Move constructor - MixedType mixed_long_string2 = Move(mixed_long_string1); + // std::move constructor + MixedType mixed_long_string2 = std::move(mixed_long_string1); EXPECT_EQ(mixed_long_string2.type, MixedValueType::kLongStr); auto *long_string_mixed_ptr2 = (LongStrMixedType *)(&mixed_long_string2); long_str = String(long_string_mixed_ptr2->ptr, long_string_mixed_ptr2->length); @@ -249,9 +249,9 @@ TEST_F(MixedTypeTest, mixed_long_str) { String header3 = String(long_string_mixed_ptr3->ptr, BaseMixedType::LONG_STR_HEADER); EXPECT_STREQ(header3.c_str(), "Hello"); - // Move assignment + // std::move assignment MixedType mixed_long_string4; - mixed_long_string4 = Move(mixed_long_string2); + mixed_long_string4 = std::move(mixed_long_string2); EXPECT_EQ(mixed_long_string4.type, MixedValueType::kLongStr); auto *long_string_mixed_ptr4 = (LongStrMixedType *)(&mixed_long_string4); long_str = String(long_string_mixed_ptr4->ptr, long_string_mixed_ptr4->length); @@ -812,7 +812,7 @@ TEST_F(MixedTypeTest, mixed_tuple2) { EXPECT_EQ(value65_ptr->type, MixedValueType::kNull); } - mixed_tuple1.MoveIntoTuple("key6", Move(mixed_tuple_key6)); + mixed_tuple1.MoveIntoTuple("key6", std::move(mixed_tuple_key6)); } { auto *value6_ptr = mixed_tuple1.GetFromTuple("key6"); @@ -870,7 +870,7 @@ TEST_F(MixedTypeTest, mixed_tuple2) { EXPECT_EQ(value4_ptr->type, MixedValueType::kNull); } - mixed_tuple1.MoveIntoTuple("key7", Move(mixed_array7)); + mixed_tuple1.MoveIntoTuple("key7", std::move(mixed_array7)); } { auto *value7_ptr = mixed_tuple1.GetFromTuple("key7"); @@ -1607,7 +1607,7 @@ TEST_F(MixedTypeTest, mixed_array2) { EXPECT_EQ(value5_ptr->type, MixedValueType::kNull); } - mixed_array1.MoveIntoArray(Move(mixed_tuple5), 5); + mixed_array1.MoveIntoArray(std::move(mixed_tuple5), 5); // Nested_array should be reset to empty EXPECT_EQ(mixed_tuple5.type, MixedValueType::kInvalid); @@ -1669,7 +1669,7 @@ TEST_F(MixedTypeTest, mixed_array2) { EXPECT_EQ(value4_ptr->type, MixedValueType::kNull); } - mixed_array1.MoveIntoArray(Move(nested_array), 6); + mixed_array1.MoveIntoArray(std::move(nested_array), 6); // Nested_array should be reset to empty EXPECT_EQ(nested_array.type, MixedValueType::kInvalid); diff --git a/src/unit_test/storage/column_vector/column_vector_mixed.cpp b/src/unit_test/storage/column_vector/column_vector_mixed.cpp index a3ba1f5c33..e33a79fa6a 100644 --- a/src/unit_test/storage/column_vector/column_vector_mixed.cpp +++ b/src/unit_test/storage/column_vector/column_vector_mixed.cpp @@ -439,7 +439,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_a) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String str = ToStr(i); + String str = std::to_string(i); MixedT mixed_str1 = MixedType::MakeString(str); Value v = Value::MakeMixedData(mixed_str1); EXPECT_EQ(v.GetValue(), mixed_str1); @@ -467,7 +467,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_a) { EXPECT_EQ(column_vector.vector_type(), clone_column_vector.vector_type()); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String str = ToStr(i); + String str = std::to_string(i); Value vx = column_vector.GetValue(i); EXPECT_EQ(vx.type().type(), LogicalType::kMixed); EXPECT_EQ(vx.value_.mixed_value.type, MixedValueType::kShortStr); @@ -503,7 +503,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_a) { EXPECT_NE(column_vector.nulls_ptr_, nullptr); EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String str = ToStr(i); + String str = std::to_string(i); MixedT mixed_str1 = MixedType::MakeString(str); column_vector.AppendByPtr((ptr_t)(&mixed_str1)); @@ -518,7 +518,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_a) { ColumnVector column_constant(data_type); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String str = ToStr(i); + String str = std::to_string(i); column_constant.Initialize(ColumnVectorType::kConstant, DEFAULT_VECTOR_SIZE); column_constant.SetValue(0, column_vector.GetValue(i)); column_constant.Finalize(1); @@ -539,7 +539,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_column_vector_select) { column_vector.Initialize(); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String str = ToStr(i); + String str = std::to_string(i); MixedT mixed_str1 = MixedType::MakeString(str); Value v = Value::MakeMixedData(mixed_str1); EXPECT_EQ(v.GetValue(), mixed_str1); @@ -548,7 +548,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_column_vector_select) { } for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String str = ToStr(i); + String str = std::to_string(i); Value vx = column_vector.GetValue(i); EXPECT_EQ(vx.type().type(), LogicalType::kMixed); EXPECT_EQ(vx.value_.mixed_value.type, MixedValueType::kShortStr); @@ -568,7 +568,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_column_vector_select) { EXPECT_EQ(target_column_vector.Size(), DEFAULT_VECTOR_SIZE / 2); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE / 2; ++i) { - String str = ToStr(2 * i); + String str = std::to_string(2 * i); Value vx = target_column_vector.GetValue(i); EXPECT_EQ(vx.type().type(), LogicalType::kMixed); EXPECT_EQ(vx.value_.mixed_value.type, MixedValueType::kShortStr); @@ -586,7 +586,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_column_slice_init) { column_vector.Initialize(); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String str = ToStr(i); + String str = std::to_string(i); MixedT mixed_str1 = MixedType::MakeString(str); Value v = Value::MakeMixedData(mixed_str1); EXPECT_EQ(v.GetValue(), mixed_str1); @@ -595,7 +595,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_column_slice_init) { } for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String str = ToStr(i); + String str = std::to_string(i); Value vx = column_vector.GetValue(i); EXPECT_EQ(vx.type().type(), LogicalType::kMixed); EXPECT_EQ(vx.value_.mixed_value.type, MixedValueType::kShortStr); @@ -614,7 +614,7 @@ TEST_F(ColumnVectorMixedTest, mixed_short_str_column_slice_init) { for (i64 i = 0; i < count; ++i) { i64 src_idx = start_idx + i; - String str = ToStr(src_idx); + String str = std::to_string(src_idx); Value vx = target_column_vector.GetValue(i); EXPECT_EQ(vx.type().type(), LogicalType::kMixed); EXPECT_EQ(vx.value_.mixed_value.type, MixedValueType::kShortStr); diff --git a/src/unit_test/storage/column_vector/column_vector_varchar.cpp b/src/unit_test/storage/column_vector/column_vector_varchar.cpp index 0e229cc20c..0f2d8c8b5e 100644 --- a/src/unit_test/storage/column_vector/column_vector_varchar.cpp +++ b/src/unit_test/storage/column_vector/column_vector_varchar.cpp @@ -55,7 +55,7 @@ TEST_F(ColumnVectorVarcharTest, flat_inline_varchar) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); Value vx = column_vector.GetValue(i); @@ -77,7 +77,7 @@ TEST_F(ColumnVectorVarcharTest, flat_inline_varchar) { EXPECT_EQ(column_vector.vector_type(), clone_column_vector.vector_type()); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value vx = column_vector.GetValue(i); EXPECT_EQ(vx.type().type(), LogicalType::kVarchar); const String &s2 = vx.GetVarchar(); @@ -111,7 +111,7 @@ TEST_F(ColumnVectorVarcharTest, flat_inline_varchar) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); VarcharT varchar_value; varchar_value.InitAsValue(s); column_vector.AppendByPtr((ptr_t)(&varchar_value)); @@ -124,7 +124,7 @@ TEST_F(ColumnVectorVarcharTest, flat_inline_varchar) { ColumnVector column_constant(data_type); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); column_constant.Initialize(ColumnVectorType::kConstant, DEFAULT_VECTOR_SIZE); column_constant.SetValue(0, column_vector.GetValue(i)); @@ -164,7 +164,7 @@ TEST_F(ColumnVectorVarcharTest, constant_inline_varchar) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < 1; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); EXPECT_THROW(column_vector.AppendValue(v), StorageException); @@ -174,7 +174,7 @@ TEST_F(ColumnVectorVarcharTest, constant_inline_varchar) { EXPECT_THROW(column_vector.GetValue(i + 1), TypeException); } for (i64 i = 0; i < 1; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value vx = column_vector.GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s.c_str(), s2.c_str()); @@ -208,7 +208,7 @@ TEST_F(ColumnVectorVarcharTest, constant_inline_varchar) { EXPECT_NE(column_vector.nulls_ptr_, nullptr); EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < 1; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); EXPECT_THROW(column_vector.AppendValue(v), StorageException); @@ -227,13 +227,13 @@ TEST_F(ColumnVectorVarcharTest, varchar_column_vector_select) { column_vector.Initialize(); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); } for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value vx = column_vector.GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s.c_str(), s2.c_str()); @@ -250,7 +250,7 @@ TEST_F(ColumnVectorVarcharTest, varchar_column_vector_select) { EXPECT_EQ(target_column_vector.Size(), DEFAULT_VECTOR_SIZE / 2); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE / 2; ++i) { - String s = "hello" + ToStr(2 * i); + String s = "hello" + std::to_string(2 * i); Value vx = target_column_vector.GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s.c_str(), s2.c_str()); @@ -265,13 +265,13 @@ TEST_F(ColumnVectorVarcharTest, varchar_column_slice_init) { column_vector.Initialize(); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); } for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hello" + ToStr(i); + String s = "hello" + std::to_string(i); Value vx = column_vector.GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s.c_str(), s2.c_str()); @@ -287,7 +287,7 @@ TEST_F(ColumnVectorVarcharTest, varchar_column_slice_init) { for (i64 i = 0; i < count; ++i) { i64 src_idx = start_idx + i; - String s = "hello" + ToStr(src_idx); + String s = "hello" + std::to_string(src_idx); Value vx = target_column_vector.GetValue(i); const String &s2 = vx.GetVarchar(); @@ -320,7 +320,7 @@ TEST_F(ColumnVectorVarcharTest, flat_not_inline_varchar) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hellohellohello" + ToStr(i); + String s = "hellohellohello" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); Value vx = column_vector.GetValue(i); @@ -342,7 +342,7 @@ TEST_F(ColumnVectorVarcharTest, flat_not_inline_varchar) { EXPECT_EQ(column_vector.vector_type(), clone_column_vector.vector_type()); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hellohellohello" + ToStr(i); + String s = "hellohellohello" + std::to_string(i); Value vx = column_vector.GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s.c_str(), s2.c_str()); @@ -376,7 +376,7 @@ TEST_F(ColumnVectorVarcharTest, flat_not_inline_varchar) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hellohellohello" + ToStr(i); + String s = "hellohellohello" + std::to_string(i); VarcharT varchar_value; varchar_value.InitAsValue(s); column_vector.AppendByPtr((ptr_t)(&varchar_value)); @@ -389,7 +389,7 @@ TEST_F(ColumnVectorVarcharTest, flat_not_inline_varchar) { ColumnVector column_constant(data_type); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "hellohellohello" + ToStr(i); + String s = "hellohellohello" + std::to_string(i); column_constant.Initialize(ColumnVectorType::kConstant, DEFAULT_VECTOR_SIZE); column_constant.SetValue(0, column_vector.GetValue(i)); @@ -424,7 +424,7 @@ TEST_F(ColumnVectorVarcharTest, constant_not_inline_varchar) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < 1; ++i) { - String s = "hellohellohello" + ToStr(i); + String s = "hellohellohello" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); EXPECT_THROW(column_vector.AppendValue(v), StorageException); @@ -434,7 +434,7 @@ TEST_F(ColumnVectorVarcharTest, constant_not_inline_varchar) { EXPECT_THROW(column_vector.GetValue(i + 1), TypeException); } for (i64 i = 0; i < 1; ++i) { - String s = "hellohellohello" + ToStr(i); + String s = "hellohellohello" + std::to_string(i); Value vx = column_vector.GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s.c_str(), s2.c_str()); @@ -468,7 +468,7 @@ TEST_F(ColumnVectorVarcharTest, constant_not_inline_varchar) { EXPECT_NE(column_vector.nulls_ptr_, nullptr); EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < 1; ++i) { - String s = "hellohellohello" + ToStr(i); + String s = "hellohellohello" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); EXPECT_THROW(column_vector.AppendValue(v), StorageException); @@ -504,7 +504,7 @@ TEST_F(ColumnVectorVarcharTest, flat_mixed_inline_varchar) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "Professional" + ToStr(i); + String s = "Professional" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); Value vx = column_vector.GetValue(i); @@ -526,7 +526,7 @@ TEST_F(ColumnVectorVarcharTest, flat_mixed_inline_varchar) { EXPECT_EQ(column_vector.vector_type(), clone_column_vector.vector_type()); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "Professional" + ToStr(i); + String s = "Professional" + std::to_string(i); Value vx = column_vector.GetValue(i); const String &s2 = vx.GetVarchar(); EXPECT_STREQ(s.c_str(), s2.c_str()); @@ -560,7 +560,7 @@ TEST_F(ColumnVectorVarcharTest, flat_mixed_inline_varchar) { EXPECT_TRUE(column_vector.initialized); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "Professional" + ToStr(i); + String s = "Professional" + std::to_string(i); Value v = Value::MakeVarchar(s); column_vector.AppendValue(v); Value vx = column_vector.GetValue(i); @@ -571,7 +571,7 @@ TEST_F(ColumnVectorVarcharTest, flat_mixed_inline_varchar) { ColumnVector column_constant(data_type); for (i64 i = 0; i < DEFAULT_VECTOR_SIZE; ++i) { - String s = "Professional" + ToStr(i); + String s = "Professional" + std::to_string(i); column_constant.Initialize(ColumnVectorType::kConstant, DEFAULT_VECTOR_SIZE); column_constant.SetValue(0, column_vector.GetValue(i)); column_constant.Finalize(1); diff --git a/src/unit_test/storage/invertedindex/irsdatastore.cpp b/src/unit_test/storage/invertedindex/irsdatastore.cpp index b3faae4bd8..abc8a0add5 100644 --- a/src/unit_test/storage/invertedindex/irsdatastore.cpp +++ b/src/unit_test/storage/invertedindex/irsdatastore.cpp @@ -56,10 +56,10 @@ class IRSDataStore { public: IRSDataStore(const String &table_name, const String &directory); struct DataSnapshot { - DataSnapshot(IRSDirectoryReader &&reader) : reader_(Move(reader)) {} + DataSnapshot(IRSDirectoryReader &&reader) : reader_(std::move(reader)) {} DataSnapshot &operator=(DataSnapshot &&rhs) noexcept { if (this != &rhs) { - reader_ = Move(rhs.reader_); + reader_ = std::move(rhs.reader_); } return *this; } @@ -87,7 +87,7 @@ class IRSDataStore { Path path_; IRSDirectory::ptr irs_directory_; IRSIndexWriter::ptr index_writer_; - Mutex commit_mutex_; + std::mutex commit_mutex_; DataSnapshotPtr snapshot_; }; @@ -128,16 +128,16 @@ void IRSDataStore::Open(bool reopen) { return std::make_pair(info, irs::FeatureWriterFactory{}); }; - index_writer_ = IRSIndexWriter::Make(*(irs_directory_), Move(format), OpenMode(open_mode), options); + index_writer_ = IRSIndexWriter::Make(*(irs_directory_), std::move(format), OpenMode(open_mode), options); auto reader = index_writer_->GetSnapshot(); - auto data = MakeShared(Move(reader)); + auto data = MakeShared(std::move(reader)); StoreSnapshot(data); } -void IRSDataStore::StoreSnapshot(DataSnapshotPtr snapshot) { std::atomic_store_explicit(&snapshot_, Move(snapshot), MemoryOrderRelease); } +void IRSDataStore::StoreSnapshot(DataSnapshotPtr snapshot) { std::atomic_store_explicit(&snapshot_, std::move(snapshot), std::memory_order::release); } void IRSDataStore::Commit() { - UniqueLock lk(commit_mutex_); + std::unique_lock lk(commit_mutex_); index_writer_->Commit(); auto reader = index_writer_->GetSnapshot(); reader->Reopen(); @@ -148,7 +148,7 @@ void IRSDataStore::Commit() { for (auto &segment : reader) { std::cout << segment.Meta().name << std::endl; } - auto data = MakeShared(Move(reader)); + auto data = MakeShared(std::move(reader)); StoreSnapshot(data); } @@ -181,7 +181,7 @@ int IRSDataStore::Search(IrsFilter *flt, const Map &options, Sco SizeT topn(DEFAULT_TOPN); if (auto it = options.find("topn"); it != options.end()) { - topn = StrToInt(it->second); + topn = std::stoi(it->second); } sorted.reserve(topn); @@ -313,7 +313,7 @@ TEST_F(IRSDatastoreTest, test1) { auto query = std::make_unique(); query->mutable_options()->term = toBstring("hello"); *query->mutable_field() = "body"; - flt = Move(query); + flt = std::move(query); SearchOptions search_ops(""); ScoredIds result; diff --git a/src/unit_test/storage/meta/catalog.cpp b/src/unit_test/storage/meta/catalog.cpp index aca2012395..e86cc2d844 100644 --- a/src/unit_test/storage/meta/catalog.cpp +++ b/src/unit_test/storage/meta/catalog.cpp @@ -177,12 +177,9 @@ TEST_F(CatalogTest, concurrent_test) { auto *txn2 = txn_mgr->CreateTxn(); txn2->Begin(); - // lock protect databases - std::mutex lock; - auto write_routine = [&](int start, Txn *txn) { for (int db_id = start; db_id < 1000; db_id += 2) { - String db_name = "db" + ToStr(db_id); + String db_name = "db" + std::to_string(db_id); Status status = txn->CreateDatabase(db_name, ConflictType::kError); EXPECT_TRUE(status.ok()); } @@ -205,7 +202,7 @@ TEST_F(CatalogTest, concurrent_test) { auto read_routine = [&](Txn *txn) { for (int db_id = 0; db_id < 1000; ++db_id) { - String db_name = "db" + ToStr(db_id); + String db_name = "db" + std::to_string(db_id); auto [db_entry, status] = catalog->NewCatalog::GetDatabase(db_name, txn->TxnID(), txn->BeginTS()); EXPECT_TRUE(status.ok()); // only read, don't need lock @@ -229,7 +226,7 @@ TEST_F(CatalogTest, concurrent_test) { auto drop_routine = [&](int start, Txn *txn) { for (int db_id = start; db_id < 1000; db_id += 2) { - String db_name = "db" + ToStr(db_id); + String db_name = "db" + std::to_string(db_id); Status status = txn->DropDatabase(db_name, ConflictType::kError); EXPECT_TRUE(status.ok()); } @@ -249,7 +246,7 @@ TEST_F(CatalogTest, concurrent_test) { // check all has been dropped for (int db_id = 0; db_id < 1000; ++db_id) { - String db_name = "db" + ToStr(db_id); + String db_name = "db" + std::to_string(db_id); auto [db_entry, status] = catalog->NewCatalog::GetDatabase(db_name, txn7->TxnID(), txn7->BeginTS()); EXPECT_TRUE(!status.ok()); } diff --git a/src/unit_test/storage/meta/entry/table_collection_entry.cpp b/src/unit_test/storage/meta/entry/table_collection_entry.cpp index 4c39228081..26f4f7cec2 100644 --- a/src/unit_test/storage/meta/entry/table_collection_entry.cpp +++ b/src/unit_test/storage/meta/entry/table_collection_entry.cpp @@ -139,7 +139,7 @@ TEST_F(TableEntryTest, test2) { } UniquePtr tbl1_def = MakeUnique(MakeShared("default"), MakeShared("tbl1"), columns); - Status s1 = new_txn->CreateTable("db1", Move(tbl1_def), ConflictType::kError); + Status s1 = new_txn->CreateTable("db1", std::move(tbl1_def), ConflictType::kError); EXPECT_TRUE(s1.ok()); // Txn1: Commit, OK diff --git a/src/unit_test/storage/wal/wal_entry.cpp b/src/unit_test/storage/wal/wal_entry.cpp index ac4d2fefe9..0bbe789207 100644 --- a/src/unit_test/storage/wal/wal_entry.cpp +++ b/src/unit_test/storage/wal/wal_entry.cpp @@ -216,7 +216,7 @@ TEST_F(WalEntryTest, WalEntryIterator) { if (wal_entry == nullptr) { break; } - Println("WAL ENTRY COMMIT TS:", ToStr(wal_entry->commit_ts)); + Println("WAL ENTRY COMMIT TS:", std::to_string(wal_entry->commit_ts)); for (const auto &cmd : wal_entry->cmds) { Println(" WAL CMD: ", WalManager::WalCommandTypeToString(cmd->GetType())); } @@ -239,7 +239,7 @@ TEST_F(WalEntryTest, WalEntryIterator) { replay_entries.push_back(wal_entry); } else { std::tie(max_commit_ts, catalog_path) = wal_entry->GetCheckpointInfo(); - Println("Checkpoint Max Commit Ts: {}", ToStr(max_commit_ts)); + Println("Checkpoint Max Commit Ts: {}", std::to_string(max_commit_ts)); Println("Catalog Path: {}", catalog_path); break; } @@ -260,7 +260,7 @@ TEST_F(WalEntryTest, WalEntryIterator) { // phase 3: replay the entries Println("Start to replay the entries", ""); for (const auto &entry : replay_entries) { - Println("WAL ENTRY COMMIT TS:", ToStr(entry->commit_ts)); + Println("WAL ENTRY COMMIT TS:", std::to_string(entry->commit_ts)); for (const auto &cmd : entry->cmds) { Println(" WAL CMD: ", WalManager::WalCommandTypeToString(cmd->GetType())); } @@ -282,7 +282,7 @@ TEST_F(WalEntryTest, WalListIterator) { if (wal_entry.get() == nullptr) { break; } - Println("WAL ENTRY COMMIT TS:", ToStr(wal_entry->commit_ts)); + Println("WAL ENTRY COMMIT TS:", std::to_string(wal_entry->commit_ts)); for (const auto &cmd : wal_entry->cmds) { Println(" WAL CMD: ", WalManager::WalCommandTypeToString(cmd->GetType())); } @@ -304,7 +304,7 @@ TEST_F(WalEntryTest, WalListIterator) { replay_entries.push_back(wal_entry); } else { std::tie(max_commit_ts, catalog_path) = wal_entry->GetCheckpointInfo(); - Println("Checkpoint Max Commit Ts: {}", ToStr(max_commit_ts)); + Println("Checkpoint Max Commit Ts: {}", std::to_string(max_commit_ts)); Println("Catalog Path: {}", catalog_path); break; } @@ -325,7 +325,7 @@ TEST_F(WalEntryTest, WalListIterator) { // phase 3: replay the entries Println("Start to replay the entries", ""); for (const auto &entry : replay_entries) { - Println("WAL ENTRY COMMIT TS:", ToStr(entry->commit_ts)); + Println("WAL ENTRY COMMIT TS:", std::to_string(entry->commit_ts)); for (const auto &cmd : entry->cmds) { Println(" WAL CMD: ", WalManager::WalCommandTypeToString(cmd->GetType())); } diff --git a/src/unit_test/storage/wal/wal_replay.cpp b/src/unit_test/storage/wal/wal_replay.cpp index b654988ca0..cd9a9aa717 100644 --- a/src/unit_test/storage/wal/wal_replay.cpp +++ b/src/unit_test/storage/wal/wal_replay.cpp @@ -156,7 +156,7 @@ TEST_F(WalReplayTest, WalReplayTables) { auto tbl1_def = MakeUnique(MakeShared("default"), MakeShared("tbl1"), columns); auto *txn = txn_mgr->CreateTxn(); txn->Begin(); - Status status = txn->CreateTable("default", Move(tbl1_def), ConflictType::kIgnore); + Status status = txn->CreateTable("default", std::move(tbl1_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn); } @@ -166,7 +166,7 @@ TEST_F(WalReplayTest, WalReplayTables) { auto *txn2 = txn_mgr->CreateTxn(); txn2->Begin(); - Status status2 = txn2->CreateTable("default", Move(tbl2_def), ConflictType::kIgnore); + Status status2 = txn2->CreateTable("default", std::move(tbl2_def), ConflictType::kIgnore); EXPECT_TRUE(status2.ok()); TxnTimeStamp txn2_ts = txn_mgr->CommitTxn(txn2); @@ -184,7 +184,7 @@ TEST_F(WalReplayTest, WalReplayTables) { auto *txn3 = txn_mgr->CreateTxn(); txn3->Begin(); - Status status = txn3->CreateTable("default", Move(tbl3_def), ConflictType::kIgnore); + Status status = txn3->CreateTable("default", std::move(tbl3_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn3); @@ -214,7 +214,7 @@ TEST_F(WalReplayTest, WalReplayTables) { auto *txn = txn_mgr->CreateTxn(); txn->Begin(); - Status status = txn->CreateTable("default", Move(tbl2_def), ConflictType::kIgnore); + Status status = txn->CreateTable("default", std::move(tbl2_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn); @@ -277,7 +277,7 @@ TEST_F(WalReplayTest, WalReplayAppend) { auto *txn = txn_mgr->CreateTxn(); txn->Begin(); - Status status = txn->CreateTable("default", Move(tbl1_def), ConflictType::kIgnore); + Status status = txn->CreateTable("default", std::move(tbl1_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn); @@ -287,7 +287,7 @@ TEST_F(WalReplayTest, WalReplayAppend) { auto *txn3 = txn_mgr->CreateTxn(); txn3->Begin(); - Status status = txn3->CreateTable("default", Move(tbl3_def), ConflictType::kIgnore); + Status status = txn3->CreateTable("default", std::move(tbl3_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn3); @@ -297,7 +297,7 @@ TEST_F(WalReplayTest, WalReplayAppend) { auto *txn4 = txn_mgr->CreateTxn(); txn4->Begin(); - Status status = txn4->CreateTable("default", Move(tbl4_def), ConflictType::kIgnore); + Status status = txn4->CreateTable("default", std::move(tbl4_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn4); @@ -369,7 +369,7 @@ TEST_F(WalReplayTest, WalReplayAppend) { auto *txn = txn_mgr->CreateTxn(); txn->Begin(); - Status status = txn->CreateTable("default", Move(tbl5_def), ConflictType::kIgnore); + Status status = txn->CreateTable("default", std::move(tbl5_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn); @@ -474,7 +474,7 @@ TEST_F(WalReplayTest, WalReplayImport) { auto *txn = txn_mgr->CreateTxn(); txn->Begin(); - Status status = txn->CreateTable("default", Move(tbl1_def), ConflictType::kIgnore); + Status status = txn->CreateTable("default", std::move(tbl1_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn); @@ -484,7 +484,7 @@ TEST_F(WalReplayTest, WalReplayImport) { auto *txn2 = txn_mgr->CreateTxn(); txn2->Begin(); - Status status = txn2->CreateTable("default", Move(tbl2_def), ConflictType::kIgnore); + Status status = txn2->CreateTable("default", std::move(tbl2_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); TxnTimeStamp tx4_commit_ts = txn_mgr->CommitTxn(txn2); @@ -502,7 +502,7 @@ TEST_F(WalReplayTest, WalReplayImport) { txn->Begin(); - Status status = txn->CreateTable("default", Move(tbl3_def), ConflictType::kIgnore); + Status status = txn->CreateTable("default", std::move(tbl3_def), ConflictType::kIgnore); EXPECT_TRUE(status.ok()); txn_mgr->CommitTxn(txn); diff --git a/src/unit_test/test_helper/sql_runner.cpp b/src/unit_test/test_helper/sql_runner.cpp index 72ebecce20..bc913fc154 100644 --- a/src/unit_test/test_helper/sql_runner.cpp +++ b/src/unit_test/test_helper/sql_runner.cpp @@ -52,7 +52,7 @@ namespace infinity { */ SharedPtr SQLRunner::Run(const String &sql_text, bool print) { // if (print) { - // LOG_TRACE(Format("{}", sql_text)); + // LOG_TRACE(fmt::format("{}", sql_text)); // } // UniquePtr session_manager = MakeUnique(); diff --git a/src/unit_test/test_hnsw_bitmask.cpp b/src/unit_test/test_hnsw_bitmask.cpp index c1dfd7d644..8b7f1266f8 100644 --- a/src/unit_test/test_hnsw_bitmask.cpp +++ b/src/unit_test/test_hnsw_bitmask.cpp @@ -25,7 +25,7 @@ import hnsw_alg; using namespace infinity; #define EXPECT_VALUE_EQ(a, b) \ - if (auto f = f64(a) - f64(b); Max(f, -f) > 1e-4) { \ + if (auto f = f64(a) - f64(b); std::max(f, -f) > 1e-4) { \ std::cerr << "values aren't equal at line\t" << __LINE__ << "\tvalues: " << a << " != " << b << std::endl; \ } diff --git a/src/unit_test/third_party/json.cpp b/src/unit_test/third_party/json.cpp index 57255b58da..9e6533a310 100644 --- a/src/unit_test/third_party/json.cpp +++ b/src/unit_test/third_party/json.cpp @@ -45,6 +45,6 @@ TEST_F(JsonTest, test1) { String json_path = String(test_data_path()) + "/json/twitter.json"; std::ifstream f(json_path); - Json data = Json::parse(f); + nlohmann::json data = nlohmann::json::parse(f); EXPECT_EQ(data["search_metadata"]["count"], 100); } diff --git a/tools/ci_tools/check_benchmark_result.py b/tools/ci_tools/check_benchmark_result.py index f004e1bf51..0fe3a4e2f3 100755 --- a/tools/ci_tools/check_benchmark_result.py +++ b/tools/ci_tools/check_benchmark_result.py @@ -7,7 +7,7 @@ def main(): - benchmark_bars = {"sift_1": 2.256, "sift_4": 0.869, "sift_8": 0.501} + benchmark_bars = {"sift_1": 2.256, "sift_4": 0.869, "sift_8": 0.451} benchmark_id = sys.argv[1] standard = benchmark_bars[benchmark_id] file_path = sys.argv[2] @@ -22,7 +22,7 @@ def main(): difference_percentage = 100 * (result - standard) / standard print("difference percentage: {:.2f}%".format(difference_percentage)) print() - if difference_percentage < 3: + if difference_percentage < 5: print("benchmark result is acceptable") sys.exit(0) else: