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

Function createPartitionFunctionSpec

bolt/exec/tests/utils/PlanBuilder.cpp:1174–1204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1172
1173namespace {
1174core::PartitionFunctionSpecPtr createPartitionFunctionSpec(
1175 const RowTypePtr& inputType,
1176 const std::vector<core::TypedExprPtr>& keys,
1177 memory::MemoryPool* pool) {
1178 if (keys.empty()) {
1179 return std::make_shared<core::GatherPartitionFunctionSpec>();
1180 } else {
1181 std::vector<column_index_t> keyIndices;
1182 keyIndices.reserve(keys.size());
1183
1184 std::vector<VectorPtr> constValues;
1185 constValues.reserve(keys.size());
1186
1187 for (const auto& key : keys) {
1188 if (auto field =
1189 std::dynamic_pointer_cast<const core::FieldAccessTypedExpr>(
1190 key)) {
1191 keyIndices.push_back(inputType->getChildIdx(field->name()));
1192 } else if (
1193 auto constant =
1194 std::dynamic_pointer_cast<const core::ConstantTypedExpr>(key)) {
1195 keyIndices.push_back(kConstantChannel);
1196 constValues.push_back(constant->toConstantVector(pool));
1197 } else {
1198 BOLT_UNREACHABLE();
1199 }
1200 }
1201 return std::make_shared<HashPartitionFunctionSpec>(
1202 inputType, std::move(keyIndices), std::move(constValues));
1203 }
1204}
1205
1206RowTypePtr concat(const RowTypePtr& a, const RowTypePtr& b) {
1207 std::vector<std::string> names = a->names();

Callers 2

createLocalPartitionNodeFunction · 0.85
PlanBuilder.cppFile · 0.85

Calls 7

getChildIdxMethod · 0.80
toConstantVectorMethod · 0.80
emptyMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected