MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / read

Method read

src/Processors/QueryPlan/ReadFromMergeTree.cpp:856–901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

854}
855
856Pipe ReadFromMergeTree::read(
857 RangesInDataParts parts_with_range,
858 const MergeTreeIndexBuildContextPtr & index_build_context,
859 Names required_columns,
860 ReadType read_type,
861 size_t max_streams,
862 size_t min_marks_for_concurrent_read,
863 bool use_uncompressed_cache)
864{
865 const auto & settings = context->getSettingsRef();
866 size_t sum_marks = parts_with_range.getMarksCountAllParts();
867
868 const size_t total_query_nodes = is_parallel_reading_from_replicas
869 ? std::min<size_t>(
870 context->getClusterForParallelReplicas()->getShardsInfo().at(0).getAllNodeCount(),
871 context->getSettingsRef()[Setting::max_parallel_replicas])
872 : 1;
873
874 PoolSettings pool_settings{
875 .threads = max_streams,
876 .sum_marks = sum_marks,
877 .min_marks_for_concurrent_read = min_marks_for_concurrent_read,
878 .preferred_block_size_bytes = settings[Setting::preferred_block_size_bytes],
879 .use_uncompressed_cache = use_uncompressed_cache,
880 .use_const_size_tasks_for_remote_reading = settings[Setting::merge_tree_use_const_size_tasks_for_remote_reading],
881 .total_query_nodes = total_query_nodes,
882 };
883
884 if (read_type == ReadType::ParallelReplicas)
885 return readFromPoolParallelReplicas(
886 std::move(parts_with_range), index_build_context, std::move(required_columns), std::move(pool_settings));
887
888 /// Reading from default thread pool is beneficial for remote storage because of new prefetches.
889 if (read_type == ReadType::Default && (max_streams > 1 || checkAllPartsOnRemoteFS(parts_with_range)))
890 return readFromPool(
891 std::move(parts_with_range), index_build_context, std::move(required_columns), std::move(pool_settings));
892
893 auto pipe = readInOrder(parts_with_range, index_build_context, required_columns, pool_settings, read_type, /*limit=*/0);
894
895 /// Use ConcatProcessor to concat sources together.
896 /// It is needed to read in parts order (and so in PK order) if single thread is used.
897 if (read_type == ReadType::Default && pipe.numOutputPorts() > 1)
898 pipe.addTransform(std::make_shared<ConcatProcessor>(pipe.getSharedHeader(), pipe.numOutputPorts()));
899
900 return pipe;
901}
902
903namespace
904{

Callers 5

readByLayersMethod · 0.95
initLoopMethod · 0.45
replaceReadingFromTableFunction · 0.45

Calls 8

checkAllPartsOnRemoteFSFunction · 0.85
getMarksCountAllPartsMethod · 0.80
getAllNodeCountMethod · 0.80
numOutputPortsMethod · 0.80
getSharedHeaderMethod · 0.80
atMethod · 0.45
addTransformMethod · 0.45

Tested by

no test coverage detected