@@ -93,7 +93,9 @@ struct Bitmap(ImplicitlyCopyable, Movable, Sized, Writable):
9393 fn is_valid (self , index : Int) -> Bool:
9494 """ Return True if bit at (_offset + index) is set (value is valid)."""
9595 var bit_index = self .bit_offset() + index
96- return Bool((self ._buffer.ptr[bit_index >> 3 ] >> UInt8(bit_index & 7 )) & 1 )
96+ return Bool(
97+ (self ._buffer.ptr[bit_index >> 3 ] >> UInt8(bit_index & 7 )) & 1
98+ )
9799
98100 @always_inline
99101 fn is_null (self , index : Int) -> Bool:
@@ -125,9 +127,17 @@ struct Bitmap(ImplicitlyCopyable, Movable, Sized, Writable):
125127 var acc0 = SIMD [DType.uint8, width](0 )
126128 var acc1 = SIMD [DType.uint8, width](0 )
127129 comptime for j in range (t1_iters):
128- acc0 += pop_count((ptr + i + (j * 2 ) * width).load[width=width]())
129- acc1 += pop_count((ptr + i + (j * 2 + 1 ) * width).load[width=width]())
130- count += Int((acc0.cast[DType.uint16]() + acc1.cast[DType.uint16]()).reduce_add())
130+ acc0 += pop_count(
131+ (ptr + i + (j * 2 ) * width).load[width=width]()
132+ )
133+ acc1 += pop_count(
134+ (ptr + i + (j * 2 + 1 ) * width).load[width=width]()
135+ )
136+ count += Int(
137+ (
138+ acc0.cast[DType.uint16]() + acc1.cast[DType.uint16]()
139+ ).reduce_add()
140+ )
131141
132142 # Tier 2: 64-byte blocks for the remainder.
133143 # NEON: 4 iters, max 32/lane ≤ 255 ✓.
@@ -144,13 +154,17 @@ struct Bitmap(ImplicitlyCopyable, Movable, Sized, Writable):
144154 for i in range (lead_bytes):
145155 count -= Int(pop_count(ptr[i]))
146156 if lead_sub_byte:
147- count -= Int(pop_count(ptr[lead_bytes] & UInt8((1 << lead_sub_byte) - 1 )))
157+ count -= Int(
158+ pop_count(ptr[lead_bytes] & UInt8((1 << lead_sub_byte) - 1 ))
159+ )
148160 if trail_bits:
149161 var trail_bytes = trail_bits >> 3
150162 var trail_sub_byte = trail_bits & 7
151163 var first_trail = total_bytes - trail_bytes
152164 if trail_sub_byte:
153- count -= Int(pop_count(ptr[first_trail - 1 ] >> UInt8(trail_sub_byte)))
165+ count -= Int(
166+ pop_count(ptr[first_trail - 1 ] >> UInt8(trail_sub_byte))
167+ )
154168 for i in range (first_trail, total_bytes):
155169 count -= Int(pop_count(ptr[i]))
156170
@@ -160,7 +174,6 @@ struct Bitmap(ImplicitlyCopyable, Movable, Sized, Writable):
160174 """ Return a zero-copy view of `length` bits starting at `offset`."""
161175 return Bitmap(self ._buffer, self .bit_offset() + offset, length)
162176
163-
164177 # --- Bulk SIMD operations ---
165178 #
166179 # Arrow buffers are 64-byte aligned and zero-padded to multiples of 64 B.
@@ -212,7 +225,9 @@ struct Bitmap(ImplicitlyCopyable, Movable, Sized, Writable):
212225
213226 @always_inline
214227 fn _binop [
215- op : fn[W: Int](SIMD [DType.uint8, W], SIMD [DType.uint8, W]) - > SIMD [DType.uint8, W]
228+ op : fn[W: Int](SIMD [DType.uint8, W], SIMD [DType.uint8, W]) - > SIMD [
229+ DType.uint8, W
230+ ]
216231 ](self , other : Bitmap) raises -> Bitmap:
217232 """ Apply a byte-level binary operation across two bitmaps.
218233
@@ -260,30 +275,37 @@ struct Bitmap(ImplicitlyCopyable, Movable, Sized, Writable):
260275
261276 return Bitmap(builder.finish(), lead_bits_a, self ._length)
262277
263-
264278 fn write_to [W : Writer](self , mut writer : W):
265279 writer.write(
266280 " Bitmap(offset=" , self .bit_offset(), " , length=" , self ._length, " )"
267281 )
268282
269283
270284@always_inline
271- fn _and [W : Int](a : SIMD [DType.uint8, W], b : SIMD [DType.uint8, W]) -> SIMD [DType.uint8, W]:
285+ fn _and [
286+ W : Int
287+ ](a : SIMD [DType.uint8, W], b : SIMD [DType.uint8, W]) -> SIMD [DType.uint8, W]:
272288 return a & b
273289
274290
275291@always_inline
276- fn _or [W : Int](a : SIMD [DType.uint8, W], b : SIMD [DType.uint8, W]) -> SIMD [DType.uint8, W]:
292+ fn _or [
293+ W : Int
294+ ](a : SIMD [DType.uint8, W], b : SIMD [DType.uint8, W]) -> SIMD [DType.uint8, W]:
277295 return a | b
278296
279297
280298@always_inline
281- fn _xor [W : Int](a : SIMD [DType.uint8, W], b : SIMD [DType.uint8, W]) -> SIMD [DType.uint8, W]:
299+ fn _xor [
300+ W : Int
301+ ](a : SIMD [DType.uint8, W], b : SIMD [DType.uint8, W]) -> SIMD [DType.uint8, W]:
282302 return a ^ b
283303
284304
285305@always_inline
286- fn _and_not [W : Int](a : SIMD [DType.uint8, W], b : SIMD [DType.uint8, W]) -> SIMD [DType.uint8, W]:
306+ fn _and_not [
307+ W : Int
308+ ](a : SIMD [DType.uint8, W], b : SIMD [DType.uint8, W]) -> SIMD [DType.uint8, W]:
287309 return a & ~ b
288310
289311
@@ -317,7 +339,8 @@ struct BitmapBuilder(Movable):
317339
318340 @always_inline
319341 fn unsafe_ptr (self ) -> UnsafePointer[UInt8, MutExternalOrigin]:
320- """ Return the raw mutable byte pointer (for low-level bit operations)."""
342+ """ Return the raw mutable byte pointer (for low-level bit operations).
343+ """
321344 return self ._builder.ptr
322345
323346 @always_inline
@@ -344,7 +367,9 @@ struct BitmapBuilder(Movable):
344367
345368 if start_byte == end_byte:
346369 # All bits in one byte
347- var mask = UInt8((1 << end_bit) - 1 ) & (UInt8(0x FF ) << UInt8(start_bit))
370+ var mask = UInt8((1 << end_bit) - 1 ) & (
371+ UInt8(0x FF ) << UInt8(start_bit)
372+ )
348373 if value:
349374 ptr[start_byte] = ptr[start_byte] | mask
350375 else :
0 commit comments