Repository navigation
feat: Remote-source bulk import (import_from_storage) - #1214
Merged
Merged
Conversation
zonotope
approved these changes
May 6, 2026
zonotope
left a comment
Contributor
There was a problem hiding this comment.
Looks good. The only small issue is that the hard coded line number in the error message starting at fluree-db-api/src/import.rs:818 is going to be difficult to keep up to date as the file changes. I think it would be better to just give a blanket "not supported" message there.
Contributor
Author
Addressed in e8349c8 |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
fluree.create("ledger").import_from_storage(storage, source).execute()soconsumers whose source data lives in
StorageRead-backed storage (S3 today;any backend tomorrow) can bulk-import directly into a new ledger without
first staging the input on local disk.
Motivation: a Lambda consumer needed to import large datasets from
S3. The local
.import(path)requires every source byte on local disk beforeimport begins — wasted I/O at best, infeasible at worst in ephemeral
environments. This streams source bytes directly into the existing parse/commit
pipeline.
What's in scope
StorageRead::list_prefix_with_metadata— new trait method returning(address, size_bytes)pairs. Default impl errors loudly;S3Storageoverrides using
list_objects_v2(size is native);MemoryStorageoverrides for tests.
RemoteObject+RemoteSource— a typed(address, size_bytes)structand a small enum (
OrderedObjects(Vec<RemoteObject>)/Prefix { prefix }).OrderedObjectsis the production-recommended path;Prefixis the convenience listing path.CreateBuilder::import_from_storage(storage, source)— new public APIparallel to
.import(path), acceptingArc<dyn StorageRead>.read_bytes, sends(idx, bytes)into a bounded tokio mpsc; a smallbridge thread forwards to a
std::sync::mpsc::SyncSenderthat parserworkers drain. Parser workers stay CPU-only — no
block_onfrom a parserthread.
oneshot::Receiver<Option<ImportError>>.Channel close alone is not treated as success; the import driver awaits the
signal so a mid-stream producer crash never silently truncates the import.
.ttl— same parser pool the localFilespathuses. Hot path.
.jsonld— drains the channel sequentially and dispatchesvia
parse_jsonld_chunk+finalize_parsed_chunk, mirroring the localserial fallback.
.trigis rejected with an actionable error pointing to the upstreamlimitation in
fluree-db-transact/src/import.rs:452(named-graph flakesaren't captured by the Tier 2 spool pipeline). The serial remote arm
already dispatches
.trigcorrectly, so enabling it here is a 5-lineresolver change once the upstream issue is fixed.
Local path is not modified
Bit-for-bit unchanged. No generics introduced into
StreamingTurtleReader,no shared traits, no
Box<dyn>in any hot loop. The localFilesandStreamingarms compile to identical machine code.The 12 existing local-import tests continue to gate the local-path
performance guarantee. None of them changed.
Lambda runtime guidance
Streaming the input from S3 means input bytes never touch local
/tmp.Scratch (spool/runs/index) still uses local disk under
FLUREE_IMPORT_DIR,so Lambda viability is bounded by scratch ratio (~4× input, data-dependent),
not input size. Working envelope at 4× scratch is roughly a 2 GB input
ceiling for Lambda's 10 GB
/tmp— but consumers should validate empiricallyon a representative subset and enforce an upload-size cap.
For unbounded import sizes, Lambda is the wrong runtime regardless — use
Fargate or EC2.
Files changed
fluree-db-core/src/storage.rsRemoteObject+list_prefix_with_metadatafluree-db-core/src/storage/memory.rsMemoryStorageoverride (used in tests)fluree-db-storage-aws/src/s3/mod.rsS3Storageoverride (list_objects_v2)fluree-db-api/src/import.rsRemoteSource,RemoteChunkProducer, async producer + bridge thread, parallel/serial remote arms,import_from_storageAPIfluree-db-api/src/lib.rsRemoteSource,RemoteObjectfluree-db-api/tests/it_import_remote.rsdocs/design/storage-traits.mdFuture work (not this PR)
.ttlstreamed via S3 byte-range reads withstatement-boundary splitting. Lets a multi-GB remote
.ttlbe splitwithout ever holding the whole object in memory. Materially more complex;
deferred until a consumer needs it.
.trigenablement — pending fix to the Tier 2 spool pipeline(see
fluree-db-transact/src/import.rs:452).import sizes by removing the
/tmpscratch dependency. Larger separateworkstream.