Yoji Shidara
null+****@clear*****
Thu Feb 27 13:39:56 JST 2014
Yoji Shidara 2014-02-27 13:39:56 +0900 (Thu, 27 Feb 2014) New Revision: 217680e5e61e0563bcd7dc7e1c4a8986911da514 https://github.com/droonga/fluent-plugin-droonga/commit/217680e5e61e0563bcd7dc7e1c4a8986911da514 Message: Change Schema to have dataset_name Modified files: lib/droonga/catalog/schema.rb lib/droonga/dispatcher.rb test/unit/catalog/test_schema.rb Modified: lib/droonga/catalog/schema.rb (+4 -1) =================================================================== --- lib/droonga/catalog/schema.rb 2014-02-27 13:30:37 +0900 (8c09f15) +++ lib/droonga/catalog/schema.rb 2014-02-27 13:39:56 +0900 (04668e5) @@ -233,7 +233,8 @@ module Droonga end attr_reader :tables - def initialize(data) + def initialize(dataset_name, data) + @dataset_name = dataset_name @data = data || [] @tables = {} @data.each do |table_name, table_data| @@ -247,6 +248,7 @@ module Droonga tables.each do |name, table| messages << { "type" => "table_create", + "dataset" => @dataset_name, "body" => table.to_table_create_body } end @@ -258,6 +260,7 @@ module Droonga columns.each do |column| messages << { "type" => "column_create", + "dataset" => @dataset_name, "body" => column.to_column_create_body } end Modified: lib/droonga/dispatcher.rb (+1 -2) =================================================================== --- lib/droonga/dispatcher.rb 2014-02-27 13:30:37 +0900 (f614f0a) +++ lib/droonga/dispatcher.rb 2014-02-27 13:39:56 +0900 (e0d5c2c) @@ -279,10 +279,9 @@ module Droonga def ensure_schema @catalog.datasets.each do |name, dataset| - schema = Droonga::Catalog::Schema.new(dataset["schema"]) + schema = Droonga::Catalog::Schema.new(name, dataset["schema"]) messages = schema.to_messages messages.each do |message| - message["dataset"] = name process_message(message) end end Modified: test/unit/catalog/test_schema.rb (+8 -4) =================================================================== --- test/unit/catalog/test_schema.rb 2014-02-27 13:30:37 +0900 (d490019) +++ test/unit/catalog/test_schema.rb 2014-02-27 13:39:56 +0900 (a86b951) @@ -17,25 +17,26 @@ require "droonga/catalog/schema" class CatalogSchemaTest < Test::Unit::TestCase private - def create_schema(data) - Droonga::Catalog::Schema.new(data) + def create_schema(dataset_name, data) + Droonga::Catalog::Schema.new(dataset_name, data) end class SchemaTest < self def test_schema_not_specified assert_equal([], - create_schema(nil).to_messages) + create_schema("dataset_name", nil).to_messages) end def test_no_table assert_equal([], - create_schema({}).to_messages) + create_schema("dataset_name", {}).to_messages) end def test_key_index assert_equal([ { "type" => "table_create", + "dataset" => "dataset_name", "body" => { "name" => "Term", "key_type" => "ShortText", @@ -45,6 +46,7 @@ class CatalogSchemaTest < Test::Unit::TestCase }, { "type" => "table_create", + "dataset" => "dataset_name", "body" => { "name" => "Store", "key_type" => "ShortText", @@ -53,6 +55,7 @@ class CatalogSchemaTest < Test::Unit::TestCase }, { "type" => "column_create", + "dataset" => "dataset_name", "body" => { "name" => "stores__key", "table" => "Term", @@ -63,6 +66,7 @@ class CatalogSchemaTest < Test::Unit::TestCase } ], create_schema( + "dataset_name", "Term" => { "type" => "PatriciaTrie", "keyType" => "ShortText", -------------- next part -------------- HTML����������������������������... 下載