Kouhei Sutou
null+****@clear*****
Mon May 19 15:41:24 JST 2014
Kouhei Sutou 2014-05-19 15:41:24 +0900 (Mon, 19 May 2014) New Revision: d6571bb01f609b33a74e9296bdc2c4029458b613 https://github.com/droonga/droonga-engine/commit/d6571bb01f609b33a74e9296bdc2c4029458b613 Message: dump: support reference vector Added files: test/command/suite/dump/record/vector/reference.catalog.json test/command/suite/dump/record/vector/reference.expected test/command/suite/dump/record/vector/reference.test Modified files: lib/droonga/plugins/dump.rb Modified: lib/droonga/plugins/dump.rb (+18 -1) =================================================================== --- lib/droonga/plugins/dump.rb 2014-05-19 15:34:29 +0900 (5796c8c) +++ lib/droonga/plugins/dump.rb 2014-05-19 15:41:24 +0900 (b8ef126) @@ -251,7 +251,8 @@ module Droonga table.each do |record| values = {} record.attributes.each do |key, value| - values[key] = value unless key.start_with?("_") + next if key.start_with?("_") + values[key] = normalize_record_value(value) end body = { "table" => table.name, @@ -263,6 +264,22 @@ module Droonga end end + def normalize_record_value(value) + case value + when Array + value.collect do |element| + case element + when Hash + element["_key"] + else + element + end + end + else + value + end + end + def dump_indexes each_index_columns do |column| dump_column(column) Added: test/command/suite/dump/record/vector/reference.catalog.json (+27 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/dump/record/vector/reference.catalog.json 2014-05-19 15:41:24 +0900 (b83c6cd) @@ -0,0 +1,27 @@ +{ + "datasets": { + "Droonga": { + "schema": { + "Tags": { + "type": "PatriciaTrie", + "keyType": "ShortText" + }, + "Memos": { + "type": "Hash", + "keyType": "ShortText", + "columns": { + "tags": { + "type": "Vector", + "valueType": "Tags" + } + } + }, + "Users": { + "type": "Hash", + "keyType": "ShortText" + } + }, + "fact": "Users" + } + } +} Added: test/command/suite/dump/record/vector/reference.expected (+213 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/dump/record/vector/reference.expected 2014-05-19 15:41:24 +0900 (b4d77bd) @@ -0,0 +1,213 @@ +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "type": "dump.start" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "type": "dump.start" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "type": "dump.start" +} +{ + "inReplyTo": "request-id", + "statusCode": 200, + "type": "dump.result", + "body": true +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "Hash", + "name": "Memos", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "table": "Memos", + "name": "tags", + "type": "Vector", + "valueType": "Tags", + "vectorOptions": { + "weight": false + } + }, + "type": "dump.column" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "PatriciaTrie", + "name": "Tags", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "Hash", + "name": "Users", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "table": "Memos", + "key": "Groonga newbie", + "values": { + "tags": [ + "Groonga", + "column store" + ] + } + }, + "type": "dump.record" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "type": "dump.end" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "Hash", + "name": "Memos", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "table": "Memos", + "name": "tags", + "type": "Vector", + "valueType": "Tags", + "vectorOptions": { + "weight": false + } + }, + "type": "dump.column" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "PatriciaTrie", + "name": "Tags", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "Hash", + "name": "Users", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "table": "Memos", + "key": "Groonga newbie", + "values": { + "tags": [ + "Groonga", + "column store" + ] + } + }, + "type": "dump.record" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "type": "dump.end" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "Hash", + "name": "Memos", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "table": "Memos", + "name": "tags", + "type": "Vector", + "valueType": "Tags", + "vectorOptions": { + "weight": false + } + }, + "type": "dump.column" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "PatriciaTrie", + "name": "Tags", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "type": "Hash", + "name": "Users", + "keyType": "ShortText" + }, + "type": "dump.table" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "body": { + "table": "Memos", + "key": "Groonga newbie", + "values": { + "tags": [ + "Groonga", + "column store" + ] + } + }, + "type": "dump.record" +} +{ + "inReplyTo": "request-id", + "dataset": "Droonga", + "type": "dump.end" +} Added: test/command/suite/dump/record/vector/reference.test (+21 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/dump/record/vector/reference.test 2014-05-19 15:41:24 +0900 (6a85f34) @@ -0,0 +1,21 @@ +#@require-catalog-version 2 +#@disable-logging +{ + "type": "add", + "dataset": "Droonga", + "body": { + "table": "Memos", + "key": "Groonga newbie", + "values": { + "tags" : [ + "Groonga", + "column store" + ] + } + } +} +#@enable-logging +{ + "type": "dump", + "dataset": "Droonga" +} -------------- next part -------------- HTML����������������������������...下載