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

Function InferBatchLength

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

Source from the content-addressed store, hash-verified

1293}
1294
1295int64_t InferBatchLength(const std::vector<Datum>& values, bool* all_same) {
1296 int64_t length = -1;
1297 bool are_all_scalar = true;
1298 for (const Datum& arg : values) {
1299 if (arg.is_array()) {
1300 int64_t arg_length = arg.array()->length;
1301 if (length < 0) {
1302 length = arg_length;
1303 } else {
1304 if (length != arg_length) {
1305 *all_same = false;
1306 return length;
1307 }
1308 }
1309 are_all_scalar = false;
1310 } else if (arg.is_chunked_array()) {
1311 int64_t arg_length = arg.chunked_array()->length();
1312 if (length < 0) {
1313 length = arg_length;
1314 } else {
1315 if (length != arg_length) {
1316 *all_same = false;
1317 return length;
1318 }
1319 }
1320 are_all_scalar = false;
1321 }
1322 }
1323
1324 if (are_all_scalar && values.size() > 0) {
1325 length = 1;
1326 } else if (length < 0) {
1327 length = 0;
1328 }
1329 *all_same = true;
1330 return length;
1331}
1332
1333} // namespace detail
1334

Callers 2

InitMethod · 0.85
ExecuteMethod · 0.85

Calls 5

is_arrayMethod · 0.80
chunked_arrayMethod · 0.80
arrayMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected