-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unifying consolidated and non-consolidated interfaces #117
Comments
Another idea is that this could just be a special store (wrapper): interface Listable {
contents(): Array<{ path: AbsolutePath, kind: "array" | "group" }>;
}
async function withConsolidated<Store extends Readable>(store: Store) Pick<Store, "get"> & Listable {
const known_metadata = await try_consolidated(store);
return {
get(...args: Parameters<Store["get"]>) {
let [key, opts] = args;
if (key in known_metadata) return known_metadata[key];
let maybe_bytes = await store.get(key, opts);
if (is_meta_key(key) && maybe_bytes) { // add to known_metadata
return maybe_bytes;
},
contents() {
return list_nodes(known_metadata);
}
}
} The reason I chose to use Then import { withConsolidated, FetchStore, open } from "zarrita";
let store = await withConsolidated(new FetchStore("http://localhost:8080"));
let contents = store.contents() // [ {path: "/", kind: "group" }, { path: "/foo", kind: "array" }, ...]
let foo = await open(contents[1].path, { kind: "array" }); |
I am experimenting with the second option. |
Added in #119 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now there are two different worlds for consolidated vs non-consolidated metadata:
consolidated
non-consolidated
But then the end users have to deal with switching between these worlds.
I can see a use case where we don't know if the metadata is consolidated or not, but if it is, it would be nice to avoid loading that metadata over the network (i.e., we have something like AnnData).
In #109 , @keller-mark had the idea to start tracking information about the stores (which we can do with
WeakMap
s). I wonder if we could extend this idea to opening consolidated metadata. I'm wondering if we could do something similar to keep track of the contents we've opened so far for a store:This would mean that if you know you have consolidated metadata, you could just use
contents
directly. But if you don't know if it's consolidated or not, you could "try" to open consolidated for a performance boost:The text was updated successfully, but these errors were encountered: