File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 12
12
13
13
if TYPE_CHECKING :
14
14
import numpy as np
15
+ import pyarrow as pa
15
16
16
17
17
18
class PandasBuffer (Buffer ):
@@ -83,14 +84,21 @@ class PandasPyarrowBackedBuffer(Buffer):
83
84
Data in the buffer is guaranteed to be contiguous in memory.
84
85
"""
85
86
86
- def __init__ (self , arr : Any , allow_copy : bool = True ) -> None :
87
+ def __init__ (
88
+ self , chunked_array : pa .ChunkedArray , * , allow_copy : bool = True
89
+ ) -> None :
87
90
"""
88
- Handle only regular columns (= numpy arrays) for now .
91
+ Handle pyarrow chunked arrays.
89
92
"""
90
-
91
- # Store the numpy array in which the data resides as a private
92
- # attribute, so we can use it to retrieve the public attributes
93
- self ._buffer = arr .chunks [0 ].buffers ()[1 ]
93
+ if len (chunked_array .chunks ) == 1 :
94
+ arr = chunked_array .chunks [0 ]
95
+ else :
96
+ if not allow_copy :
97
+ raise RuntimeError (
98
+ "Found multi-chunk pyarrow array, but `allow_copy` is False"
99
+ )
100
+ arr = chunked_array .combine_chunks ()
101
+ self ._buffer = arr .buffers ()[1 ]
94
102
self ._length = len (arr )
95
103
96
104
@property
You can’t perform that action at this time.
0 commit comments