MCPcopy Create free account
hub / github.com/apache/arrow-rs / remainder_bits

Method remainder_bits

arrow-buffer/src/util/bit_chunk_iterator.rs:267–291  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

265 /// Returns the bitmask of remaining bits
266 #[inline]
267 pub fn remainder_bits(&self) -> u64 {
268 let bit_len = self.remainder_len;
269 if bit_len == 0 {
270 0
271 } else {
272 let bit_offset = self.bit_offset;
273 // number of bytes to read
274 // might be one more than sizeof(u64) if the offset is in the middle of a byte
275 let byte_len = ceil(bit_len + bit_offset, 8);
276 // pointer to remainder bytes after all complete chunks
277 let base = unsafe {
278 self.buffer
279 .as_ptr()
280 .add(self.chunk_len * std::mem::size_of::<u64>())
281 };
282
283 let mut bits = unsafe { std::ptr::read(base) } as u64 >> bit_offset;
284 for i in 1..byte_len {
285 let byte = unsafe { std::ptr::read(base.add(i)) };
286 bits |= (byte as u64) << (i * 8 - bit_offset);
287 }
288
289 bits & ((1 << bit_len) - 1)
290 }
291 }
292
293 /// Return the number of `u64` that are needed to represent all bits
294 /// (including remainder).

Callers 12

bitwise_bin_op_helperFunction · 0.80
bitwise_unary_op_helperFunction · 0.80
bit_sliceMethod · 0.80
iter_paddedMethod · 0.80
aggregate_nullable_lanesFunction · 0.80
min_booleanFunction · 0.80

Calls 3

ceilFunction · 0.70
addMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected