diff options
Diffstat (limited to 'storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/logical_operation.rb')
-rw-r--r-- | storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/logical_operation.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/logical_operation.rb b/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/logical_operation.rb new file mode 100644 index 00000000..e8d494f8 --- /dev/null +++ b/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression_tree/logical_operation.rb @@ -0,0 +1,33 @@ +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 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 |