Kouhei Sutou
null+****@clear*****
Thu Feb 19 16:52:28 JST 2015
Kouhei Sutou 2015-02-19 16:52:28 +0900 (Thu, 19 Feb 2015) New Revision: b11aa99a2f6cf13c0e936377d931258d8857665a https://github.com/groonga/groonga/commit/b11aa99a2f6cf13c0e936377d931258d8857665a Message: mrb: support estimating size for GREATER_EQUAL operator Modified files: lib/mrb/scripts/expression_size_estimator.rb test/query_optimizer/suite/test_estimate_size.rb Modified: lib/mrb/scripts/expression_size_estimator.rb (+5 -1) =================================================================== --- lib/mrb/scripts/expression_size_estimator.rb 2015-02-19 16:51:14 +0900 (7c6d02b) +++ lib/mrb/scripts/expression_size_estimator.rb 2015-02-19 16:52:28 +0900 (3d34321) @@ -21,7 +21,8 @@ module Groonga size = estimate_match(data, search_index) when Operator::LESS, Operator::LESS_EQUAL, - Operator::GREATER + Operator::GREATER, + Operator::GREATER_EQUAL size = estimate_range(data, search_index) end size || @table.size @@ -61,6 +62,9 @@ module Groonga when Operator::GREATER options[:min] = value options[:flags] = TableCursorFlags::GT + when Operator::GREATER_EQUAL + options[:min] = value + options[:flags] = TableCursorFlags::GE end TableCursor.open(lexicon, options) do |cursor| index_column.estimate_size(:lexicon_cursor => cursor) Modified: test/query_optimizer/suite/test_estimate_size.rb (+31 -0) =================================================================== --- test/query_optimizer/suite/test_estimate_size.rb 2015-02-19 16:51:14 +0900 (6725253) +++ test/query_optimizer/suite/test_estimate_size.rb 2015-02-19 16:52:28 +0900 (cc51e27) @@ -135,4 +135,35 @@ class TestEstimateSize < QueryOptimizerTestCase assert_equal(8, estimate_size("timestamp > '2015-02-19 02:17:00'")) end end + + class TestGreaterEqualSearch < self + def setup + Groonga::Schema.define do |schema| + schema.create_table("Logs") do |table| + table.time("timestamp") + end + + schema.create_table("Times", + :type => :patricia_trie, + :key_type => :time) do |table| + table.index("Logs", "timestamp") + end + end + super + end + + def test_no_record + assert_equal(0, estimate_size("timestamp >= '2015-02-19 02:18:00'")) + end + + def test_have_record + @logs.add(:timestamp => "2015-02-19 02:17:00") + @logs.add(:timestamp => "2015-02-19 02:17:00") + @logs.add(:timestamp => "2015-02-19 02:18:00") + @logs.add(:timestamp => "2015-02-19 02:18:00") + @logs.add(:timestamp => "2015-02-19 02:19:00") + @logs.add(:timestamp => "2015-02-19 02:19:00") + assert_equal(8, estimate_size("timestamp >= '2015-02-19 02:18:00'")) + end + end end -------------- next part -------------- HTML����������������������������...Download