Skip to content

Commit ed253b0

Browse files
committed
a runnable version without memleak and seg fault
1 parent 5c9aed2 commit ed253b0

18 files changed

+212
-246
lines changed

src/snowflake/connector/cpp/ArrowIterator/BinaryConverter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ namespace sf
99
{
1010
Logger* BinaryConverter::logger = new Logger("snowflake.connector.BinaryConverter");
1111

12-
BinaryConverter::BinaryConverter(std::shared_ptr<ArrowArrayView> array)
12+
BinaryConverter::BinaryConverter(ArrowArrayView* array)
1313
: m_array(array)
1414
{
1515
}
1616

1717
PyObject* BinaryConverter::toPyObject(int64_t rowIndex) const
1818
{
19-
if(ArrowArrayViewIsNull(m_array.get(), rowIndex)) {
19+
if(ArrowArrayViewIsNull(m_array, rowIndex)) {
2020
Py_RETURN_NONE;
2121
}
22-
ArrowStringView stringView = ArrowArrayViewGetStringUnsafe(m_array.get(), rowIndex);
22+
ArrowStringView stringView = ArrowArrayViewGetStringUnsafe(m_array, rowIndex);
2323
return PyByteArray_FromStringAndSize(stringView.data, stringView.size_bytes);
2424
}
2525

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace sf
1616
class BinaryConverter : public IColumnConverter
1717
{
1818
public:
19-
explicit BinaryConverter(std::shared_ptr<ArrowArrayView> array);
19+
explicit BinaryConverter(ArrowArrayView* array);
2020

2121
PyObject* toPyObject(int64_t rowIndex) const override;
2222

2323
private:
24-
std::shared_ptr<ArrowArrayView> m_array;
24+
ArrowArrayView* m_array;
2525

2626
static Logger* logger;
2727
};

src/snowflake/connector/cpp/ArrowIterator/BooleanConverter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
namespace sf
99
{
1010

11-
BooleanConverter::BooleanConverter(std::shared_ptr<ArrowArrayView> array)
12-
: m_nanoarrowArrayView(array)
11+
BooleanConverter::BooleanConverter(ArrowArrayView* array)
12+
: m_array(array)
1313
{
1414
}
1515

1616
PyObject* BooleanConverter::toPyObject(int64_t rowIndex) const
1717
{
18-
if(ArrowArrayViewIsNull(m_nanoarrowArrayView.get(), rowIndex)) {
18+
if(ArrowArrayViewIsNull(m_array, rowIndex)) {
1919
Py_RETURN_NONE;
2020
}
2121

22-
if(ArrowArrayViewGetIntUnsafe(m_nanoarrowArrayView.get(), rowIndex)) {
22+
if(ArrowArrayViewGetIntUnsafe(m_array, rowIndex)) {
2323
Py_RETURN_TRUE;
2424
} else {
2525
Py_RETURN_FALSE;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ namespace sf
1515
class BooleanConverter : public IColumnConverter
1616
{
1717
public:
18-
explicit BooleanConverter(std::shared_ptr<ArrowArrayView> array);
18+
explicit BooleanConverter(ArrowArrayView* array);
1919

2020
PyObject* toPyObject(int64_t rowIndex) const override;
2121

2222
private:
23-
std::shared_ptr<ArrowArrayView> m_nanoarrowArrayView;
23+
ArrowArrayView* m_array;
2424
};
2525

2626
} // namespace sf

0 commit comments

Comments
 (0)