[Groonga-commit] droonga/drnbench at 27394c7 [master] Add a command line utility to extract searc hterms from Groonga's select result

Back to archive index

Kouhei Sutou kou****@clear*****
Thu Jul 31 12:36:59 JST 2014


>     bin/drnbench-extract-searchterms

How about splitting "search" and "terms"?

In <27394c7707b61a3569d2345d606e89845e0899c9 ¡÷ jenkins.clear-code.com>
  "[Groonga-commit] droonga/drnbench ¡÷ 27394c7 [master] Add a command line utility to extract searc hterms from Groonga's select result" on Thu, 31 Jul 2014 11:17:10 +0900,
  YUKI Hiroshi <null+groonga ¡÷ clear-code.com> wrote:

> YUKI Hiroshi	2014-07-31 11:17:10 +0900 (Thu, 31 Jul 2014)
> 
>   New Revision: 27394c7707b61a3569d2345d606e89845e0899c9
>   https://github.com/droonga/drnbench/commit/27394c7707b61a3569d2345d606e89845e0899c9
> 
>   Message:
>     Add a command line utility to extract searc hterms from Groonga's select result
> 
>   Added files:
>     bin/drnbench-extract-searchterms
> 
>   Added: bin/drnbench-extract-searchterms (+56 -0) 100755
> ===================================================================
> --- /dev/null
> +++ bin/drnbench-extract-searchterms    2014-07-31 11:17:10 +0900 (e13c30f)
> @@ -0,0 +1,56 @@
> +#!/usr/bin/env ruby
> +#
> +# Copyright (C) 2014  Droonga Project
> +#
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +require "drnbench"
> +require "ostruct"
> +require "optparse"
> +require "json"
> +
> +options = OpenStruct.new
> +options.column_index = 0
> +
> +option_parser = OptionParser.new do |parser|
> +  parser.version = Drnbench::VERSION
> +
> +  parser.on("--column-index=INDEX", Integer,
> +            "Index number of the column to be extracted.",
> +            "(#{options.output_column_index})") do |index|
> +    options.column_index = index
> +  end
> +end
> +
> +groonga_select_result_files = option_parser.parse!(ARGV)
> +
> +def output_column_value(select_result, column_index)
> +  select_result = JSON.parse(select_result)
> +  body = select_result[1]
> +  search_result = body.first
> +  records = search_result[2..-1]
> +  records.each do |record|
> +    puts record[column_index]
> +  end
> +end
> +
> +if groonga_select_result_files.empty?
> +  output_column_value($stdin.read, options.column_index)
> +else
> +  groonga_select_result_files.each do |select_result_file|
> +    File.open(select_result_file) do |input|
> +      output_column_value(input.read, options.column_index)
> +    end
> +  end
> +end




More information about the Groonga-commit mailing list
Back to archive index