Skip to content

List group members level by level instead of enumerating all keys - #92

Open
konstibob wants to merge 1 commit into
zarr-developers:mainfrom
konstibob:fix-group-list-levelwise
Open

List group members level by level instead of enumerating all keys#92
konstibob wants to merge 1 commit into
zarr-developers:mainfrom
konstibob:fix-group-list-levelwise

Conversation

@konstibob

Copy link
Copy Markdown
Contributor

Group.list() called storeHandle.list(), which is fully recursive and returns every key below the group, including all chunk keys. Listing a group with 1M chunks on S3 cost ~1000 paginated requests to find a handful of zarr.json files.

Walk the hierarchy with listChildren() instead, one level at a time, and never descend into arrays. The implementation moves to core.Group, so v2 and v3 share it, and adds members() for the immediate children only.

Also:

  • S3Store.listChildren() used a single listObjectsV2 call, silently truncating groups with more than 1000 children. Use the paginator.
  • FilesystemStore.get() threw instead of returning null when a path component is a file rather than a directory. Probing a plain file next to a group's nodes is normal now, and such a key holds no data.

Group.list() called storeHandle.list(), which is fully recursive and
returns every key below the group, including all chunk keys. Listing a
group with 1M chunks on S3 cost ~1000 paginated requests to find a
handful of zarr.json files.

Walk the hierarchy with listChildren() instead, one level at a time, and
never descend into arrays. The implementation moves to core.Group, so v2
and v3 share it, and adds members() for the immediate children only.

Also:
- S3Store.listChildren() used a single listObjectsV2 call, silently
  truncating groups with more than 1000 children. Use the paginator.
- FilesystemStore.get() threw instead of returning null when a path
  component is a file rather than a directory. Probing a plain file next
  to a group's nodes is normal now, and such a key holds no data.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
}

/**
* Lists all descendants (arrays and groups) of this group, at any depth.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Lists all descendants (arrays and groups) of this group, at any depth.
* Recursively lists all descendants (arrays and groups) of this group, at any depth.

* Lists the keys directly below {@code prefix} that may hold a child node, relative to this
* group.
*/
private List<String[]> childKeys(String[] prefix) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private List<String[]> childKeys(String[] prefix) {
private List<String[]> descendantKeys(String[] prefix) {

* Opens the node at {@code key}, or returns null if there is no node there.
*/
@Nullable
private Node openChild(String[] key) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private Node openChild(String[] key) {
private Node openDescendant(String[] key) {

/**
* Keys that hold metadata of the group itself and never point at a child node.
*/
private static final Set<String> METADATA_KEYS = Collections.unmodifiableSet(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the v2 vs. v3 abstraction. Could this be delegated to the subclasses?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants