Xuanwo opened a new pull request, #9408:
URL: https://github.com/apache/opendal/pull/9408

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements. You can link an issue to this PR using the GitHub syntax. For 
example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Refs #2476.
   
   # Rationale for this change
   
   <!--
   Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.
   -->
   
   `blockingRead(_:)` returns the whole file as `Data`. A Swift caller 
inspecting a header or scanning for a record can reuse one buffer across reads 
and stop as soon as it has the bytes it needs.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   The Swift binding wraps the existing C reader. The reader can outlive its 
operator and frees the native handle on deinitialization, including when the 
caller stops early. The Swift README includes a read loop.
   
   On Linux x86_64, all 21 package tests passed with Swift 5.10.1. A separate 
SwiftPM client exercised Memory and local Fs with Swift 5.10.1 and 6.3.3 in 
Swift 5 language mode, including buffer reuse, short reads, repeated EOF, and 
early release.
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   Call `try op.blockingReader(path)` on a service that supports reads. Pass 
initialized, writable storage to `BlockingReader.read(into:)` 
(`UnsafeMutableRawBufferPointer`) one call at a time. Process exactly the 
returned byte count, even when it is smaller than the buffer. Only zero from a 
nonempty buffer signals EOF. An empty buffer returns zero without advancing the 
reader. Opening and reading can both throw `OperatorError`, and a missing file 
may surface on the first nonempty read.
   
   # Breaking changes
   
   <!--
   Leave this section empty for compatible changes. For breaking changes, add 
the
   breaking-changes label and use the following format outside this comment:
   
   Affected packages: core, bindings/java
   
   Migration:
   - Replace `old_api()` with `new_api()`.
   
   Use package names from dev/src/release/package.rs. You can also list 
bindings/zig
   for migration notes. Include bindings affected by behavior changes even when
   their source files are unchanged. Explain how users can migrate, or explain 
the
   removal and available alternatives.
   -->
   
   # AI Usage Statement
   
   <!--
   If AI materially assisted or authored this PR, list each harness/model/effort
   combination that materially contributed, and briefly describe its role:
   
   - Harness: Application or agent framework used to run the model.
   - Model: Model name or identifier shown by the harness, with version if 
available.
   - Effort: Reasoning effort setting as named by the harness.
   - Role: AI's contribution and any assumptions or unknowns that affect review.
   
   Do not include routine command output or repeat information provided 
elsewhere.
   
   The accountable human author remains responsible for every submitted claim 
and
   change. If AI did not materially assist this PR, write "None".
   -->
   
   - Pi, `magpie/codex/gpt-6.2-astra`, `high` — assessed the Swift use case and 
drafted the PR description.
   - Pi, `magpie/codex/gpt-6.2-astra`, `xhigh` — coordinated implementation and 
validation.
   - Pi, `magpie/codex/gpt-6.2-sol`, `max` — designed and implemented the 
wrapper, wrote the tests, and ran the validation.
   - Pi, `magpie/kimi-code-cn/k3.1-pro`, default effort — independently 
reviewed the Swift wrapper and reran an external SwiftPM client on Swift 5.10.1.
   


-- 
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]

Reply via email to