diff options
Diffstat (limited to 'storage/mroonga/vendor/groonga/lib/mrb/scripts/expression.rb')
-rw-r--r-- | storage/mroonga/vendor/groonga/lib/mrb/scripts/expression.rb | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression.rb b/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression.rb index 7b1199b7795..27dadcb7aca 100644 --- a/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression.rb +++ b/storage/mroonga/vendor/groonga/lib/mrb/scripts/expression.rb @@ -1,16 +1,48 @@ +require "expression_rewriter" +require "expression_rewriters" + +require "expression_tree_builder" + require "scan_info" require "scan_info_builder" +require "scan_info_data_size_estimator" require "expression_size_estimator" module Groonga class Expression - def build_scan_info(op, size) + def rewrite + rewritten = nil + begin + return nil unless ExpressionRewriters.enabled? + source = self + ExpressionRewriters.classes.each do |rewriter_class| + rewriter = rewriter_class.new(source) + new_rewritten = rewriter.rewrite + if new_rewritten + rewritten.close if rewritten + rewritten = new_rewritten + source = rewritten + end + end + rescue GroongaError => groonga_error + context.set_groonga_error(groonga_error) + rewritten.close if rewritten + rewritten = nil + rescue => error + context.record_error(:invalid_argument, error) + rewritten.close if rewritten + rewritten = nil + end + rewritten + end + + def build_scan_info(op, record_exist) begin - builder = ScanInfoBuilder.new(self, op, size) + builder = ScanInfoBuilder.new(self, op, record_exist) builder.build rescue => error - Context.instance.record_error(:invalid_argument, error) + context.record_error(:invalid_argument, error) nil end end |