[Groonga-commit] groonga/groonga at a9769d8 [master] logical_range_filter: add use_range_index parameter

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jul 8 11:22:49 JST 2015


Kouhei Sutou	2015-07-08 11:22:49 +0900 (Wed, 08 Jul 2015)

  New Revision: a9769d8d0118cde65e09982e92e0c099a55b88f8
  https://github.com/groonga/groonga/commit/a9769d8d0118cde65e09982e92e0c099a55b88f8

  Message:
    logical_range_filter: add use_range_index parameter
    
    It's a parameter for test. It should not be used for production.

  Added files:
    test/command/fixture/sharding/logical_range_filter/use_range_index/schema.grn
    test/command/suite/sharding/logical_range_filter/use_range_index/no/filter/sub_filter.expected
    test/command/suite/sharding/logical_range_filter/use_range_index/no/filter/sub_filter.test
    test/command/suite/sharding/logical_range_filter/use_range_index/yes/filter/sub_filter.expected
    test/command/suite/sharding/logical_range_filter/use_range_index/yes/filter/sub_filter.test
  Modified files:
    plugins/sharding/logical_range_filter.rb

  Modified: plugins/sharding/logical_range_filter.rb (+21 -0)
===================================================================
--- plugins/sharding/logical_range_filter.rb    2015-07-08 11:19:58 +0900 (94ae860)
+++ plugins/sharding/logical_range_filter.rb    2015-07-08 11:22:49 +0900 (51b78a6)
@@ -14,6 +14,7 @@ module Groonga
                  "offset",
                  "limit",
                  "output_columns",
+                 "use_range_index",
                ])
 
       def run_body(input)
@@ -56,6 +57,7 @@ module Groonga
       end
 
       class ExecuteContext
+        attr_reader :use_range_index
         attr_reader :enumerator
         attr_reader :order
         attr_reader :filter
@@ -68,6 +70,7 @@ module Groonga
         attr_reader :threshold
         def initialize(input)
           @input = input
+          @use_range_index = parse_use_range_index(@input["use_range_index"])
           @enumerator = LogicalEnumerator.new("logical_range_filter", @input)
           @order = parse_order(@input, :order)
           @filter = @input[:filter]
@@ -93,6 +96,17 @@ module Groonga
         end
 
         private
+        def parse_use_range_index(use_range_index)
+          case use_range_index
+          when "yes"
+            true
+          when "no"
+            false
+          else
+            nil
+          end
+        end
+
         def parse_order(input, name)
           order = input[name]
           return :ascending if order.nil?
@@ -223,6 +237,13 @@ module Groonga
 
         private
         def use_range_index?(range_index)
+          case****@conte*****_range_index
+          when true
+            return true
+          when false
+            return false
+          end
+
           current_limit =****@conte*****_limit
           if current_limit < 0
             return false

  Added: test/command/fixture/sharding/logical_range_filter/use_range_index/schema.grn (+59 -0) 100644
