class NoSE::Plans::SortPlanStep

A query plan step performing external sort

Attributes

sort_fields[R]

Public Class Methods

apply(parent, state) click to toggle source

Check if an external sort can used (if a sort is the last step) @return [SortPlanStep]

# File lib/nose/plans/sort.rb, line 34
def self.apply(parent, state)
  fetched_all_ids = state.fields.none? { |f| f.is_a? Fields::IDField }
  resolved_predicates = state.eq.empty? && state.range.nil?
  can_order = !(state.order_by.to_set & parent.fields).empty?
  return nil unless fetched_all_ids && resolved_predicates && can_order

  new_state = state.dup
  new_state.order_by = []
  new_step = SortPlanStep.new(state.order_by, new_state)
  new_step.state.freeze

  new_step
end
new(sort_fields, state = nil) click to toggle source
Calls superclass method NoSE::Plans::PlanStep::new
# File lib/nose/plans/sort.rb, line 9
def initialize(sort_fields, state = nil)
  super()

  @sort_fields = sort_fields
  @state = state
end

Public Instance Methods

==(other) click to toggle source

Two sorting steps are equal if they sort on the same fields

# File lib/nose/plans/sort.rb, line 23
def ==(other)
  other.instance_of?(self.class) && @sort_fields == other.sort_fields
end
Also aliased as: eql?
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/nose/plans/sort.rb, line 28
def hash
  @sort_fields.map(&:id).hash
end
to_color() click to toggle source

:nocov:

Calls superclass method NoSE::Plans::PlanStep#to_color
# File lib/nose/plans/sort.rb, line 17
def to_color
  super + ' [' + @sort_fields.map(&:to_color).join(', ') + ']'
end