Don't create a memory pool locally (and destroy it when the function
returns), use the global singleton pool from `arrow::default_memory_pool()`
instead.

__
Felipe

On Mon, Aug 12, 2024 at 12:44 PM Surya Kiran Gullapalli <
suryakiran.gullapa...@gmail.com> wrote:

> Hello all,
> I'm trying to convert a single line string (which is in json format) into
> a table. Below is the sample code to create table from the json string
> (input to this function, passed as copy)
>
>
>
>>     auto buffer      = arrow::Buffer::FromString(pString);
>>     auto reader      = std::make_shared<arrow::io::BufferReader>(buffer);
>>     auto memoryPool  = arrow::MemoryPool::CreateDefault();
>>     auto tableReader = arrow::json::TableReader::Make(
>>         memoryPool.get(), reader, arrow::json::ReadOptions::Defaults(),
>> arrow::json::ParseOptions::Defaults());
>>     if (!tableReader.ok()) {
>>           return nullptr;
>>     }
>>     auto res = (*tableReader)->Read();
>>     if (!res.ok()) {
>>           return nullptr;
>>     }
>>     return std::move(*res);
>
>
> It is working as expected. The table is created and returned correctly
> from this function. I'm able to print the table to a parquet file. The
> contents are correct.
>
> But when the table goes out of scope, I see a crash in the PoolBuffer
> destructor.
>
> Using Apache arrow 16.1.0 with MSVC 2022 and Gcc 13.2.0
>
> What am I missing here ?
>
> Thanks in advance,
> Surya
>

Reply via email to