[Groonga-commit] droonga/fluent-plugin-droonga at 2c767c9 [master] Introduce SearchResult class

Back to archive index

Yoji Shidara null+****@clear*****
Thu Dec 19 14:39:02 JST 2013


Yoji Shidara	2013-12-19 14:39:02 +0900 (Thu, 19 Dec 2013)

  New Revision: 2c767c9a7f4b03d8d81e7ba29f5a17be10e19f5e
  https://github.com/droonga/fluent-plugin-droonga/commit/2c767c9a7f4b03d8d81e7ba29f5a17be10e19f5e

  Merged ce62e72: Merge branch 'refactor-searcher'

  Message:
    Introduce SearchResult class

  Modified files:
    lib/droonga/searcher.rb

  Modified: lib/droonga/searcher.rb (+26 -15)
===================================================================
--- lib/droonga/searcher.rb    2013-12-19 14:11:42 +0900 (cd5e745)
+++ lib/droonga/searcher.rb    2013-12-19 14:39:02 +0900 (a699671)
@@ -114,14 +114,16 @@ module Droonga
     end
 
     class ResultFormatter
-      def initialize(search_request, result, condition, count, start_time)
+      def initialize(search_request, search_result)
         @request = search_request
         @context =****@reque*****
         @query =****@reque*****
-        @records = result
-        @start_time = start_time
-        @count = count
-        @condition = condition
+
+        @result = search_result
+        @records =****@resul*****
+        @start_time =****@resul*****_time
+        @count =****@resul*****
+        @condition =****@resul*****
       end
 
       def format
@@ -289,27 +291,36 @@ module Droonga
       end
     end
 
+    class SearchResult
+      attr_accessor :start_time, :condition, :records, :count
+
+      def initialize
+        @start_time = nil
+        @condition = nil
+        @records = nil
+        @count = nil
+      end
+    end
+
     class QuerySearcher
       def initialize(search_request)
         @request = search_request
         @context =****@reque*****
         @query =****@reque*****
-        @records = nil
-        @condition = nil
-        @start_time = nil
       end
 
       def search(results)
+        @result = SearchResult.new
         search_query(results)
+        @result.records # FIXME later, this should be just result
       end
 
       def need_output?
-        @records and****@query*****_key?("output")
+        @result.records and****@query*****_key?("output")
       end
 
       def format
-        # XXX too many arguments are passed to ResultFormatter
-        formatter = ResultFormatter.new(@request, @records, @condition, @count, @start_time)
+        formatter = ResultFormatter.new(@request, @result)
         formatter.format
       end
 
@@ -394,7 +405,7 @@ module Droonga
       def search_query(results)
         $log.trace("#{log_tag}: search_query: start")
 
-        @start_time = Time.now
+        @result.start_time = Time.now
         @records = results[@query["source"]]
 
         condition = @query["condition"]
@@ -403,13 +414,13 @@ module Droonga
         group_by = @query["groupBy"]
         apply_group_by!(group_by) if group_by
 
-        @count =****@recor*****
+        @result.count =****@recor*****
 
         sort_by = @query["sortBy"]
         apply_sort_by!(sort_by) if sort_by
 
         $log.trace("#{log_tag}: search_query: done")
-        @records
+        @result.records = @records
       end
 
       def apply_condition!(condition)
@@ -420,7 +431,7 @@ module Droonga
                    :condition => condition)
         @records =****@recor*****(expression)
         $log.trace("#{log_tag}: search_query: select: done")
-        @condition = expression
+        @result.condition = expression
       end
 
       def apply_group_by!(group_by)
-------------- next part --------------
HTML����������������������������...
다운로드 



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