jorisvandenbossche commented on code in PR #313:
URL: https://github.com/apache/arrow-nanoarrow/pull/313#discussion_r1397683475
##########
python/src/nanoarrow/_lib.pyx:
##########
@@ -964,3 +1003,121 @@ cdef class ArrayStream:
def __next__(self):
return self.get_next()
+
+ @staticmethod
+ def allocate():
+ base = ArrayStreamHolder()
+ return ArrayStream(base, base._addr())
+
+
+cdef class DeviceArrayHolder:
+ """Memory holder for an ArrowDeviceArray
+
+ This class is responsible for the lifecycle of the ArrowDeviceArray
+ whose memory it is responsible. When this object is deleted,
+ a non-NULL release callback is invoked.
+ """
+ cdef ArrowDeviceArray c_array
+
+ def __cinit__(self):
+ self.c_array.array.release = NULL
+
+ def __dealloc__(self):
+ if self.c_array.array.release != NULL:
+ self.c_array.array.release(&self.c_array.array)
+
+ def _addr(self):
+ return <uintptr_t>&self.c_array
+
+cdef class DeviceHolder:
+ """Memory holder for an ArrowDevice
+
+ The ArrowDevice structure is a nanoarrow internal struct (i.e.,
+ not ABI stable) that contains callbacks for device operations
+ beyond its type and identifier.
+
+ This class is responsible for the lifecycle of the ArrowDevice
+ whose memory it is responsible. When this object is deleted,
+ a non-NULL release callback is invoked.
+ """
+
+ cdef ArrowDevice c_device
+
+ def __cinit__(self):
+ self.c_device.release = NULL
+
+ def __dealloc__(self):
+ if self.c_device.release != NULL:
+ self.c_device.release(&self.c_device)
+
+ def _addr(self):
+ return <uintptr_t>&self.c_device
+
+
+cdef class Device:
+ cdef object _base
+ cdef ArrowDevice* _ptr
+
+ def __cinit__(self, object base, uintptr_t addr):
+ self._base = base,
+ self._ptr = <ArrowDevice*>addr
+
+ def array_init(self, uintptr_t array_addr, Schema schema):
Review Comment:
```suggestion
def _array_init(self, uintptr_t array_addr, Schema schema):
```
(doesn't need to be public I assume)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]