srdatalog.ir.mir.types¶
Python mirror of src/srdatalog/mir/mir_types.nim.
Pure IR data. Distinct from the existing python/mir_commands.py which emits C++ for mhk’s codegen and carries codegen-side state (cursor slots, program backref). My MirNode types carry only what the Nim MIR carries; they are suitable for S-expr printing and byte-diff against Nim golden.
Mapping to Nim: moColumnSource -> ColumnSource moScan -> Scan moColumnJoin -> ColumnJoin moCartesianJoin -> CartesianJoin moFilter -> Filter moNegation -> Negation moInsertInto -> InsertInto moExecutePipeline -> ExecutePipeline moRebuildIndex -> RebuildIndex moClearRelation -> ClearRelation moCheckSize -> CheckSize moComputeDelta -> ComputeDelta moComputeDeltaIndex -> ComputeDeltaIndex moMergeIndex -> MergeIndex moMergeRelation -> MergeRelation moRebuildIndexFromIndex -> RebuildIndexFromIndex moFixpointPlan -> FixpointPlan moBlock -> Block moProgram -> Program
All registered Nim MIR op kinds are now covered. Advanced ops (Aggregate, CreateFlatView, InnerPipeline, ProbeJoin, GatherColumn) have types + emitters but aren’t yet produced by Python lowering; they’re here so downstream codegen bridges and future lowering extensions have the node shapes to target.
Module Contents¶
Classes¶
(aggregate #:var cnt #:func AggCount #:index (Rel 0 1) #:ver FULL #:prefix (x y)) |
|
(balanced-scan #:group-var v #:source1 (…) #:source2 (…)) |
|
(block <instructions…>) |
|
(cartesian-join #:vars (…) #:var-from-source ((…)) #:sources (…)) |
|
(check-size #:schema R #:ver V) |
|
(clear-relation #:schema R #:ver V) |
|
(column-join #:var x #:sources (…)) |
|
(column-source #:index (Rel cols…) #:ver V #:prefix (vars)) |
|
(compute-delta #:schema R) |
|
(compute-delta-index #:schema R #:canonical-index (cols…)) |
|
(constant-bind #:var v #:code “…” #:deps (…)) |
|
(create-flat-view #:schema R #:index (cols…) #:ver V) |
|
(execute-pipeline #:rule N #:sources (tuple …) #:dests (tuple …) ) |
|
(filter #:vars (…) #:code “…”) |
|
(fixpoint-plan <instructions…>) |
|
(gather-column …) — binary-join mode node. Dereferences
|
|
(inject-cpp-hook #:rule R #:code “…”) — raw C++ injection point. |
|
(inner-pipeline #:rule R #:bound-vars (…) #:handles (…) #:ops (…)) |
|
(insert-into #:schema R #:ver V #:dedup-index (cols…) #:terms (vars)) |
|
(merge-index #:index (R cols…)) |
|
(merge-relation #:schema R) |
|
(negation #:schema R #:ver V #:index (R cols…) #:prefix (…)) |
|
(parallel-group <ops…>) — independent ops that can run concurrently. |
|
(positioned-extract #:var v #:sources ((…) (…)) #:bind (…)) |
|
(post-stratum-reconstruct-intern-cols #:rel R #:canonical-index (cols…)) |
|
(probe-join …) — binary-join mode node. Performs a binary-search
probe of |
|
(program (step #:recursive b |
|
(rebuild-index #:index (R cols…) #:ver V) |
|
(rebuild-index-from-index #:source (R cols…) #:target (R cols…) #:ver V) |
|
(scan #:vars (…) #:index (Rel cols…) #:ver V #:prefix (…)) |
Data¶
API¶
- class srdatalog.ir.mir.types.Aggregate[source]¶
(aggregate #:var cnt #:func AggCount #:index (Rel 0 1) #:ver FULL #:prefix (x y))
Aggregation body clause lowered to MIR.
result_varis the variable bound by the aggregate;funcis the C++ aggregation type (AggCount / AggSum / … / custom).prefix_varsare join-prefix vars read by the aggregate’s index lookup.- version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.BalancedScan[source]¶
(balanced-scan #:group-var v #:source1 (…) #:source2 (…))
Pre-computes a work-distribution histogram for a skewed join: partition work across (source1 × source2) pairs grouped by
group_var(the “balanced root”). Emitted by lowering when a rule’s plan specifiesbalanced_root+balanced_sources.- source1: srdatalog.ir.mir.types.ColumnSource¶
None
- source2: srdatalog.ir.mir.types.ColumnSource¶
None
- class srdatalog.ir.mir.types.CartesianJoin[source]¶
(cartesian-join #:vars (…) #:var-from-source ((…)) #:sources (…))
- sources: list[srdatalog.ir.mir.types.ColumnSource]¶
None
- class srdatalog.ir.mir.types.CheckSize[source]¶
(check-size #:schema R #:ver V)
- version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.ClearRelation[source]¶
(clear-relation #:schema R #:ver V)
- version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.ColumnJoin[source]¶
(column-join #:var x #:sources (…))
- sources: list[srdatalog.ir.mir.types.ColumnSource]¶
None
- class srdatalog.ir.mir.types.ColumnSource[source]¶
(column-source #:index (Rel cols…) #:ver V #:prefix (vars))
- version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.ComputeDeltaIndex[source]¶
(compute-delta-index #:schema R #:canonical-index (cols…))
- class srdatalog.ir.mir.types.ConstantBind[source]¶
(constant-bind #:var v #:code “…” #:deps (…))
Generated by head-constant rewriting: a HIR LetClause lowers to this MIR node, which binds
var_nametocodeoncedepsare bound.
- class srdatalog.ir.mir.types.CreateFlatView[source]¶
(create-flat-view #:schema R #:index (cols…) #:ver V)
Emitted by split-rule lowering to expose temp-relation intern columns as an unsorted view (avoids a GPU sort between Pipeline A and B).
- version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.ExecutePipeline[source]¶
(execute-pipeline #:rule N #:sources (tuple …) #:dests (tuple …)
)- dest_specs: list[srdatalog.ir.mir.types.InsertInto]¶
None
- class srdatalog.ir.mir.types.GatherColumn[source]¶
(gather-column …) — binary-join mode node. Dereferences
input_bufferof row IDs into values ofcolumnfromrel_name, binding the result tooutput_var.- rel_version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.InjectCppHook[source]¶
(inject-cpp-hook #:rule R #:code “…”) — raw C++ injection point.
The Nim emitter prints #:code “…” without the actual code body (just the ellipsis), matching debug/tooling display; real content stays in the node’s code field for codegen.
- class srdatalog.ir.mir.types.InnerPipeline[source]¶
(inner-pipeline #:rule R #:bound-vars (…) #:handles (…) #:ops (…))
JIT-generated inner device function for nested joins (Level 2+). Nim emits an explicit C++ functor rather than recursive template metaprogramming.
- class srdatalog.ir.mir.types.InsertInto[source]¶
(insert-into #:schema R #:ver V #:dedup-index (cols…) #:terms (vars))
- version: srdatalog.ir.hir.types.Version¶
None
- srdatalog.ir.mir.types.MirNode¶
None
- class srdatalog.ir.mir.types.Negation[source]¶
(negation #:schema R #:ver V #:index (R cols…) #:prefix (…))
- version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.ParallelGroup[source]¶
(parallel-group <ops…>) — independent ops that can run concurrently.
- class srdatalog.ir.mir.types.PositionedExtract[source]¶
(positioned-extract #:var v #:sources ((…) (…)) #:bind (…))
After a BalancedScan binds its group variable, any subsequent ColumnJoin for that variable becomes a positioned extract: point-lookup rather than iteration.
- sources: list[srdatalog.ir.mir.types.ColumnSource]¶
None
- class srdatalog.ir.mir.types.PostStratumReconstructInternCols[source]¶
(post-stratum-reconstruct-intern-cols #:rel R #:canonical-index (cols…))
Emitted once per stratum per relation: single cleanup step that replaces a per-index RebuildIndex loop, pushing complexity into the C++ runtime.
- class srdatalog.ir.mir.types.ProbeJoin[source]¶
(probe-join …) — binary-join mode node. Performs a binary-search probe of
probe_relkeyed onjoin_key, writing row-id pairs intooutput_buffer. Uses merge-path balancing for unbalanced output.- probe_version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.RebuildIndex[source]¶
(rebuild-index #:index (R cols…) #:ver V)
- version: srdatalog.ir.hir.types.Version¶
None
- class srdatalog.ir.mir.types.RebuildIndexFromIndex[source]¶
(rebuild-index-from-index #:source (R cols…) #:target (R cols…) #:ver V)
- version: srdatalog.ir.hir.types.Version¶
None