[Groonga-commit] droonga/fluent-plugin-droonga at cb6137e [master] Store formated results in format method

Back to archive index

Yoji Shidara null+****@clear*****
Thu Dec 19 19:59:49 JST 2013


Yoji Shidara	2013-12-19 19:59:49 +0900 (Thu, 19 Dec 2013)

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

  Message:
    Store formated results in format method

  Modified files:
    lib/droonga/searcher.rb

  Modified: lib/droonga/searcher.rb (+16 -12)
===================================================================
--- lib/droonga/searcher.rb    2013-12-19 19:55:41 +0900 (1a2f13a)
+++ lib/droonga/searcher.rb    2013-12-19 19:59:49 +0900 (6aaac21)
@@ -349,7 +349,8 @@ module Droonga
 
         SUB_FORMATTERS.each do |name, sub_formatter_method_name|
           if need_element_output?(name)
-            method(sub_formatter_method_name).call(formatted_result)
+            formatted_result[name] =
+              method(sub_formatter_method_name).call
           end
         end
 
@@ -366,11 +367,11 @@ module Droonga
         elements.include?(element)
       end
 
-      def format_count(formatted_result)
-        formatted_result["count"] =****@resul*****
+      def format_count
+        @result.count
       end
 
-      def format_attributes(formatted_result)
+      def format_attributes
         # XXX IMPLEMENT ME!!!
         attributes = nil
         if****@reque*****_output?
@@ -383,27 +384,30 @@ module Droonga
           attributes = []
         end
 
-        formatted_result["attributes"] = attributes
+        attributes
       end
 
-      def format_records(formatted_result)
+      def format_records
         params =****@reque*****
 
         attributes = params["attributes"]
         target_attributes = normalize_target_attributes(attributes)
         offset = params["offset"] || 0
         limit = params["limit"] || 10
+        formatted_records = nil
         @result.records.open_cursor(:offset => offset, :limit => limit) do |cursor|
           if****@reque*****_output?
-            formatted_result["records"] = cursor.collect do |record|
+            formatted_records = cursor.collect do |record|
               complex_record(target_attributes, record)
             end
           else
-            formatted_result["records"] = cursor.collect do |record|
+            formatted_records = cursor.collect do |record|
               simple_record(target_attributes, record)
             end
           end
         end
+
+        formatted_records
       end
 
       def complex_record(attributes, record)
@@ -492,12 +496,12 @@ module Droonga
         /\A[a-zA-Z\#@$_][a-zA-Z\d\#@$_\-.]*\z/ === source
       end
 
-      def format_start_time(formatted_result)
-        formatted_result["startTime"] =****@resul*****_time.iso8601
+      def format_start_time
+        @result.start_time.iso8601
       end
 
-      def format_elapsed_time(formatted_result)
-        formatted_result["elapsedTime"] =****@resul*****_time.to_f -****@resul*****_time.to_f
+      def format_elapsed_time
+        @result.end_time.to_f -****@resul*****_time.to_f
       end
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



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