Skip to content

getRanges on AsyncReadable #358

@wietzesuijker

Description

@wietzesuijker

From #347 (discussion with @kylebarron).

Where this helps today

  1. Sharding codec (sharding.ts#L38-L76): two sequential getRange calls per shard (index suffix + chunk data). These are sequential, so a wrapper like feat: add BatchedFetchStore for request batching and range merging #347 can't batch them.

  2. Chunk indexing (get.ts#L53-L61): concurrent chunk fetches hit the same shard file. feat: add BatchedFetchStore for request batching and range merging #347 intercepts this at the wrapper level, but a store-level method would let backends optimize natively (S3 multipart GET, local FS single file handle).

Proposal

interface AsyncReadable<Options = unknown> {
  get(key: AbsolutePath, opts?: Options): Promise<Uint8Array | undefined>;
  getRange?(key: AbsolutePath, range: RangeQuery, opts?: Options): Promise<Uint8Array | undefined>;
  getRanges?(key: AbsolutePath, ranges: RangeQuery[], opts?: Options): Promise<(Uint8Array | undefined)[]>;
}

Optional, like getRange. A defaultGetRanges utility could provide the coalescing fallback (reusing groupRequests from #347) for stores that don't override. Same pattern as Rust object_store::get_ranges, but narrower: just this method, not the full list/put/delete surface.

Open questions

  • Single-path (getRanges(key, ranges[])) or multi-path (getRanges(requests[]{key, range}))? Single-path is simpler and matches object_store.
  • Should the sharding codec call getRanges directly, or is that a follow-up?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds discussionRequires further discussion before action

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions