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

Method evalSpecialFormSimplified

bolt/expression/FieldReference.cpp:174–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174void FieldReference::evalSpecialFormSimplified(
175 const SelectivityVector& rows,
176 EvalCtx& context,
177 VectorPtr& result) {
178 ExceptionContextSetter exceptionContext(
179 {[](BoltException::Type /*exceptionType*/, auto* expr) {
180 return static_cast<Expr*>(expr)->toString();
181 },
182 this});
183 VectorPtr input;
184 const RowVector* row;
185 if (inputs_.empty()) {
186 row = context.row();
187 } else {
188 BOLT_CHECK_EQ(inputs_.size(), 1);
189 inputs_[0]->evalSimplified(rows, context, input);
190 BaseVector::flattenVector(input);
191 row = input->as<RowVector>();
192 BOLT_CHECK(row);
193 }
194 auto index = row->type()->asRow().getChildIdx(field_);
195 if (index_ == -1) {
196 index_ = index;
197 } else {
198 BOLT_CHECK_EQ(index_, index);
199 }
200
201 LocalSelectivityVector nonNullRowsHolder(*context.execCtx());
202 const SelectivityVector* nonNullRows = &rows;
203 if (row->mayHaveNulls()) {
204 nonNullRowsHolder.get(rows);
205 nonNullRowsHolder->deselectNulls(row->rawNulls(), rows.begin(), rows.end());
206 nonNullRows = nonNullRowsHolder.get();
207 if (!nonNullRows->hasSelections()) {
208 addNulls(rows, row->rawNulls(), context, result);
209 return;
210 }
211 }
212
213 auto& child = row->childAt(index_);
214 context.ensureWritable(rows, type_, result);
215 result->copy(child.get(), *nonNullRows, nullptr, context.isFinalSelection());
216 if (row->mayHaveNulls()) {
217 addNulls(rows, row->rawNulls(), context, result);
218 }
219}
220
221std::string FieldReference::toString(bool recursive) const {
222 std::stringstream out;

Callers

nothing calls this directly

Calls 15

evalSimplifiedMethod · 0.80
getChildIdxMethod · 0.80
rawNullsMethod · 0.80
hasSelectionsMethod · 0.80
childAtMethod · 0.80
isFinalSelectionMethod · 0.80
toStringMethod · 0.45
emptyMethod · 0.45
rowMethod · 0.45
sizeMethod · 0.45
typeMethod · 0.45
execCtxMethod · 0.45

Tested by

no test coverage detected