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

Function DoInferLength

cpp/src/arrow/compute/exec.cc:174–197  ·  view source on GitHub ↗

\brief Infer the ExecBatch length from values. \return the inferred length of the batch. If there are no values in the batch then kEmptyInput (-1) is returned. If the values in the batch have different lengths then kInvalidValues (-2) is returned.

Source from the content-addressed store, hash-verified

172/// batch then kEmptyInput (-1) is returned. If the values in the batch have
173/// different lengths then kInvalidValues (-2) is returned.
174int64_t DoInferLength(const std::vector<Datum>& values) {
175 if (values.empty()) {
176 return kEmptyInput;
177 }
178
179 int64_t length = -1;
180 for (const auto& value : values) {
181 if (value.is_scalar()) {
182 continue;
183 }
184
185 if (length == -1) {
186 length = value.length();
187 continue;
188 }
189
190 if (length != value.length()) {
191 // all the arrays should have the same length
192 return kInvalidValues;
193 }
194 }
195
196 return length == -1 ? 1 : length;
197}
198
199} // namespace
200

Callers 2

InferLengthMethod · 0.85
MakeMethod · 0.85

Calls 3

is_scalarMethod · 0.80
emptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected