| 36 | return std::make_shared<ReadStorageRowCountStep>(output_stream->header, query, agg_desc, num_rows, is_final_agg, database_and_table); |
| 37 | } |
| 38 | void ReadStorageRowCountStep::initializePipeline(QueryPipeline & pipeline, const BuildQueryPipelineSettings & context) |
| 39 | { |
| 40 | const auto & func = agg_desc.function; |
| 41 | const AggregateFunctionCount & agg_count = static_cast<const AggregateFunctionCount &>(*func); |
| 42 | Block output_header; |
| 43 | if (is_final_agg) |
| 44 | { |
| 45 | auto count_column = ColumnVector<UInt64>::create(); |
| 46 | count_column->insertValue(num_rows); |
| 47 | output_header.insert({count_column->getPtr(), agg_count.getReturnType(), agg_desc.column_name}); |
| 48 | } |
| 49 | else |
| 50 | { |
| 51 | std::vector<char> state(agg_count.sizeOfData()); |
| 52 | AggregateDataPtr place = state.data(); |
| 53 | |
| 54 | agg_count.create(place); |
| 55 | SCOPE_EXIT_MEMORY_SAFE(agg_count.destroy(place)); |
| 56 | |
| 57 | agg_count.set(place, num_rows); |
| 58 | auto column = ColumnAggregateFunction::create(func); |
| 59 | column->insertFrom(place); |
| 60 | |
| 61 | // AggregateFunction's argument type must keep same. |
| 62 | output_header.insert( |
| 63 | {std::move(column), std::make_shared<DataTypeAggregateFunction>(func, func->getArgumentTypes(), agg_desc.parameters), agg_desc.column_name}); |
| 64 | } |
| 65 | |
| 66 | auto istream = std::make_shared<OneBlockInputStream>(output_header); |
| 67 | auto pipe = Pipe(std::make_shared<SourceFromInputStream>(istream)); |
| 68 | |
| 69 | for (const auto & processor : pipe.getProcessors()) |
| 70 | processors.emplace_back(processor); |
| 71 | |
| 72 | pipeline.init(std::move(pipe)); |
| 73 | |
| 74 | if (context.context) |
| 75 | pipeline.addInterpreterContext(context.context); |
| 76 | } |
| 77 | |
| 78 | void ReadStorageRowCountStep::toProto(Protos::ReadStorageRowCountStep & proto, bool) const |
| 79 | { |
nothing calls this directly
no test coverage detected