Sha256: 7a834d21ed289b21b3b66d23eda74085ee924675aaeb60b05a307cc50065f3a3

Contents?: true

Size: 863 Bytes

Versions: 6

Compression:

Stored size: 863 Bytes

Contents

module Groonga
  module ExpressionTree
    class LogicalOperation
      attr_reader :operator
      attr_reader :nodes
      def initialize(operator, nodes)
        @operator = operator
        @nodes = nodes
      end

      def build(expression)
        @nodes.each_with_index do |node, i|
          node.build(expression)
          expression.append_operator(@operator, 2) if i > 0
        end
      end

      def estimatable?
        @nodes.all? do |node|
          node.estimatable?
        end
      end

      def estimate_size(table)
        estimated_sizes = @nodes.collect do |node|
          node.estimate_size(table)
        end
        case @operator
        when Operator::AND
          estimated_sizes.min
        when Operator::OR
          estimated_sizes.max
        else
          estimated_sizes.first
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rroonga-9.0.7-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/expression_tree/logical_operation.rb
rroonga-9.0.7-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/expression_tree/logical_operation.rb
rroonga-9.0.3-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/expression_tree/logical_operation.rb
rroonga-9.0.3-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/expression_tree/logical_operation.rb
rroonga-9.0.2-x64-mingw32 vendor/local/lib/groonga/scripts/ruby/expression_tree/logical_operation.rb
rroonga-9.0.2-x86-mingw32 vendor/local/lib/groonga/scripts/ruby/expression_tree/logical_operation.rb