[Groonga-commit] droonga/droonga-engine at b38cf1a [master] Add system.object-count command (mainly for internal use)

Back to archive index

YUKI Hiroshi yuki****@clear*****
Wed Apr 22 11:10:36 JST 2015


言われてみればそうですね。

system.count-objects
system.object.count

必要に応じて機能を増やしやすいかどうか・「system」直下の名前が増えすぎな
いかどうかを考えると、
system.object.count
の方がいいでしょうか。count以外に何かやりたくなるか?と言われると、
今の段階では特には思いつきませんが。


Kouhei Sutou wrote:
>>      Add system.object-count command (mainly for internal use)
> 
> 「動詞-名詞(目的語?)」の方がいいんじゃないかなぁと思いま
> した。absorb-dataはそうですよね。
> 
> もう1階層増やすほうがいいんですかねぇ。system.object.countと
> か。
> 
> 
> 
> In <b38cf1afaa2c42e07c36f0238b5d18e034f62561 �� jenkins.clear-code.com>
>    "[Groonga-commit] droonga/droonga-engine �� b38cf1a [master] Add system.object-count command (mainly for internal use)" on Tue, 21 Apr 2015 21:31:44 +0900,
>    YUKI Hiroshi <null+groonga �� clear-code.com> wrote:
> 
>> YUKI Hiroshi	2015-04-21 21:31:44 +0900 (Tue, 21 Apr 2015)
>>
>>    New Revision: b38cf1afaa2c42e07c36f0238b5d18e034f62561
>>    https://github.com/droonga/droonga-engine/commit/b38cf1afaa2c42e07c36f0238b5d18e034f62561
>>
>>    Message:
>>      Add system.object-count command (mainly for internal use)
>>
>>    Added files:
>>      lib/droonga/plugins/system/object_count.rb
>>      test/command/suite/system/object-count/empty.expected
>>      test/command/suite/system/object-count/empty.test
>>      test/command/suite/system/object-count/record.catalog.json
>>      test/command/suite/system/object-count/record.expected
>>      test/command/suite/system/object-count/record.test
>>      test/command/suite/system/object-count/schema.catalog.json
>>      test/command/suite/system/object-count/schema.expected
>>      test/command/suite/system/object-count/schema.test
>>    Modified files:
>>      lib/droonga/plugins/system.rb
>>
>>    Modified: lib/droonga/plugins/system.rb (+1 -0)
>> ===================================================================
>> --- lib/droonga/plugins/system.rb    2015-04-21 21:26:26 +0900 (55434d1)
>> +++ lib/droonga/plugins/system.rb    2015-04-21 21:31:44 +0900 (2f4dea1)
>> @@ -25,4 +25,5 @@ module Droonga
>>   end
>>   
>>   require "droonga/plugins/system/status"
>> +require "droonga/plugins/system/object_count"
>>   require "droonga/plugins/system/absorb_data"
>>
>>    Added: lib/droonga/plugins/system/object_count.rb (+53 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ lib/droonga/plugins/system/object_count.rb    2015-04-21 21:31:44 +0900 (40dc304)
>> @@ -0,0 +1,53 @@
>> +# Copyright (C) 2015 Droonga Project
>> +#
>> +# This library is free software; you can redistribute it and/or
>> +# modify it under the terms of the GNU Lesser General Public
>> +# License version 2.1 as published by the Free Software Foundation.
>> +#
>> +# This library is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +# Lesser General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU Lesser General Public
>> +# License along with this library; if not, write to the Free Software
>> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
>> +
>> +require "droonga/plugin"
>> +require "droonga/database_scanner"
>> +
>> +module Droonga
>> +  module Plugins
>> +    module System
>> +      class ObjectCountHandler < Droonga::Handler
>> +        include DatabaseScanner
>> +
>> +        def handle(message)
>> +          counts = {}
>> +          output = message.request["output"]
>> +          if output and output.is_a?(Array)
>> +            if output.include?("tables")
>> +              counts["tables"] = n_tables
>> +            end
>> +            if output.include?("columns")
>> +              counts["columns"] = n_columns
>> +            end
>> +            if output.include?("records")
>> +              counts["records"] = n_records
>> +            end
>> +            if output.include?("total")
>> +              counts["total"] = total_n_objects
>> +            end
>> +          end
>> +          counts
>> +        end
>> +      end
>> +
>> +      define_single_step do |step|
>> +        step.name = "system.object-count"
>> +        step.handler = ObjectCountHandler
>> +        step.collector = Collectors::Sum
>> +      end
>> +    end
>> +  end
>> +end
>>
>>    Added: test/command/suite/system/object-count/empty.expected (+11 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ test/command/suite/system/object-count/empty.expected    2015-04-21 21:31:44 +0900 (4229827)
>> @@ -0,0 +1,11 @@
>> +{
>> +  "inReplyTo": "request-id",
>> +  "statusCode": 200,
>> +  "type": "system.object-count.result",
>> +  "body": {
>> +    "tables":  0,
>> +    "columns": 0,
>> +    "records": 0,
>> +    "total":   0
>> +  }
>> +}
>>
>>    Added: test/command/suite/system/object-count/empty.test (+12 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ test/command/suite/system/object-count/empty.test    2015-04-21 21:31:44 +0900 (1d7b179)
>> @@ -0,0 +1,12 @@
>> +{
>> +  "type": "system.object-count",
>> +  "dataset": "Default",
>> +  "body": {
>> +    "output": [
>> +      "tables",
>> +      "columns",
>> +      "records",
>> +      "total"
>> +    ]
>> +  }
>> +}
>>
>>    Added: test/command/suite/system/object-count/record.catalog.json (+12 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ test/command/suite/system/object-count/record.catalog.json    2015-04-21 21:31:44 +0900 (00eec13)
>> @@ -0,0 +1,12 @@
>> +{
>> +  "datasets": {
>> +    "Default": {
>> +      "schema": {
>> +        "Users": {
>> +          "type": "PatriciaTrie",
>> +          "keyType": "ShortText"
>> +        }
>> +      }
>> +    }
>> +  }
>> +}
>>
>>    Added: test/command/suite/system/object-count/record.expected (+11 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ test/command/suite/system/object-count/record.expected    2015-04-21 21:31:44 +0900 (565abec)
>> @@ -0,0 +1,11 @@
>> +{
>> +  "inReplyTo": "request-id",
>> +  "statusCode": 200,
>> +  "type": "system.object-count.result",
>> +  "body": {
>> +    "tables":  2,
>> +    "columns": 0,
>> +    "records": 1,
>> +    "total":   3
>> +  }
>> +}
>>
>>    Added: test/command/suite/system/object-count/record.test (+23 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ test/command/suite/system/object-count/record.test    2015-04-21 21:31:44 +0900 (6fd0a9e)
>> @@ -0,0 +1,23 @@
>> +#@require-catalog-version 2
>> +#@disable-logging
>> +{
>> +  "type": "add",
>> +  "dataset": "Source",
>> +  "body": {
>> +    "table": "Users",
>> +    "key": "Adam"
>> +  }
>> +}
>> +#@enable-logging
>> +{
>> +  "type": "system.object-count",
>> +  "dataset": "Default",
>> +  "body": {
>> +    "output": [
>> +      "tables",
>> +      "columns",
>> +      "records",
>> +      "total"
>> +    ]
>> +  }
>> +}
>>
>>    Added: test/command/suite/system/object-count/schema.catalog.json (+12 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ test/command/suite/system/object-count/schema.catalog.json    2015-04-21 21:31:44 +0900 (00eec13)
>> @@ -0,0 +1,12 @@
>> +{
>> +  "datasets": {
>> +    "Default": {
>> +      "schema": {
>> +        "Users": {
>> +          "type": "PatriciaTrie",
>> +          "keyType": "ShortText"
>> +        }
>> +      }
>> +    }
>> +  }
>> +}
>>
>>    Added: test/command/suite/system/object-count/schema.expected (+11 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ test/command/suite/system/object-count/schema.expected    2015-04-21 21:31:44 +0900 (e5321de)
>> @@ -0,0 +1,11 @@
>> +{
>> +  "inReplyTo": "request-id",
>> +  "statusCode": 200,
>> +  "type": "system.object-count.result",
>> +  "body": {
>> +    "tables":  2,
>> +    "columns": 0,
>> +    "records": 0,
>> +    "total":   2
>> +  }
>> +}
>>
>>    Added: test/command/suite/system/object-count/schema.test (+13 -0) 100644
>> ===================================================================
>> --- /dev/null
>> +++ test/command/suite/system/object-count/schema.test    2015-04-21 21:31:44 +0900 (18d9247)
>> @@ -0,0 +1,13 @@
>> +#@require-catalog-version 2
>> +{
>> +  "type": "system.object-count",
>> +  "dataset": "Default",
>> +  "body": {
>> +    "output": [
>> +      "tables",
>> +      "columns",
>> +      "records",
>> +      "total"
>> +    ]
>> +  }
>> +}
> 
> _______________________________________________
> Groonga-commit mailing list
> Groonga-commit �� lists.sourceforge.jp
> http://lists.sourceforge.jp/mailman/listinfo/groonga-commit
> 

-- 
結城 洋志 <YUKI Hiroshi>
E-mail: yuki �� clear-code.com

株式会社クリアコード
〒170-0005 東京都豊島区南大塚3-29-9
           中野ビル3階
TEL : 03-5927-9440
FAX : 03-5927-9441
WWW : http://www.clear-code.com/




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