libzarr
Header-only C++17 Zarr v2/v3, WASM-compatible
Loading...
Searching...
No Matches
Public Member Functions | List of all members
zarr::Store Class Referenceabstract

#include <store.hpp>

Public Member Functions

 Store (const Store &)=delete
 
Storeoperator= (const Store &)=delete
 
 Store (Store &&)=delete
 
Storeoperator= (Store &&)=delete
 
virtual std::optional< Bytesread (std::string_view key)=0
 Full value at key, or std::nullopt if the key is absent.
 
virtual std::optional< Bytesread_range (std::string_view key, ByteRange range)
 
virtual std::optional< std::uint64_t > size (std::string_view key)
 
virtual std::vector< std::optional< Bytes > > read_many (const std::vector< ReadRequest > &requests)
 
virtual void write (std::string_view key, Bytes value)=0
 Create or replace the value at key.
 
virtual bool exists (std::string_view key)=0
 True if key holds a value.
 
virtual void erase (std::string_view key)=0
 Remove key; removing an absent key is a no-op.
 
virtual void flush ()
 
virtual std::vector< std::string > list_prefix (std::string_view prefix)=0
 All keys starting with prefix ("" or ending in '/'), sorted.
 
virtual DirListing list_dir (std::string_view prefix)=0
 Immediate children under prefix ("" or ending in '/').
 

Detailed Description

Abstract key->bytes store. All array and metadata logic in libzarr is written against this interface; backends supply bytes from memory, files, ZIP archives, HTTP range requests, ...

The core is single-threaded by design; implementations are not required to be thread-safe.

Member Function Documentation

◆ erase()

virtual void zarr::Store::erase ( std::string_view  key)
pure virtual

Remove key; removing an absent key is a no-op.

Implemented in zarr::FilesystemStore, zarr::MemoryStore, and zarr::ZipStore.

◆ exists()

virtual bool zarr::Store::exists ( std::string_view  key)
pure virtual

True if key holds a value.

Implemented in zarr::FilesystemStore, zarr::MemoryStore, and zarr::ZipStore.

◆ flush()

virtual void zarr::Store::flush ( )
inlinevirtual

Completes any buffered writes. Plain stores write through and need nothing; adapters that assemble objects (sharding) override.

◆ list_dir()

virtual DirListing zarr::Store::list_dir ( std::string_view  prefix)
pure virtual

Immediate children under prefix ("" or ending in '/').

Implemented in zarr::FilesystemStore, zarr::MemoryStore, and zarr::ZipStore.

◆ list_prefix()

virtual std::vector< std::string > zarr::Store::list_prefix ( std::string_view  prefix)
pure virtual

All keys starting with prefix ("" or ending in '/'), sorted.

Implemented in zarr::FilesystemStore, zarr::MemoryStore, and zarr::ZipStore.

◆ read()

virtual std::optional< Bytes > zarr::Store::read ( std::string_view  key)
pure virtual

Full value at key, or std::nullopt if the key is absent.

Implemented in zarr::FilesystemStore, zarr::MemoryStore, and zarr::ZipStore.

◆ read_many()

virtual std::vector< std::optional< Bytes > > zarr::Store::read_many ( const std::vector< ReadRequest > &  requests)
inlinevirtual

Reads several ranges in one call, order-preserving: result[i] is the value for requests[i], or std::nullopt if that key is absent. The default implementation loops over read_range; backends whose I/O has per-request latency (HTTP, object stores) should override to issue the requests concurrently or as coalesced multi-range reads, cutting round trips. Still synchronous: it returns only once every range is resolved.

◆ read_range()

std::optional< Bytes > zarr::Store::read_range ( std::string_view  key,
ByteRange  range 
)
inlinevirtual

Part of the value at key: std::nullopt if the key is absent, throws zarr::error if the range lies outside the value. The default implementation reads the full value and slices it; backends with native range reads (files, HTTP) should override.

Reimplemented in zarr::FilesystemStore, and zarr::ZipStore.

◆ size()

virtual std::optional< std::uint64_t > zarr::Store::size ( std::string_view  key)
inlinevirtual

Size in bytes of the value at key, or std::nullopt if absent. The default implementation reads the whole value; backends with cheap stat (files: fstat, HTTP: HEAD) should override.

Reimplemented in zarr::FilesystemStore, zarr::MemoryStore, and zarr::ZipStore.

◆ write()

virtual void zarr::Store::write ( std::string_view  key,
Bytes  value 
)
pure virtual

Create or replace the value at key.

Implemented in zarr::FilesystemStore, zarr::MemoryStore, and zarr::ZipStore.


The documentation for this class was generated from the following file: