@@ -397,6 +397,7 @@ cdef class BitmaskArray:
397
397
398
398
ArrowBitmapInit(& bitmap)
399
399
ArrowBitmapReserve(& bitmap, total_bits)
400
+
400
401
ConcatenateBitmapData(bitmaps, nbitmaps, & bitmap)
401
402
free(bitmaps)
402
403
@@ -492,14 +493,14 @@ cdef class BitmaskArray:
492
493
else :
493
494
nbits = stop
494
495
495
- nbytes = (stop + 7 ) // 8
496
+ nbytes = (nbits + 7 ) // 8
496
497
497
498
bma = BitmaskArray.__new__ (BitmaskArray)
498
499
ArrowBitmapInit(& bitmap)
499
500
ArrowBitmapReserve(& bitmap, nbits)
500
501
memcpy(bitmap.buffer.data, self_.bitmap.buffer.data, nbytes)
501
502
bitmap.buffer.size_bytes = nbytes
502
- bitmap.size_bits = stop
503
+ bitmap.size_bits = nbits
503
504
504
505
bma.bitmap = bitmap
505
506
bma.buffer_owner = True
@@ -557,10 +558,11 @@ cdef class BitmaskArray:
557
558
BitmapAnd(& self_.bitmap, & other_bma.bitmap, & bitmap)
558
559
559
560
result = np.empty(self_.bitmap.size_bits, dtype = bool )
560
- BitmaskArray.buffer_to_array_1d(
561
- result,
561
+ ArrowBitsUnpackInt8(
562
562
bitmap.buffer.data,
563
- bitmap.size_bits
563
+ 0 ,
564
+ bitmap.size_bits,
565
+ < int8_t* > & result[0 ]
564
566
)
565
567
ArrowBitmapReset(& bitmap)
566
568
@@ -592,10 +594,11 @@ cdef class BitmaskArray:
592
594
BitmapOr(& self_.bitmap, & other_bma.bitmap, & bitmap)
593
595
594
596
result = np.empty(self_.bitmap.size_bits, dtype = bool )
595
- BitmaskArray.buffer_to_array_1d(
596
- result,
597
+ ArrowBitsUnpackInt8(
597
598
bitmap.buffer.data,
598
- bitmap.size_bits
599
+ 0 ,
600
+ bitmap.size_bits,
601
+ < int8_t* > & result[0 ]
599
602
)
600
603
ArrowBitmapReset(& bitmap)
601
604
@@ -627,10 +630,11 @@ cdef class BitmaskArray:
627
630
BitmapXor(& self_.bitmap, & other_bma.bitmap, & bitmap)
628
631
629
632
result = np.empty(self_.bitmap.size_bits, dtype = bool )
630
- BitmaskArray.buffer_to_array_1d(
631
- result,
633
+ ArrowBitsUnpackInt8(
632
634
bitmap.buffer.data,
633
- bitmap.size_bits
635
+ 0 ,
636
+ bitmap.size_bits,
637
+ < int8_t* > & result[0 ]
634
638
)
635
639
ArrowBitmapReset(& bitmap)
636
640
if self_.ndim == 2 :
@@ -737,7 +741,7 @@ cdef class BitmaskArray:
737
741
self_.bitmap.buffer.data,
738
742
0 ,
739
743
self_.bitmap.size_bits,
740
- < const int8_t* > self_.memview_buf
744
+ < int8_t* > self_.memview_buf
741
745
)
742
746
743
747
buffer .buf = self_.memview_buf
@@ -840,19 +844,15 @@ cdef class BitmaskArray:
840
844
def copy (self ):
841
845
return BitmaskArray.copy_from_bitmaskarray(self )
842
846
843
- @ cython.boundscheck (False ) # TODO: Removing this causes an IndexError? Zero size?
844
- @ cython.wraparound (False )
845
- @staticmethod
846
- cdef void buffer_to_array_1d(uint8_t[:] out, const uint8_t* buf, Py_ssize_t size):
847
- ArrowBitsUnpackInt8(buf, 0 , size, < const int8_t* > & out[0 ])
848
-
849
847
def to_numpy (self ) -> ndarray:
850
848
cdef BitmaskArray self_ = self
851
- cdef ndarray[uint8_t] result = np.empty(self .bitmap.size_bits, dtype = bool )
852
- BitmaskArray.buffer_to_array_1d(
853
- result ,
854
- self.bitmap.buffer.data ,
855
- self.bitmap.size_bits
849
+ cdef ndarray[uint8_t] result = np.empty(self_.bitmap.size_bits, dtype = bool )
850
+
851
+ ArrowBitsUnpackInt8(
852
+ self_.bitmap.buffer.data ,
853
+ 0,
854
+ self_.bitmap.size_bits ,
855
+ <int8_t*>cnp.PyArray_BYTES(result ),
856
856
)
857
857
858
858
if self_.ndim == 2:
0 commit comments