[Groonga-commit] groonga/groonga at d880dc6 [master] logical_range_filter: support negative limit and offset

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Apr 2 18:21:49 JST 2015


Kouhei Sutou	2015-04-02 18:21:49 +0900 (Thu, 02 Apr 2015)

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

  Message:
    logical_range_filter: support negative limit and offset

  Added files:
    test/command/suite/sharding/logical_range_filter/limit/negative/all.expected
    test/command/suite/sharding/logical_range_filter/limit/negative/all.test
    test/command/suite/sharding/logical_range_filter/limit/negative/all_offset.expected
    test/command/suite/sharding/logical_range_filter/limit/negative/all_offset.test
    test/command/suite/sharding/logical_range_filter/limit/negative/partial.expected
    test/command/suite/sharding/logical_range_filter/limit/negative/partial.test
    test/command/suite/sharding/logical_range_filter/limit/negative/partial_offset.expected
    test/command/suite/sharding/logical_range_filter/limit/negative/partial_offset.test
  Modified files:
    plugins/sharding/logical_range_filter.rb

  Modified: plugins/sharding/logical_range_filter.rb (+37 -7)
===================================================================
--- plugins/sharding/logical_range_filter.rb    2015-04-02 17:42:41 +0900 (7461ad4)
+++ plugins/sharding/logical_range_filter.rb    2015-04-02 18:21:49 +0900 (014599c)
@@ -35,8 +35,19 @@ module Groonga
             if first_result_set
               writer.write_table_columns(first_result_set, output_columns)
             end
+            limit = context.limit
+            if limit < 0
+              n_records = result_sets.inject(0) do |n, result_set|
+                n + result_set.size
+              end
+              limit = n_records + limit + 1
+            end
+            options = {}
             result_sets.each do |result_set|
-              writer.write_table_records(result_set, output_columns)
+              options[:limit] = limit
+              writer.write_table_records(result_set, output_columns, options)
+              limit -= result_set.size
+              break if limit <= 0
             end
           end
         ensure
@@ -63,7 +74,7 @@ module Groonga
           @offset = (@input[:offset] || 0).to_i
           @limit = (@input[:limit] || 10).to_i
 
-          @current_offset = 0
+          @current_offset = @offset
           @current_limit = @limit
 
           @result_sets = []
@@ -207,7 +218,12 @@ module Groonga
 
         private
         def use_range_index?(range_index)
-          required_n_records =****@conte*****_offset +****@conte*****_limit
+          current_limit =****@conte*****_limit
+          if current_limit < 0
+            return false
+          end
+
+          required_n_records =****@conte*****_offset + current_limit
           max_n_records =****@table*****
           if max_n_records <= required_n_records
             return false
@@ -305,8 +321,13 @@ module Groonga
                              :flags => flags) do |table_cursor|
               options = {
                 :offset => @context.current_offset,
-                :limit => @context.current_limit,
               }
+              current_limit =****@conte*****_limit
+              if current_limit < 0
+                options[:limit] = data_table.size
+              else
+                options[:limit] = current_limit
+              end
               if @filter
                 create_expression(data_table) do |expression|
                   expression.parse(@filter)
@@ -335,7 +356,9 @@ module Groonga
           if****@conte*****_offset > 0
             @context.current_offset = 0
           end
-          @context.current_limit -= result_set.size
+          if****@conte*****_limit > 0
+            @context.current_limit -= result_set.size
+          end
           @result_sets << result_set
         end
 
@@ -389,14 +412,21 @@ module Groonga
               :order => @context.order,
             },
           ]
+          if****@conte*****_limit > 0
+            limit =****@conte*****_limit
+          else
+            limit = result_set.size
+          end
           sorted_result_set = result_set.sort(sort_keys,
                                               :offset => @context.current_offset,
-                                              :limit => @context.current_limit)
+                                              :limit => limit)
           @result_sets << sorted_result_set
           if****@conte*****_offset > 0
             @context.current_offset = 0
           end
