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

Function delay

cpp/src/arrow/dataset/file_test.cc:366–381  ·  view source on GitHub ↗

This kernel delays execution for some specific scalar values, which guarantees the writing phase sees out-of-order exec batches

Source from the content-addressed store, hash-verified

364// This kernel delays execution for some specific scalar values,
365// which guarantees the writing phase sees out-of-order exec batches
366Status 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

Callers

nothing calls this directly

Calls 2

SetBitToFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected