Skip to content

Commit c5d1536

Browse files
committed
deallocate arrow array and arrow array view
1 parent 4ed393d commit c5d1536

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/snowflake/connector/cpp/ArrowIterator/CArrowChunkIterator.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ CArrowChunkIterator::CArrowChunkIterator(PyObject* context, std::vector<std::sha
9696
m_columnCount, m_useNumpy);
9797
}
9898

99+
CArrowChunkIterator::~CArrowChunkIterator()
100+
{
101+
for(int i = 0; i < m_arrays.size(); i += 1) {
102+
m_arrays[i]->release(m_arrays[i].get());
103+
ArrowArrayViewReset(m_arrayViews[i].get());
104+
}
105+
}
106+
99107
std::shared_ptr<ReturnVal> CArrowChunkIterator::next()
100108
{
101109
m_rowIndexInBatch++;
@@ -167,9 +175,6 @@ void CArrowChunkIterator::initColumnConverters()
167175
std::shared_ptr<ArrowArray> nanoarrowUniqueColumnArrowArray = std::make_shared<ArrowArray>();
168176
std::shared_ptr<ArrowArrayView> nanoarrowUniqueColumnArrowArrayView = std::make_shared<ArrowArrayView>();
169177

170-
//nanoarrow::UniqueArray nanoarrowUniqueColumnArrowArray;
171-
//nanoarrow::UniqueArrayView nanoarrowUniqueColumnArrowArrayView;
172-
173178
arrow::ExportArray(*columnArray, nanoarrowUniqueColumnArrowArray.get());
174179

175180
int res = 0;
@@ -187,10 +192,7 @@ void CArrowChunkIterator::initColumnConverters()
187192
PyErr_SetString(PyExc_Exception, errorInfo.c_str());
188193
}
189194

190-
// std::shared_ptr<ArrowArrayView> nanoarrowColumnArrowArrayViewInstance = std::shared_ptr<ArrowArrayView>(nanoarrowUniqueColumnArrowArrayView.get());
191195
std::shared_ptr<ArrowArrayView> nanoarrowColumnArrowArrayViewInstance = nanoarrowUniqueColumnArrowArrayView;
192-
// m_uniqueColumnArrowArrays.push_back(nanoarrowUniqueColumnArrowArray.get());
193-
// m_uniqueColumnArrowArrayViews.push_back(nanoarrowUniqueColumnArrowArrayView.get());
194196
m_arrays.push_back(nanoarrowUniqueColumnArrowArray);
195197
m_arrayViews.push_back(nanoarrowUniqueColumnArrowArrayView);
196198

src/snowflake/connector/cpp/ArrowIterator/CArrowChunkIterator.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class CArrowChunkIterator : public CArrowIterator
3030
CArrowChunkIterator(PyObject* context, std::vector<std::shared_ptr<arrow::RecordBatch>> * batches, PyObject *use_numpy);
3131

3232
/**
33-
* Desctructor
33+
* Destructor
3434
*/
35-
virtual ~CArrowChunkIterator() = default;
35+
virtual ~CArrowChunkIterator();
3636

3737
/**
3838
* @return a python tuple object which contains all data in current row
@@ -50,8 +50,6 @@ class CArrowChunkIterator : public CArrowIterator
5050

5151
/** list of column converters*/
5252
std::vector<std::shared_ptr<sf::IColumnConverter>> m_currentBatchConverters;
53-
std::vector<nanoarrow::UniqueArray> m_uniqueColumnArrowArrays;
54-
std::vector<nanoarrow::UniqueArrayView> m_uniqueColumnArrowArrayViews;
5553
std::vector<std::shared_ptr<ArrowArray>> m_arrays;
5654
std::vector<std::shared_ptr<ArrowArrayView>> m_arrayViews;
5755
/** row index inside current record batch (start from 0) */

0 commit comments

Comments
 (0)