Skip to content

Commit

Permalink
few comment fixes in view.rb and simple_skiplist.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Andreev committed May 2, 2008
1 parent a96a40b commit 913a7ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 7 additions & 2 deletions lib/strokedb/data_structures/simple_skiplist.rb
Expand Up @@ -42,7 +42,12 @@ def empty?
node_next(@head, 0) == @tail
end

# Complicated search algorithm
# Smart prefix search algorithm.
# Algorithm is two-step: find the first matching key,
# then collect all the values.
#
# 1) Define a direction of search
#
#
def search(start_key, end_key, limit, offset, reverse, with_keys)
offset ||= 0
Expand All @@ -56,7 +61,7 @@ def search(start_key, end_key, limit, offset, reverse, with_keys)
collect_values(start_node, end_key, limit, reverse, with_keys)
end

# TODO: add C routins for this to optimize performance
# TODO: add C routines for this to optimize performance
#
def find_by_prefix(start_key, reverse)
dir = dir_for_reverse(reverse)
Expand Down
15 changes: 12 additions & 3 deletions lib/strokedb/views/view.rb
Expand Up @@ -85,12 +85,21 @@ def clear!
# Examples:
# view.find # returns all the items in a view
# view.find(:limit => 1) # returns the first document in a view
# view.find(:offset => 10, :limit => 1) # returns 11-th document in a view
# view.find(:key => doc) # returns all items with a doc.uuid prefix
# view.find(:offset => 10, :limit => 1) # returns 11-th document in a view (Note: [doc] instead of doc)
# view.find(doc) # returns all items with a doc.uuid prefix
#
# # returns the latest 10 comments for a given document
# # (assuming the key defined as [comment.document, comment.created_at])
# has_many_comments.find(:key => doc, :limit => 10, :reverse => true)
# has_many_comments.find(doc, :limit => 10, :reverse => true)
#
# comments.find([doc, 2.days.ago..Time.now]) # returns doc's comments within a time interval
# # example above is equivalent to:
# a) find(:key => [doc, 2.days.ago..Time.now])
# b) find(:start_key => [doc, 2.days.ago], :end_key => [doc, Time.now])
#
# Effectively, first argument sets :key option, which in turn
# specifies :start_key and :end_key.
# Low-level search is performed using :start_key and :end_key only.
#
def find(key = nil, options = {})

Expand Down

0 comments on commit 913a7ce

Please sign in to comment.