chitralverma opened a new pull request, #8966:
URL: https://github.com/apache/opendal/pull/8966
# Which issue does this PR close?
Closes #8964.
# Rationale for this change
For patterns that span directories, `GlobLayer` walks one directory at a
time. On object stores a recursive listing is already one flat, paged key
listing, so the walk turns 1 ListObjectsV2 request into one per visited prefix:
201 requests and about 55 s instead of 1 request and about 0.4 s for 1000 keys
on real S3 (details in the issue). Directory walkers such as fs should keep the
guided walk, since there it skips directories the pattern cannot match.
`Capability` has no way to tell the two apart today: `list_with_recursive` is
true for both s3 and fs.
# What changes are included in this PR?
- New `Capability::list_with_recursive_flat`: a recursive listing is one
flat key listing of the subtree rather than a walk of directories.
- Set to `true` on s3 (following `list_with_recursive`, so not on S3 Express
directory buckets), gcs, gcs-grpc, azblob, oss, cos, obs, tos, b2, swift and
memory. Each of these drops the delimiter for recursive listing. Walkers (fs,
and anything simulated by `SimulateLayer`, which never advertises recursion)
are unchanged.
- `GlobLayer`: when the pattern spans directories and the service advertises
both `list_with_recursive` and `list_with_recursive_flat`, it lists the
pattern's literal prefix once, recursively, and filters it. Otherwise it keeps
the guided walk. Requiring both flags means a layer that turns recursion off
(for example `CapabilityOverrideLayer`) cannot leave a stale flat hint.
- `FilteredLister` synthesizes directory entries for parents that exist only
as key prefixes (once each), and never returns the listed directory itself.
Results stay identical to the guided walk for patterns such as `t/*/` and
`t/**`.
- Single-component patterns (`*.parquet`) still list one directory
non-recursively.
- Generated mirrors refreshed with `cargo run --manifest-path dev/Cargo.toml
-- generate -l {python,java,dotnet,docs}`: Java and .NET `Capability`, and
`website/data/capabilities.json`.
- `upgrade.md` note and `GlobLayer` docs.
Tests in `layers/glob/tests.rs`:
- `recursive_services_filter_one_listing`: 3 globs on a flat-recursive
fixture issue exactly 3 recursive requests; checks `limit` passthrough,
synthesized parents and their de-duplication.
- `single_component_patterns_list_one_directory`
- `walking_services_keep_the_guided_listing`: recursive but not flat stays
guided.
- `flat_listing_requires_recursive_listing`: flat hint without recursion
stays guided.
`recursive_services_filter_one_listing` fails on `main`; the other three pin
behavior that must not change.
Verification:
- Real AWS S3, 9 patterns over 1,725 keys and 3 explicit directory markers,
compared with a reference matcher: every pattern drops to 1 ListObjectsV2 with
identical results. For example, `t/**/*.parquet` went from 201 requests in 56.3
s to 1 in 0.36 s, `logs/**/*.json` from 267 in 67.5 s to 1 in 0.34 s, and
`t/part=7/*.parquet` stays at 1.
- Behavior `list` tests on real S3 (with `test_list_with_glob` temporarily
enabled for s3): 16 passed. The 4 version and deleted-marker tests fail
identically on unmodified `main` because the test bucket has versioning off.
- Local differential of 163 patterns against fs and memory (flat and
simulated): results unchanged; fs timings unchanged.
- `cargo test --lib` in `core/core`: 493 passed.
- Behavior `list` tests with `OPENDAL_TEST=fs` and `OPENDAL_TEST=memory`:
20/20 each.
- `cargo clippy --all-targets -- -D warnings`: core with all features, plus
every touched service.
- `cargo fmt --all --check`, and the `check_generated` steps leave no diff.
# Are there any user-facing changes?
- `glob()` on the services above issues one recursive listing instead of one
listing per directory. Entries returned are the same.
- New public field `Capability::list_with_recursive_flat`, also exposed in
the Java and .NET bindings and in the capability docs.
# Breaking changes
Affected packages: core, bindings/java, bindings/dotnet
Migration:
- In exhaustive Rust `Capability` struct literals, add
`list_with_recursive_flat: false`, or use `..Default::default()`.
- Java and .NET `Capability` gain a `listWithRecursiveFlat` /
`ListWithRecursiveFlat` property. Code that only reads capabilities needs no
change.
# AI Usage Statement
- Harness: Jcode
- Model: claude-opus-5-5
- Effort: low
- Role: Measured the request counts on real S3, designed and wrote the
patch, tests and this description, and ran the verification listed above. The
human author reviewed the change and the results.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]