MCPcopy Create free account
hub / github.com/PDAL/PDAL / flushBatch

Method flushBatch

plugins/arrow/io/ArrowWriter.cpp:510–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508
509
510void ArrowWriter::flushBatch()
511{
512 std::vector<std::shared_ptr<arrow::Array>> arrays;
513
514 // Get the data from the builders into arrays.
515 for (auto& handler : m_dimHandlers)
516 {
517 std::shared_ptr<arrow::Array> array;
518 auto status = handler->finish(array);
519 if (!status)
520 throwError(status.what());
521 arrays.push_back(std::move(array));
522 }
523
524 if (m_formatType == arrowsupport::Parquet)
525 {
526#if ARROW_VERSION_MAJOR >= 20
527 auto result = m_parquetFileWriter->NewRowGroup();
528#else
529 auto result = m_parquetFileWriter->NewRowGroup(m_batchSize);
530#endif
531 if (!result.ok())
532 throwError("Unable to make NewRowGroup: " + result.ToString());
533
534 for (auto& array: arrays)
535 {
536 result = m_parquetFileWriter->WriteColumnChunk(*array);
537 if (!result.ok())
538 throwError("Unable to make WriteColumnChunk: " + result.ToString());
539 }
540
541 }
542 else // Feather
543 {
544 std::shared_ptr<arrow::RecordBatch> batch =
545 arrow::RecordBatch::Make(m_schema, m_batchIndex, arrays);
546
547 auto result = m_arrowFileWriter->WriteRecordBatch(*batch);
548 if (!result.ok())
549 throwError("Unable to write arrow batch" + result.ToString());
550 }
551 m_batchIndex = 0;
552}
553
554
555void ArrowWriter::done(PointTableRef table)

Callers

nothing calls this directly

Calls 2

finishMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected