aglinxinyuan opened a new issue, #5736:
URL: https://github.com/apache/texera/issues/5736
### Task Summary
Add dedicated unit-specs for three storage-model classes / traits in
`common/workflow-core/core/storage/model/`. Pin the trait contracts via
test-only subclasses and the local-file concrete impl through a temp-file
harness.
## Background
| Source class | Purpose |
| --- | --- |
| `VirtualCollection` | Abstract base for a one-level collection of
`VirtualDocument`s (`getURI` / `getDocuments` / `getDocument(name)` /
`remove()`) |
| `ReadonlyVirtualDocument[T]` | Trait declaring the read-only document
surface (`getURI` / `getItem` / `get()` / `getRange` / `getAfter` / `getCount`
/ `asInputStream` / `asFile`) |
| `ReadonlyLocalFileDocument` | `private[storage]` concrete impl of
`ReadonlyVirtualDocument[Nothing]` backed by a local file URI; iterator-style
methods are deliberately unsupported (`throw new NotImplementedError`) |
## Behavior to pin
### `VirtualCollection`
| Surface | Contract |
| --- | --- |
| Trait declares four abstract methods | `getURI`, `getDocuments`,
`getDocument`, `remove` (pinned via a test-only concrete subclass) |
| A concrete subclass implementing all four | composes (no missing abstract
member errors) |
| Pattern matching | `_: VirtualCollection` matches a concrete instance |
### `ReadonlyVirtualDocument`
| Surface | Contract |
| --- | --- |
| Trait declares eight abstract methods | enumerated in the Background
table; pinned via a minimal test-only concrete subclass that returns sentinel
values |
| Default `getRange` signature accepts `columns: Option[Seq[String]] = None`
| call site can omit the third argument |
| Type parameter `T` | preserved through `getItem` / `get` / `getRange` /
`getAfter` |
### `ReadonlyLocalFileDocument`
| Surface | Contract |
| --- | --- |
| Constructor takes a `URI` | exposes it via `getURI` |
| `asFile()` | returns a `File` pointing at the same URI |
| `asInputStream()` | reads bytes from the file (round-trip the file
content) |
| Successive `asInputStream()` calls | return independent streams |
| `getItem` / `get` / `getRange` / `getAfter` / `getCount` | each throws
`NotImplementedError` with a descriptive message |
| Visibility | `private[storage]` — accessible from a spec in the same
package |
## Scope
- New spec files (one per source class per the spec-filename convention):
- `VirtualCollectionSpec.scala`
- `ReadonlyVirtualDocumentSpec.scala`
- `ReadonlyLocalFileDocumentSpec.scala`
- No production-code changes.
- `ReadonlyLocalFileDocumentSpec` lives in
`org.apache.texera.amber.core.storage.model` so the `private[storage]` class is
accessible. It uses a `Files.createTempFile` harness to write known bytes and
round-trip them via `asInputStream` / `asFile`.
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
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]