pub struct ArrayFile { /* private fields */ }Expand description
The top-level file handle.
Layers are stacked oldest → newest in deltas. Uncommitted writes
accumulate in a disk-backed mutable delta (pending) and are flushed
by flush. The mutable delta is created lazily on the
first mutation after open/flush.
Implementations§
Source§impl ArrayFile
impl ArrayFile
Sourcepub async fn create<C: CompressionCodec + 'static>(
store: Arc<dyn ObjectStore>,
path: Path,
config: FileConfig<C>,
) -> Result<Self>
pub async fn create<C: CompressionCodec + 'static>( store: Arc<dyn ObjectStore>, path: Path, config: FileConfig<C>, ) -> Result<Self>
Creates a new empty file at path within store.
path is the base file object and should end in .af; sidecars
({stem}.N.af) and the stats file ({stem}.stats) are written alongside
it in the same prefix. Fails if an object already exists at path only
insofar as the backend allows overwriting — the base is (re)written empty.
Sourcepub async fn open<C: CompressionCodec + 'static>(
store: Arc<dyn ObjectStore>,
path: Path,
config: FileConfig<C>,
) -> Result<Self>
pub async fn open<C: CompressionCodec + 'static>( store: Arc<dyn ObjectStore>, path: Path, config: FileConfig<C>, ) -> Result<Self>
Opens an existing file from store, discovering the base and all
sidecar layers under the same stem.
path must end in .af. Aggregate statistics are loaded from
{stem}.stats if present; a missing or unreadable stats file is not an
error (see array_stats).
Sourcepub async fn create_memory<C: CompressionCodec + 'static>(
config: FileConfig<C>,
) -> Result<Self>
pub async fn create_memory<C: CompressionCodec + 'static>( config: FileConfig<C>, ) -> Result<Self>
Creates a new empty in-memory file.
Backed by object_store’s in-memory backend, so it behaves exactly like
an on-disk file (commit pending writes with flush) but
keeps everything in process. Useful for tests and ephemeral pipelines.
Source§impl ArrayFile
impl ArrayFile
Sourcepub fn get_array(&self, name: &str) -> Result<&ArrayMeta>
pub fn get_array(&self, name: &str) -> Result<&ArrayMeta>
Returns a reference to the merged array metadata for name,
searching from the newest layer towards the oldest.
Sourcepub fn list_arrays(&self) -> Vec<MergedArrayMeta>
pub fn list_arrays(&self) -> Vec<MergedArrayMeta>
Returns all non-deleted visible arrays (newest-wins merge).
Sourcepub fn array_stats(&self, name: &str) -> Option<&ArrayStats>
pub fn array_stats(&self, name: &str) -> Option<&ArrayStats>
Returns aggregate statistics for name, or None if no stats exist yet.
Sourcepub fn num_layers(&self) -> usize
pub fn num_layers(&self) -> usize
Number of committed (immutable) delta layers.
Sourcepub fn get_attribute(
&self,
name: &str,
key: &str,
) -> Result<Option<&AttributeValue>>
pub fn get_attribute( &self, name: &str, key: &str, ) -> Result<Option<&AttributeValue>>
Returns the value of attribute key on array name, or None if the
array has no such attribute. Errors if the array does not exist.
Sourcepub fn set_attribute(
&mut self,
name: &str,
key: &str,
value: AttributeValue,
) -> Result<()>
pub fn set_attribute( &mut self, name: &str, key: &str, value: AttributeValue, ) -> Result<()>
Sets attribute key on array name to value, inserting or replacing
any existing entry. The change lands in the pending layer and is
persisted on the next flush. Errors if the array does
not exist.
Source§impl ArrayFile
impl ArrayFile
Sourcepub fn define_array<T: ArrayElement>(
&mut self,
name: impl Into<String>,
dimension_names: Vec<String>,
shape: Vec<usize>,
chunk_shape: Option<Vec<usize>>,
fill_value: Option<FillValue>,
) -> Result<()>
pub fn define_array<T: ArrayElement>( &mut self, name: impl Into<String>, dimension_names: Vec<String>, shape: Vec<usize>, chunk_shape: Option<Vec<usize>>, fill_value: Option<FillValue>, ) -> Result<()>
Defines a new array in the pending layer.
shape is the full array shape; chunk_shape tiles it into a grid of
independently stored chunks, or None to store the whole array as a
single chunk. If dimension_names does not have one entry per dimension
it is replaced with dim0, dim1, … . fill_value is returned for
elements that are never written.
Errors with Error::ArrayAlreadyExists if an array of this name is
already visible. The definition is persisted on the next
flush.
Source§impl ArrayFile
impl ArrayFile
Sourcepub async fn write_array<T: ArrayElement>(
&mut self,
name: &str,
start: Vec<usize>,
data: ArrayView<'_, T, IxDyn>,
) -> Result<()>
pub async fn write_array<T: ArrayElement>( &mut self, name: &str, start: Vec<usize>, data: ArrayView<'_, T, IxDyn>, ) -> Result<()>
Writes data into array name with its origin at coordinate start.
The region may span multiple chunks and need not be chunk-aligned;
partially covered chunks are read-modify-written automatically. T must
match the array’s declared dtype, otherwise Error::DTypeMismatch is
returned. Writes accumulate in the pending layer until
flush.
Sourcepub async fn read_array<T: ArrayElement>(
&self,
name: &str,
start: Vec<usize>,
shape: Vec<usize>,
) -> Result<ArcArray<T, IxDyn>>
pub async fn read_array<T: ArrayElement>( &self, name: &str, start: Vec<usize>, shape: Vec<usize>, ) -> Result<ArcArray<T, IxDyn>>
Reads the sub-region of array name starting at start with the given
shape.
Pass vec![], vec![] to read the whole array. Chunks that were never
written are materialized from the array’s fill value. T must match the
array’s declared dtype, otherwise Error::DTypeMismatch is returned.
Source§impl ArrayFile
impl ArrayFile
Sourcepub async fn compact(&mut self) -> Result<()>
pub async fn compact(&mut self) -> Result<()>
Merges all committed layers into a single new base file, deleting the sidecars and reclaiming space held by overwritten and tombstoned chunks.
After a successful compaction num_layers returns
1. Recomputes and rewrites the {stem}.stats file.
Auto Trait Implementations§
impl Freeze for ArrayFile
impl !RefUnwindSafe for ArrayFile
impl Send for ArrayFile
impl Sync for ArrayFile
impl Unpin for ArrayFile
impl UnsafeUnpin for ArrayFile
impl !UnwindSafe for ArrayFile
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> 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.