Luxar Viewer API Documentation - v2026.10.19
    Preparing search index...
    • Wrap a zarr.Array with L0 decompressed chunk caching.

      The returned proxy intercepts getChunk() calls:

      1. Checks L0 cache for the requested chunk
      2. On hit: returns cached decompressed data immediately (~1μs)
      3. If the chunk is already being decoded — through ANY proxy over the same cache — joins that decode instead of starting another (the in-flight map lives on the DecompressedChunkCache, not on the proxy)
      4. On miss: calls original getChunk(), caches result, returns data

      READ-ONLY CONTRACT: every caller — the miss that decoded a chunk, the waiters that joined that decode, and every later hit — receives the SAME buffer L0 holds, so no consumer may mutate a chunk it is handed. zarrita get() (readArray) satisfies this by construction: it copies each chunk into its own freshly allocated output (setter.setFromChunk). A direct getChunk() caller must copy before writing. A decoded view that does not span its whole ArrayBuffer (e.g. an uncompressed chunk sliced out of a larger shard/archive buffer) is still copied for storage, so L0 never retains more bytes than it accounts for.

      Abort isolation: the shared decode runs under its own AbortController, never under a caller's signal. Each caller races the decode against its own signal (the call's options.signal, else hooks.getSignal()), and the decode is cancelled only once EVERY waiter has aborted. A decode that is not fully abandoned completes and is cached; so does an abandoned one that the cancellation could no longer stop.

      All other zarr.Array properties and methods pass through unchanged.

      Type Parameters

      • D extends DataType

      Parameters

      • array: Array<D, Readable>

        Original zarr.Array to wrap

      • cache: DecompressedChunkCache

        L0 decompressed chunk cache instance

      • arrayPath: string

        Full path to the array (used for cache key generation)

      • hooks: CachedArrayHooks = {}

        Optional residency-probe / abort-signal / decode-origin accessors (see CachedArrayHooks).

      Returns Array<D, Readable>

      Proxied zarr.Array with L0 caching enabled

      const cache = new DecompressedChunkCache({ maxSize: 200 * 1024 * 1024 });

      // Wrap array after opening
      const rawArray = await zarr.open(location.resolve('positions'), { kind: 'array' });
      const cachedArray = wrapWithCache(rawArray, cache, '/scene/points/positions');

      // Use normally - getChunk() now checks L0 cache
      const chunk = await cachedArray.getChunk([0, 1, 2]);
      // First call: decompresses and caches
      // Subsequent calls: returns from L0 cache instantly