我编写了 c++ 代码来读取羽毛文件并将数据插入到箭头::表中,但是如果文件包含任何数据类型为箭头::large_utf8 的列,则会出现分段错误。它仅针对此数据类型提供段错误,utf8/int/float 数据类型没有错误。
我认为用于读/写的羽毛 API 实现存在问题,因为如果我对镶木地板文件执行相同操作,它就可以正常工作。
我发现了一个与同一问题密切相关的链接,但它与python有关 - https://github.com/pandas-dev/pandas/issues/24767
有人知道为什么会出现这种行为吗?
arrow::Status write_to_feather(std::string path,std::shared_ptr <arrow::Table> table) {
arrow::fs::LocalFileSystem file_system;
auto output = file_system.OpenOutputStream(path).ValueOrDie();
ABORT_ON_FAILURE(arrow::ipc::feather::WriteTable(*table,output.get()));
return arrow::Status::OK();
}
void read_feather_to_table(std::string path,std::shared_ptr<arrow::Table> *feather_table){
arrow::fs::LocalFileSystem file_system;
std::shared_ptr <arrow::io::RandomAccessFile> input_file = file_system.OpenInputFile(path).ValueOrDie();
std::shared_ptr <arrow::ipc::feather::Reader> feather_reader = arrow::ipc::feather::Reader::Open(input_file).ValueOrDie();
arrow::Status temp_status = feather_reader -> Read(feather_table);
if(temp_status.ok()){
std::cout << "Read feather file Successfully." << std::endl;
std::cout << ((*feather_table).get()) -> ToString() << std::endl; // this line gives segfault
}
else{
std::cout << "Feather file reading process failed." << std::endl;
}
return;
}
当我使用 write_to_feather 编写包含任何具有 large_utf8 数据类型的列的表时,我的 read_feather_to_table 函数给出了段错误,而在所有其他情况下,这两个函数都可以正常工作。当我尝试打印上面代码中指定的表格内容时,会发生段错误。