-          @context.current_limit -= sorted_result_set.size
+          if****@conte*****_limit > 0
+            @context.current_limit -= sorted_result_set.size
+          end
         end
       end
     end

  Added: test/command/suite/sharding/logical_range_filter/limit/negative/all.expected (+75 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/limit/negative/all.expected    2015-04-02 18:21:49 +0900 (a2196a3)
@@ -0,0 +1,75 @@
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Shutdown"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Shutdown"}
+]
+[[0,0.0,0.0],4]
+load --table Logs_20150204
+[
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Shutdown"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Shutdown"}
+]
+[[0,0.0,0.0],6]
+load --table Logs_20150205
+[
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Shutdown"}
+]
+[[0,0.0,0.0],4]
+logical_range_filter Logs timestamp   --filter 'message == "Shutdown"'   --min "2015-02-03 23:59:59"   --min_border "include"   --max "2015-02-05 00:00:00"   --max_border "include"   --limit -1
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "message",
+        "Text"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-03 23:59:59",
+      "Shutdown",
+      1422975599.0
+    ],
+    [
+      "2015-02-04 00:00:00",
+      "Shutdown",
+      1422975600.0
+    ],
+    [
+      "2015-02-04 00:00:01",
+      "Shutdown",
+      1422975601.0
+    ],
+    [
+      "2015-02-04 23:59:59",
+      "Shutdown",
+      1423061999.0
+    ],
+    [
+      "2015-02-05 00:00:00",
+      "Shutdown",
+      1423062000.0
+    ]
+  ]
+]

  Added: test/command/suite/sharding/logical_range_filter/limit/negative/all.test (+36 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/limit/negative/all.test    2015-04-02 18:21:49 +0900 (5e5cecd)
@@ -0,0 +1,36 @@
+#@include fixture/sharding/logical_range_filter/index/schema.grn
+
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Shutdown"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Shutdown"}
+]
+
+load --table Logs_20150204
+[
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Shutdown"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Shutdown"}
+]
+
+load --table Logs_20150205
+[
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Shutdown"}
+]
+
+logical_range_filter Logs timestamp \
+  --filter 'message == "Shutdown"' \
+  --min "2015-02-03 23:59:59" \
+  --min_border "include" \
+  --max "2015-02-05 00:00:00" \
+  --max_border "include" \
+  --limit -1
+

  Added: test/command/suite/sharding/logical_range_filter/limit/negative/all_offset.expected (+65 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/limit/negative/all_offset.expected    2015-04-02 18:21:49 +0900 (2c08d0e)
@@ -0,0 +1,65 @@
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Shutdown"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Shutdown"}
+]
+[[0,0.0,0.0],4]
+load --table Logs_20150204
+[
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Shutdown"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Shutdown"}
+]
+[[0,0.0,0.0],6]
+load --table Logs_20150205
+[
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Shutdown"}
+]
+[[0,0.0,0.0],4]
+logical_range_filter Logs timestamp   --filter 'message == "Shutdown"'   --min "2015-02-03 23:59:59"   --min_border "include"   --max "2015-02-05 00:00:00"   --max_border "include"   --offset 2   --limit -1
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "message",
+        "Text"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-04 00:00:01",
+      "Shutdown",
+      1422975601.0
+    ],
+    [
+      "2015-02-04 23:59:59",
+      "Shutdown",
+      1423061999.0
+    ],
+    [
+      "2015-02-05 00:00:00",
+      "Shutdown",
+      1423062000.0
+    ]
+  ]
+]

  Added: test/command/suite/sharding/logical_range_filter/limit/negative/all_offset.test (+37 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/limit/negative/all_offset.test    2015-04-02 18:21:49 +0900 (553b4cb)
@@ -0,0 +1,37 @@
+#@include fixture/sharding/logical_range_filter/index/schema.grn
+
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Shutdown"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Shutdown"}
+]
+
+load --table Logs_20150204
+[
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Shutdown"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Shutdown"}
+]
+
+load --table Logs_20150205
+[
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Shutdown"}
+]
+
+logical_range_filter Logs timestamp \
+  --filter 'message == "Shutdown"' \
+  --min "2015-02-03 23:59:59" \
+  --min_border "include" \
+  --max "2015-02-05 00:00:00" \
+  --max_border "include" \
+  --offset 2 \
+  --limit -1
+

  Added: test/command/suite/sharding/logical_range_filter/limit/negative/partial.expected (+65 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/limit/negative/partial.expected    2015-04-02 18:21:49 +0900 (5a397d6)
@@ -0,0 +1,65 @@
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Shutdown"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Shutdown"}
+]
+[[0,0.0,0.0],4]
+load --table Logs_20150204
+[
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Shutdown"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Shutdown"}
+]
+[[0,0.0,0.0],6]
+load --table Logs_20150205
+[
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Shutdown"}
+]
+[[0,0.0,0.0],4]
+logical_range_filter Logs timestamp   --filter 'message == "Shutdown"'   --min "2015-02-03 23:59:59"   --min_border "include"   --max "2015-02-05 00:00:00"   --max_border "include"   --limit -3
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "message",
+        "Text"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-03 23:59:59",
+      "Shutdown",
+      1422975599.0
+    ],
+    [
+      "2015-02-04 00:00:00",
+      "Shutdown",
+      1422975600.0
+    ],
+    [
+      "2015-02-04 00:00:01",
+      "Shutdown",
+      1422975601.0
+    ]
+  ]
+]

  Added: test/command/suite/sharding/logical_range_filter/limit/negative/partial.test (+36 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/limit/negative/partial.test    2015-04-02 18:21:49 +0900 (1c80eb9)
@@ -0,0 +1,36 @@
+#@include fixture/sharding/logical_range_filter/index/schema.grn
+
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Shutdown"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Shutdown"}
+]
+
+load --table Logs_20150204
+[
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Shutdown"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Shutdown"}
+]
+
+load --table Logs_20150205
+[
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Shutdown"}
+]
+
+logical_range_filter Logs timestamp \
+  --filter 'message == "Shutdown"' \
+  --min "2015-02-03 23:59:59" \
+  --min_border "include" \
+  --max "2015-02-05 00:00:00" \
+  --max_border "include" \
+  --limit -3
+

  Added: test/command/suite/sharding/logical_range_filter/limit/negative/partial_offset.expected (+60 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/limit/negative/partial_offset.expected    2015-04-02 18:21:49 +0900 (b0a9801)
@@ -0,0 +1,60 @@
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Shutdown"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Shutdown"}
+]
+[[0,0.0,0.0],4]
+load --table Logs_20150204
+[
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Shutdown"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Shutdown"}
+]
+[[0,0.0,0.0],6]
+load --table Logs_20150205
+[
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Shutdown"}
+]
+[[0,0.0,0.0],4]
+logical_range_filter Logs timestamp   --filter 'message == "Shutdown"'   --min "2015-02-03 23:59:59"   --min_border "include"   --max "2015-02-05 00:00:00"   --max_border "include"   --offset 1   --limit -3
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        "memo",
+        "ShortText"
+      ],
+      [
+        "message",
+        "Text"
+      ],
+      [
+        "timestamp",
+        "Time"
+      ]
+    ],
+    [
+      "2015-02-04 00:00:00",
+      "Shutdown",
+      1422975600.0
+    ],
+    [
+      "2015-02-04 00:00:01",
+      "Shutdown",
+      1422975601.0
+    ]
+  ]
+]

  Added: test/command/suite/sharding/logical_range_filter/limit/negative/partial_offset.test (+37 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_range_filter/limit/negative/partial_offset.test    2015-04-02 18:21:49 +0900 (348507c)
@@ -0,0 +1,37 @@
+#@include fixture/sharding/logical_range_filter/index/schema.grn
+
+load --table Logs_20150203
+[
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:58", "memo": "2015-02-03 23:59:58", "message": "Shutdown"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-03 23:59:59", "memo": "2015-02-03 23:59:59", "message": "Shutdown"}
+]
+
+load --table Logs_20150204
+[
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:00", "memo": "2015-02-04 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-04 00:00:01", "memo": "2015-02-04 00:00:01", "message": "Shutdown"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Start"},
+{"timestamp": "2015-02-04 23:59:59", "memo": "2015-02-04 23:59:59", "message": "Shutdown"}
+]
+
+load --table Logs_20150205
+[
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:00", "memo": "2015-02-05 00:00:00", "message": "Shutdown"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Start"},
+{"timestamp": "2015-02-05 00:00:01", "memo": "2015-02-05 00:00:01", "message": "Shutdown"}
+]
+
+logical_range_filter Logs timestamp \
+  --filter 'message == "Shutdown"' \
+  --min "2015-02-03 23:59:59" \
+  --min_border "include" \
+  --max "2015-02-05 00:00:00" \
+  --max_border "include" \
+  --offset 1 \
+  --limit -3
+
-------------- next part --------------
HTML����������������������������...
Download 



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