Kouhei Sutou
null+****@clear*****
Mon Oct 30 17:26:17 JST 2017
Kouhei Sutou 2017-10-30 17:26:17 +0900 (Mon, 30 Oct 2017) New Revision: 57dd9c1ad4d0b90991a54fe71a8c708436d001f3 https://github.com/ranguba/groonga-client/commit/57dd9c1ad4d0b90991a54fe71a8c708436d001f3 Message: index-check: define shortcut method Modified files: lib/groonga/client/command-line/groonga-client-index-check.rb lib/groonga/client/command-line/groonga-client-index-recreate.rb lib/groonga/client/command-line/runner.rb Modified: lib/groonga/client/command-line/groonga-client-index-check.rb (+13 -16) =================================================================== --- lib/groonga/client/command-line/groonga-client-index-check.rb 2017-10-30 17:22:58 +0900 (c076c80) +++ lib/groonga/client/command-line/groonga-client-index-check.rb 2017-10-30 17:26:17 +0900 (c13d6e8) @@ -129,10 +129,9 @@ module Groonga end def list_tokens(table_name) - response = execute_command(:select, - :table => table_name, - :limit => "-1", - :output_columns => "_key") + response = select(table_name, + :limit => "-1", + :output_columns => "_key") response.records.collect do |record| record["_key"] end @@ -148,18 +147,16 @@ module Groonga else value = token end - old_response = execute_command(:select, - :table => source_table, - :filter => "#{full_old_column} @ #{value}", - :output_columns => "_id", - :limit => "-1", - :sort_keys => "_id") - new_response = execute_command(:select, - :table => source_table, - :filter => "#{full_new_column} @ #{value}", - :output_columns => "_id", - :limit => "-1", - :sort_keys => "_id") + old_response = select(source_table, + :filter => "#{full_old_column} @ #{value}", + :output_columns => "_id", + :limit => "-1", + :sort_keys => "_id") + new_response = select(source_table, + :filter => "#{full_new_column} @ #{value}", + :output_columns => "_id", + :limit => "-1", + :sort_keys => "_id") old_response_ids = old_response.records.collect do |record| record["_id"] end Modified: lib/groonga/client/command-line/groonga-client-index-recreate.rb (+3 -4) =================================================================== --- lib/groonga/client/command-line/groonga-client-index-recreate.rb 2017-10-30 17:22:58 +0900 (be01833) +++ lib/groonga/client/command-line/groonga-client-index-recreate.rb 2017-10-30 17:26:17 +0900 (1e9238e) @@ -122,10 +122,9 @@ module Groonga def resolve_alias(alias_column, key) table, column = alias_column.split(".", 2) filter = "_key == #{ScriptSyntax.format_string(key)}" - response = execute_command(:select, - :table => table, - :filter => filter, - :output_columns => column) + response = select(table, + :filter => filter, + :output_columns => column) return nil if response.n_hits.zero? response.records.first[column] end Modified: lib/groonga/client/command-line/runner.rb (+5 -0) =================================================================== --- lib/groonga/client/command-line/runner.rb 2017-10-30 17:22:58 +0900 (3bd3623) +++ lib/groonga/client/command-line/runner.rb 2017-10-30 17:26:17 +0900 (d6a0c96) @@ -84,6 +84,11 @@ module Groonga :name => name, :new_name => new_name).body end + + def select(table, arguments={}) + execute_command(:select, + arguments.merge(:table => table)) + end end end end -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171030/77b62c96/attachment-0001.htm