-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature request: support network-based filesystem support for large files #4
Comments
It appears that this feature already exists in emscripten: https://emscripten.org/docs/porting/files/Synchronous-Virtual-XHR-Backed-File-System-Usage.html Prerequisites:
Then worker code like this can function: import * as hdf5 from "../h5wasm/dist/esm/hdf5_hl.js";
var file;
const DEMO_FILEPATH="https://ncnr.nist.gov/pub/ncnrdata/ngbsans/202009/nonims294/data/sans114140.nxs.ngb?gzip=false";
self.onmessage = async function (event) {
const { action, payload } = event.data;
if (action === "load") {
await hdf5.ready;
hdf5.FS.createLazyFile('/', "current.h5", DEMO_FILEPATH, true, false);
file = new hdf5.File("current.h5");
}
else if (action === "get") {
await hdf5.ready;
if (file) {
self.postMessage(file.get("entry").attrs["NX_class"].value)
}
}
}; |
I needed the exact same feature, and this solution works really well! |
I haven't been providing an IIFE "plain javascript" build because it's easier to support ESM outputs, but you can get a version of the library that will work
if you do a little bit of post-processing on the distributed library:
The resulting file can then be loaded in (any!) worker with importScripts("h5wasm_iife.js"); In fact, it's so easy I should probably include that build in a future release! |
That was indeed super easy and works like a charm. ❤️ Thank you so much for the prompt answer!! (And I guess this issue could be closed as everything works as intended) |
For files too large to load into memory, it would be nice to be able to load parts of a file on-demand over the network (see discussion in #2). The new WASM Filesystem being designed for emscripten seems like it is anticipating this use case: see design documents at emscripten-core/emscripten#15041
When this is implemented and generally available, look into adding this capability to h5wasm so that very large files can be retrieved piecewise and on-demand by URL.
The text was updated successfully, but these errors were encountered: