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

Method evalSpecialForm

bolt/expression/SwitchExpr.cpp:73–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void SwitchExpr::evalSpecialForm(
74 const SelectivityVector& rows,
75 EvalCtx& context,
76 VectorPtr& finalResult) {
77 VectorPtr localResult;
78 LocalSelectivityVector remainingRows(context, rows);
79
80 LocalSelectivityVector thenRows(context);
81
82 // SWITCH: fix finalSelection at "rows" unless already fixed
83 ScopedFinalSelectionSetter scopedFinalSelectionSetter(context, &rows);
84 if (propagatesNulls_) {
85 // If propagates nulls, we load lazies before conditions so that we can
86 // avoid errors for null rows. Null propagation is on only if all thens and
87 // else load access the same vectors, so there is no extra loading.
88 auto& remaining = *remainingRows.get();
89 for (auto* field : distinctFields_) {
90 context.ensureFieldLoaded(field->index(context), remaining);
91 const auto& vector = context.getField(field->index(context));
92 if (vector->mayHaveNulls()) {
93 LocalDecodedVector decoded(context, *vector, remaining);
94 addNulls(remaining, decoded->nulls(&remaining), context, localResult);
95 remaining.deselectNulls(
96 decoded->nulls(&remaining), remaining.begin(), remaining.end());
97 }
98 }
99 }
100
101 VectorPtr condition;
102 const uint64_t* values;
103
104 for (auto i = 0; i < numCases_; i++) {
105 context.releaseVector(condition);
106
107 if (!remainingRows.get()->hasSelections()) {
108 break;
109 }
110
111 // evaluate the case condition
112 inputs_[2 * i]->eval(*remainingRows.get(), context, condition);
113
114 if (context.errors()) {
115 context.deselectErrors(*remainingRows);
116 if (!remainingRows->hasSelections()) {
117 break;
118 }
119 }
120
121 const auto booleanMix = getFlatBool(
122 condition.get(),
123 *remainingRows.get(),
124 context,
125 &tempValues_,
126 nullptr,
127 true,
128 &values,
129 nullptr);
130 switch (booleanMix) {

Callers

nothing calls this directly

Calls 15

getFlatBoolFunction · 0.85
andBitsFunction · 0.85
ensureFieldLoadedMethod · 0.80
releaseVectorMethod · 0.80
hasSelectionsMethod · 0.80
updateBoundsMethod · 0.80
deselectMethod · 0.80
backMethod · 0.80
applyToSelectedMethod · 0.80
typeEnum · 0.50
getMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected