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

Function InferBatchLength

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

Source from the content-addressed store, hash-verified

1283}
1284
1285int64_t InferBatchLength(const std::vector<Datum>& values, bool* all_same) {
1286 int64_t length = -1;
1287 bool are_all_scalar = true;
1288 for (const Datum& arg : values) {
1289 if (arg.is_array()) {
1290 int64_t arg_length = arg.array()->length;
1291 if (length < 0) {
1292 length = arg_length;
1293 } else {
1294 if (length != arg_length) {
1295 *all_same = false;
1296 return length;
1297 }
1298 }
1299 are_all_scalar = false;
1300 } else if (arg.is_chunked_array()) {
1301 int64_t arg_length = arg.chunked_array()->length();
1302 if (length < 0) {
1303 length = arg_length;
1304 } else {
1305 if (length != arg_length) {
1306 *all_same = false;
1307 return length;
1308 }
1309 }
1310 are_all_scalar = false;
1311 }
1312 }
1313
1314 if (are_all_scalar && values.size() > 0) {
1315 length = 1;
1316 } else if (length < 0) {
1317 length = 0;
1318 }
1319 *all_same = true;
1320 return length;
1321}
1322
1323} // namespace detail
1324

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