[Groonga-commit] droonga/droonga-engine at 8f353b0 [master] Implement a new command to count up the totla number of records in the database

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Nov 21 16:00:58 JST 2014


YUKI Hiroshi	2014-11-21 16:00:58 +0900 (Fri, 21 Nov 2014)

  New Revision: 8f353b0d4d3e8c16c81826fecfef43c4b735fe88
  https://github.com/droonga/droonga-engine/commit/8f353b0d4d3e8c16c81826fecfef43c4b735fe88

  Message:
    Implement a new command to count up the totla number of records in the database

  Modified files:
    lib/droonga/plugins/system.rb

  Modified: lib/droonga/plugins/system.rb (+18 -0)
===================================================================
--- lib/droonga/plugins/system.rb    2014-11-21 15:41:00 +0900 (16c6d4d)
+++ lib/droonga/plugins/system.rb    2014-11-21 16:00:58 +0900 (5eadb51)
@@ -45,6 +45,24 @@ module Droonga
         step.handler = StatusHandler
         step.collector = Collectors::Or
       end
+
+      class NTotalRecordsHandler < Droonga::Handler
+        def handle(message)
+          n_records = 0
+          @context.database.tables.collect do |table|
+            n_records += table.size
+          end
+          {
+            "n_total_records" => n_records,
+          }
+        end
+      end
+
+      define_single_step do |step|
+        step.name = "system.n_total_records"
+        step.handler = NTotalRecordsHandler
+        step.collector = Collectors::Sum
+      end
     end
   end
 end
-------------- next part --------------
HTML����������������������������...
下載 



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