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

Method from_bytes

arrow-buffer/src/buffer/mutable.rs:187–206  ·  view source on GitHub ↗

Allocates a new [MutableBuffer] from given `Bytes`.

(bytes: Bytes)

Source from the content-addressed store, hash-verified

185
186 /// Allocates a new [MutableBuffer] from given `Bytes`.
187 pub(crate) fn from_bytes(bytes: Bytes) -> Result<Self, Bytes> {
188 let layout = match bytes.deallocation() {
189 Deallocation::Standard(layout) => *layout,
190 _ => return Err(bytes),
191 };
192
193 let len = bytes.len();
194 let data = bytes.ptr();
195 #[cfg(feature = "pool")]
196 let reservation = bytes.reservation.lock().unwrap().take();
197 mem::forget(bytes);
198
199 Ok(Self {
200 data,
201 len,
202 layout,
203 #[cfg(feature = "pool")]
204 reservation: Mutex::new(reservation),
205 })
206 }
207
208 /// creates a new [MutableBuffer] with capacity and length capable of holding `len` bits.
209 /// This is useful to create a buffer for packed bitmaps.

Callers

nothing calls this directly

Calls 4

ptrMethod · 0.80
deallocationMethod · 0.45
lenMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected