pub struct ArrayData {
pub metadata: ArrayMetadata,
pub values: ArrayValues,
}Expand description
A block of numbers, as read, with the shape it came in.
§How many copies
Reading a compressed or chunked dataset cannot be done without the library materialising it somewhere, so one copy - from the file into the caller’s memory - is the floor. What this type is shaped to avoid is the second and third:
ArrayData::values | filled straight by the backend. One copy |
ArrayValues::as_bytes | a borrow of that same memory. Zero |
ArrayData::f64 and friends | a borrow when the type already matches. Zero |
ArrayData::to_f64 | widens every element. One more copy, and you asked for it |
And crate::ArrayBackend::read_into removes even the first allocation:
the caller supplies the buffer - a vertex buffer, a memory-mapped region -
and the file is decoded straight into it.
Fields§
§metadata: ArrayMetadataShape of what was read.
values: ArrayValuesThe values, in the file’s own element type.
Implementations§
Source§impl ArrayData
impl ArrayData
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
How many elements the shape promises.
Sourcepub fn f64(&self) -> Option<&[f64]>
pub fn f64(&self) -> Option<&[f64]>
The values as f64, borrowed, when that is what the file holds.
The path a 3D application takes for coordinates: no conversion, no allocation, just the numbers.
Sourcepub fn f32(&self) -> Option<&[f32]>
pub fn f32(&self) -> Option<&[f32]>
The values as f32, borrowed, when that is what the file holds.
Sourcepub fn i64(&self) -> Option<&[i64]>
pub fn i64(&self) -> Option<&[i64]>
The values as i64, borrowed, when that is what the file holds.
Sourcepub fn u32(&self) -> Option<&[u32]>
pub fn u32(&self) -> Option<&[u32]>
The values as u32, borrowed, when that is what the file holds -
what RESQML uses for indices.
Sourcepub fn to_f64(&self) -> Vec<f64>
pub fn to_f64(&self) -> Vec<f64>
Every element widened to f64.
This copies, and it is the only method here that does. Use
ArrayData::f64 when the file already holds doubles, which for
coordinates it does.