MCPcopy Create free account
hub / github.com/bytedance/bolt / registerSimpleAverageAggregate

Function registerSimpleAverageAggregate

bolt/exec/tests/SimpleAverageAggregate.cpp:112–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110} // namespace
111
112exec::AggregateRegistrationResult registerSimpleAverageAggregate(
113 const std::string& name) {
114 std::vector<std::shared_ptr<exec::AggregateFunctionSignature>> signatures;
115
116 for (const auto& inputType : {"smallint", "integer", "bigint", "double"}) {
117 signatures.push_back(exec::AggregateFunctionSignatureBuilder()
118 .returnType("double")
119 .intermediateType("row(double,bigint)")
120 .argumentType(inputType)
121 .build());
122 }
123
124 signatures.push_back(exec::AggregateFunctionSignatureBuilder()
125 .returnType("real")
126 .intermediateType("row(double,bigint)")
127 .argumentType("real")
128 .build());
129
130 return exec::registerAggregateFunction(
131 name,
132 std::move(signatures),
133 [name](
134 core::AggregationNode::Step step,
135 const std::vector<TypePtr>& argTypes,
136 const TypePtr& resultType,
137 const core::QueryConfig&
138 /*config*/) -> std::unique_ptr<exec::Aggregate> {
139 BOLT_CHECK_LE(
140 argTypes.size(), 1, "{} takes at most one argument", name);
141 auto inputType = argTypes[0];
142 if (exec::isRawInput(step)) {
143 switch (inputType->kind()) {
144 case TypeKind::SMALLINT:
145 return std::make_unique<
146 SimpleAggregateAdapter<AverageAggregate<int16_t>>>(
147 step, argTypes, resultType);
148 case TypeKind::INTEGER:
149 return std::make_unique<
150 SimpleAggregateAdapter<AverageAggregate<int32_t>>>(
151 step, argTypes, resultType);
152 case TypeKind::BIGINT:
153 return std::make_unique<
154 SimpleAggregateAdapter<AverageAggregate<int64_t>>>(
155 step, argTypes, resultType);
156 case TypeKind::REAL:
157 return std::make_unique<
158 SimpleAggregateAdapter<AverageAggregate<float>>>(
159 step, argTypes, resultType);
160 case TypeKind::DOUBLE:
161 return std::make_unique<
162 SimpleAggregateAdapter<AverageAggregate<double>>>(
163 step, argTypes, resultType);
164 default:
165 BOLT_FAIL(
166 "Unknown input type for {} aggregation {}",
167 name,
168 inputType->kindName());
169 }

Callers 2

SetUpMethod · 0.85
SetUpMethod · 0.85

Calls 9

isRawInputFunction · 0.85
intermediateTypeMethod · 0.80
push_backMethod · 0.45
buildMethod · 0.45
sizeMethod · 0.45
kindMethod · 0.45
kindNameMethod · 0.45

Tested by

no test coverage detected