| 60 | } |
| 61 | |
| 62 | void apply( |
| 63 | const SelectivityVector& rows, |
| 64 | std::vector<VectorPtr>& args, |
| 65 | const TypePtr& /*outputType*/, |
| 66 | exec::EvalCtx& context, |
| 67 | VectorPtr& result) const override { |
| 68 | exec::LocalDecodedVector decoder(context, *args[0], rows); |
| 69 | auto& decodedContainer = *decoder.get(); |
| 70 | |
| 71 | auto flatContainer = flattenContainer(rows, args[0], decodedContainer); |
| 72 | auto* rawOffsets = flatContainer->rawOffsets(); |
| 73 | auto* rawSizes = flatContainer->rawSizes(); |
| 74 | |
| 75 | std::vector<VectorPtr> lambdaArgs = {lambdaArgument(flatContainer)}; |
| 76 | const auto numElements = lambdaArgs[0]->size(); |
| 77 | |
| 78 | context.ensureWritable(rows, BOOLEAN(), result); |
| 79 | auto* flatResult = result->asFlatVector<bool>(); |
| 80 | |
| 81 | VectorPtr matchBits; |
| 82 | exec::LocalDecodedVector bitsDecoder(context); |
| 83 | |
| 84 | // Loop over lambda functions and apply these to elements of the base array, |
| 85 | // in most cases there will be only one function and the loop will run once. |
| 86 | auto it = args[1]->asUnchecked<FunctionVector>()->iterator(&rows); |
| 87 | while (auto entry = it.next()) { |
| 88 | auto elementRows = toElementRows<TContainer>( |
| 89 | numElements, *entry.rows, flatContainer.get()); |
| 90 | auto wrapCapture = toWrapCapture<TContainer>( |
| 91 | numElements, entry.callable, *entry.rows, flatContainer); |
| 92 | |
| 93 | ErrorVectorPtr elementErrors; |
| 94 | entry.callable->applyNoThrow( |
| 95 | elementRows, |
| 96 | nullptr, // No need to preserve any values in 'matchBits'. |
| 97 | wrapCapture, |
| 98 | &context, |
| 99 | lambdaArgs, |
| 100 | elementErrors, |
| 101 | &matchBits); |
| 102 | |
| 103 | bitsDecoder.get()->decode(*matchBits, elementRows); |
| 104 | entry.rows->applyToSelected([&](vector_size_t row) { |
| 105 | if (flatContainer->isNullAt(row)) { |
| 106 | flatResult->setNull(row, true); |
| 107 | } else { |
| 108 | applyInternal( |
| 109 | *flatResult, |
| 110 | context, |
| 111 | row, |
| 112 | rawOffsets[row], |
| 113 | rawSizes[row], |
| 114 | elementErrors, |
| 115 | bitsDecoder); |
| 116 | } |
| 117 | }); |
| 118 | } |
| 119 | } |
nothing calls this directly
no test coverage detected