[Groonga-commit] groonga/fluent-plugin-droonga [master] Enable offset and limit

Zurück zum Archiv-Index

Daijiro MORI null+****@clear*****
Thu Mar 28 10:12:13 JST 2013


Daijiro MORI	2013-03-28 10:12:13 +0900 (Thu, 28 Mar 2013)

  New Revision: 3a7235c031e71c853c69fea2703879bb679b31d1
  https://github.com/groonga/fluent-plugin-droonga/commit/3a7235c031e71c853c69fea2703879bb679b31d1

  Message:
    Enable offset and limit

  Modified files:
    lib/droonga/worker.rb

  Modified: lib/droonga/worker.rb (+8 -3)
===================================================================
--- lib/droonga/worker.rb    2013-03-26 19:09:18 +0900 (39fd3df)
+++ lib/droonga/worker.rb    2013-03-28 10:12:13 +0900 (b8d082e)
@@ -52,6 +52,8 @@ module Droonga
     def search_query(query)
       start_time = Time.now
       source = @context[query["source"]]
+      offset = query["offset"] || 0
+      limit = query["limit"] || 10
       columns = source.columns
       attributes = columns.collect do |column|
         {
@@ -61,9 +63,12 @@ module Droonga
         }
       end
       column_names = columns.collect(&:local_name)
-      records = source.collect do |record|
-        column_names.collect do |name|
-          record[name]
+      records = source.open_cursor(:offset => offset,
+                                   :limit => limit) do |cursor|
+        cursor.collect do |record|
+          column_names.collect do |name|
+            record[name]
+          end
         end
       end
       elapsed_time = Time.now.to_f - start_time.to_f
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index