pub struct DatasetView { /* private fields */ }Expand description
A borrowed handle to one dataset within an Atlas.
Carries no independent state — every mutation (define_array,
write_array, set_attribute, delete_array) updates the parent
atlas’s shared in-memory metadata. Persistence happens when the
parent Atlas::flush is called; DatasetView
has no flush of its own.
DatasetView is Send and can be moved across tasks, but holding
many concurrent views to the same dataset and mutating from each is
not protected — the underlying lock is on the shared metadata, not
per-view.
Implementations§
Source§impl DatasetView
impl DatasetView
Sourcepub fn meta(&self) -> DatasetMeta
pub fn meta(&self) -> DatasetMeta
Returns a clone of the metadata for this dataset.
Sourcepub fn list_arrays(&self) -> Vec<String>
pub fn list_arrays(&self) -> Vec<String>
All array names declared in this dataset, in insertion order. Reads from the shared in-memory meta — no disk I/O.
Sourcepub fn set_attribute(&mut self, key: &str, value: Attr)
pub fn set_attribute(&mut self, key: &str, value: Attr)
Set or overwrite a typed attribute on this dataset. Buffered in the
in-memory meta until the parent Atlas::flush.
Sourcepub fn get_attribute(&self, key: &str) -> Option<Attr>
pub fn get_attribute(&self, key: &str) -> Option<Attr>
Look up an attribute by key. None if the key isn’t present (or the
dataset has no attributes at all yet).
Sourcepub fn array_meta(&self, array: &str) -> Option<ArraySchema>
pub fn array_meta(&self, array: &str) -> Option<ArraySchema>
Returns the cached schema for array, or None if no array with that
name exists in this dataset.
Sourcepub async fn array_stats(&self, array: &str) -> Option<ArrayStats>
pub async fn array_stats(&self, array: &str) -> Option<ArrayStats>
Returns aggregate statistics for array in this dataset, or None
if no such array exists or stats haven’t been computed yet (stats are
computed on flush).
Sourcepub async fn define_array<T: ArrayElement>(
&mut self,
array: &str,
dims: Vec<String>,
shape: Vec<usize>,
chunk_shape: Option<Vec<usize>>,
fill_value: Option<FillValue>,
) -> Result<()>
pub async fn define_array<T: ArrayElement>( &mut self, array: &str, dims: Vec<String>, shape: Vec<usize>, chunk_shape: Option<Vec<usize>>, fill_value: Option<FillValue>, ) -> Result<()>
Declare a new array in this dataset.
dims are named dimensions (one per axis); shape is the logical
size per axis. chunk_shape = None means one chunk per axis (a
single block per dataset entry — fastest write for small arrays;
pessimal for slice reads on large arrays). fill_value is the
scalar returned for unwritten cells; cells equal to it are tallied
as nulls in array_stats after Atlas::flush.
Errors with Error::ArrayAlreadyExists if this dataset already
declares an array with that name, or Error::InvalidName if
array violates the naming rules.
Sourcepub async fn write_array<T: ArrayElement>(
&mut self,
array: &str,
start: Vec<usize>,
data: ArrayView<'_, T, IxDyn>,
) -> Result<()>
pub async fn write_array<T: ArrayElement>( &mut self, array: &str, start: Vec<usize>, data: ArrayView<'_, T, IxDyn>, ) -> Result<()>
Write a slab of values into an array previously declared via
define_array.
start is the per-axis offset to begin writing at; data’s shape
determines the extent. Out-of-bounds writes truncate at the array’s
declared shape. The bytes are buffered in the per-array in-memory
layer; nothing reaches disk until Atlas::flush.
Errors with Error::ArrayNotFound if no array with this name has
been declared.
Sourcepub async fn read_array<T: ArrayElement>(
&self,
array: &str,
start: Vec<usize>,
shape: Vec<usize>,
) -> Result<Option<ArcArray<T, IxDyn>>>
pub async fn read_array<T: ArrayElement>( &self, array: &str, start: Vec<usize>, shape: Vec<usize>, ) -> Result<Option<ArcArray<T, IxDyn>>>
Read a full or partial array from this dataset.
Empty start + empty shape reads the full array. Otherwise both
must have one entry per dimension; only chunks overlapping the
requested region are decompressed.
Returns Ok(None) if this dataset doesn’t declare an array with
that name.
§Examples
use atlas::{Atlas, StoreConfig};
use ndarray::Array2;
let tmp = tempfile::tempdir().unwrap();
let mut s = Atlas::create_path(tmp.path(), StoreConfig::default()).await.unwrap();
{
let mut ds = s.create_dataset("ds").await.unwrap();
ds.define_array::<f32>("temp", vec!["x".into(), "y".into()],
vec![4, 8], None, None).await.unwrap();
let data = Array2::<f32>::from_elem([4, 8], 9.0).into_dyn();
ds.write_array("temp", vec![0, 0], data.view()).await.unwrap();
// Full read.
let full = ds.read_array::<f32>("temp", vec![], vec![]).await.unwrap().unwrap();
assert_eq!(full.shape(), &[4, 8]);
// Partial read — a 2×4 sub-region.
let part = ds.read_array::<f32>("temp", vec![1, 2], vec![2, 4]).await.unwrap().unwrap();
assert_eq!(part.shape(), &[2, 4]);
}
s.flush().await.unwrap();Sourcepub async fn array_fill_value(&self, array: &str) -> Result<Option<FillValue>>
pub async fn array_fill_value(&self, array: &str) -> Result<Option<FillValue>>
Returns the fill value passed to define_array for array, or None
if the array isn’t present in this dataset or was defined without one.
Sourcepub async fn delete_array(&mut self, array: &str) -> Result<()>
pub async fn delete_array(&mut self, array: &str) -> Result<()>
Remove an array from this dataset. Tombstones the dataset’s entry
inside the shared array file; persistence happens on the next
Atlas::flush. Errors with
Error::ArrayNotFound if no array with that name is declared here.
Auto Trait Implementations§
impl !RefUnwindSafe for DatasetView
impl !UnwindSafe for DatasetView
impl Freeze for DatasetView
impl Send for DatasetView
impl Sync for DatasetView
impl Unpin for DatasetView
impl UnsafeUnpin for DatasetView
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.