我正在尝试根据官方https://arrow.apache.org/docs/cpp/csv.html#在 c++ 中通过 apache-arrow 编写一个读取 csv 的示例,但它遇到了分段错误status = reader->Read(&table);
任何人都可以帮忙吗?谢谢~
环境信息:
g++:7.3.1
制作命令:
c++ -g -std=c++11 -Wall -O2 test.cpp -o test -I../../arrow/src -L../../arrow/lib -larrow -lparquet -Wl,-rpath,./
代码信息:
arrow::Status status;
arrow::MemoryPool *pool = arrow::default_memory_pool();
std::shared_ptr<arrow::io::InputStream> input;
std::string csv_file = "test.csv";
auto input_readable = std::dynamic_pointer_cast<arrow::io::ReadableFile>(input);
PARQUET_THROW_NOT_OK(arrow::io::ReadableFile::Open(csv_file, pool, &input_readable));
auto read_options = arrow::csv::ReadOptions::Defaults();
read_options.use_threads = false;
read_options.column_names.emplace_back("name");
read_options.column_names.emplace_back("age");
auto parse_options = arrow::csv::ParseOptions::Defaults();
auto convert_options = arrow::csv::ConvertOptions::Defaults();
convert_options.include_missing_columns = true;
std::shared_ptr<arrow::csv::TableReader> reader;
status = arrow::csv::TableReader::Make(pool, input, read_options,
parse_options, convert_options,
&reader);
if (!status.ok())
{
std::cout << "make csv table error" << std::endl;
return -1;
}
std::shared_ptr<arrow::Table> table;
status = reader->Read(&table);
if (!status.ok())
{
std::cout << "read csv table error" << std::endl;
return -1;
}
核心转储信息:
Program terminated with signal 11, Segmentation fault.
#0 0x00007fe4fcda83e7 in arrow::io::internal::ReadaheadSpooler::Impl::WorkerLoop() () from ./libarrow.so.15
(gdb) bt
#0 0x00007fe4fcda83e7 in arrow::io::internal::ReadaheadSpooler::Impl::WorkerLoop() () from ./libarrow.so.15
#1 0x00007fe4fd405a2f in execute_native_thread_routine () from ./libarrow.so.15
#2 0x00007fe4fa8ecdf3 in start_thread () from /lib64/libpthread.so.0
#3 0x00007fe4fb86e1bd in clone () from /lib64/libc.so.6
csv 信息
name,age
aaa,12
bbb,13
ccc,14
ddd,15