@@ -32,8 +32,8 @@ cdef class PartitionMapChunk:
3232 The CUDA stream on which this chunk was created. If `None`,
3333 the stream is obtained from the handle.
3434 owner
35- Python object that owns the underlying buffers and must
36- be kept alive for the lifetime of this PartitionMapChunk .
35+ An optional Python object to keep alive for as long as this
36+ PartitionMapChunk exists (e.g., to maintain resource lifetime) .
3737
3838 Returns
3939 -------
@@ -156,3 +156,154 @@ cdef class PartitionMapChunk:
156156 The CUDA stream.
157157 """
158158 return self ._stream
159+
160+
161+ cdef class PartitionVectorChunk:
162+ def __init__ (self ):
163+ raise ValueError (" use the `from_*` factory functions" )
164+
165+ def __dealloc__ (self ):
166+ with nogil:
167+ self ._handle.reset()
168+
169+ @staticmethod
170+ cdef PartitionVectorChunk from_handle(
171+ unique_ptr[cpp_PartitionVectorChunk] handle, Stream stream, object owner
172+ ):
173+ """
174+ Construct a PartitionVectorChunk from an existing C++ handle.
175+
176+ Parameters
177+ ----------
178+ handle
179+ A unique pointer to a C++ PartitionVectorChunk.
180+ stream
181+ The CUDA stream on which this chunk was created. If `None`,
182+ the stream is obtained from the handle.
183+ owner
184+ An optional Python object to keep alive for as long as this
185+ PartitionVectorChunk exists (e.g., to maintain resource lifetime).
186+
187+ Returns
188+ -------
189+ A new PartitionVectorChunk wrapping the given handle.
190+ """
191+
192+ if stream is None :
193+ stream = Stream._from_cudaStream_t(
194+ deref(handle).stream.value()
195+ )
196+ cdef PartitionVectorChunk ret = PartitionVectorChunk.__new__ (
197+ PartitionVectorChunk
198+ )
199+ ret._handle = move(handle)
200+ ret._stream = stream
201+ ret._owner = owner
202+ return ret
203+
204+ @staticmethod
205+ def from_message (Message message not None ):
206+ """
207+ Construct a PartitionVectorChunk by consuming a Message.
208+
209+ Parameters
210+ ----------
211+ message
212+ Message containing a PartitionVectorChunk. The message is released
213+ and is empty after this call.
214+
215+ Returns
216+ -------
217+ A new PartitionVectorChunk extracted from the given message.
218+ """
219+ return PartitionVectorChunk.from_handle(
220+ make_unique[cpp_PartitionVectorChunk](
221+ message._handle.release[cpp_PartitionVectorChunk]()
222+ ),
223+ stream = None ,
224+ owner = None ,
225+ )
226+
227+ def into_message (self , Message message not None ):
228+ """
229+ Move this PartitionVectorChunk into a Message.
230+
231+ This method is not typically called directly. Instead, it is invoked by
232+ `Message.__init__()` when creating a new Message with this PartitionVectorChunk
233+ as its payload.
234+
235+ Parameters
236+ ----------
237+ message
238+ Message object that will take ownership of this PartitionVectorChunk.
239+
240+ Raises
241+ ------
242+ ValueError
243+ If the provided message is not empty.
244+
245+ Warnings
246+ --------
247+ The PartitionVectorChunk is released and must not be used after this call.
248+ """
249+ message._handle = cpp_Message(self .release_handle())
250+
251+ cdef const cpp_PartitionVectorChunk* handle_ptr(self ):
252+ """
253+ Return a pointer to the underlying C++ PartitionVectorChunk.
254+
255+ Returns
256+ -------
257+ Raw pointer to the underlying C++ object.
258+
259+ Raises
260+ ------
261+ ValueError
262+ If the PartitionVectorChunk is uninitialized.
263+ """
264+ if not self ._handle:
265+ raise ValueError (" is uninitialized, has it been released?" )
266+ return self ._handle.get()
267+
268+ cdef unique_ptr[cpp_PartitionVectorChunk] release_handle(self ):
269+ """
270+ Release ownership of the underlying C++ PartitionVectorChunk.
271+
272+ After this call, the current object is in a moved-from state and
273+ must not be accessed.
274+
275+ Returns
276+ -------
277+ Unique pointer to the underlying C++ object.
278+
279+ Raises
280+ ------
281+ ValueError
282+ If the PartitionVectorChunk is uninitialized.
283+ """
284+ if not self ._handle:
285+ raise ValueError (" is uninitialized, has it been released?" )
286+ return move(self ._handle)
287+
288+ @property
289+ def sequence_number (self ):
290+ """
291+ Return the sequence number of this chunk.
292+
293+ Returns
294+ -------
295+ The sequence number.
296+ """
297+ return deref(self .handle_ptr()).sequence_number
298+
299+ @property
300+ def stream (self ):
301+ """
302+ Return the CUDA stream on which this chunk was created.
303+
304+ Returns
305+ -------
306+ Stream
307+ The CUDA stream.
308+ """
309+ return self ._stream
0 commit comments