-
Notifications
You must be signed in to change notification settings - Fork 19
add usage guide and examples for relational_fusion #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ff8f492
Added docs file for relational_fusion
Rohank3 1b00d6b
fix: address moderator review comments on relational_fusion usage doc
Rohank3 3f88449
Did the mentioned changes
Rohank3 60eb9b3
Delete docs/usage/image.png
Aaryan-Dadu f06ba8f
Remove demo script output image
Aaryan-Dadu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # relational_fusion — Usage Guide | ||
|
|
||
| `relational_fusion` performs a hash-join on two relations (left and right) and | ||
| computes aggregated summary values over the joined rows. It mirrors a common | ||
| database execution strategy: build a hash index on one side, stream the other, | ||
| and aggregate on the fly. | ||
|
|
||
| --- | ||
|
|
||
| ## Quick CLI usage | ||
|
|
||
| ```bash | ||
| # benchmark all tasks (relational_fusion included) | ||
| python -m chuck bench | ||
|
|
||
| # benchmark only relational_fusion | ||
| python -m chuck bench --task relational_fusion | ||
|
|
||
| # run regression checks (validates relational_fusion against stored baselines) | ||
| python -m chuck regress | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Using the Python API directly | ||
|
|
||
| `generate(row_count, seed)` creates a synthetic workload of two relations. | ||
| `solve(payload)` performs the hash-join + aggregation and returns summary statistics. | ||
|
|
||
| Each row in the input is a `(key, value)` tuple — keys are strings like `"k002"`, values are integers in `[1, 999]`. | ||
|
|
||
| | Output field | Description | | ||
| |---|---| | ||
| | `left_rows` | Number of rows in the left relation | | ||
| | `right_rows` | Number of rows in the right relation | | ||
| | `join_rows` | Total rows produced by the inner join | | ||
| | `aggregate` | Sum of `(left_value + right_value)` across all joined pairs | | ||
|
|
||
| --- | ||
|
|
||
| ## End-to-end example script | ||
|
|
||
| ```python | ||
| """relational_fusion end-to-end demo.""" | ||
|
|
||
| from chuck.tasks.relational_fusion import generate, solve | ||
|
|
||
| # 1. Generate a workload | ||
| payload = generate(row_count=128, seed=10) | ||
| print(f"Left rows : {len(payload['left'])}") | ||
| print(f"Right rows : {len(payload['right'])}") | ||
|
|
||
| # 2. Solve | ||
| result = solve(payload) | ||
| print(f"Join rows : {result['join_rows']}") | ||
| print(f"Aggregate : {result['aggregate']}") | ||
|
|
||
| ``` | ||
|
|
||
| **Expected terminal output:** | ||
|
|
||
| ```text | ||
| Left rows : 128 | ||
| Right rows : 64 | ||
| Join rows : 269 | ||
| Aggregate : 276559 | ||
| ✓ Output matches regression baseline | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Benchmarking | ||
|
|
||
| ```python | ||
| from chuck.benchmarks.relational_fusion import run | ||
|
|
||
| result = run() | ||
| print(f"Task : {result['task']}") | ||
| print(f"Size : {result['size']}") | ||
| print(f"Seconds : {result['seconds']}") | ||
| print(f"Output : {result['output']}") | ||
| ``` | ||
|
|
||
| The benchmark uses `row_count=40_000` (the task's `benchmark_size`) by default, | ||
| giving a realistic workload for performance measurement. | ||
|
|
||
| --- | ||
|
|
||
| ## Native C++ backend | ||
|
|
||
| If the C++ native module is built, `chuck` will automatically use it for faster | ||
| execution with no code changes required — the Python fallback is used otherwise. | ||
|
|
||
| See [NATIVE_BINDINGS.md](../NATIVE_BINDINGS.md) for build and comparison details. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.