[Groonga-commit] groonga/groonga at 0e2b5b1 [master] sharding: fix a bug that --min with December date doesn't cover target records

Back to archive index

Kouhei Sutou null+****@clear*****
Thu May 25 10:37:50 JST 2017


Kouhei Sutou	2017-05-25 10:37:50 +0900 (Thu, 25 May 2017)

  New Revision: 0e2b5b1e6e155ae5bcc4a90391b02aa259a50cfd
  https://github.com/groonga/groonga/commit/0e2b5b1e6e155ae5bcc4a90391b02aa259a50cfd

  Message:
    sharding: fix a bug that --min with December date doesn't cover target records

  Added files:
    test/command/suite/sharding/logical_select/range/min_last_month_per_month.expected
    test/command/suite/sharding/logical_select/range/min_last_month_per_month.test
  Modified files:
    plugins/sharding/logical_enumerator.rb

  Modified: plugins/sharding/logical_enumerator.rb (+5 -2)
===================================================================
--- plugins/sharding/logical_enumerator.rb    2017-05-25 09:59:25 +0900 (8fa388c)
+++ plugins/sharding/logical_enumerator.rb    2017-05-25 10:37:50 +0900 (d770c90)
@@ -186,8 +186,11 @@ module Groonga
 
         def least_over_time
           if @max_day.nil?
-            next_month = (1..11).include?(@month) ? @month+1 : 1
-            Time.local(@year, next_month, 1)
+            if @month == 12
+              Time.local(@year + 1, 1, 1)
+            else
+              Time.local(@year, @month + 1, 1)
+            end
           else
             Time.local(@year, @month, @max_day, 23, 59, 59, 999999)
           end

  Added: test/command/suite/sharding/logical_select/range/min_last_month_per_month.expected (+86 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_select/range/min_last_month_per_month.expected    2017-05-25 10:37:50 +0900 (ee4fd65)
@@ -0,0 +1,86 @@
+plugin_register sharding
+[[0,0.0,0.0],true]
+table_create Logs_201512 TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Logs_201512 timestamp COLUMN_SCALAR Time
+[[0,0.0,0.0],true]
+column_create Logs_201512 memo COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Times_201512 TABLE_PAT_KEY Time
+[[0,0.0,0.0],true]
+column_create Times_201512 timestamp_index COLUMN_INDEX Logs_201512 timestamp
+[[0,0.0,0.0],true]
+table_create Logs_201601 TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Logs_201601 timestamp COLUMN_SCALAR Time
+[[0,0.0,0.0],true]
+column_create Logs_201601 memo COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+table_create Times_201601 TABLE_PAT_KEY Time
+[[0,0.0,0.0],true]
+column_create Times_201601 timestamp_index COLUMN_INDEX Logs_201601 timestamp
+[[0,0.0,0.0],true]
+load --table Logs_201512
+[
+{
+  "timestamp": "2015-12-31 00:00:00",
+  "memo":      "2015-12-31 00:00:00"
+},
+{
+  "timestamp": "2015-12-31 23:59:59",
+  "memo":      "2015-12-31 23:59:59"
+}
+]
+[[0,0.0,0.0],2]
+load --table Logs_201601
+[
+{
+  "timestamp": "2016-01-01 00:00:00",
+  "memo":      "2016-01-01 00:00:00"
+}
+]
+[[0,0.0,0.0],1]
+logical_select Logs timestamp   --min "2015-12-31 00:00:00"   --min_border "include"
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        3
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "memo",
+          "ShortText"
+        ],
+        [
+          "timestamp",
+          "Time"
+        ]
+      ],
+      [
+        1,
+        "2015-12-31 00:00:00",
+        1451487600.0
+      ],
+      [
+        2,
+        "2015-12-31 23:59:59",
+        1451573999.0
+      ],
+      [
+        1,
+        "2016-01-01 00:00:00",
+        1451574000.0
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/sharding/logical_select/range/min_last_month_per_month.test (+39 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_select/range/min_last_month_per_month.test    2017-05-25 10:37:50 +0900 (f2222ad)
@@ -0,0 +1,39 @@
+#@on-error omit
+plugin_register sharding
+#@on-error default
+
+table_create Logs_201512 TABLE_NO_KEY
+column_create Logs_201512 timestamp COLUMN_SCALAR Time
+column_create Logs_201512 memo COLUMN_SCALAR ShortText
+table_create Times_201512 TABLE_PAT_KEY Time
+column_create Times_201512 timestamp_index COLUMN_INDEX Logs_201512 timestamp
+
+table_create Logs_201601 TABLE_NO_KEY
+column_create Logs_201601 timestamp COLUMN_SCALAR Time
+column_create Logs_201601 memo COLUMN_SCALAR ShortText
+table_create Times_201601 TABLE_PAT_KEY Time
+column_create Times_201601 timestamp_index COLUMN_INDEX Logs_201601 timestamp
+
+load --table Logs_201512
+[
+{
+  "timestamp": "2015-12-31 00:00:00",
+  "memo":      "2015-12-31 00:00:00"
+},
+{
+  "timestamp": "2015-12-31 23:59:59",
+  "memo":      "2015-12-31 23:59:59"
+}
+]
+
+load --table Logs_201601
+[
+{
+  "timestamp": "2016-01-01 00:00:00",
+  "memo":      "2016-01-01 00:00:00"
+}
+]
+
+logical_select Logs timestamp \
+  --min "2015-12-31 00:00:00" \
+  --min_border "include"
-------------- next part --------------
HTML����������������������������...
Télécharger 



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