Permalink
Browse files

Improving paginate performance.

  • Loading branch information...
1 parent 0cc8988 commit 9e3647d2b064180f2e5f5848ca36967f0aca6e70 @JEG2 committed Feb 21, 2010
Showing with 11 additions and 21 deletions.
  1. +2 −1 CHANGELOG.rdoc
  2. +5 −7 TODO.rdoc
  3. +4 −13 lib/oklahoma_mixer/table_database.rb
View
@@ -9,7 +9,8 @@ Below is a complete listing of changes for each revision of Oklahoma Mixer.
* Added support for Table Databases queries on read only databases
* Added support for iteration blocks to Table Databases searches
* Modified Table Databases blocks to yield tuples consistent with the iterators
-* Improved count performance by removing unneeded document conversion
+* Improved count() performance by removing unneeded document conversion
+* Improved paginate() performance by avoiding double type conversion
== 0.3.0
View
@@ -3,10 +3,8 @@
The following is a list of planned expansions for Oklahoma Mixer in the order I
intend to address them.
-1. Resolve minor issues
- * Push :select down into all() call to speed up paginate()
-2. Include some higher level abstractions like mixed tables, queues, and shards
-3. Add support for Tokyo Tyrant
-4. Ensure Ruby 1.9 compatibility
-5. Write API documentation
-6. Add support for Tokyo Dystopia
+1. Include some higher level abstractions like mixed tables, queues, and shards
+2. Add support for Tokyo Tyrant
+3. Ensure Ruby 1.9 compatibility
+4. Write API documentation
+5. Add support for Tokyo Dystopia
@@ -178,22 +178,13 @@ def paginate(options)
results.per_page = (options[:per_page] || 30).to_i
fail Error::QueryError, ":per_page must be >= 1" if results.per_page < 1
results.total_entries = 0
- all( options.merge( :select => :keys_and_docs,
- :return => :aoa,
- :limit => nil ) ) do |key, value|
+ all(options.merge(:limit => nil)) do |kv|
if results.total_entries >= results.offset and
results.size < results.per_page
- case mode
- when :keys
- results << key
- when :docs
- results << value
- when :hoh
- results[key] = value
- when :aoh
- results << value.merge(:primary_key => key)
+ if mode == :hoh
+ results[kv.first] = kv.last
else
- results << [key, value]
+ results << kv
end
end
results.total_entries += 1

0 comments on commit 9e3647d

Please sign in to comment.