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

Method truncate

arrow-buffer/src/builder/boolean.rs:142–156  ·  view source on GitHub ↗
(&mut self, len: usize)

Source from the content-addressed store, hash-verified

140 /// If `len` is greater than the buffer's current length, this has no effect
141 #[inline]
142 pub fn truncate(&mut self, len: usize) {
143 if len > self.len {
144 return;
145 }
146
147 let new_len_bytes = bit_util::ceil(len, 8);
148 self.buffer.truncate(new_len_bytes);
149 self.len = len;
150
151 let remainder = self.len % 8;
152 if remainder != 0 {
153 let mask = (1_u8 << remainder).wrapping_sub(1);
154 *self.buffer.as_mut().last_mut().unwrap() &= mask;
155 }
156 }
157
158 /// Reserve space to at least `additional` new bits.
159 /// Capacity will be `>= self.len() + additional`.

Callers 3

new_from_bufferMethod · 0.45
resizeMethod · 0.45
test_truncateFunction · 0.45

Calls 2

ceilFunction · 0.50
wrapping_subMethod · 0.45

Tested by 1

test_truncateFunction · 0.36