22#include <arrow/io/api.h>
37 arrow::Status
Close()
override {
39 return arrow::Status::OK();
42 arrow::Status
Flush()
override {
44 return arrow::Status::OK();
47 arrow::Result<int64_t>
Tell()
const override {
55 arrow::Status
Write(
const void* data, int64_t nbytes)
override {
57 return arrow::Status::IOError(
"Write on closed stream");
59 myOStream.write(
reinterpret_cast<const char*
>(data), nbytes);
61 return arrow::Status::IOError(
"Failed to write to ostream");
63 return arrow::Status::OK();
77 if (compression ==
"snappy") {
79 }
else if (compression ==
"gzip") {
81 }
else if (compression ==
"brotli") {
83 }
else if (compression ==
"zstd") {
85 }
else if (compression ==
"lz4") {
87 }
else if (compression ==
"bz2") {
89 }
else if (compression !=
"" && compression !=
"uncompressed") {
93 WRITE_WARNINGF(
"Compression '%' not available, falling back to uncompressed.", compression);
105 WRITE_WARNINGF(
"Encountered mismatch in XML tags (expected % but got %). Column names may be incorrect.",
myCurrentTag, xmlElement);
129 WRITE_WARNING(
"Column based formats are still experimental. Autodetection only works for homogeneous output.");
131 auto arrow_stream = std::make_shared<ArrowOStreamWrapper>(into);
132 std::shared_ptr<parquet::WriterProperties> props = parquet::WriterProperties::Builder().compression(
myCompression)->build();
133 myParquetWriter = *parquet::arrow::FileWriter::Open(*
mySchema, arrow::default_memory_pool(), arrow_stream, props);
136 bool writeBatch =
false;
141 WRITE_ERRORF(
"Incomplete attribute set, '%' is missing. This file format does not support Parquet output yet.",
149 PARQUET_THROW_NOT_OK(val ==
nullptr ? builder->AppendNull() : builder->AppendScalar(*val));
155 std::vector<std::shared_ptr<arrow::Array> > data;
157 std::shared_ptr<arrow::Array> column;
158 PARQUET_THROW_NOT_OK(builder->Finish(&column));
159 data.push_back(column);
162 auto batch = arrow::RecordBatch::Make(
mySchema, data.back()->length(), data);
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool closed() const override
arrow::Status Close() override
arrow::Status Flush() override
arrow::Status Write(const void *data, int64_t nbytes) override
ArrowOStreamWrapper(std::ostream &out)
arrow::Result< int64_t > Tell() const override