===================================================================
--- /dev/null
+++ test/command/fixture/sharding/logical_range_filter/use_range_index/schema.grn    2015-07-08 11:22:49 +0900 (e7a6da7)
@@ -0,0 +1,59 @@
+#@disable-logging
+
+#@on-error omit
+register sharding
+#@on-error default
+
+table_create Actions TABLE_PAT_KEY ShortText
+
+table_create Errors TABLE_PAT_KEY ShortText
+column_create Errors level COLUMN_SCALAR ShortText
+column_create Errors action COLUMN_SCALAR Actions
+
+column_create Actions errors_action COLUMN_INDEX Errors action
+
+
+table_create Terms TABLE_PAT_KEY ShortText \
+  --default_tokenizer TokenizerBigram \
+  --normalizer NormalizserAuto
+
+table_create Logs_20150203 TABLE_NO_KEY
+column_create Logs_20150203 timestamp COLUMN_SCALAR Time
+column_create Logs_20150203 memo COLUMN_SCALAR ShortText
+column_create Logs_20150203 action COLUMN_SCALAR Actions
+
+table_create Timestamp_20150203 TABLE_PAT_KEY Time
+column_create Timestamp_20150203 index COLUMN_INDEX Logs_20150203 timestamp
+
+column_create Terms index_20150203 COLUMN_INDEX|WITH_POSITION Logs_20150203 memo
+
+column_create Actions index_20150203 COLUMN_INDEX Logs_20150203 action
+
+
+table_create Logs_20150204 TABLE_NO_KEY
+column_create Logs_20150204 timestamp COLUMN_SCALAR Time
+column_create Logs_20150204 memo COLUMN_SCALAR ShortText
+column_create Logs_20150204 action COLUMN_SCALAR Actions
+
+table_create Timestamp_20150204 TABLE_PAT_KEY Time
+column_create Timestamp_20150204 index COLUMN_INDEX Logs_20150204 timestamp
+
+column_create Terms index_20150204 COLUMN_INDEX|WITH_POSITION Logs_20150204 memo
+
+column_create Actions index_20150204 COLUMN_INDEX Logs_20150204 action
+
+
+table_create Logs_20150205 TABLE_NO_KEY
+column_create Logs_20150205 timestamp COLUMN_SCALAR Time
+column_create Logs_20150205 memo COLUMN_SCALAR ShortText
+column_create Logs_20150205 action COLUMN_SCALAR Actions
+
+table_create Timestamp_20150205 TABLE_PAT_KEY Time
+column_create Timestamp_20150205 index COLUMN_INDEX Logs_20150205 timestamp
+
+column_create Terms index_20150205 COLUMN_INDEX|WITH_POSITION Logs_20150205 memo
+
+column_create Actions index_20150205 COLUMN_INDEX Logs_20150205 action
+
+
+#@enable-logging

  Added: test/command/suite/sharding/logical_range_filter/use_range_index/no/filter/sub_filter.expected (+85 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/use_range_index/no/filter/sub_filter.expected    2015-07-08 11:22:49 +0900 (870127b)
@@ -0,0 +1,85 @@
+load --table Errors
+[
+{
+    "_key": "error1",
+   "level": "critical",
+  "action": "Shutdown"
+}
+]
+[[0,0.0,0.0],1]
+load --table Logs_20150203
+[
+{
+  "timestamp": "2015-02-03 12:49:00",
+       "memo": "2015-02-03 12:49:00",
+     "action": "Start"
+}
+]
+[[0,0.0,0.0],1]
+load --table Logs_20150204
+[
+{
+  "timestamp": "2015-02-04 13:49:00",
+       "memo": "2015-02-04 13:49:00",
+     "action": "Start"
+},
+{
+  "timestamp": "2015-02-04 13:50:00",
+       "memo": "2015-02-04 13:50:00",
+     "action": "Shutdown"
+}
+]
+[[0,0.0,0.0],2]
+load --table Logs_20150205
+[
+{
+  "timestamp": "2015-02-05 13:49:00",
+       "memo": "2015-02-05 13:49:00",
+     "action": "Start"
+},
+{
+  "timestamp": "2015-02-05 13:50:00",
+       "memo": "2015-02-05 13:50:00",
+     "action": "Running"
+},
+{
+  "timestamp": "2015-02-05 13:51:00",
+       "memo": "2015-02-05 13:51:00",
+     "action": "Shutdown"
+}
+]
+[[0,0.0,0.0],3]
+logical_range_filter Logs timestamp   --use_range_index no   --filter 'sub_filter(action.errors_action, "level == \\"critical\\"")'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "action",
+        "Actions"
+      ],
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "Shutdown",
+      "2015-02-04 13:50:00",
+      1423025400.0
+    ],
+    [
+      "Shutdown",
+      "2015-02-05 13:51:00",
+      1423111860.0
+    ]
+  ]
+]

  Added: test/command/suite/sharding/logical_range_filter/use_range_index/no/filter/sub_filter.test (+56 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/use_range_index/no/filter/sub_filter.test    2015-07-08 11:22:49 +0900 (25e74ec)
@@ -0,0 +1,56 @@
+#@include fixture/sharding/logical_range_filter/use_range_index/schema.grn
+
+load --table Errors
+[
+{
+    "_key": "error1",
+   "level": "critical",
+  "action": "Shutdown"
+}
+]
+
+load --table Logs_20150203
+[
+{
+  "timestamp": "2015-02-03 12:49:00",
+       "memo": "2015-02-03 12:49:00",
+     "action": "Start"
+}
+]
+
+load --table Logs_20150204
+[
+{
+  "timestamp": "2015-02-04 13:49:00",
+       "memo": "2015-02-04 13:49:00",
+     "action": "Start"
+},
+{
+  "timestamp": "2015-02-04 13:50:00",
+       "memo": "2015-02-04 13:50:00",
+     "action": "Shutdown"
+}
+]
+
+load --table Logs_20150205
+[
+{
+  "timestamp": "2015-02-05 13:49:00",
+       "memo": "2015-02-05 13:49:00",
+     "action": "Start"
+},
+{
+  "timestamp": "2015-02-05 13:50:00",
+       "memo": "2015-02-05 13:50:00",
+     "action": "Running"
+},
+{
+  "timestamp": "2015-02-05 13:51:00",
+       "memo": "2015-02-05 13:51:00",
+     "action": "Shutdown"
+}
+]
+
+logical_range_filter Logs timestamp \
+  --use_range_index no \
+  --filter 'sub_filter(action.errors_action, "level == \\"critical\\"")'

  Added: test/command/suite/sharding/logical_range_filter/use_range_index/yes/filter/sub_filter.expected (+63 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/use_range_index/yes/filter/sub_filter.expected    2015-07-08 11:22:49 +0900 (a801fac)
@@ -0,0 +1,63 @@
+load --table Errors
+[
+{
+    "_key": "error1",
+   "level": "critical",
+  "action": "Shutdown"
+}
+]
+[[0,0.0,0.0],1]
+load --table Logs_20150203
+[
+{
+  "timestamp": "2015-02-03 12:49:00",
+       "memo": "2015-02-03 12:49:00",
+     "action": "Start"
+}
+]
+[[0,0.0,0.0],1]
+load --table Logs_20150204
+[
+{
+  "timestamp": "2015-02-04 13:49:00",
+       "memo": "2015-02-04 13:49:00",
+     "action": "Start"
+},
+{
+  "timestamp": "2015-02-04 13:50:00",
+       "memo": "2015-02-04 13:50:00",
+     "action": "Shutdown"
+}
+]
+[[0,0.0,0.0],2]
+load --table Logs_20150205
+[
+{
+  "timestamp": "2015-02-05 13:49:00",
+       "memo": "2015-02-05 13:49:00",
+     "action": "Start"
+},
+{
+  "timestamp": "2015-02-05 13:50:00",
+       "memo": "2015-02-05 13:50:00",
+     "action": "Running"
+},
+{
+  "timestamp": "2015-02-05 13:51:00",
+       "memo": "2015-02-05 13:51:00",
+     "action": "Shutdown"
+}
+]
+[[0,0.0,0.0],3]
+logical_range_filter Logs timestamp   --use_range_index yes   --filter 'sub_filter(action.errors_action, "level == \\"critical\\"")'
+[
+  [
+    [
+      -38,
+      0.0,
+      0.0
+    ],
+    "function not implemented: <selector only proc can't be called: <sub_filter>>(-38)"
+  ]
+]
+#|e| selector only proc can't be called: <sub_filter>

  Added: test/command/suite/sharding/logical_range_filter/use_range_index/yes/filter/sub_filter.test (+56 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/use_range_index/yes/filter/sub_filter.test    2015-07-08 11:22:49 +0900 (4d6645a)
@@ -0,0 +1,56 @@
+#@include fixture/sharding/logical_range_filter/use_range_index/schema.grn
+
+load --table Errors
+[
+{
+    "_key": "error1",
+   "level": "critical",
+  "action": "Shutdown"
+}
+]
+
+load --table Logs_20150203
+[
+{
+  "timestamp": "2015-02-03 12:49:00",
+       "memo": "2015-02-03 12:49:00",
+     "action": "Start"
+}
+]
+
+load --table Logs_20150204
+[
+{
+  "timestamp": "2015-02-04 13:49:00",
+       "memo": "2015-02-04 13:49:00",
+     "action": "Start"
+},
+{
+  "timestamp": "2015-02-04 13:50:00",
+       "memo": "2015-02-04 13:50:00",
+     "action": "Shutdown"
+}
+]
+
+load --table Logs_20150205
+[
+{
+  "timestamp": "2015-02-05 13:49:00",
+       "memo": "2015-02-05 13:49:00",
+     "action": "Start"
+},
+{
+  "timestamp": "2015-02-05 13:50:00",
+       "memo": "2015-02-05 13:50:00",
+     "action": "Running"
+},
+{
+  "timestamp": "2015-02-05 13:51:00",
+       "memo": "2015-02-05 13:51:00",
+     "action": "Shutdown"
+}
+]
+
+logical_range_filter Logs timestamp \
+  --use_range_index yes \
+  --filter 'sub_filter(action.errors_action, "level == \\"critical\\"")'
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index