[Groonga-commit] droonga/fluent-plugin-droonga at c363236 [master] Use OPERATOR_CONVERSION_TABLE to convert operators

Back to archive index

Kouhei Sutou kou****@clear*****
Tue Dec 24 18:57:56 JST 2013


この間リリースしたRroongaで、"||"とかそのまま指定しても動く
ようにしたので、そもそもGroonga::Operator::XXXに変換しなくて
も大丈夫です!

In <c363236b25d27904be0ed5e2378659d4e51c7e95 �� jenkins.clear-code.com>
  "[Groonga-commit] droonga/fluent-plugin-droonga �� c363236 [master] Use OPERATOR_CONVERSION_TABLE to convert operators" on Tue, 24 Dec 2013 18:12:17 +0900,
  Yoji Shidara <null+groonga �� clear-code.com> wrote:

> Yoji Shidara	2013-12-24 18:12:17 +0900 (Tue, 24 Dec 2013)
> 
>   New Revision: c363236b25d27904be0ed5e2378659d4e51c7e95
>   https://github.com/droonga/fluent-plugin-droonga/commit/c363236b25d27904be0ed5e2378659d4e51c7e95
> 
>   Message:
>     Use OPERATOR_CONVERSION_TABLE to convert operators
> 
>   Modified files:
>     lib/droonga/searcher.rb
> 
>   Modified: lib/droonga/searcher.rb (+13 -17)
> ===================================================================
> --- lib/droonga/searcher.rb    2013-12-24 18:03:27 +0900 (2d023be)
> +++ lib/droonga/searcher.rb    2013-12-24 18:12:17 +0900 (bf62ecc)
> @@ -153,6 +153,12 @@ module Droonga
>      end
>  
>      class QuerySearcher
> +      OPERATOR_CONVERSION_TABLE = {
> +        "||" => Groonga::Operator::OR,
> +        "&&" => Groonga::Operator::AND,
> +        "-"  => Groonga::Operator::BUT
> +      }.freeze
> +
>        class << self
>          def search(search_request)
>            new(search_request).search
> @@ -196,16 +202,12 @@ module Droonga
>          if condition["query"]
>            options[:syntax] = :query
>            if condition["defaultOperator"]
> -            case condition["defaultOperator"]
> -            when "||"
> -              options[:default_operator] = Groonga::Operator::OR
> -            when "&&"
> -              options[:default_operator] = Groonga::Operator::AND
> -            when "-"
> -              options[:default_operator] = Groonga::Operator::BUT
> -            else
> -              raise "undefined operator assigned #{condition["default_operator"]}"
> +            default_operator_string = condition["defaultOperator"]
> +            default_operator = OPERATOR_CONVERSION_TABLE[default_operator_string]
> +            unless default_operator
> +              raise "undefined operator assigned #{default_operator_string}"
>              end
> +            options[:default_operator] = default_operator
>            end
>            if condition["allowPragma"]
>              options[:allow_pragma] = true
> @@ -227,14 +229,8 @@ module Droonga
>        end
>  
>        def parse_condition_array(source, expression, condition)
> -        case condition[0]
> -        when "||"
> -          operator = Groonga::Operator::OR
> -        when "&&"
> -          operator = Groonga::Operator::AND
> -        when "-"
> -          operator = Groonga::Operator::BUT
> -        else
> +        operator = OPERATOR_CONVERSION_TABLE[condition[0]]
> +        unless operator
>            raise "undefined operator assigned #{condition[0]}"
>          end
>          if condition[1]




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