Navigation Menu

Skip to content

Commit

Permalink
index-check: define shortcut method
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 30, 2017
1 parent 99b1030 commit 57dd9c1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
29 changes: 13 additions & 16 deletions lib/groonga/client/command-line/groonga-client-index-check.rb
Expand Up @@ -129,10 +129,9 @@ def check_source(column)
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
Expand All @@ -148,18 +147,16 @@ def verify_tokens(source_table, table_name, old_column, new_column, tokens)
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
Expand Down
Expand Up @@ -122,10 +122,9 @@ def set_alias(alias_column, alias_name, real_name)
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
Expand Down
5 changes: 5 additions & 0 deletions lib/groonga/client/command-line/runner.rb
Expand Up @@ -84,6 +84,11 @@ def column_rename(table, name, new_name)
:name => name,
:new_name => new_name).body
end

def select(table, arguments={})
execute_command(:select,
arguments.merge(:table => table))
end
end
end
end
Expand Down

0 comments on commit 57dd9c1

Please sign in to comment.