Class: Kumi::Core::Compiler::AccessPlannerV2
- Inherits:
-
Object
- Object
- Kumi::Core::Compiler::AccessPlannerV2
- Defined in:
- lib/kumi/core/compiler/access_planner_v2.rb
Constant Summary collapse
- DEFAULTS =
{ on_missing: :error, key_policy: :indifferent }.freeze
Instance Attribute Summary collapse
-
#index_table ⇒ Object
readonly
Returns the value of attribute index_table.
-
#plans ⇒ Object
readonly
Returns the value of attribute plans.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(meta, options = {}, debug_on: false) ⇒ AccessPlannerV2
constructor
A new instance of AccessPlannerV2.
- #plan ⇒ Object
Constructor Details
#initialize(meta, options = {}, debug_on: false) ⇒ AccessPlannerV2
Returns a new instance of AccessPlannerV2.
12 13 14 15 16 17 18 |
# File 'lib/kumi/core/compiler/access_planner_v2.rb', line 12 def initialize(, = {}, debug_on: false) = @debug_on = debug_on @defaults = DEFAULTS.merge(.transform_keys(&:to_sym)) @plans = [] @index_table = {} end |
Instance Attribute Details
#index_table ⇒ Object (readonly)
Returns the value of attribute index_table.
7 8 9 |
# File 'lib/kumi/core/compiler/access_planner_v2.rb', line 7 def index_table @index_table end |
#plans ⇒ Object (readonly)
Returns the value of attribute plans.
7 8 9 |
# File 'lib/kumi/core/compiler/access_planner_v2.rb', line 7 def plans @plans end |
Class Method Details
.plan(meta, options = {}, debug_on: false) ⇒ Object
10 |
# File 'lib/kumi/core/compiler/access_planner_v2.rb', line 10 def self.plan(, = {}, debug_on: false) = new(, , debug_on:).plan |
Instance Method Details
#plan ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kumi/core/compiler/access_planner_v2.rb', line 20 def plan .each do |root_name, node| # Synthetic hop: implicit root hash → reach declared root by key steps = [{ kind: :property_access, key: root_name.to_s }] axes = [] # If the root itself is an array, open its loop at the root axis if node.container == :array steps << { kind: :array_loop, axis: root_name.to_s } axes << root_name.to_sym end # Emit normal plan for the root node # The root axes are always [], e.g. array :x (the container :x opens [:x], but is not inside that dim) walk([root_name.to_s], node, steps, axes, steps, []) # If the root array defines an index, emit a *synthetic* index plan now next unless node.container == :array && node.define_index emit_index_plan!( idx_name: node.define_index, fqn_prefix: root_name.to_s, axes: axes.dup, steps: steps.dup ) end @plans.sort_by! { |p| p.path_fqn } self end |