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

Method SwitchExpr

bolt/expression/SwitchExpr.cpp:44–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42} // namespace
43
44SwitchExpr::SwitchExpr(
45 TypePtr type,
46 const std::vector<ExprPtr>& inputs,
47 bool inputsSupportFlatNoNullsFastPath)
48 : SpecialForm(
49 std::move(type),
50 inputs,
51 "switch",
52 hasElseClause(inputs) && inputsSupportFlatNoNullsFastPath,
53 false /* trackCpuUsage */),
54 numCases_{inputs_.size() / 2},
55 hasElseClause_{hasElseClause(inputs_)} {
56 std::vector<TypePtr> inputTypes;
57 inputTypes.reserve(inputs_.size());
58 std::transform(
59 inputs_.begin(),
60 inputs_.end(),
61 std::back_inserter(inputTypes),
62 [](const ExprPtr& expr) { return expr->type(); });
63
64 // Apply type checking.
65 auto typeExpected = resolveType(inputTypes);
66 BOLT_CHECK(
67 *typeExpected == *this->type(),
68 "Switch expression type different than then clause. Expected {} but got Actual {}.",
69 typeExpected->toString(),
70 this->type()->toString());
71}
72
73void SwitchExpr::evalSpecialForm(
74 const SelectivityVector& rows,

Callers

nothing calls this directly

Calls 8

hasElseClauseFunction · 0.85
resolveTypeFunction · 0.85
sizeMethod · 0.45
reserveMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
typeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected