This kernel delays execution for some specific scalar values, which guarantees the writing phase sees out-of-order exec batches
| 364 | // This kernel delays execution for some specific scalar values, |
| 365 | // which guarantees the writing phase sees out-of-order exec batches |
| 366 | Status delay(compute::KernelContext* ctx, const compute::ExecSpan& batch, |
| 367 | compute::ExecResult* out) { |
| 368 | const ArraySpan& input = batch[0].array; |
| 369 | const auto* input_values = input.GetValues<uint32_t>(1); |
| 370 | uint8_t* output_values = out->array_span()->buffers[1].data; |
| 371 | |
| 372 | // Boolean data is stored in 1 bit per value |
| 373 | for (int64_t i = 0; i < input.length; ++i) { |
| 374 | if (input_values[i] % 16 == 0) { |
| 375 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
| 376 | } |
| 377 | bit_util::SetBitTo(output_values, i, true); |
| 378 | } |
| 379 | |
| 380 | return Status::OK(); |
| 381 | } |
| 382 | |
| 383 | // A fragment with start=0 will defer ScanBatchesAsync returning a batch generator |
| 384 | // This guarantees a dataset of multiple fragments could produce out-of-order batches |