This commit is contained in:
Hassan Abedi 2026-06-03 12:17:52 +02:00
parent 1c3b693ded
commit a1d46d37d1

View File

@ -5,8 +5,8 @@ The operators are: atom scan, semijoin, and natural join.
### Public API ### Public API
| Item | Type | Description | | Item | Kind | Description |
|--------------------------------------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |--------------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `scan_atom(&Table, &AtomPattern) -> Relation` | function | Scans the table under the pattern and returns a binding relation with one column per distinct variable in first-occurrence order. Literal positions and repeated variables filter rows during the scan. | | `scan_atom(&Table, &AtomPattern) -> Relation` | function | Scans the table under the pattern and returns a binding relation with one column per distinct variable in first-occurrence order. Literal positions and repeated variables filter rows during the scan. |
| `semijoin(&Relation, &Relation) -> Relation` | function | Returns the rows of `left` whose values on the columns shared with `right` also appear in `right`. The output column list is the same as `left.columns`. | | `semijoin(&Relation, &Relation) -> Relation` | function | Returns the rows of `left` whose values on the columns shared with `right` also appear in `right`. The output column list is the same as `left.columns`. |
| `natural_join(&Relation, &Relation) -> Relation` | function | Returns every pair of `left` and `right` rows that agree on shared columns. Each output row holds the columns of `left` followed by the non-shared columns of `right`. | | `natural_join(&Relation, &Relation) -> Relation` | function | Returns every pair of `left` and `right` rows that agree on shared columns. Each output row holds the columns of `left` followed by the non-shared columns of `right`. |
@ -16,9 +16,11 @@ The operators are: atom scan, semijoin, and natural join.
| `Relation` | struct | Holds rows over named columns and is the type produced by every operator. Construct it with `Relation::new(columns)` or `Relation::from_rows(columns, rows)`. Column names within a single relation must be unique. | | `Relation` | struct | Holds rows over named columns and is the type produced by every operator. Construct it with `Relation::new(columns)` or `Relation::from_rows(columns, rows)`. Column names within a single relation must be unique. |
| `Value` | enum | Represents a single cell value stored in a `Table` or `Relation`. A value is either `Int(i64)` or `Str(String)`. | | `Value` | enum | Represents a single cell value stored in a `Table` or `Relation`. A value is either `Int(i64)` or `Str(String)`. |
Data types and their relationships:
<div align="center"> <div align="center">
<picture> <picture>
<img alt="Types" src="docs/diagrams/types.svg" height="50%" width="50%"> <img alt="Types" src="docs/diagrams/types.svg" height="60%" width="60%">
</picture> </picture>
</div> </div>
@ -30,7 +32,7 @@ It uses all three operators:
- `semijoin` to keep only authors of bestsellers, - `semijoin` to keep only authors of bestsellers,
- and `natural_join` to attach each book's price. - and `natural_join` to attach each book's price.
```text ```prolog
Q(name, book, dollars) :- author(name, book), bestseller(book), price(book, dollars). Q(name, book, dollars) :- author(name, book), bestseller(book), price(book, dollars).
``` ```