[pull] master from GaijinEntertainment:master#1038
Merged
Conversation
5 rows + 4 emit archetypes replace the imperative ~543-LOC plan_order_family.
Row priority (most-specific first):
Row 1 order_streaming_min — inline-cmp + first[_or_default]
Row 2 order_bounded_heap — inline-cmp + take(N); distinct gate variant
Row 3 order_then_plain_distinct — order + plain distinct (NOT distinct_by)
Row 4 order_fused_prefilter — where/distinct + order; emit_fused_prefilter
Row 5 order_buffer_helper_dispatch — bare order; direct helper calls
Row 3 reuses emit_fused_prefilter via a distinct_after capture key —
extract_order_captures normalizes either c.single["distinct"] (pre-order, row 4)
or c.single["distinct_after"] (post-order plain, row 3) into the same
distinctName state. distinct_by AFTER order is structurally excluded by Row 3's
m_literal("distinct") matcher (position-invariant whole-tuple equality only
holds for plain distinct).
Kernel change — Captures gains a `single_name` parallel table:
struct Captures {
single : table<string; ExprCall?>
single_name : table<string; string> // NEW — PR B2
many : table<string; array<ExprCall?>>
}
The walker now records the LinqCall.name at capture time. Load-bearing because
normalize_order_reverse swaps `calls[i]._1.name` (the LinqCall record) but
leaves `calls[i]._0.func` (the ExprCall function pointer) unchanged. The
imperative loop read `cll._1.name` directly and saw the swap; the pattern
walker captures `cll._0`, and call_norm_name(captured) walks func.fromGeneric
back to the source name — silently undoing the swap. extract_order_captures
and inline_cmp_available read c.single_name[key] instead.
Surfaced by test_linq_fold_theme45_quick_wins — `_order_by(_).reverse().take(3)`
was returning ascending top-3 instead of descending. Fix preserves the swap at
the captures level so PR B1's plan_loop_or_count and PR A's plan_reverse /
plan_distinct continue working unchanged (they don't run a name-swap pre-pass).
Other planners (no rename pre-pass) can continue using call_norm_name.
emit_loop_or_count_lane refactor reused: extract_order_captures helper
centralizes captures→state across all 4 archetypes (~80 LOC saved on shared
capture-reading boilerplate).
Wires collapse_chained_wheres into plan_order_family stub alongside
collapse_chained_selects and normalize_order_reverse.
Tests:
- tests/linq/test_linq_fold_order_family.das (new) — 6 tests / 12 sub-runs:
normalize_order_reverse parity, KR-1 closure on plan_order_family,
Row 3 plain distinct after order, streaming-min with where, bounded-heap
with distinct gate.
Validation: full linq matrix (29 files, 1632 sub-runs) + decs matrix
(11 files smoke, 117 sub-runs) green. Lint clean.
Masterplan: PR B2 row flipped to complete; kernel snippet, naming table,
PR B2 sketch, and decision log all reflect what shipped (including the
single_name addition, the row-priority discipline, and the row 5 reuse of
emit_fused_prefilter).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…attern-table-prb2 linq_fold PR B2: plan_order_family pattern-table migration
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )