Repository navigation
DDIR: flatmap returns complete rows, without positions - #1088
Merged
frankmcsherry merged 1 commit intoNov 13, 2026
Merged
Conversation
`flatmap((k, v) -> l)` now takes `l : List((key, val))`, and each element is a whole output row, key included. It no longer keeps the input key or adds each element's position to the value. Positions came from the June port, so `flatmap` and `collect` could round-trip a list; a lambda that wants them now writes `((0, l len) range, l) zip`. The runtime takes keys and values straight from the list's element storage, and repeats only times and diffs. When every list holds at most one row, it gathers times and diffs by the surviving input rows; when every list holds exactly one, it reuses them as they are. Shape and demand analysis, explain, the language reference and README, every DDP program, the Rust fixtures, the Python plan generators and the plan snapshots follow. Of the 25 written uses, 18 now write positions explicitly, and 7 choose their key in the lambda, removing a following map. Co-Authored-By: GPT-6 Sol (Codex) <noreply@openai.com> Claude-Session: https://claude.ai/code/session_01H6wB4H99TLw4tqu4x48pXL
frankmcsherry
marked this pull request as ready for review
November 13, 2026 23:41
frankmcsherry
added a commit
that referenced
this pull request
Nov 14, 2026
#1088's new test declared `type Member = User int | Group int;`, written before #1087 made `type` an alias and `enum` the sum declaration. The two merged separately, so master-next failed two tests in `tests/flatmap.rs`. Claude-Session: https://claude.ai/code/session_01H6wB4H99TLw4tqu4x48pXL Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
flatmapnow returns complete(key, val)rows, with no implicit positions, so a lambda that keeps zero or one row per input is a filter-and-map, and one that chooses a new key needs nomapafter it.A draft, as a step toward smoother pattern matching in join fragments (#1085).
The change
flatmap((k, v) -> l)takesl : List((key, val)). Each element is a whole output row, key included.(pos, element)to the value. Positions came with the June port (interactive: port the data model from flat [i64] to a Value ADT + Term scalar language #760), so thatflatmapandcollectround-trip a list. A lambda that wants them writes((0, l len) range, l) zip.map(one row) andjoin_function(rows with times and diffs), the per-row linear operations now form a ladder of complete rows.Run time
Conversion
.ddpfiles: 25 written programs and 8 generated snapshots. Of the 25 uses, 18 needed positions and now writerange/zip; 7 choose their key in the lambda, removing a followingmap.snb/rel.py,test_topk.py), explain's backward rules, shape and demand analysis, the language reference and README.arrange_idem, each line aflatmapconversion.Checks
cargo test --release -p interactivepasses, including a newtests/flatmap.rs: keeping and dropping, signed diffs, retractions, named variant arms, literal tests, rekeying, and a kernel that fails on dropped data, which shows dropped lanes are never built.check.py --fixture; the top-k checker passes at one and four workers; all 33 AoC parts and the example.expectedoutputs match.Measured
On 3 M rows of
(int, (Member, int))through DDIR's linear-operator path (ns per input row):map | filter | mapflatmapwithenlist unweavefilterfilterwritten as aflatmapThe demux is 21% faster as one
flatmap;filterstays its own kind.Implemented by GPT-6 Sol (Codex); reviewed, tested and opened by Claude Code.
🤖 Generated with Claude Code
https://claude.ai/code/session_01H6wB4H99TLw4tqu4x48pXL