Skip to main content

DatasetView

Struct DatasetView 

Source
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

Source

pub fn meta(&self) -> DatasetMeta

Returns a clone of the metadata for this dataset.

Source

pub fn name(&self) -> &str

The dataset name this view points to.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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.

Source

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();
Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more