Kouhei Sutou
null+****@clear*****
Mon Apr 7 19:05:30 JST 2014
Kouhei Sutou 2014-04-07 19:05:30 +0900 (Mon, 07 Apr 2014) New Revision: b86e22bf7824f59a8a4591e33891219deb9cb680 https://github.com/droonga/fluent-plugin-droonga/commit/b86e22bf7824f59a8a4591e33891219deb9cb680 Message: Accept Integer as hash slicer's key Added files: test/command/suite/add/dimension/integer.catalog.json test/command/suite/add/dimension/integer.expected test/command/suite/add/dimension/integer.test Modified files: lib/droonga/catalog/collection_volume.rb Modified: lib/droonga/catalog/collection_volume.rb (+10 -1) =================================================================== --- lib/droonga/catalog/collection_volume.rb 2014-04-07 18:50:01 +0900 (c5d9def) +++ lib/droonga/catalog/collection_volume.rb 2014-04-07 19:05:30 +0900 (b531b30) @@ -48,7 +48,7 @@ module Droonga def choose_slice(record) return slices.first unless ratio_scaled_slicer? - key = record[dimension] + key = stringify_key(record[dimension]) hash = Zlib.crc32(key) min = 0 max =****@conti***** - 1 @@ -92,6 +92,15 @@ module Droonga result + slice.weight end end + + def stringify_key(key) + case key + when Integer + key.to_s + else + key + end + end end end end Added: test/command/suite/add/dimension/integer.catalog.json (+19 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/add/dimension/integer.catalog.json 2014-04-07 19:05:30 +0900 (9e8682f) @@ -0,0 +1,19 @@ +{ + "datasets": { + "Droonga": { + "schema": { + "Products": { + "type": "Hash", + "keyType": "Integer", + "columns": { + "name": { + "type": "Scalar", + "valueType": "ShortText" + } + } + } + }, + "fact": "Products" + } + } +} Added: test/command/suite/add/dimension/integer.expected (+57 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/add/dimension/integer.expected 2014-04-07 19:05:30 +0900 (e87a1d7) @@ -0,0 +1,57 @@ +[ + "droonga.message", + 0, + { + "inReplyTo": "request-id", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +[ + "droonga.message", + 0, + { + "inReplyTo": "request-id", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +[ + "droonga.message", + 0, + { + "inReplyTo": "request-id", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +[ + "droonga.message", + 0, + { + "inReplyTo": "request-id", + "statusCode": 200, + "type": "search.result", + "body": { + "products": { + "records": [ + [ + 1, + "Groonga" + ], + [ + 2, + "Droonga" + ], + [ + 3, + "Ruby" + ] + ] + } + } + } +] Added: test/command/suite/add/dimension/integer.test (+51 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/add/dimension/integer.test 2014-04-07 19:05:30 +0900 (8af3dc9) @@ -0,0 +1,51 @@ +#@require-catalog-version 2 +{ + "type": "add", + "dataset": "Droonga", + "body": { + "table": "Products", + "key": 1, + "values": { + "name": "Groonga" + } + } +} +{ + "type": "add", + "dataset": "Droonga", + "body": { + "table": "Products", + "key": 2, + "values": { + "name": "Droonga" + } + } +} +{ + "type": "add", + "dataset": "Droonga", + "body": { + "table": "Products", + "key": 3, + "values": { + "name": "Ruby" + } + } +} +{ + "type": "search", + "dataset": "Droonga", + "body": { + "queries": { + "products": { + "source": "Products", + "sortBy": ["_key"], + "output": { + "elements": ["records"], + "attributes": ["_key", "name"], + "limit": -1 + } + } + } + } +} -------------- next part -------------- HTML����������������������������...Download