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

Function WriteBatch

cpp/src/arrow/dataset/file_base.cc:374–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372namespace {
373
374Status WriteBatch(
375 std::shared_ptr<RecordBatch> batch, compute::Expression guarantee,
376 FileSystemDatasetWriteOptions write_options,
377 std::function<Status(std::shared_ptr<RecordBatch>, const PartitionPathFormat&)>
378 write) {
379 ARROW_ASSIGN_OR_RAISE(auto groups, write_options.partitioning->Partition(batch));
380 batch.reset(); // drop to hopefully conserve memory
381
382 if (write_options.max_partitions <= 0) {
383 return Status::Invalid("max_partitions must be positive (was ",
384 write_options.max_partitions, ")");
385 }
386
387 if (groups.batches.size() > static_cast<size_t>(write_options.max_partitions)) {
388 return Status::Invalid("Fragment would be written into ", groups.batches.size(),
389 " partitions. This exceeds the maximum of ",
390 write_options.max_partitions);
391 }
392
393 for (std::size_t index = 0; index < groups.batches.size(); index++) {
394 auto partition_expression = and_(groups.expressions[index], guarantee);
395 auto next_batch = groups.batches[index];
396 PartitionPathFormat destination;
397 ARROW_ASSIGN_OR_RAISE(destination,
398 write_options.partitioning->Format(partition_expression));
399 RETURN_NOT_OK(write(next_batch, destination));
400 }
401 return Status::OK();
402}
403
404class DatasetWritingSinkNodeConsumer : public acero::SinkNodeConsumer {
405 public:

Callers 2

WriteNextBatchMethod · 0.70
WriteNextBatchMethod · 0.70

Calls 7

and_Function · 0.85
FormatMethod · 0.80
InvalidFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
OKFunction · 0.50
resetMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected