将箭头架构与实木复合地板StreamWriter结合使用

问题描述

我正在尝试使用Apache Arrow提供的C ++ StreamWriter类。

使用StreamWriter的唯一示例是使用底层Parquet API,即

parquet::schema::NodeVector fields;

fields.push_back(parquet::schema::PrimitiveNode::Make(
  "string_field",parquet::Repetition::OPTIONAL,parquet::Type::BYTE_ARRAY,parquet::ConvertedType::UTF8));

fields.push_back(parquet::schema::PrimitiveNode::Make(
   "char_field",parquet::Repetition::REQUIRED,parquet::Type::FIXED_LEN_BYTE_ARRAY,parquet::ConvertedType::NONE,1));

auto node = std::static_pointer_cast<parquet::schema::GroupNode>(
   parquet::schema::GroupNode::Make("schema",fields));

最终结果是一个std::shared_ptr<parquet::schema::GroupNode>,然后可以将其传递到StreamWriter

是否可以通过StreamWriter 构建和使用“高级”箭头模式?使用WriteTable函数(非流式处理)时支持它们,但是我没有找到将其与流式API一起使用的示例。

我当然可以求助于使用低级API,但是在创建大型而复杂的架构时它非常冗长,我更愿意(但不需要)使用高级Arrow架构机制。

例如,

std::shared_ptr<arrow::io::FileOutputStream> outfile_;
PARQUET_ASSIGN_OR_THROW(outfile_,arrow::io::FileOutputStream::Open("test.parquet"));

// construct an arrow schema
auto schema = arrow::schema({arrow::field("field1",arrow::int64()),arrow::field("field2",arrow::float64()),arrow::field("field3",arrow::float64())});

// build the writer properties
parquet::WriterProperties::Builder builder;
auto properties = builder.build()

// my current best attempt at converting the Arrow schema to a Parquet schema
std::shared_ptr<parquet::SchemaDescriptor> parquet_schema;
parquet::arrow::ToParquetSchema(schema.get(),*properties,&parquet_schema); // parquet_schema is now populated

// and now I try and build the writer - this fails
auto writer = parquet::ParquetFileWriter::Open(outfile_,parquet_schema->group_node(),properties);

最后一行失败,因为parquet_schema->group_node()(这是我知道的访问架构的GroupNode的唯一方法)返回const GroupNode*,而{{1} }需要ParquetFileWriter::Open)

我不确定抛弃返回的组节点的常数并将其强制进入std::shared_ptr<GroupNode>调用是否是::Open()的官方支持(或正确使用)。

我想做些什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)