[Groonga-commit] groonga/groonga at 3417590 [master] test logical_range_filter: support --cache no

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Aug 7 13:07:44 JST 2015


Kouhei Sutou	2015-08-07 13:07:44 +0900 (Fri, 07 Aug 2015)

  New Revision: 34175902efb19e14b86f97d27c817066c562d89a
  https://github.com/groonga/groonga/commit/34175902efb19e14b86f97d27c817066c562d89a

  Message:
    test logical_range_filter: support --cache no

  Added files:
    test/command/suite/sharding/logical_range_filter/cache/default.expected
    test/command/suite/sharding/logical_range_filter/cache/default.test
    test/command/suite/sharding/logical_range_filter/cache/no.expected
    test/command/suite/sharding/logical_range_filter/cache/no.test
  Modified files:
    lib/mrb/scripts/command.rb

  Modified: lib/mrb/scripts/command.rb (+6 -3)
===================================================================
--- lib/mrb/scripts/command.rb    2015-08-07 11:39:11 +0900 (eaa769b)
+++ lib/mrb/scripts/command.rb    2015-08-07 13:07:44 +0900 (5bc1fbe)
@@ -28,7 +28,7 @@ module Groonga
       nil
     end
 
-    def cache_output(key)
+    def cache_output(key, options={})
       if key.nil?
         yield
       else
@@ -40,14 +40,17 @@ module Groonga
           query_logger.log(:cache, ":", "cache(#{cached_value.bytesize})")
         else
           yield
-          cache.update(key, context.output)
+          cache.update(key, context.output) if options[:update]
         end
       end
     end
 
     def run_internal(input)
       begin
-        cache_output(cache_key(input)) do
+        options = {
+          :update => (input["cache"] != "no"),
+        }
+        cache_output(cache_key(input), options) do
           run_body(input)
         end
       rescue GroongaError => groonga_error

  Added: test/command/suite/sharding/logical_range_filter/cache/default.expected (+69 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/cache/default.expected    2015-08-07 13:07:44 +0900 (a31a1d0)
@@ -0,0 +1,69 @@
+register sharding
+[[0,0.0,0.0],true]
+table_create Logs_20150203 TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Logs_20150203 timestamp COLUMN_SCALAR Time
+[[0,0.0,0.0],true]
+column_create Logs_20150203 memo COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59"}
+]
+[[0,0.0,0.0],4]
+logical_range_filter Logs timestamp --limit 1
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-03 23:59:58",
+      1422975598.0
+    ]
+  ]
+]
+#>logical_range_filter Logs timestamp --limit 1 --output_type json
+#<000000000000000 rc=0
+logical_range_filter Logs timestamp --limit 1
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-03 23:59:58",
+      1422975598.0
+    ]
+  ]
+]
+#>logical_range_filter Logs timestamp --limit 1 --output_type json
+#:000000000000000 cache(0)
+#<000000000000000 rc=0

  Added: test/command/suite/sharding/logical_range_filter/cache/default.test (+22 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/cache/default.test    2015-08-07 13:07:44 +0900 (3ec2a68)
@@ -0,0 +1,22 @@
+#@on-error omit
+register sharding
+#@on-error default
+
+table_create Logs_20150203 TABLE_NO_KEY
+column_create Logs_20150203 timestamp COLUMN_SCALAR Time
+column_create Logs_20150203 memo COLUMN_SCALAR ShortText
+
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59"}
+]
+
+#@sleep 1
+
+#@collect-query-log true
+logical_range_filter Logs timestamp --limit 1
+logical_range_filter Logs timestamp --limit 1
+#@collect-query-log false

  Added: test/command/suite/sharding/logical_range_filter/cache/no.expected (+68 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/cache/no.expected    2015-08-07 13:07:44 +0900 (0aee565)
@@ -0,0 +1,68 @@
+register sharding
+[[0,0.0,0.0],true]
+table_create Logs_20150203 TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Logs_20150203 timestamp COLUMN_SCALAR Time
+[[0,0.0,0.0],true]
+column_create Logs_20150203 memo COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59"}
+]
+[[0,0.0,0.0],4]
+logical_range_filter Logs timestamp --limit 1 --cache no
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-03 23:59:58",
+      1422975598.0
+    ]
+  ]
+]
+#>logical_range_filter Logs timestamp --limit 1 --cache no --output_type json
+#<000000000000000 rc=0
+logical_range_filter Logs timestamp --limit 1
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-03 23:59:58",
+      1422975598.0
+    ]
+  ]
+]
+#>logical_range_filter Logs timestamp --limit 1 --output_type json
+#<000000000000000 rc=0

  Added: test/command/suite/sharding/logical_range_filter/cache/no.test (+22 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/cache/no.test    2015-08-07 13:07:44 +0900 (179c962)
@@ -0,0 +1,22 @@
+#@on-error omit
+register sharding
+#@on-error default
+
+table_create Logs_20150203 TABLE_NO_KEY
+column_create Logs_20150203 timestamp COLUMN_SCALAR Time
+column_create Logs_20150203 memo COLUMN_SCALAR ShortText
+
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59"}
+]
+
+#@sleep 1
+
+#@collect-query-log true
+logical_range_filter Logs timestamp --limit 1 --cache no
+logical_range_filter Logs timestamp --limit 1
+#@collect-query-log false
-------------- next part --------------
HTML����������������������������...
Download 



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