[Groonga-commit] groonga/groonga at 2998ab0 [master] logical_count: check nonexistent logical table

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Nov 7 16:15:51 JST 2017


Kouhei Sutou	2017-11-07 16:15:51 +0900 (Tue, 07 Nov 2017)

  New Revision: 2998ab08f3b15c4bde9538119ad00fb56c60a1b9
  https://github.com/groonga/groonga/commit/2998ab08f3b15c4bde9538119ad00fb56c60a1b9

  Message:
    logical_count: check nonexistent logical table

  Added files:
    test/command/suite/sharding/logical_count/nonexistent_logical_table.expected
    test/command/suite/sharding/logical_count/nonexistent_logical_table.test
  Modified files:
    plugins/sharding/logical_count.rb

  Modified: plugins/sharding/logical_count.rb (+9 -0)
===================================================================
--- plugins/sharding/logical_count.rb    2017-11-07 14:34:15 +0900 (de0039c20)
+++ plugins/sharding/logical_count.rb    2017-11-07 16:15:51 +0900 (3dbc0d79a)
@@ -17,9 +17,18 @@ module Groonga
 
         counter = Counter.new(input, enumerator.target_range)
         total = 0
+        have_shard = false
         enumerator.each do |shard, shard_range|
+          have_shard = true
           total += counter.count(shard, shard_range)
         end
+        unless have_shard
+          message =
+            "[logical_count] no shard exists: " +
+            "logical_table: <#{enumerator.logical_table}>: " +
+            "shard_key: <#{enumerator.shard_key_name}>"
+          raise InvalidArgument, message
+        end
         writer.write(total)
       end
 

  Added: test/command/suite/sharding/logical_count/nonexistent_logical_table.expected (+13 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_count/nonexistent_logical_table.expected    2017-11-07 16:15:51 +0900 (5efa647e6)
@@ -0,0 +1,13 @@
+plugin_register sharding
+[[0,0.0,0.0],true]
+logical_count   --logical_table Nonexistent   --shard_key created_at
+[
+  [
+    [
+      -22,
+      0.0,
+      0.0
+    ],
+    "[logical_count] no shard exists: logical_table: <Nonexistent>: shard_key: <created_at>"
+  ]
+]

  Added: test/command/suite/sharding/logical_count/nonexistent_logical_table.test (+7 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_count/nonexistent_logical_table.test    2017-11-07 16:15:51 +0900 (39465e8c1)
@@ -0,0 +1,7 @@
+#@on-error omit
+plugin_register sharding
+#@on-error default
+
+logical_count \
+  --logical_table Nonexistent \
+  --shard_key created_at
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171107/ded03d11/attachment-0001.htm 



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