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

Method apply

bolt/expression/FieldReference.cpp:71–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void FieldReference::apply(
72 const SelectivityVector& rows,
73 EvalCtx& context,
74 VectorPtr& result) {
75 const RowVector* row;
76 DecodedVector decoded;
77 VectorPtr input;
78 std::shared_ptr<PeeledEncoding> peeledEncoding;
79 bool useDecode = false;
80 LocalSelectivityVector nonNullRowsHolder(*context.execCtx());
81 const SelectivityVector* nonNullRows = &rows;
82 if (inputs_.empty()) {
83 row = context.row();
84 } else {
85 inputs_[0]->eval(rows, context, input);
86
87 if (auto rowTry = input->as<RowVector>()) {
88 // Make sure output is not copied
89 if (rowTry->isCodegenOutput()) {
90 auto rowType = dynamic_cast<const RowType*>(rowTry->type().get());
91 index_ = rowType->getChildIdx(field_);
92 result = std::move(rowTry->childAt(index_));
93 BOLT_CHECK(result.use_count() == 1);
94 return;
95 }
96 }
97
98 decoded.decode(*input, rows);
99 if (decoded.mayHaveNulls()) {
100 nonNullRowsHolder.get(rows);
101 nonNullRowsHolder->deselectNulls(
102 decoded.nulls(&rows), rows.begin(), rows.end());
103 nonNullRows = nonNullRowsHolder.get();
104 if (!nonNullRows->hasSelections()) {
105 addNulls(rows, decoded.nulls(&rows), context, result);
106 return;
107 }
108 }
109 useDecode = !decoded.isIdentityMapping();
110 if (useDecode) {
111 std::vector<VectorPtr> peeledVectors;
112 LocalDecodedVector localDecoded{context};
113 peeledEncoding = PeeledEncoding::peel(
114 {input}, *nonNullRows, localDecoded, true, peeledVectors);
115 BOLT_CHECK_NOT_NULL(peeledEncoding);
116 if (peeledVectors[0]->isLazy()) {
117 peeledVectors[0] =
118 peeledVectors[0]->as<LazyVector>()->loadedVectorShared();
119 }
120 BOLT_CHECK(peeledVectors[0]->encoding() == VectorEncoding::Simple::ROW);
121 row = peeledVectors[0]->as<const RowVector>();
122 } else {
123 BOLT_CHECK(input->encoding() == VectorEncoding::Simple::ROW);
124 row = input->as<const RowVector>();
125 }
126 }
127 if (index_ == -1) {
128 auto rowType = dynamic_cast<const RowType*>(row->type().get());

Callers

nothing calls this directly

Calls 15

getChildIdxMethod · 0.80
childAtMethod · 0.80
hasSelectionsMethod · 0.80
isIdentityMappingMethod · 0.80
isFinalSelectionMethod · 0.80
execCtxMethod · 0.45
emptyMethod · 0.45
rowMethod · 0.45
evalMethod · 0.45
getMethod · 0.45
typeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected