Class: Kumi::Core::Compiler::AccessPlanner
- Inherits:
-
Object
- Object
- Kumi::Core::Compiler::AccessPlanner
- Defined in:
- lib/kumi/core/compiler/access_planner.rb
Overview
Generates deterministic access plans from normalized input metadata.
Metadata expectations (produced by InputCollector):
-
Each node has:
:container => :scalar | :read | :array :children => { name => } (optional) -
Each non-root node (i.e., any child) carries edge hints from its parent:
:enter_via => :field | :array # how the parent reaches THIS node :consume_alias => true|false # inline array edge; planner does not need this to emit ops
Planning rules (single source of truth):
-
Root is an implicit object.
-
If parent is :array, always emit :enter_array before stepping to the child.
- If child.enter_via == :field -
If parent is :read (or root), emit :enter_hash(child_name).
Modes (one plan per mode):
-
Scalar paths (no array in lineage) → [:read]
-
Vector paths (≥1 array in lineage) → [:each_indexed, :materialize, :ravel]
-
If @defaults is set, emit only that mode (alias :read → :read).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(meta, options = {}) ⇒ AccessPlanner
constructor
A new instance of AccessPlanner.
- #plan ⇒ Object
- #plan_for(path) ⇒ Object
Constructor Details
#initialize(meta, options = {}) ⇒ AccessPlanner
Returns a new instance of AccessPlanner.
34 35 36 37 38 |
# File 'lib/kumi/core/compiler/access_planner.rb', line 34 def initialize(, = {}) = @defaults = { on_missing: :error, key_policy: :indifferent, mode: nil }.merge() @plans = {} end |
Class Method Details
.plan(meta, options = {}) ⇒ Object
31 |
# File 'lib/kumi/core/compiler/access_planner.rb', line 31 def self.plan(, = {}) = new(, ).plan |
.plan_for(meta, path, options = {}) ⇒ Object
32 |
# File 'lib/kumi/core/compiler/access_planner.rb', line 32 def self.plan_for(, path, = {}) = new(, ).plan_for(path) |
Instance Method Details
#plan ⇒ Object
40 41 42 43 |
# File 'lib/kumi/core/compiler/access_planner.rb', line 40 def plan .each_key { |root| walk_and_emit([root.to_s]) } @plans end |
#plan_for(path) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/kumi/core/compiler/access_planner.rb', line 45 def plan_for(path) segs = path.split(".") ensure_path!(segs) emit_for_segments(segs, explicit_mode: @defaults[:mode]) @plans end |