MCPcopy Create free account
hub / github.com/apache/arrow / Visit

Method Visit

cpp/src/arrow/compute/kernels/vector_swizzle.cc:89–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88 template <typename Type>
89 enable_if_t<is_integer_type<Type>::value, Status> Visit(const Type& output_type) {
90 using OutputCType = typename Type::c_type;
91
92 RETURN_NOT_OK(CheckInput(output_type));
93
94 // Dispatch the execution based on whether there are likely many nulls in the output.
95 // - If many nulls (i.e. the output is "sparse"), preallocate an all-false validity
96 // buffer and a zero-initialized data buffer (just to avoid exposing previous memory
97 // contents - even if it is shadowed by the validity bit). The subsequent processing
98 // will fill the valid values only.
99 // - Otherwise (i.e. the output is "dense"), the validity buffer is lazily allocated
100 // and initialized all-true in the subsequent processing only when needed. The data
101 // buffer is preallocated and filled with "impossible" values (that is, input_length -
102 // note that the range of inverse_permutation is [0, input_length)) for the subsequent
103 // processing to detect validity.
104 if (LikelyManyNulls()) {
105 RETURN_NOT_OK(AllocateValidityBufAndFill(false));
106 RETURN_NOT_OK(AllocateDataBufAndZero(output_type));
107 return Execute<Type, true>();
108 } else {
109 RETURN_NOT_OK(
110 AllocateDataBufAndFill(output_type, static_cast<OutputCType>(input_length_)));
111 return Execute<Type, false>();
112 }
113 }
114
115 Status Visit(const DataType& output_type) {
116 DCHECK(false) << "Shouldn't reach here";

Callers

nothing calls this directly

Calls 1

InvalidFunction · 0.50

Tested by

no test coverage detected