@@ -11,7 +11,7 @@ extern PyObject* numbuf_deserialize_callback;
1111
1212namespace numbuf {
1313
14- PyObject* get_value (ArrayPtr arr, int32_t index, int32_t type) {
14+ PyObject* get_value (ArrayPtr arr, int32_t index, int32_t type, PyObject* base ) {
1515 PyObject* result;
1616 switch (arr->type ()->type ) {
1717 case Type::BOOL:
@@ -36,13 +36,13 @@ PyObject* get_value(ArrayPtr arr, int32_t index, int32_t type) {
3636 auto s = std::static_pointer_cast<StructArray>(arr);
3737 auto l = std::static_pointer_cast<ListArray>(s->field (0 ));
3838 if (s->type ()->child (0 )->name == " list" ) {
39- ARROW_CHECK_OK (DeserializeList (l->values (), l->value_offset (index), l->value_offset (index+1 ), &result));
39+ ARROW_CHECK_OK (DeserializeList (l->values (), l->value_offset (index), l->value_offset (index+1 ), base, &result));
4040 } else if (s->type ()->child (0 )->name == " tuple" ) {
41- ARROW_CHECK_OK (DeserializeTuple (l->values (), l->value_offset (index), l->value_offset (index+1 ), &result));
41+ ARROW_CHECK_OK (DeserializeTuple (l->values (), l->value_offset (index), l->value_offset (index+1 ), base, &result));
4242 } else if (s->type ()->child (0 )->name == " dict" ) {
43- ARROW_CHECK_OK (DeserializeDict (l->values (), l->value_offset (index), l->value_offset (index+1 ), &result));
43+ ARROW_CHECK_OK (DeserializeDict (l->values (), l->value_offset (index), l->value_offset (index+1 ), base, &result));
4444 } else {
45- ARROW_CHECK_OK (DeserializeArray (arr, index, &result));
45+ ARROW_CHECK_OK (DeserializeArray (arr, index, base, &result));
4646 }
4747 return result;
4848 }
@@ -181,17 +181,17 @@ Status SerializeSequences(std::vector<PyObject*> sequences, std::shared_ptr<Arra
181181 int32_t offset = offsets->Value (i); \
182182 int8_t type = types->Value (i); \
183183 ArrayPtr arr = data->child (type); \
184- SET_ITEM (result, i-start_idx, get_value (arr, offset, type)); \
184+ SET_ITEM (result, i-start_idx, get_value (arr, offset, type, base )); \
185185 } \
186186 } \
187187 *out = result; \
188188 return Status::OK();
189189
190- Status DeserializeList (std::shared_ptr<Array> array, int32_t start_idx, int32_t stop_idx, PyObject** out) {
190+ Status DeserializeList (std::shared_ptr<Array> array, int32_t start_idx, int32_t stop_idx, PyObject* base, PyObject* * out) {
191191 DESERIALIZE_SEQUENCE (PyList_New, PyList_SetItem)
192192}
193193
194- Status DeserializeTuple (std::shared_ptr<Array> array, int32_t start_idx, int32_t stop_idx, PyObject** out) {
194+ Status DeserializeTuple (std::shared_ptr<Array> array, int32_t start_idx, int32_t stop_idx, PyObject* base, PyObject* * out) {
195195 DESERIALIZE_SEQUENCE (PyTuple_New, PyTuple_SetItem)
196196}
197197
@@ -227,13 +227,13 @@ Status SerializeDict(std::vector<PyObject*> dicts, std::shared_ptr<Array>* out)
227227 return Status::OK ();
228228}
229229
230- Status DeserializeDict (std::shared_ptr<Array> array, int32_t start_idx, int32_t stop_idx, PyObject** out) {
230+ Status DeserializeDict (std::shared_ptr<Array> array, int32_t start_idx, int32_t stop_idx, PyObject* base, PyObject* * out) {
231231 auto data = std::dynamic_pointer_cast<StructArray>(array);
232232 // TODO(pcm): error handling, get rid of the temporary copy of the list
233233 PyObject *keys, *vals;
234234 PyObject* result = PyDict_New ();
235- ARROW_RETURN_NOT_OK (DeserializeList (data->field (0 ), start_idx, stop_idx, &keys));
236- ARROW_RETURN_NOT_OK (DeserializeList (data->field (1 ), start_idx, stop_idx, &vals));
235+ ARROW_RETURN_NOT_OK (DeserializeList (data->field (0 ), start_idx, stop_idx, base, &keys));
236+ ARROW_RETURN_NOT_OK (DeserializeList (data->field (1 ), start_idx, stop_idx, base, &vals));
237237 for (size_t i = start_idx; i < stop_idx; ++i) {
238238 PyDict_SetItem (result, PyList_GetItem (keys, i - start_idx), PyList_GetItem (vals, i - start_idx));
239239 }
0 commit comments