void registerAggregateFunctionsQuantileTiming(AggregateFunctionFactory & factory) { factory.registerFunction({"quantileTiming", "medianTiming"}, createAggregateFunctionQuantileTiming); factory.registerFunction({"quantilesTiming"}, createAggregateFunctionQuantilesTiming); factory.registerFunction({"quantileTimingWeighted", "medianTimingWeighted"}, createAggregateFunctionQuantileTimingWeighted); factory.registerFunction({"quantilesTimingWeighted"}, createAggregateFunctionQuantilesTimingWeighted); }
void registerAggregateFunctionsStatisticsStable(AggregateFunctionFactory & factory) { factory.registerFunction("varSampStable", createAggregateFunctionStatisticsUnary<AggregateFunctionVarSampStable>); factory.registerFunction("varPopStable", createAggregateFunctionStatisticsUnary<AggregateFunctionVarPopStable>); factory.registerFunction("stddevSampStable", createAggregateFunctionStatisticsUnary<AggregateFunctionStddevSampStable>); factory.registerFunction("stddevPopStable", createAggregateFunctionStatisticsUnary<AggregateFunctionStddevPopStable>); factory.registerFunction("covarSampStable", createAggregateFunctionStatisticsBinary<AggregateFunctionCovarSampStable>); factory.registerFunction("covarPopStable", createAggregateFunctionStatisticsBinary<AggregateFunctionCovarPopStable>); factory.registerFunction("corrStable", createAggregateFunctionStatisticsBinary<AggregateFunctionCorrStable>); }
void registerAggregateFunctionsStatistics(AggregateFunctionFactory & factory) { factory.registerFunction({"varSamp"}, createAggregateFunctionVarSamp); factory.registerFunction({"varPop"}, createAggregateFunctionVarPop); factory.registerFunction({"stddevSamp"}, createAggregateFunctionStdDevSamp); factory.registerFunction({"stddevPop"}, createAggregateFunctionStdDevPop); factory.registerFunction({"covarSamp"}, createAggregateFunctionCovarSamp); factory.registerFunction({"covarPop"}, createAggregateFunctionCovarPop); factory.registerFunction({"corr"}, createAggregateFunctionCorr); }
void registerAggregateFunctionsQuantileTDigest(AggregateFunctionFactory & factory) { factory.registerFunction("quantileTDigest", createAggregateFunctionQuantileTDigest<AggregateFunctionQuantileTDigest>); factory.registerFunction("medianTDigest", createAggregateFunctionQuantileTDigest<AggregateFunctionQuantileTDigest>); factory.registerFunction("quantilesTDigest", createAggregateFunctionQuantileTDigest<AggregateFunctionQuantilesTDigest>); factory.registerFunction("quantileTDigestWeighted", createAggregateFunctionQuantileTDigestWeighted<AggregateFunctionQuantileTDigestWeighted>); factory.registerFunction("medianTDigestWeighted", createAggregateFunctionQuantileTDigestWeighted<AggregateFunctionQuantileTDigestWeighted>); factory.registerFunction("quantilesTDigestWeighted", createAggregateFunctionQuantileTDigestWeighted<AggregateFunctionQuantilesTDigestWeighted>); }
void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory) { factory.registerFunction("sumMap", createAggregateFunctionSumMap); factory.registerFunction("sumMapFiltered", createAggregateFunctionSumMapFiltered); }
void registerAggregateFunctionsStatisticsSimple(AggregateFunctionFactory & factory) { factory.registerFunction("varSamp", createAggregateFunctionStatisticsUnary<AggregateFunctionVarSampSimple>); factory.registerFunction("varPop", createAggregateFunctionStatisticsUnary<AggregateFunctionVarPopSimple>); factory.registerFunction("stddevSamp", createAggregateFunctionStatisticsUnary<AggregateFunctionStddevSampSimple>); factory.registerFunction("stddevPop", createAggregateFunctionStatisticsUnary<AggregateFunctionStddevPopSimple>); factory.registerFunction("covarSamp", createAggregateFunctionStatisticsBinary<AggregateFunctionCovarSampSimple>); factory.registerFunction("covarPop", createAggregateFunctionStatisticsBinary<AggregateFunctionCovarPopSimple>); factory.registerFunction("corr", createAggregateFunctionStatisticsBinary<AggregateFunctionCorrSimple>, AggregateFunctionFactory::CaseInsensitive); /// Synonims for compatibility. factory.registerAlias("VAR_SAMP", "varSamp", AggregateFunctionFactory::CaseInsensitive); factory.registerAlias("VAR_POP", "varPop", AggregateFunctionFactory::CaseInsensitive); factory.registerAlias("STDDEV_SAMP", "stddevSamp", AggregateFunctionFactory::CaseInsensitive); factory.registerAlias("STDDEV_POP", "stddevPop", AggregateFunctionFactory::CaseInsensitive); factory.registerAlias("COVAR_SAMP", "covarSamp", AggregateFunctionFactory::CaseInsensitive); factory.registerAlias("COVAR_POP", "covarPop", AggregateFunctionFactory::CaseInsensitive); }
void registerAggregateFunctionCount(AggregateFunctionFactory & factory) { factory.registerFunction("count", createAggregateFunctionCount, AggregateFunctionFactory::CaseInsensitive); }
void registerAggregateFunctionsSequenceMatch(AggregateFunctionFactory & factory) { factory.registerFunction("sequenceMatch", createAggregateFunctionSequenceMatch); factory.registerFunction("sequenceCount", createAggregateFunctionSequenceCount); }
void registerAggregateFunctionAvg(AggregateFunctionFactory & factory) { factory.registerFunction("avg", createAggregateFunctionAvg, AggregateFunctionFactory::CaseInsensitive); }
void registerAggregateFunctionHistogram(AggregateFunctionFactory & factory) { factory.registerFunction("histogram", createAggregateFunctionHistogram); }
void registerAggregateFunctionGroupUniqArray(AggregateFunctionFactory & factory) { factory.registerFunction("groupUniqArray", createAggregateFunctionGroupUniqArray); }
void registerAggregateFunctionCount(AggregateFunctionFactory & factory) { factory.registerFunction({"count"}, createAggregateFunctionCount); }
void registerAggregateFunctionsQuantile(AggregateFunctionFactory & factory) { factory.registerFunction("quantile", createAggregateFunctionQuantile); factory.registerFunction("median", createAggregateFunctionQuantile); factory.registerFunction("quantiles", createAggregateFunctionQuantiles); }
void registerAggregateFunctionsStatistics(AggregateFunctionFactory & factory) { factory.registerFunction("varSamp", createAggregateFunctionVarSamp); factory.registerFunction("varPop", createAggregateFunctionVarPop); factory.registerFunction("stddevSamp", createAggregateFunctionStdDevSamp); factory.registerFunction("stddevPop", createAggregateFunctionStdDevPop); factory.registerFunction("covarSamp", createAggregateFunctionCovarSamp); factory.registerFunction("covarPop", createAggregateFunctionCovarPop); factory.registerFunction("corr", createAggregateFunctionCorr, AggregateFunctionFactory::CaseInsensitive); /// Synonims for compatibility. factory.registerFunction("VAR_SAMP", createAggregateFunctionVarSamp, AggregateFunctionFactory::CaseInsensitive); factory.registerFunction("VAR_POP", createAggregateFunctionVarPop, AggregateFunctionFactory::CaseInsensitive); factory.registerFunction("STDDEV_SAMP", createAggregateFunctionStdDevSamp, AggregateFunctionFactory::CaseInsensitive); factory.registerFunction("STDDEV_POP", createAggregateFunctionStdDevPop, AggregateFunctionFactory::CaseInsensitive); factory.registerFunction("COVAR_SAMP", createAggregateFunctionCovarSamp, AggregateFunctionFactory::CaseInsensitive); factory.registerFunction("COVAR_POP", createAggregateFunctionCovarPop, AggregateFunctionFactory::CaseInsensitive); }
int main(int argc, char ** argv) { using namespace DB; try { size_t n = argc == 2 ? atoi(argv[1]) : 10; Block block; ColumnWithTypeAndName column_x; column_x.name = "x"; column_x.type = std::make_shared<DataTypeInt16>(); auto x = std::make_shared<ColumnInt16>(); column_x.column = x; auto & vec_x = x->getData(); vec_x.resize(n); for (size_t i = 0; i < n; ++i) vec_x[i] = i % 9; block.insert(column_x); const char * strings[] = {"abc", "def", "abcd", "defg", "ac"}; ColumnWithTypeAndName column_s1; column_s1.name = "s1"; column_s1.type = std::make_shared<DataTypeString>(); column_s1.column = std::make_shared<ColumnString>(); for (size_t i = 0; i < n; ++i) column_s1.column->insert(std::string(strings[i % 5])); block.insert(column_s1); ColumnWithTypeAndName column_s2; column_s2.name = "s2"; column_s2.type = std::make_shared<DataTypeString>(); column_s2.column = std::make_shared<ColumnString>(); for (size_t i = 0; i < n; ++i) column_s2.column->insert(std::string(strings[i % 3])); block.insert(column_s2); BlockInputStreamPtr stream = std::make_shared<OneBlockInputStream>(block); AggregatedDataVariants aggregated_data_variants; Names key_column_names; key_column_names.emplace_back("x"); key_column_names.emplace_back("s1"); AggregateFunctionFactory factory; AggregateDescriptions aggregate_descriptions(1); DataTypes empty_list_of_types; aggregate_descriptions[0].function = factory.get("count", empty_list_of_types); Aggregator::Params params(key_column_names, aggregate_descriptions, false); Aggregator aggregator(params); { Stopwatch stopwatch; stopwatch.start(); aggregator.execute(stream, aggregated_data_variants); stopwatch.stop(); std::cout << std::fixed << std::setprecision(2) << "Elapsed " << stopwatch.elapsedSeconds() << " sec." << ", " << n / stopwatch.elapsedSeconds() << " rows/sec." << std::endl; } } catch (const Exception & e) { std::cerr << e.displayText() << std::endl; } return 0; }
void registerAggregateFunctionsQuantileExactWeighted(AggregateFunctionFactory & factory) { factory.registerFunction("quantileExactWeighted", createAggregateFunctionQuantileExactWeighted); factory.registerFunction("medianExactWeighted", createAggregateFunctionQuantileExactWeighted); factory.registerFunction("quantilesExactWeighted", createAggregateFunctionQuantilesExactWeighted); }
int main(int argc, char ** argv) { using namespace DB; try { size_t n = argc == 2 ? atoi(argv[1]) : 10; Block block; ColumnWithTypeAndName column_x; column_x.name = "x"; column_x.type = std::make_shared<DataTypeInt16>(); auto x = std::make_shared<ColumnInt16>(); column_x.column = x; auto & vec_x = x->getData(); vec_x.resize(n); for (size_t i = 0; i < n; ++i) vec_x[i] = i % 9; block.insert(column_x); const char * strings[] = {"abc", "def", "abcd", "defg", "ac"}; ColumnWithTypeAndName column_s1; column_s1.name = "s1"; column_s1.type = std::make_shared<DataTypeString>(); column_s1.column = std::make_shared<ColumnString>(); for (size_t i = 0; i < n; ++i) column_s1.column->insert(std::string(strings[i % 5])); block.insert(column_s1); ColumnWithTypeAndName column_s2; column_s2.name = "s2"; column_s2.type = std::make_shared<DataTypeString>(); column_s2.column = std::make_shared<ColumnString>(); for (size_t i = 0; i < n; ++i) column_s2.column->insert(std::string(strings[i % 3])); block.insert(column_s2); Names key_column_names; key_column_names.emplace_back("x"); AggregateFunctionFactory factory; AggregateDescriptions aggregate_descriptions(1); DataTypes empty_list_of_types; aggregate_descriptions[0].function = factory.get("count", empty_list_of_types); DataTypes result_types { std::make_shared<DataTypeInt16>(), // std::make_shared<DataTypeString>(), std::make_shared<DataTypeUInt64>(), }; Block sample; for (DataTypes::const_iterator it = result_types.begin(); it != result_types.end(); ++it) { ColumnWithTypeAndName col; col.type = *it; sample.insert(std::move(col)); } Aggregator::Params params(key_column_names, aggregate_descriptions, false); BlockInputStreamPtr stream = std::make_shared<OneBlockInputStream>(block); stream = std::make_shared<AggregatingBlockInputStream>(stream, params, true); WriteBufferFromOStream ob(std::cout); RowOutputStreamPtr row_out = std::make_shared<TabSeparatedRowOutputStream>(ob, sample); BlockOutputStreamPtr out = std::make_shared<BlockOutputStreamFromRowOutputStream>(row_out); { Stopwatch stopwatch; stopwatch.start(); copyData(*stream, *out); stopwatch.stop(); std::cout << std::fixed << std::setprecision(2) << "Elapsed " << stopwatch.elapsedSeconds() << " sec." << ", " << n / stopwatch.elapsedSeconds() << " rows/sec." << std::endl; } std::cout << std::endl; stream->dumpTree(std::cout); std::cout << std::endl; } catch (const Exception & e) { std::cerr << e.displayText() << std::endl; } return 0; }