diff --git a/contrib/tipb b/contrib/tipb index 3e2483c20a9..d6f1aebebab 160000 --- a/contrib/tipb +++ b/contrib/tipb @@ -1 +1 @@ -Subproject commit 3e2483c20a9ec3f9ea587c49808c4b66c9716a2c +Subproject commit d6f1aebebabd82bd874c8dcff0b49d694bca0148 diff --git a/dbms/src/Debug/DBGInvoker.cpp b/dbms/src/Debug/DBGInvoker.cpp index df993d8e6e9..3654a437bf7 100644 --- a/dbms/src/Debug/DBGInvoker.cpp +++ b/dbms/src/Debug/DBGInvoker.cpp @@ -120,8 +120,6 @@ DBGInvoker::DBGInvoker() regSchemafulFunc("query_mapped", dbgFuncQueryMapped); regSchemalessFunc("get_tiflash_replica_count", dbgFuncGetTiflashReplicaCount); regSchemalessFunc("get_partition_tables_tiflash_replica_count", dbgFuncGetPartitionTablesTiflashReplicaCount); - regSchemalessFunc("get_tiflash_mode", dbgFuncGetTiflashMode); - regSchemalessFunc("get_partition_tables_tiflash_mode", dbgFuncGetPartitionTablesTiflashMode); regSchemalessFunc("search_log_for_key", dbgFuncSearchLogForKey); regSchemalessFunc("tidb_dag", dbgFuncTiDBQueryFromNaturalDag); diff --git a/dbms/src/Debug/dbgFuncSchemaName.cpp b/dbms/src/Debug/dbgFuncSchemaName.cpp index 3aa7b6e3af4..c9bd958805f 100644 --- a/dbms/src/Debug/dbgFuncSchemaName.cpp +++ b/dbms/src/Debug/dbgFuncSchemaName.cpp @@ -180,57 +180,4 @@ void dbgFuncGetPartitionTablesTiflashReplicaCount(Context & context, const ASTs output(fmt_buf.toString()); } - -void dbgFuncGetTiflashMode(Context & context, const ASTs & args, DBGInvoker::Printer output) -{ - if (args.empty() || args.size() != 2) - throw Exception("Args not matched, should be: database-name[, table-name]", ErrorCodes::BAD_ARGUMENTS); - - const String & database_name = typeid_cast(*args[0]).name; - FmtBuffer fmt_buf; - - const String & table_name = typeid_cast(*args[1]).name; - auto mapped = mappedTable(context, database_name, table_name); - auto storage = context.getTable(mapped->first, mapped->second); - auto managed_storage = std::dynamic_pointer_cast(storage); - if (!managed_storage) - throw Exception(database_name + "." + table_name + " is not ManageableStorage", ErrorCodes::BAD_ARGUMENTS); - - fmt_buf.append((TiFlashModeToString(managed_storage->getTableInfo().tiflash_mode))); - - output(fmt_buf.toString()); -} - -void dbgFuncGetPartitionTablesTiflashMode(Context & context, const ASTs & args, DBGInvoker::Printer output) -{ - if (args.empty() || args.size() != 2) - throw Exception("Args not matched, should be: database-name[, table-name]", ErrorCodes::BAD_ARGUMENTS); - - const String & database_name = typeid_cast(*args[0]).name; - FmtBuffer fmt_buf; - - const String & table_name = typeid_cast(*args[1]).name; - auto mapped = mappedTable(context, database_name, table_name); - auto storage = context.getTable(mapped->first, mapped->second); - auto managed_storage = std::dynamic_pointer_cast(storage); - if (!managed_storage) - throw Exception(database_name + "." + table_name + " is not ManageableStorage", ErrorCodes::BAD_ARGUMENTS); - - auto table_info = managed_storage->getTableInfo(); - - if (!table_info.isLogicalPartitionTable()) - throw Exception(database_name + "." + table_name + " is not logical partition table", ErrorCodes::BAD_ARGUMENTS); - - SchemaNameMapper name_mapper; - for (const auto & part_def : table_info.partition.definitions) - { - auto paritition_table_info = table_info.producePartitionTableInfo(part_def.id, name_mapper); - auto partition_storage = context.getTMTContext().getStorages().get(paritition_table_info->id); - fmt_buf.append((TiFlashModeToString(partition_storage->getTableInfo().tiflash_mode))); - fmt_buf.append("/"); - } - - output(fmt_buf.toString()); -} - } // namespace DB diff --git a/dbms/src/Debug/dbgFuncSchemaName.h b/dbms/src/Debug/dbgFuncSchemaName.h index ec18f89e911..2a31b3a7f6d 100644 --- a/dbms/src/Debug/dbgFuncSchemaName.h +++ b/dbms/src/Debug/dbgFuncSchemaName.h @@ -50,14 +50,4 @@ void dbgFuncGetTiflashReplicaCount(Context & context, const ASTs & args, DBGInvo // ./storage-client.sh "DBGInvoke get_partition_tables_tiflash_replica_count(db_name, table_name)" void dbgFuncGetPartitionTablesTiflashReplicaCount(Context & context, const ASTs & args, DBGInvoker::Printer output); -// Get table's tiflash mode with mapped table name -// Usage: -// ./storage-client.sh "DBGInvoke get_tiflash_mode(db_name, table_name)" -void dbgFuncGetTiflashMode(Context & context, const ASTs & args, DBGInvoker::Printer output); - -// Get the logical table's partition tables' tiflash replica counts with mapped table name -// Usage: -// ./storage-client.sh "DBGInvoke get_partition_tables_tiflash_mode(db_name, table_name)" -void dbgFuncGetPartitionTablesTiflashMode(Context & context, const ASTs & args, DBGInvoker::Printer output); - } // namespace DB diff --git a/dbms/src/Flash/Coprocessor/DAGStorageInterpreter.cpp b/dbms/src/Flash/Coprocessor/DAGStorageInterpreter.cpp index fb4a03f0999..087949d2b89 100644 --- a/dbms/src/Flash/Coprocessor/DAGStorageInterpreter.cpp +++ b/dbms/src/Flash/Coprocessor/DAGStorageInterpreter.cpp @@ -600,6 +600,7 @@ std::unordered_map DAGStorageInterpreter::generateSele context.getTimezoneInfo()); query_info.req_id = fmt::format("{} Table<{}>", log->identifier(), table_id); query_info.keep_order = table_scan.keepOrder(); + query_info.is_fast_scan = table_scan.isFastScan(); return query_info; }; if (table_scan.isPartitionTableScan()) diff --git a/dbms/src/Flash/Coprocessor/TiDBTableScan.cpp b/dbms/src/Flash/Coprocessor/TiDBTableScan.cpp index dca738a2e6c..20a12770c73 100644 --- a/dbms/src/Flash/Coprocessor/TiDBTableScan.cpp +++ b/dbms/src/Flash/Coprocessor/TiDBTableScan.cpp @@ -27,6 +27,7 @@ TiDBTableScan::TiDBTableScan( // Only No-partition table need keep order when tablescan executor required keep order. // If keep_order is not set, keep order for safety. , keep_order(!is_partition_table_scan && (table_scan->tbl_scan().keep_order() || !table_scan->tbl_scan().has_keep_order())) + , is_fast_scan(table_scan->tbl_scan().is_fast_scan()) { if (is_partition_table_scan) { @@ -73,6 +74,7 @@ void TiDBTableScan::constructTableScanForRemoteRead(tipb::TableScan * tipb_table tipb_table_scan->set_next_read_engine(tipb::EngineType::Local); for (auto id : partition_table_scan.primary_prefix_column_ids()) tipb_table_scan->add_primary_prefix_column_ids(id); + tipb_table_scan->set_is_fast_scan(partition_table_scan.is_fast_scan()); } else { diff --git a/dbms/src/Flash/Coprocessor/TiDBTableScan.h b/dbms/src/Flash/Coprocessor/TiDBTableScan.h index a5a463a8ff2..574d4b0a15f 100644 --- a/dbms/src/Flash/Coprocessor/TiDBTableScan.h +++ b/dbms/src/Flash/Coprocessor/TiDBTableScan.h @@ -56,6 +56,11 @@ class TiDBTableScan return keep_order; } + bool isFastScan() const + { + return is_fast_scan; + } + private: const tipb::Executor * table_scan; String executor_id; @@ -71,6 +76,7 @@ class TiDBTableScan std::vector physical_table_ids; Int64 logical_table_id; bool keep_order; + bool is_fast_scan; }; } // namespace DB diff --git a/dbms/src/Storages/DeltaMerge/DeltaMergeStore.cpp b/dbms/src/Storages/DeltaMerge/DeltaMergeStore.cpp index d2244cae7d5..900239e623a 100644 --- a/dbms/src/Storages/DeltaMerge/DeltaMergeStore.cpp +++ b/dbms/src/Storages/DeltaMerge/DeltaMergeStore.cpp @@ -1242,7 +1242,7 @@ BlockInputStreams DeltaMergeStore::read(const Context & db_context, const RSOperatorPtr & filter, const String & tracing_id, bool keep_order, - bool is_fast_mode, + bool is_fast_scan, size_t expected_block_size, const SegmentIdSet & read_segments, size_t extra_table_id_index) @@ -1277,8 +1277,8 @@ BlockInputStreams DeltaMergeStore::read(const Context & db_context, filter, max_version, expected_block_size, - /* is_raw = */ is_fast_mode, - /* do_delete_mark_filter_for_raw = */ is_fast_mode, + /* is_raw = */ is_fast_scan, + /* do_delete_mark_filter_for_raw = */ is_fast_scan, std::move(tasks), after_segment_read); @@ -1308,8 +1308,8 @@ BlockInputStreams DeltaMergeStore::read(const Context & db_context, filter, max_version, expected_block_size, - /* is_raw_ */ is_fast_mode, - /* do_delete_mark_filter_for_raw_ */ is_fast_mode, + /* is_raw_= */ is_fast_scan, + /* do_delete_mark_filter_for_raw_= */ is_fast_scan, extra_table_id_index, physical_table_id, req_info); diff --git a/dbms/src/Storages/DeltaMerge/DeltaMergeStore.h b/dbms/src/Storages/DeltaMerge/DeltaMergeStore.h index 4013cd22c90..769786ce070 100644 --- a/dbms/src/Storages/DeltaMerge/DeltaMergeStore.h +++ b/dbms/src/Storages/DeltaMerge/DeltaMergeStore.h @@ -359,9 +359,9 @@ class DeltaMergeStore : private boost::noncopyable /// Read rows in two modes: - /// when is_fast_mode == false, we are in normal mode. Thus we will read rows with MVCC filtering, del mark !=0 filter and sorted merge - /// when is_fast_mode == true, we are in fast mode. Thus we will read rows without MVCC and sorted merge - /// `sorted_ranges` should be already sorted and merged + /// when is_fast_scan == false, we will read rows with MVCC filtering, del mark !=0 filter and sorted merge. + /// when is_fast_scan == true, we will read rows without MVCC and sorted merge. + /// `sorted_ranges` should be already sorted and merged. BlockInputStreams read(const Context & db_context, const DB::Settings & db_settings, const ColumnDefines & columns_to_read, @@ -371,7 +371,7 @@ class DeltaMergeStore : private boost::noncopyable const RSOperatorPtr & filter, const String & tracing_id, bool keep_order, - bool is_fast_mode = false, // set true when read in fast mode + bool is_fast_scan = false, size_t expected_block_size = DEFAULT_BLOCK_SIZE, const SegmentIdSet & read_segments = {}, size_t extra_table_id_index = InvalidColumnID); diff --git a/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp b/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp index f8f73574b4b..bfb5d2cc054 100644 --- a/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp +++ b/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.cpp @@ -64,7 +64,7 @@ DMFileBlockInputStreamPtr DMFileBlockInputStreamBuilder::build(const DMFilePtr & is_common_handle, enable_handle_clean_read, enable_del_clean_read, - is_fast_mode, + is_fast_scan, max_data_version, std::move(pack_filter), mark_cache, diff --git a/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h b/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h index ce2d06f2410..e1552994396 100644 --- a/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h +++ b/dbms/src/Storages/DeltaMerge/File/DMFileBlockInputStream.h @@ -83,20 +83,19 @@ class DMFileBlockInputStreamBuilder // **** filters **** // // Only set enable_handle_clean_read_ param to true when - // in normal mode: - // 1. There is no delta. - // 2. You don't need pk, version and delete_tag columns - // in fast mode: - // 1. You don't need pk columns - // If you have no idea what it means, then simply set it to false. - // Only set is_fast_mode_ param to true when read in fast mode. - // Only set enable_del_clean_read_ param to true when you don't need del columns in fast mode. + // in normal mode (is_fast_scan_ == false): + // 1. There is no delta. + // 2. You don't need pk, version and delete_tag columns + // in fast scan mode (is_fast_scan_ == true): + // 1. You don't need pk columns + // If you have no idea what it means, then simply set it to false. + // Only set enable_del_clean_read_ param to true when you don't need del columns in fast scan. // `max_data_version_` is the MVCC filter version for reading. Used by clean read check - DMFileBlockInputStreamBuilder & enableCleanRead(bool enable_handle_clean_read_, bool is_fast_mode_, bool enable_del_clean_read_, UInt64 max_data_version_) + DMFileBlockInputStreamBuilder & enableCleanRead(bool enable_handle_clean_read_, bool is_fast_scan_, bool enable_del_clean_read_, UInt64 max_data_version_) { enable_handle_clean_read = enable_handle_clean_read_; enable_del_clean_read = enable_del_clean_read_; - is_fast_mode = is_fast_mode_; + is_fast_scan = is_fast_scan_; max_data_version = max_data_version_; return *this; } @@ -159,8 +158,9 @@ class DMFileBlockInputStreamBuilder FileProviderPtr file_provider; // clean read + bool enable_handle_clean_read = false; - bool is_fast_mode = false; + bool is_fast_scan = false; bool enable_del_clean_read = false; UInt64 max_data_version = std::numeric_limits::max(); // Rough set filter diff --git a/dbms/src/Storages/DeltaMerge/File/DMFileReader.cpp b/dbms/src/Storages/DeltaMerge/File/DMFileReader.cpp index c8e425453c9..19ddf66c015 100644 --- a/dbms/src/Storages/DeltaMerge/File/DMFileReader.cpp +++ b/dbms/src/Storages/DeltaMerge/File/DMFileReader.cpp @@ -210,7 +210,7 @@ DMFileReader::DMFileReader( // clean read bool enable_handle_clean_read_, bool enable_del_clean_read_, - bool is_fast_mode_, + bool is_fast_scan_, UInt64 max_read_version_, // filters DMFilePackFilter && pack_filter_, @@ -233,7 +233,7 @@ DMFileReader::DMFileReader( , single_file_mode(dmfile_->isSingleFileMode()) , enable_handle_clean_read(enable_handle_clean_read_) , enable_del_clean_read(enable_del_clean_read_) - , is_fast_mode(is_fast_mode_) + , is_fast_scan(is_fast_scan_) , max_read_version(max_read_version_) , pack_filter(std::move(pack_filter_)) , skip_packs_by_column(read_columns.size(), 0) @@ -364,10 +364,11 @@ Block DMFileReader::read() } // TODO: this will need better algorithm: we should separate those packs which can and can not do clean read. - bool do_clean_read_on_normal_mode = enable_handle_clean_read && expected_handle_res == All && not_clean_rows == 0 && (!is_fast_mode); + bool do_clean_read_on_normal_mode = enable_handle_clean_read && expected_handle_res == All && not_clean_rows == 0 && (!is_fast_scan); + + bool do_clean_read_on_handle_on_fast_mode = enable_handle_clean_read && is_fast_scan && expected_handle_res == All; + bool do_clean_read_on_del_on_fast_mode = enable_del_clean_read && is_fast_scan && deleted_rows == 0; - bool do_clean_read_on_handle_on_fast_mode = enable_handle_clean_read && is_fast_mode && expected_handle_res == All; - bool do_clean_read_on_del_on_fast_mode = enable_del_clean_read && is_fast_mode && deleted_rows == 0; if (do_clean_read_on_normal_mode) { diff --git a/dbms/src/Storages/DeltaMerge/File/DMFileReader.h b/dbms/src/Storages/DeltaMerge/File/DMFileReader.h index 76adef0301a..2eb14c6d19e 100644 --- a/dbms/src/Storages/DeltaMerge/File/DMFileReader.h +++ b/dbms/src/Storages/DeltaMerge/File/DMFileReader.h @@ -78,7 +78,7 @@ class DMFileReader // If you have no idea what it means, then simply set it to false. bool enable_handle_clean_read_, bool enable_del_clean_read_, - bool is_fast_mode_, + bool is_fast_scan_, // The the MVCC filter version. Used by clean read check. UInt64 max_read_version_, // filters @@ -148,7 +148,8 @@ class DMFileReader // if we don't need del column, we will try to do clean read on del_column(enable_del_clean_read is true). const bool enable_handle_clean_read; const bool enable_del_clean_read; - const bool is_fast_mode; + const bool is_fast_scan; + const UInt64 max_read_version; /// Filters diff --git a/dbms/src/Storages/DeltaMerge/Segment.cpp b/dbms/src/Storages/DeltaMerge/Segment.cpp index e706b51a767..3742a18aff2 100644 --- a/dbms/src/Storages/DeltaMerge/Segment.cpp +++ b/dbms/src/Storages/DeltaMerge/Segment.cpp @@ -534,6 +534,8 @@ BlockInputStreamPtr Segment::getInputStreamRaw(const DMContext & dm_context, /// But this way seems not to be robustness enough, maybe we need another flag? auto new_columns_to_read = std::make_shared(); + // new_columns_to_read need at most columns_to_read.size() + 2, due to may extra insert into the handle column and del_mark column. + new_columns_to_read->reserve(columns_to_read.size() + 2); new_columns_to_read->push_back(getExtraHandleColumnDefine(is_common_handle)); if (filter_delete_mark) @@ -578,7 +580,7 @@ BlockInputStreamPtr Segment::getInputStreamRaw(const DMContext & dm_context, std::numeric_limits::max(), expected_block_size, /* enable_handle_clean_read */ enable_handle_clean_read, - /* is_fast_mode */ filter_delete_mark, + /* is_fast_scan */ filter_delete_mark, /* enable_del_clean_read */ enable_del_clean_read); BlockInputStreamPtr delta_stream = std::make_shared(dm_context, segment_snap->delta, new_columns_to_read, this->rowkey_range); diff --git a/dbms/src/Storages/DeltaMerge/StableValueSpace.cpp b/dbms/src/Storages/DeltaMerge/StableValueSpace.cpp index 3a968ed1dfa..9827655a265 100644 --- a/dbms/src/Storages/DeltaMerge/StableValueSpace.cpp +++ b/dbms/src/Storages/DeltaMerge/StableValueSpace.cpp @@ -330,17 +330,17 @@ StableValueSpace::Snapshot::getInputStream( UInt64 max_data_version, size_t expected_block_size, bool enable_handle_clean_read, - bool is_fast_mode, + bool is_fast_scan, bool enable_del_clean_read) { - LOG_FMT_DEBUG(log, "max_data_version: {}, enable_handle_clean_read: {}, is_fast_mode: {}, enable_del_clean_read: {}", max_data_version, enable_handle_clean_read, is_fast_mode, enable_del_clean_read); + LOG_FMT_DEBUG(log, "max_data_version: {}, enable_handle_clean_read: {}, is_fast_mode: {}, enable_del_clean_read: {}", max_data_version, enable_handle_clean_read, is_fast_scan, enable_del_clean_read); SkippableBlockInputStreams streams; for (size_t i = 0; i < stable->files.size(); i++) { DMFileBlockInputStreamBuilder builder(context.db_context); builder - .enableCleanRead(enable_handle_clean_read, is_fast_mode, enable_del_clean_read, max_data_version) + .enableCleanRead(enable_handle_clean_read, is_fast_scan, enable_del_clean_read, max_data_version) .setRSOperator(filter) .setColumnCache(column_caches[i]) .setTracingID(context.tracing_id) diff --git a/dbms/src/Storages/DeltaMerge/StableValueSpace.h b/dbms/src/Storages/DeltaMerge/StableValueSpace.h index f254a8c21a4..1ab6449dc01 100644 --- a/dbms/src/Storages/DeltaMerge/StableValueSpace.h +++ b/dbms/src/Storages/DeltaMerge/StableValueSpace.h @@ -151,7 +151,7 @@ class StableValueSpace : public std::enable_shared_from_this UInt64 max_data_version, size_t expected_block_size, bool enable_handle_clean_read, - bool is_fast_mode = false, + bool is_fast_scan = false, bool enable_del_clean_read = false); RowsAndBytes getApproxRowsAndBytes(const DMContext & context, const RowKeyRange & range) const; diff --git a/dbms/src/Storages/DeltaMerge/tests/CMakeLists.txt b/dbms/src/Storages/DeltaMerge/tests/CMakeLists.txt index 44ca6ccb367..1e52939a46c 100644 --- a/dbms/src/Storages/DeltaMerge/tests/CMakeLists.txt +++ b/dbms/src/Storages/DeltaMerge/tests/CMakeLists.txt @@ -42,8 +42,8 @@ target_link_libraries(dm_test_storage_delta_merge add_executable(dm_test_delta_merge_store EXCLUDE_FROM_ALL gtest_dm_delta_merge_store.cpp) target_link_libraries(dm_test_delta_merge_store dbms gtest_main clickhouse_functions) -add_executable(dm_test_delta_merge_store_for_fast_mode EXCLUDE_FROM_ALL gtest_dm_delta_merge_store_for_fast_mode.cpp) -target_link_libraries(dm_test_delta_merge_store_for_fast_mode dbms gtest_main clickhouse_functions) +add_executable(dm_test_delta_merge_store_for_fast_scan EXCLUDE_FROM_ALL gtest_dm_delta_merge_store_for_fast_scan.cpp) +target_link_libraries(dm_test_delta_merge_store_for_fast_scan dbms gtest_main clickhouse_functions) add_executable(dm_test_segment EXCLUDE_FROM_ALL gtest_dm_segment.cpp) target_link_libraries(dm_test_segment dbms gtest_main clickhouse_functions) diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp index 1e48dd4e4af..0259d228038 100644 --- a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp +++ b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store.cpp @@ -259,7 +259,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -358,7 +358,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_NROWS(in, 0); } @@ -437,7 +437,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -486,7 +486,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -513,7 +513,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -588,7 +588,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -663,7 +663,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -680,11 +680,11 @@ try columns, {RowKeyRange::newAll(store->isCommonHandle(), store->getRowKeyColumnSize())}, /* num_streams= */ 1, - /* max_version= */ UInt64(1), + /* max_version= */ static_cast(1), EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -729,7 +729,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -759,7 +759,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -802,7 +802,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -821,7 +821,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -840,7 +840,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -859,7 +859,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -916,7 +916,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -942,7 +942,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -968,7 +968,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -987,7 +987,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -1008,7 +1008,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -1065,7 +1065,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1); BlockInputStreamPtr in = ins[0]; @@ -1091,7 +1091,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1); BlockInputStreamPtr in = ins[0]; @@ -1117,7 +1117,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1); BlockInputStreamPtr in = ins[0]; @@ -1169,7 +1169,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1); BlockInputStreamPtr in = ins[0]; @@ -1195,7 +1195,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1); BlockInputStreamPtr in = ins[0]; @@ -1277,7 +1277,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; @@ -1366,7 +1366,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr & in = ins[0]; @@ -1455,7 +1455,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr & in = ins[0]; @@ -1531,7 +1531,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr & in = ins[0]; @@ -1615,7 +1615,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( @@ -1681,7 +1681,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( @@ -1747,7 +1747,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -1812,7 +1812,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -1877,7 +1877,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( @@ -1941,7 +1941,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; std::vector datetime_data( @@ -2011,7 +2011,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -2091,7 +2091,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr & in = ins[0]; @@ -2208,7 +2208,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr & in = ins[0]; @@ -2256,7 +2256,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr & in = ins[0]; @@ -2342,7 +2342,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -2384,7 +2384,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; // FIXME!!! @@ -2495,7 +2495,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; // mock common handle @@ -2597,7 +2597,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; // mock common handle auto common_handle_coldata = []() { @@ -2669,7 +2669,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; // mock common handle auto common_handle_coldata = []() { @@ -2694,11 +2694,11 @@ try columns, {RowKeyRange::newAll(store->isCommonHandle(), store->getRowKeyColumnSize())}, /* num_streams= */ 1, - /* max_version= */ UInt64(1), + /* max_version= */ static_cast(1), EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; // mock common handle auto common_handle_coldata = []() { @@ -2754,7 +2754,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; // mock common handle auto common_handle_coldata = []() { @@ -2791,7 +2791,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; // mock common handle, data range after deletion is [64, 128) auto common_handle_coldata = []() { @@ -2858,7 +2858,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024); ASSERT_EQ(ins.size(), 1UL); BlockInputStreamPtr in = ins[0]; diff --git a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_for_fast_mode.cpp b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_for_fast_scan.cpp similarity index 96% rename from dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_for_fast_mode.cpp rename to dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_for_fast_scan.cpp index 86499ec4fbc..42736b3d893 100644 --- a/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_for_fast_mode.cpp +++ b/dbms/src/Storages/DeltaMerge/tests/gtest_dm_delta_merge_store_for_fast_scan.cpp @@ -27,7 +27,7 @@ namespace DM { namespace tests { -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithoutRangeFilter) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithOnlyInsertWithoutRangeFilter) { /// test under only insert data (no update, no delete) with all range @@ -87,7 +87,7 @@ TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithoutRangeFilter) EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -100,7 +100,7 @@ TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithoutRangeFilter) } } -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithRangeFilter) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithOnlyInsertWithRangeFilter) { /// test under only insert data (no update, no delete) with range filter @@ -171,7 +171,7 @@ TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithRangeFilter) EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -184,7 +184,7 @@ TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithRangeFilter) } } -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithMultipleBlockWithoutFlushCache) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithOnlyInsertWithMultipleBlockWithoutFlushCache) try { const size_t num_write_rows = 32; @@ -246,7 +246,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; switch (mode) { @@ -303,7 +303,7 @@ try } CATCH -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithMultipleBlockWithoutCompact) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithOnlyInsertWithMultipleBlockWithoutCompact) try { const size_t num_write_rows = 32; @@ -367,7 +367,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; switch (mode) { @@ -408,7 +408,7 @@ try } CATCH -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithMultipleBlockWithCompact) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithOnlyInsertWithMultipleBlockWithCompact) try { const size_t num_write_rows = 32; @@ -473,7 +473,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; switch (mode) { @@ -514,7 +514,7 @@ try } CATCH -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithOnlyInsertWithMultipleBlockWithCompactAndMergeDelta) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithOnlyInsertWithMultipleBlockWithCompactAndMergeDelta) try { const size_t num_write_rows = 32; @@ -582,7 +582,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -593,7 +593,7 @@ try CATCH // Insert + Update -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithMultipleBlockWithOverlap) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithMultipleBlockWithOverlap) try { const size_t num_write_rows = 32; @@ -661,7 +661,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; switch (mode) @@ -732,7 +732,7 @@ try CATCH // Insert + Delete row -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithDeleteRow) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithDeleteRow) try { const ColumnDefine col_str_define(2, "col2", std::make_shared()); @@ -808,7 +808,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; // filter del mark = 1, thus just read the insert data before delete ASSERT_INPUTSTREAM_COLS_UR( @@ -834,7 +834,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -845,7 +845,7 @@ try CATCH // Insert + Delete Range -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithDeleteRange) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithDeleteRange) try { const size_t num_rows_write = 128; @@ -880,7 +880,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -905,7 +905,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order = */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; // filter del mark = 1, thus just read the insert data before delete ASSERT_INPUTSTREAM_COLS_UR( @@ -916,7 +916,7 @@ try } CATCH -TEST_P(DeltaMergeStoreRWTest, TestFastModeWithDeleteWithMergeDelta) +TEST_P(DeltaMergeStoreRWTest, TestFastScanWithDeleteWithMergeDelta) try { const size_t num_rows_write = 128; @@ -965,7 +965,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; auto pk_coldata = createNumbers(num_deleted_rows, num_rows_write); ASSERT_EQ(pk_coldata.size(), num_rows_write - num_deleted_rows); @@ -978,7 +978,7 @@ try CATCH // insert + update + delete and fast mode first and then normal mode, to check the mode conversion is ok -TEST_P(DeltaMergeStoreRWTest, TestFastModeComplexWithModeConversion) +TEST_P(DeltaMergeStoreRWTest, TestFastScanComplexWithModeConversion) try { const size_t num_write_rows = 128; @@ -1053,7 +1053,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; switch (mode) @@ -1133,7 +1133,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ false, + /* is_fast_scan= */ false, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -1143,7 +1143,7 @@ try } CATCH -TEST_P(DeltaMergeStoreRWTest, TestFastModeForCleanRead) +TEST_P(DeltaMergeStoreRWTest, TestFastScanForCleanRead) try { const size_t num_rows_write = 128; @@ -1185,7 +1185,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_COLS_UR( in, @@ -1229,7 +1229,7 @@ try EMPTY_FILTER, TRACING_NAME, /* keep_order= */ false, - /* is_fast_mode= */ true, + /* is_fast_scan= */ true, /* expected_block_size= */ 1024)[0]; ASSERT_INPUTSTREAM_NROWS(in, num_rows_write - num_deleted_rows); } diff --git a/dbms/src/Storages/DeltaMerge/workload/DTWorkload.cpp b/dbms/src/Storages/DeltaMerge/workload/DTWorkload.cpp index ba78ea6c606..bf241efa0b4 100644 --- a/dbms/src/Storages/DeltaMerge/workload/DTWorkload.cpp +++ b/dbms/src/Storages/DeltaMerge/workload/DTWorkload.cpp @@ -192,7 +192,7 @@ void DTWorkload::read(const ColumnDefines & columns, int stream_count, T func) auto filter = EMPTY_FILTER; int excepted_block_size = 1024; uint64_t read_ts = ts_gen->get(); - auto streams = store->read(*context, context->getSettingsRef(), columns, ranges, stream_count, read_ts, filter, "DTWorkload", false, opts->is_fast_mode, excepted_block_size); + auto streams = store->read(*context, context->getSettingsRef(), columns, ranges, stream_count, read_ts, filter, "DTWorkload", false, opts->is_fast_scan, excepted_block_size); std::vector threads; threads.reserve(streams.size()); for (auto & stream : streams) diff --git a/dbms/src/Storages/DeltaMerge/workload/Options.cpp b/dbms/src/Storages/DeltaMerge/workload/Options.cpp index f10f008ced5..40fd3c594a3 100644 --- a/dbms/src/Storages/DeltaMerge/workload/Options.cpp +++ b/dbms/src/Storages/DeltaMerge/workload/Options.cpp @@ -48,7 +48,7 @@ std::string WorkloadOptions::toString(std::string seperator) const fmt::format("bg_thread_count {}{}", bg_thread_count, seperator) + // fmt::format("table_id {}{}", table_id, seperator) + // fmt::format("table_name {}{}", table_name, seperator) + // - fmt::format("is_fast_mode {}{}", is_fast_mode, seperator) + // + fmt::format("is_fast_scan {}{}", is_fast_scan, seperator) + // fmt::format("enable_read_thread {}{}", enable_read_thread, seperator); } @@ -96,11 +96,8 @@ std::pair WorkloadOptions::parseOptions(int argc, char * argv // ("table_name", value()->default_value(""), "") // ("table_id", value()->default_value(-1), "") // - // - ("is_fast_mode", value()->default_value(false), "default is false, means normal mode. When we in fast mode, we should set verification as false") // - // - ("enable_read_thread", value()->default_value(true), "") // - ; + ("is_fast_scan", value()->default_value(false), "default is false, means normal mode. When we in fast mode, we should set verification as false") // + ("enable_read_thread", value()->default_value(true), ""); boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); @@ -180,11 +177,11 @@ std::pair WorkloadOptions::parseOptions(int argc, char * argv table_id = vm["table_id"].as(); table_name = vm["table_name"].as(); - is_fast_mode = vm["is_fast_mode"].as(); + is_fast_scan = vm["is_fast_scan"].as(); - if (is_fast_mode && verification) + if (is_fast_scan && verification) { - return {false, fmt::format("When in_fast_mode, we should set verification as false")}; + return {false, fmt::format("When in_fast_scan, we should set verification as false")}; } enable_read_thread = vm["enable_read_thread"].as(); diff --git a/dbms/src/Storages/DeltaMerge/workload/Options.h b/dbms/src/Storages/DeltaMerge/workload/Options.h index 2a0860b5d2b..61844a53211 100644 --- a/dbms/src/Storages/DeltaMerge/workload/Options.h +++ b/dbms/src/Storages/DeltaMerge/workload/Options.h @@ -62,7 +62,7 @@ struct WorkloadOptions int64_t table_id; std::string table_name; - bool is_fast_mode; + bool is_fast_scan; bool enable_read_thread; diff --git a/dbms/src/Storages/SelectQueryInfo.cpp b/dbms/src/Storages/SelectQueryInfo.cpp index 9b5dbf0d30f..4569b25ef35 100644 --- a/dbms/src/Storages/SelectQueryInfo.cpp +++ b/dbms/src/Storages/SelectQueryInfo.cpp @@ -30,6 +30,7 @@ SelectQueryInfo::SelectQueryInfo(const SelectQueryInfo & rhs) , dag_query(rhs.dag_query != nullptr ? std::make_unique(*rhs.dag_query) : nullptr) , req_id(rhs.req_id) , keep_order(rhs.keep_order) + , is_fast_scan(rhs.is_fast_scan) {} SelectQueryInfo::SelectQueryInfo(SelectQueryInfo && rhs) noexcept @@ -39,6 +40,7 @@ SelectQueryInfo::SelectQueryInfo(SelectQueryInfo && rhs) noexcept , dag_query(std::move(rhs.dag_query)) , req_id(std::move(rhs.req_id)) , keep_order(rhs.keep_order) + , is_fast_scan(rhs.is_fast_scan) {} } // namespace DB diff --git a/dbms/src/Storages/SelectQueryInfo.h b/dbms/src/Storages/SelectQueryInfo.h index 0807647aa26..4734076dff0 100644 --- a/dbms/src/Storages/SelectQueryInfo.h +++ b/dbms/src/Storages/SelectQueryInfo.h @@ -52,6 +52,7 @@ struct SelectQueryInfo std::string req_id; bool keep_order = true; + bool is_fast_scan = false; SelectQueryInfo(); ~SelectQueryInfo(); diff --git a/dbms/src/Storages/StorageDeltaMerge.cpp b/dbms/src/Storages/StorageDeltaMerge.cpp index 485c0057135..6eb6a16736b 100644 --- a/dbms/src/Storages/StorageDeltaMerge.cpp +++ b/dbms/src/Storages/StorageDeltaMerge.cpp @@ -759,7 +759,7 @@ BlockInputStreams StorageDeltaMerge::read( rs_operator, req_id, query_info.keep_order, - /* is_fast_mode */ tidb_table_info.tiflash_mode == TiDB::TiFlashMode::Fast, // read in normal mode or read in fast mode + /* is_fast_scan */ query_info.is_fast_scan, max_block_size, parseSegmentSet(select_query.segment_expression_list), extra_table_id_index); diff --git a/dbms/src/Storages/Transaction/TiDB.cpp b/dbms/src/Storages/Transaction/TiDB.cpp index cd1dc583a7c..ed107e99aba 100644 --- a/dbms/src/Storages/Transaction/TiDB.cpp +++ b/dbms/src/Storages/Transaction/TiDB.cpp @@ -62,19 +62,19 @@ Field GenDefaultField(const TiDB::ColumnInfo & col_info) case TiDB::CodecFlagCompactBytes: return Field(String()); case TiDB::CodecFlagFloat: - return Field(Float64(0)); + return Field(static_cast(0)); case TiDB::CodecFlagUInt: - return Field(UInt64(0)); + return Field(static_cast(0)); case TiDB::CodecFlagInt: - return Field(Int64(0)); + return Field(static_cast(0)); case TiDB::CodecFlagVarInt: - return Field(Int64(0)); + return Field(static_cast(0)); case TiDB::CodecFlagVarUInt: - return Field(UInt64(0)); + return Field(static_cast(0)); case TiDB::CodecFlagJson: return TiDB::genJsonNull(); case TiDB::CodecFlagDuration: - return Field(Int64(0)); + return Field(static_cast(0)); default: throw Exception("Not implemented codec flag: " + std::to_string(col_info.getCodecFlag()), ErrorCodes::LOGICAL_ERROR); } @@ -407,7 +407,7 @@ try size_t elems_size = elems_arr->size(); for (size_t i = 1; i <= elems_size; i++) { - elems.push_back(std::make_pair(elems_arr->getElement(i - 1), Int16(i))); + elems.push_back(std::make_pair(elems_arr->getElement(i - 1), static_cast(i))); } } /// need to do this check for forward compatibility @@ -773,37 +773,6 @@ catch (const Poco::Exception & e) DB::Exception(e)); } -String TiFlashModeToString(TiFlashMode tiflash_mode) -{ - switch (tiflash_mode) - { - case TiFlashMode::Normal: - return ""; - case TiFlashMode::Fast: - return "fast"; - default: - LOG_FMT_WARNING(&Poco::Logger::get("TiDB"), "TiFlashModeToString with invalid tiflash mode {}", tiflash_mode); - return ""; - } -} - -TiFlashMode parseTiFlashMode(String mode_str) -{ - if (mode_str.empty()) - { - return TiFlashMode::Normal; - } - else if (mode_str == "fast") - { - return TiFlashMode::Fast; - } - else - { - throw DB::Exception( - std::string(__PRETTY_FUNCTION__) - + " ParseTiFlashMode Failed. mode " + mode_str + " is unvalid, please set mode as fast/normal"); - } -} /////////////////////// ////// TableInfo ////// /////////////////////// @@ -872,8 +841,6 @@ try json->set("tiflash_replica", replica_info.getJSONObject()); - json->set("tiflash_mode", std::string(TiFlashModeToString(tiflash_mode))); - json->stringify(buf); return buf.str(); @@ -960,14 +927,6 @@ try replica_info.deserialize(replica_obj); } } - if (obj->has("tiflash_mode")) - { - auto mode = obj->getValue("tiflash_mode"); - if (!mode.empty()) - { - tiflash_mode = parseTiFlashMode(mode); - } - } if (is_common_handle && index_infos.size() != 1) { throw DB::Exception( @@ -1138,7 +1097,7 @@ TableInfoPtr TableInfo::producePartitionTableInfo(TableID table_or_partition_id, String genJsonNull() { // null - const static String null({char(DB::TYPE_CODE_LITERAL), char(DB::LITERAL_NIL)}); + const static String null({static_cast(DB::TYPE_CODE_LITERAL), static_cast(DB::LITERAL_NIL)}); return null; } diff --git a/dbms/src/Storages/Transaction/TiDB.h b/dbms/src/Storages/Transaction/TiDB.h index 0f136786fd5..9bd78abeed3 100644 --- a/dbms/src/Storages/Transaction/TiDB.h +++ b/dbms/src/Storages/Transaction/TiDB.h @@ -197,10 +197,19 @@ struct ColumnInfo #ifdef M #error "Please undefine macro M first." #endif -#define M(f, v) \ - inline bool has##f##Flag() const { return (flag & (v)) != 0; } \ - inline void set##f##Flag() { flag |= (v); } \ - inline void clear##f##Flag() { flag &= (~(v)); } +#define M(f, v) \ + inline bool has##f##Flag() const \ + { \ + return (flag & (v)) != 0; \ + } \ + inline void set##f##Flag() \ + { \ + flag |= (v); \ + } \ + inline void clear##f##Flag() \ + { \ + flag &= (~(v)); \ + } COLUMN_FLAGS(M) #undef M @@ -334,12 +343,6 @@ struct IndexInfo bool is_global; }; -enum class TiFlashMode -{ - Normal, - Fast, -}; - struct TableInfo { TableInfo() = default; @@ -389,8 +392,6 @@ struct TableInfo // The TiFlash replica info persisted by TiDB TiFlashReplicaInfo replica_info; - TiFlashMode tiflash_mode = TiFlashMode::Normal; - ::TiDB::StorageEngine engine_type = ::TiDB::StorageEngine::UNSPECIFIED; ColumnID getColumnID(const String & name) const; @@ -423,7 +424,4 @@ tipb::FieldType columnInfoToFieldType(const ColumnInfo & ci); ColumnInfo fieldTypeToColumnInfo(const tipb::FieldType & field_type); ColumnInfo toTiDBColumnInfo(const tipb::ColumnInfo & tipb_column_info); -String TiFlashModeToString(TiFlashMode tiflash_mode); -TiFlashMode parseTiFlashMode(String mode_str); - } // namespace TiDB diff --git a/dbms/src/Storages/Transaction/tests/gtest_table_info.cpp b/dbms/src/Storages/Transaction/tests/gtest_table_info.cpp index 871153cb0e9..76b084f6de1 100644 --- a/dbms/src/Storages/Transaction/tests/gtest_table_info.cpp +++ b/dbms/src/Storages/Transaction/tests/gtest_table_info.cpp @@ -143,44 +143,44 @@ try {StmtCase{ 1145, // R"json({"id":1939,"db_name":{"O":"customer","L":"customer"},"charset":"utf8mb4","collate":"utf8mb4_bin","state":5})json", // - R"json({"id":1145,"name":{"O":"customerdebt","L":"customerdebt"},"cols":[{"id":1,"name":{"O":"id","L":"id"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"type":{"Tp":8,"Flag":515,"Flen":20,"Decimal":0},"state":5,"comment":"i\"d"}],"state":5,"pk_is_handle":true,"schema_version":-1,"comment":"负债信息","partition":null,"tiflash_mode":"fast"})json", // - R"stmt(CREATE TABLE `customer`.`customerdebt`(`id` Int64) Engine = DeltaMerge((`id`), '{"cols":[{"comment":"i\\"d","default":null,"default_bit":null,"id":1,"name":{"L":"id","O":"id"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":null,"Collate":null,"Decimal":0,"Elems":null,"Flag":515,"Flen":20,"Tp":8}}],"comment":"\\u8D1F\\u503A\\u4FE1\\u606F","id":1145,"index_info":[],"is_common_handle":false,"name":{"L":"customerdebt","O":"customerdebt"},"partition":null,"pk_is_handle":true,"schema_version":-1,"state":5,"tiflash_mode":"fast","tiflash_replica":{"Count":0},"update_timestamp":0}'))stmt", // + R"json({"id":1145,"name":{"O":"customerdebt","L":"customerdebt"},"cols":[{"id":1,"name":{"O":"id","L":"id"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"type":{"Tp":8,"Flag":515,"Flen":20,"Decimal":0},"state":5,"comment":"i\"d"}],"state":5,"pk_is_handle":true,"schema_version":-1,"comment":"负债信息","partition":null})json", // + R"stmt(CREATE TABLE `customer`.`customerdebt`(`id` Int64) Engine = DeltaMerge((`id`), '{"cols":[{"comment":"i\\"d","default":null,"default_bit":null,"id":1,"name":{"L":"id","O":"id"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":null,"Collate":null,"Decimal":0,"Elems":null,"Flag":515,"Flen":20,"Tp":8}}],"comment":"\\u8D1F\\u503A\\u4FE1\\u606F","id":1145,"index_info":[],"is_common_handle":false,"name":{"L":"customerdebt","O":"customerdebt"},"partition":null,"pk_is_handle":true,"schema_version":-1,"state":5,"tiflash_replica":{"Count":0},"update_timestamp":0}'))stmt", // }, StmtCase{ 2049, // R"json({"id":1939,"db_name":{"O":"customer","L":"customer"},"charset":"utf8mb4","collate":"utf8mb4_bin","state":5})json", // - R"json({"id":2049,"name":{"O":"customerdebt","L":"customerdebt"},"cols":[{"id":1,"name":{"O":"id","L":"id"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"type":{"Tp":8,"Flag":515,"Flen":20,"Decimal":0},"state":5,"comment":"i\"d"}],"state":5,"pk_is_handle":true,"schema_version":-1,"comment":"负债信息","update_timestamp":404545295996944390,"partition":null,"tiflash_mode":""})json", // - R"stmt(CREATE TABLE `customer`.`customerdebt`(`id` Int64) Engine = DeltaMerge((`id`), '{"cols":[{"comment":"i\\"d","default":null,"default_bit":null,"id":1,"name":{"L":"id","O":"id"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":null,"Collate":null,"Decimal":0,"Elems":null,"Flag":515,"Flen":20,"Tp":8}}],"comment":"\\u8D1F\\u503A\\u4FE1\\u606F","id":2049,"index_info":[],"is_common_handle":false,"name":{"L":"customerdebt","O":"customerdebt"},"partition":null,"pk_is_handle":true,"schema_version":-1,"state":5,"tiflash_mode":"","tiflash_replica":{"Count":0},"update_timestamp":404545295996944390}'))stmt", // + R"json({"id":2049,"name":{"O":"customerdebt","L":"customerdebt"},"cols":[{"id":1,"name":{"O":"id","L":"id"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"type":{"Tp":8,"Flag":515,"Flen":20,"Decimal":0},"state":5,"comment":"i\"d"}],"state":5,"pk_is_handle":true,"schema_version":-1,"comment":"负债信息","update_timestamp":404545295996944390,"partition":null})json", // + R"stmt(CREATE TABLE `customer`.`customerdebt`(`id` Int64) Engine = DeltaMerge((`id`), '{"cols":[{"comment":"i\\"d","default":null,"default_bit":null,"id":1,"name":{"L":"id","O":"id"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":null,"Collate":null,"Decimal":0,"Elems":null,"Flag":515,"Flen":20,"Tp":8}}],"comment":"\\u8D1F\\u503A\\u4FE1\\u606F","id":2049,"index_info":[],"is_common_handle":false,"name":{"L":"customerdebt","O":"customerdebt"},"partition":null,"pk_is_handle":true,"schema_version":-1,"state":5,"tiflash_replica":{"Count":0},"update_timestamp":404545295996944390}'))stmt", // }, StmtCase{ 31, // R"json({"id":1,"db_name":{"O":"db1","L":"db1"},"charset":"utf8mb4","collate":"utf8mb4_bin","state":5})json", // - R"json({"id":31,"name":{"O":"simple_t","L":"simple_t"},"charset":"","collate":"","cols":[{"id":1,"name":{"O":"i","L":"i"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":3,"Flag":0,"Flen":11,"Decimal":0,"Charset":"binary","Collate":"binary","Elems":null},"state":5,"comment":""}],"index_info":null,"fk_info":null,"state":5,"pk_is_handle":false,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":0,"update_timestamp":404545295996944390,"ShardRowIDBits":0,"partition":null,"tiflash_mode":""})json", // - R"stmt(CREATE TABLE `db1`.`simple_t`(`i` Nullable(Int32), `_tidb_rowid` Int64) Engine = DeltaMerge((`_tidb_rowid`), '{"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"i","O":"i"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Elems":null,"Flag":0,"Flen":11,"Tp":3}}],"comment":"","id":31,"index_info":[],"is_common_handle":false,"name":{"L":"simple_t","O":"simple_t"},"partition":null,"pk_is_handle":false,"schema_version":-1,"state":5,"tiflash_mode":"","tiflash_replica":{"Count":0},"update_timestamp":404545295996944390}'))stmt", // + R"json({"id":31,"name":{"O":"simple_t","L":"simple_t"},"charset":"","collate":"","cols":[{"id":1,"name":{"O":"i","L":"i"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":3,"Flag":0,"Flen":11,"Decimal":0,"Charset":"binary","Collate":"binary","Elems":null},"state":5,"comment":""}],"index_info":null,"fk_info":null,"state":5,"pk_is_handle":false,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":0,"update_timestamp":404545295996944390,"ShardRowIDBits":0,"partition":null})json", // + R"stmt(CREATE TABLE `db1`.`simple_t`(`i` Nullable(Int32), `_tidb_rowid` Int64) Engine = DeltaMerge((`_tidb_rowid`), '{"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"i","O":"i"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Elems":null,"Flag":0,"Flen":11,"Tp":3}}],"comment":"","id":31,"index_info":[],"is_common_handle":false,"name":{"L":"simple_t","O":"simple_t"},"partition":null,"pk_is_handle":false,"schema_version":-1,"state":5,"tiflash_replica":{"Count":0},"update_timestamp":404545295996944390}'))stmt", // }, StmtCase{ 33, // R"json({"id":2,"db_name":{"O":"db2","L":"db2"},"charset":"utf8mb4","collate":"utf8mb4_bin","state":5})json", // - R"json({"id":33,"name":{"O":"pk_t","L":"pk_t"},"charset":"","collate":"","cols":[{"id":1,"name":{"O":"i","L":"i"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":3,"Flag":3,"Flen":11,"Decimal":0,"Charset":"binary","Collate":"binary","Elems":null},"state":5,"comment":""}],"index_info":null,"fk_info":null,"state":5,"pk_is_handle":true,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":0,"update_timestamp":404545312978108418,"ShardRowIDBits":0,"partition":null,"tiflash_mode":""})json", // - R"stmt(CREATE TABLE `db2`.`pk_t`(`i` Int32) Engine = DeltaMerge((`i`), '{"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"i","O":"i"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Elems":null,"Flag":3,"Flen":11,"Tp":3}}],"comment":"","id":33,"index_info":[],"is_common_handle":false,"name":{"L":"pk_t","O":"pk_t"},"partition":null,"pk_is_handle":true,"schema_version":-1,"state":5,"tiflash_mode":"","tiflash_replica":{"Count":0},"update_timestamp":404545312978108418}'))stmt", // + R"json({"id":33,"name":{"O":"pk_t","L":"pk_t"},"charset":"","collate":"","cols":[{"id":1,"name":{"O":"i","L":"i"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":3,"Flag":3,"Flen":11,"Decimal":0,"Charset":"binary","Collate":"binary","Elems":null},"state":5,"comment":""}],"index_info":null,"fk_info":null,"state":5,"pk_is_handle":true,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":0,"update_timestamp":404545312978108418,"ShardRowIDBits":0,"partition":null})json", // + R"stmt(CREATE TABLE `db2`.`pk_t`(`i` Int32) Engine = DeltaMerge((`i`), '{"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"i","O":"i"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Elems":null,"Flag":3,"Flen":11,"Tp":3}}],"comment":"","id":33,"index_info":[],"is_common_handle":false,"name":{"L":"pk_t","O":"pk_t"},"partition":null,"pk_is_handle":true,"schema_version":-1,"state":5,"tiflash_replica":{"Count":0},"update_timestamp":404545312978108418}'))stmt", // }, StmtCase{ 35, // R"json({"id":1,"db_name":{"O":"db1","L":"db1"},"charset":"utf8mb4","collate":"utf8mb4_bin","state":5})json", // - R"json({"id":35,"name":{"O":"not_null_t","L":"not_null_t"},"charset":"","collate":"","cols":[{"id":1,"name":{"O":"i","L":"i"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":3,"Flag":4097,"Flen":11,"Decimal":0,"Charset":"binary","Collate":"binary","Elems":null},"state":5,"comment":""}],"index_info":null,"fk_info":null,"state":5,"pk_is_handle":false,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":0,"update_timestamp":404545324922961926,"ShardRowIDBits":0,"partition":null,"tiflash_mode":""})json", // - R"stmt(CREATE TABLE `db1`.`not_null_t`(`i` Int32, `_tidb_rowid` Int64) Engine = DeltaMerge((`_tidb_rowid`), '{"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"i","O":"i"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Elems":null,"Flag":4097,"Flen":11,"Tp":3}}],"comment":"","id":35,"index_info":[],"is_common_handle":false,"name":{"L":"not_null_t","O":"not_null_t"},"partition":null,"pk_is_handle":false,"schema_version":-1,"state":5,"tiflash_mode":"","tiflash_replica":{"Count":0},"update_timestamp":404545324922961926}'))stmt", // + R"json({"id":35,"name":{"O":"not_null_t","L":"not_null_t"},"charset":"","collate":"","cols":[{"id":1,"name":{"O":"i","L":"i"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":3,"Flag":4097,"Flen":11,"Decimal":0,"Charset":"binary","Collate":"binary","Elems":null},"state":5,"comment":""}],"index_info":null,"fk_info":null,"state":5,"pk_is_handle":false,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":0,"update_timestamp":404545324922961926,"ShardRowIDBits":0,"partition":null})json", // + R"stmt(CREATE TABLE `db1`.`not_null_t`(`i` Int32, `_tidb_rowid` Int64) Engine = DeltaMerge((`_tidb_rowid`), '{"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"i","O":"i"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Elems":null,"Flag":4097,"Flen":11,"Tp":3}}],"comment":"","id":35,"index_info":[],"is_common_handle":false,"name":{"L":"not_null_t","O":"not_null_t"},"partition":null,"pk_is_handle":false,"schema_version":-1,"state":5,"tiflash_replica":{"Count":0},"update_timestamp":404545324922961926}'))stmt", // }, StmtCase{ 37, // R"json({"id":2,"db_name":{"O":"db2","L":"db2"},"charset":"utf8mb4","collate":"utf8mb4_bin","state":5})json", - R"json({"id":37,"name":{"O":"mytable","L":"mytable"},"charset":"","collate":"","cols":[{"id":1,"name":{"O":"mycol","L":"mycol"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":15,"Flag":4099,"Flen":256,"Decimal":0,"Charset":"utf8","Collate":"utf8_bin","Elems":null},"state":5,"comment":""}],"index_info":[{"id":1,"idx_name":{"O":"PRIMARY","L":"primary"},"tbl_name":{"O":"","L":""},"idx_cols":[{"name":{"O":"mycol","L":"mycol"},"offset":0,"length":-1}],"is_unique":true,"is_primary":true,"state":5,"comment":"","index_type":1}],"fk_info":null,"state":5,"pk_is_handle":true,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":1,"update_timestamp":404566455285710853,"ShardRowIDBits":0,"partition":null,"tiflash_mode":""})json", // - R"stmt(CREATE TABLE `db2`.`mytable`(`mycol` String) Engine = DeltaMerge((`mycol`), '{"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"mycol","O":"mycol"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"utf8","Collate":"utf8_bin","Decimal":0,"Elems":null,"Flag":4099,"Flen":256,"Tp":15}}],"comment":"","id":37,"index_info":[],"is_common_handle":false,"name":{"L":"mytable","O":"mytable"},"partition":null,"pk_is_handle":true,"schema_version":-1,"state":5,"tiflash_mode":"","tiflash_replica":{"Count":0},"update_timestamp":404566455285710853}'))stmt", // + R"json({"id":37,"name":{"O":"mytable","L":"mytable"},"charset":"","collate":"","cols":[{"id":1,"name":{"O":"mycol","L":"mycol"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":15,"Flag":4099,"Flen":256,"Decimal":0,"Charset":"utf8","Collate":"utf8_bin","Elems":null},"state":5,"comment":""}],"index_info":[{"id":1,"idx_name":{"O":"PRIMARY","L":"primary"},"tbl_name":{"O":"","L":""},"idx_cols":[{"name":{"O":"mycol","L":"mycol"},"offset":0,"length":-1}],"is_unique":true,"is_primary":true,"state":5,"comment":"","index_type":1}],"fk_info":null,"state":5,"pk_is_handle":true,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":1,"update_timestamp":404566455285710853,"ShardRowIDBits":0,"partition":null})json", // + R"stmt(CREATE TABLE `db2`.`mytable`(`mycol` String) Engine = DeltaMerge((`mycol`), '{"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"mycol","O":"mycol"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"utf8","Collate":"utf8_bin","Decimal":0,"Elems":null,"Flag":4099,"Flen":256,"Tp":15}}],"comment":"","id":37,"index_info":[],"is_common_handle":false,"name":{"L":"mytable","O":"mytable"},"partition":null,"pk_is_handle":true,"schema_version":-1,"state":5,"tiflash_replica":{"Count":0},"update_timestamp":404566455285710853}'))stmt", // }, StmtCase{ 32, // R"json({"id":1,"db_name":{"O":"test","L":"test"},"charset":"utf8mb4","collate":"utf8mb4_bin","state":5})json", // - R"json({"id":31,"name":{"O":"range_part_t","L":"range_part_t"},"charset":"utf8mb4","collate":"utf8mb4_bin","cols":[{"id":1,"name":{"O":"i","L":"i"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":3,"Flag":0,"Flen":11,"Decimal":0,"Charset":"binary","Collate":"binary","Elems":null},"state":5,"comment":"","version":0}],"index_info":null,"fk_info":null,"state":5,"pk_is_handle":false,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":0,"update_timestamp":407445773801488390,"ShardRowIDBits":0,"partition":{"type":1,"expr":"`i`","columns":null,"enable":true,"definitions":[{"id":32,"name":{"O":"p0","L":"p0"},"less_than":["0"]},{"id":33,"name":{"O":"p1","L":"p1"},"less_than":["100"]}],"num":0},"compression":"","version":1,"tiflash_mode":""})json", // - R"stmt(CREATE TABLE `test`.`range_part_t_32`(`i` Nullable(Int32), `_tidb_rowid` Int64) Engine = DeltaMerge((`_tidb_rowid`), '{"belonging_table_id":31,"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"i","O":"i"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Elems":null,"Flag":0,"Flen":11,"Tp":3}}],"comment":"","id":32,"index_info":[],"is_common_handle":false,"is_partition_sub_table":true,"name":{"L":"range_part_t_32","O":"range_part_t_32"},"partition":null,"pk_is_handle":false,"schema_version":-1,"state":5,"tiflash_mode":"","tiflash_replica":{"Count":0},"update_timestamp":407445773801488390}'))stmt", // + R"json({"id":31,"name":{"O":"range_part_t","L":"range_part_t"},"charset":"utf8mb4","collate":"utf8mb4_bin","cols":[{"id":1,"name":{"O":"i","L":"i"},"offset":0,"origin_default":null,"default":null,"default_bit":null,"generated_expr_string":"","generated_stored":false,"dependences":null,"type":{"Tp":3,"Flag":0,"Flen":11,"Decimal":0,"Charset":"binary","Collate":"binary","Elems":null},"state":5,"comment":"","version":0}],"index_info":null,"fk_info":null,"state":5,"pk_is_handle":false,"schema_version":-1,"comment":"","auto_inc_id":0,"max_col_id":1,"max_idx_id":0,"update_timestamp":407445773801488390,"ShardRowIDBits":0,"partition":{"type":1,"expr":"`i`","columns":null,"enable":true,"definitions":[{"id":32,"name":{"O":"p0","L":"p0"},"less_than":["0"]},{"id":33,"name":{"O":"p1","L":"p1"},"less_than":["100"]}],"num":0},"compression":"","version":1})json", // + R"stmt(CREATE TABLE `test`.`range_part_t_32`(`i` Nullable(Int32), `_tidb_rowid` Int64) Engine = DeltaMerge((`_tidb_rowid`), '{"belonging_table_id":31,"cols":[{"comment":"","default":null,"default_bit":null,"id":1,"name":{"L":"i","O":"i"},"offset":0,"origin_default":null,"state":5,"type":{"Charset":"binary","Collate":"binary","Decimal":0,"Elems":null,"Flag":0,"Flen":11,"Tp":3}}],"comment":"","id":32,"index_info":[],"is_common_handle":false,"is_partition_sub_table":true,"name":{"L":"range_part_t_32","O":"range_part_t_32"},"partition":null,"pk_is_handle":false,"schema_version":-1,"state":5,"tiflash_replica":{"Count":0},"update_timestamp":407445773801488390}'))stmt", // }}; for (const auto & c : cases) diff --git a/dbms/src/TiDB/Schema/SchemaBuilder.cpp b/dbms/src/TiDB/Schema/SchemaBuilder.cpp index af7169e7c47..85287bebc0f 100644 --- a/dbms/src/TiDB/Schema/SchemaBuilder.cpp +++ b/dbms/src/TiDB/Schema/SchemaBuilder.cpp @@ -543,11 +543,6 @@ void SchemaBuilder::applyDiff(const SchemaDiff & diff) applySetTiFlashReplica(db_info, diff.table_id); break; } - case SchemaActionType::SetTiFlashMode: - { - applySetTiFlashMode(db_info, diff.table_id); - break; - } default: { if (diff.type < SchemaActionType::MaxRecognizedType) @@ -1265,76 +1260,6 @@ void SchemaBuilder::applySetTiFlashReplicaOnPhysicalTable( LOG_FMT_INFO(log, "Updated replica info for {}", name_mapper.debugCanonicalName(*db_info, table_info)); } - -template -void SchemaBuilder::applySetTiFlashMode(const TiDB::DBInfoPtr & db_info, TableID table_id) -{ - auto latest_table_info = getter.getTableInfo(db_info->id, table_id); - - if (unlikely(latest_table_info == nullptr)) - { - throw TiFlashException(fmt::format("miss table in TiKV : {}", table_id), Errors::DDL::StaleSchema); - } - - auto & tmt_context = context.getTMTContext(); - auto storage = tmt_context.getStorages().get(latest_table_info->id); - if (unlikely(storage == nullptr)) - { - throw TiFlashException(fmt::format("miss table in TiFlash : {}", name_mapper.debugCanonicalName(*db_info, *latest_table_info)), - Errors::DDL::MissingTable); - } - - applySetTiFlashModeOnLogicalTable(db_info, latest_table_info, storage); -} - -template -void SchemaBuilder::applySetTiFlashModeOnLogicalTable( - const TiDB::DBInfoPtr & db_info, - const TiDB::TableInfoPtr & table_info, - const ManageableStoragePtr & storage) -{ - applySetTiFlashModeOnPhysicalTable(db_info, table_info, storage); - - if (table_info->isLogicalPartitionTable()) - { - auto & tmt_context = context.getTMTContext(); - for (const auto & part_def : table_info->partition.definitions) - { - auto new_part_table_info = table_info->producePartitionTableInfo(part_def.id, name_mapper); - auto part_storage = tmt_context.getStorages().get(new_part_table_info->id); - if (unlikely(part_storage == nullptr)) - { - throw TiFlashException(fmt::format("miss table in TiFlash : {}", name_mapper.debugCanonicalName(*db_info, *new_part_table_info)), - Errors::DDL::MissingTable); - } - applySetTiFlashModeOnPhysicalTable(db_info, new_part_table_info, part_storage); - } - } -} - - -template -void SchemaBuilder::applySetTiFlashModeOnPhysicalTable( - const TiDB::DBInfoPtr & db_info, - const TiDB::TableInfoPtr & latest_table_info, - const ManageableStoragePtr & storage) -{ - if (storage->getTableInfo().tiflash_mode == latest_table_info->tiflash_mode) - return; - - TiDB::TableInfo table_info = storage->getTableInfo(); - table_info.tiflash_mode = latest_table_info->tiflash_mode; - table_info.schema_version = target_version; - AlterCommands commands; - - LOG_FMT_INFO(log, "Updating tiflash mode for {} to {}", name_mapper.debugCanonicalName(*db_info, table_info), TiFlashModeToString(table_info.tiflash_mode)); - - auto alter_lock = storage->lockForAlter(getThreadName()); - storage->alterFromTiDB(alter_lock, commands, name_mapper.mapDatabaseName(*db_info), table_info, name_mapper, context); - LOG_FMT_INFO(log, "Updated tiflash mode for {} to {}", name_mapper.debugCanonicalName(*db_info, table_info), TiFlashModeToString(table_info.tiflash_mode)); -} - - template void SchemaBuilder::syncAllSchema() { @@ -1404,8 +1329,6 @@ void SchemaBuilder::syncAllSchema() applyRenameLogicalTable(db, table, storage); /// Update replica info if needed. applySetTiFlashReplicaOnLogicalTable(db, table, storage); - /// Update tiflash mode if needed. - applySetTiFlashModeOnLogicalTable(db, table, storage); /// Alter if needed. applyAlterLogicalTable(db, table, storage); LOG_FMT_DEBUG(log, "Table {} synced during sync all schemas", name_mapper.debugCanonicalName(*db, *table)); diff --git a/dbms/src/TiDB/Schema/SchemaBuilder.h b/dbms/src/TiDB/Schema/SchemaBuilder.h index 827203a682f..461d7ff9c12 100644 --- a/dbms/src/TiDB/Schema/SchemaBuilder.h +++ b/dbms/src/TiDB/Schema/SchemaBuilder.h @@ -89,10 +89,6 @@ struct SchemaBuilder void applySetTiFlashReplica(const TiDB::DBInfoPtr & db_info, TableID table_id); void applySetTiFlashReplicaOnLogicalTable(const TiDB::DBInfoPtr & db_info, const TiDB::TableInfoPtr & table_info, const ManageableStoragePtr & storage); void applySetTiFlashReplicaOnPhysicalTable(const TiDB::DBInfoPtr & db_info, const TiDB::TableInfoPtr & table_info, const ManageableStoragePtr & storage); - - void applySetTiFlashMode(const TiDB::DBInfoPtr & db_info, TableID table_id); - void applySetTiFlashModeOnLogicalTable(const TiDB::DBInfoPtr & db_info, const TiDB::TableInfoPtr & table_info, const ManageableStoragePtr & storage); - void applySetTiFlashModeOnPhysicalTable(const TiDB::DBInfoPtr & db_info, const TiDB::TableInfoPtr & table_info, const ManageableStoragePtr & storage); }; } // namespace DB diff --git a/dbms/src/TiDB/Schema/SchemaGetter.h b/dbms/src/TiDB/Schema/SchemaGetter.h index 72fd00678f7..b03ea01e5bb 100644 --- a/dbms/src/TiDB/Schema/SchemaGetter.h +++ b/dbms/src/TiDB/Schema/SchemaGetter.h @@ -95,13 +95,11 @@ enum class SchemaActionType : Int8 AlterNoCacheTable = 59, CreateTables = 60, ActionMultiSchemaChange = 61, - SetTiFlashMode = 62, - // If we supporte new type from TiDB. // MaxRecognizedType also needs to be changed. // It should always be equal to the maximum supported type + 1 - MaxRecognizedType = 63, + MaxRecognizedType = 62, }; struct AffectedOption diff --git a/tests/fullstack-test2/variables/set_variable_fastscan.test b/tests/fullstack-test2/variables/set_variable_fastscan.test new file mode 100644 index 00000000000..dbd62bc53ce --- /dev/null +++ b/tests/fullstack-test2/variables/set_variable_fastscan.test @@ -0,0 +1,93 @@ +# Copyright 2022 PingCAP, Ltd. +# +# 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 +# +# http://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. + +## test correctness in simple case +mysql> drop table if exists test.t +mysql> create table test.t (a int, b int) +mysql> alter table test.t set tiflash replica 1 + +func> wait_table test t + +mysql> insert into test.t values(1,2); +mysql> insert into test.t values(2,4); +mysql> insert into test.t values(5,7); + +mysql> set session tiflash_fastscan=ON; set session tidb_isolation_read_engines='tiflash'; select * from test.t; ++------+-----+ +| a | b | ++------+-----+ +| 1 | 2| +| 2 | 4| +| 5 | 7| ++------+-----+ + +mysql> delete from test.t where a = 1; + +mysql> set session tiflash_fastscan=ON; set session tidb_isolation_read_engines='tiflash'; select * from test.t; ++------+-----+ +| a | b | ++------+-----+ +| 1 | 2| +| 2 | 4| +| 5 | 7| ++------+-----+ + +## verify session variable tiflash_fastscan will not effect global variable +mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t; ++------+-----+ +| a | b | ++------+-----+ +| 2 | 4| +| 5 | 7| ++------+-----+ + +mysql> set session tiflash_fastscan=OFF; set session tidb_isolation_read_engines='tiflash'; select * from test.t; ++------+-----+ +| a | b | ++------+-----+ +| 2 | 4| +| 5 | 7| ++------+-----+ + +mysql> alter table test.t compact tiflash replica; + +mysql> set session tiflash_fastscan=ON; set session tidb_isolation_read_engines='tiflash'; select * from test.t; ++------+-----+ +| a | b | ++------+-----+ +| 1 | 2| +| 2 | 4| +| 5 | 7| ++------+-----+ + +## verfiy set global session tiflash_fastscan will not make other current session take effect. +mysql> set global tiflash_fastscan=ON; set session tidb_isolation_read_engines='tiflash'; select * from test.t; ++------+-----+ +| a | b | ++------+-----+ +| 2 | 4| +| 5 | 7| ++------+-----+ + +## verfiy set global session tiflash_fastscan will make other new session take effect. +mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t; ++------+-----+ +| a | b | ++------+-----+ +| 1 | 2| +| 2 | 4| +| 5 | 7| ++------+-----+ + +mysql> set global tiflash_fastscan=OFF; \ No newline at end of file