perf(csv-loader): optimize reverse reference resolution
Implement a reverse lookup cache to avoid re-filtering the entire referenced table for every row during reverse reference resolution. This improves performance from O(N*M) to O(N+M) where N is the number of rows in the current table and M is the number of rows in the referenced table. Also update documentation to reflect the new union resolution behavior and migration notes for version 2.0.0.
This commit is contained in:
@@ -139,6 +139,8 @@ The following TypeScript types are exported:
|
||||
| Int | `int` | `42` |
|
||||
| Float | `float` | `3.14` |
|
||||
| Number | `number` | `42` or `3.14` |
|
||||
|
||||
> **Note:** `int`, `float`, and `number` all collapse to the `number` type in generated TypeScript declarations (`schemaToTypeString`). The distinction is preserved at parse time — `int` rejects non-integer values while `float`/`number` accept them.
|
||||
| Boolean | `boolean` | `true` or `false` |
|
||||
| Tuple | `[Type1; Type2; ...]` | `[hello; 42; true]` |
|
||||
| Array | `Type[]` | `[1; 2; 3]` |
|
||||
@@ -159,6 +161,16 @@ The following TypeScript types are exported:
|
||||
- In CSV schema rows, double-quoted string literals like `"active" | "inactive"` are handled automatically by the loader; avoid commas inside string literals (use single-quoted literals like `'a,b'` for those)
|
||||
- For CSV loading with reference resolution, see [csv-loader.md](./csv-loader.md)
|
||||
|
||||
## Migration from 1.x
|
||||
|
||||
Version 2.0.0 introduces breaking changes to the schema DSL:
|
||||
|
||||
1. **Composite values must be fully bracketed.** Tuple and array values now always require `[]` — `[a; 1]; [b; 2]` is no longer accepted; write `[[a; 1]; [b; 2]]`.
|
||||
2. **The `[Type][]` array form is removed.** Use `Type[]` (e.g. `[string; number][]` instead of `[[string; number]][]`).
|
||||
3. **`[single]` is now a 1-tuple, not an array.** Use `Type[]` for single-element arrays.
|
||||
4. **Union resolution prefers reference members.** In a union containing references, reference members are tried before non-reference members regardless of author order (see the notes above).
|
||||
5. **Schema cells may be fully quoted.** Double-quoted string literals like `"active" | "inactive"` in a CSV schema row are handled automatically by the loader.
|
||||
|
||||
```javascript
|
||||
// rspack.config.js
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user