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

Method apply

bolt/functions/prestosql/FilterFunctions.cpp:133–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131class ArrayFilterFunction : public FilterFunctionBase {
132 public:
133 void apply(
134 const SelectivityVector& rows,
135 std::vector<VectorPtr>& args,
136 const TypePtr& /* outputType */,
137 exec::EvalCtx& context,
138 VectorPtr& result) const override {
139 BOLT_CHECK_EQ(args.size(), 2);
140 exec::LocalDecodedVector arrayDecoder(context, *args[0], rows);
141 auto& decodedArray = *arrayDecoder.get();
142
143 auto flatArray = flattenArray(rows, args[0], decodedArray);
144
145 VectorPtr elements = flatArray->elements();
146 BufferPtr resultSizes;
147 BufferPtr resultOffsets;
148 BufferPtr selectedIndices;
149 auto numSelected = doApply(
150 rows,
151 flatArray,
152 args[1],
153 {elements},
154 context,
155 resultOffsets,
156 resultSizes,
157 selectedIndices);
158
159 auto wrappedElements = numSelected ? BaseVector::wrapInDictionary(
160 BufferPtr(nullptr),
161 std::move(selectedIndices),
162 numSelected,
163 std::move(elements))
164 : nullptr;
165 // Set nulls for rows not present in 'rows'.
166 BufferPtr newNulls = addNullsForUnselectedRows(flatArray, rows);
167 auto localResult = std::make_shared<ArrayVector>(
168 flatArray->pool(),
169 flatArray->type(),
170 std::move(newNulls),
171 rows.end(),
172 std::move(resultOffsets),
173 std::move(resultSizes),
174 wrappedElements);
175 context.moveOrCopyResult(localResult, rows, result);
176 }
177
178 static std::vector<std::shared_ptr<exec::FunctionSignature>> signatures() {
179 // array(T), function(T, boolean) -> array(T)

Callers

nothing calls this directly

Calls 8

flattenArrayFunction · 0.85
wrapInDictionaryFunction · 0.85
sizeMethod · 0.45
getMethod · 0.45
poolMethod · 0.45
typeMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected