0

I am trying to write a example for reading csv by apache-arrow in c++ according to the offical one,https://arrow.apache.org/docs/cpp/csv.html#, but it meets Segmentation fault at status = reader->Read(&table);

Can anyone help? thank you~

environment info: g++:7.3.1

make command: c++ -g -std=c++11 -Wall -O2 test.cpp -o test -I../../arrow/src -L../../arrow/lib -larrow -lparquet -Wl,-rpath,./

code info:

    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;
    }

coredump info:

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 info

name,age
aaa,12
bbb,13
ccc,14
ddd,15
  • I don't know Arrow but your cast from InputStream to ReadableFile looks suspicious to me. Is that definitely valid? That isn't something you've taken from the example code you linked. Is the `input` that you're passing to TableReader definitely set up correctly? – Rup Oct 30 '19 at 12:49
  • How did you install Arrow? – Uwe L. Korn Oct 30 '19 at 13:07
  • 1
    @Rup ouhh~~the ReadableFile is the child of InputStream~thank you guys~ I fixed it – annsshadow Oct 30 '19 at 13:16
  • @UweL.Korn follow the offical steps with some cmake options. -DARROW_ORC=ON -DARROW_PARQUET=ON -DARROW_BUILD_EXAMPLES=ON -DARROW_TEST_LINKAGE=static -DARROW_TEST_MEMCHECK=ON -DPARQUET_BUILD_EXECUTABLES=ON -DPARQUET_BUILD_EXAMPLES=ON -DPARQUET_REQUIRE_ENCRYPTION=ON -DARROW_EXTRA_ERROR_CONTEXT=ON – annsshadow Oct 30 '19 at 13:20

0 Answers0