Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: rlane@club.cc.cmu.edu (Rich Lane)
Subject: [sup-talk] [PATCH 12/18] remove last external uses of ferret docid
Date: Sat, 20 Jun 2009 13:50:11 -0700	[thread overview]
Message-ID: <1245531017-9907-13-git-send-email-rlane@club.cc.cmu.edu> (raw)
In-Reply-To: <1245531017-9907-12-git-send-email-rlane@club.cc.cmu.edu>

---
 bin/sup-sync-back       |    2 +-
 bin/sup-tweak-labels    |    6 +++---
 lib/sup/ferret_index.rb |   10 ++--------
 lib/sup/index.rb        |   12 +++++++-----
 4 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/bin/sup-sync-back b/bin/sup-sync-back
index 679e03a..8aa2039 100755
--- a/bin/sup-sync-back
+++ b/bin/sup-sync-back
@@ -17,7 +17,7 @@ def die msg
 end
 def has_any_from_source_with_label? index, source, label
   query = { :source_id => source.id, :label => label, :limit => 1 }
-  not Enumerable::Enumerator.new(index, :each_docid, query).map.empty?
+  not Enumerable::Enumerator.new(index, :each_id, query).map.empty?
 end
 
 opts = Trollop::options do
diff --git a/bin/sup-tweak-labels b/bin/sup-tweak-labels
index 95a3b03..a8115ea 100755
--- a/bin/sup-tweak-labels
+++ b/bin/sup-tweak-labels
@@ -83,14 +83,14 @@ begin
   query += ' ' + opts[:query] if opts[:query]
 
   parsed_query = index.parse_query query
-  docs = Enumerable::Enumerator.new(index, :each_docid, parsed_query).map
-  num_total = docs.size
+  ids = Enumerable::Enumerator.new(index, :each_id, parsed_query).map
+  num_total = ids.size
 
   $stderr.puts "Found #{num_total} documents across #{source_ids.length} sources. Scanning..."
 
   num_changed = num_scanned = 0
   last_info_time = start_time = Time.now
-  docs.each do |id|
+  ids.each do |id|
     num_scanned += 1
 
     m = index.build_message id
diff --git a/lib/sup/ferret_index.rb b/lib/sup/ferret_index.rb
index 53c19e0..a2c30ab 100644
--- a/lib/sup/ferret_index.rb
+++ b/lib/sup/ferret_index.rb
@@ -301,16 +301,10 @@ class FerretIndex < BaseIndex
     contacts.keys.compact
   end
 
-  def each_docid query={}
+  def each_id query={}
     ferret_query = build_ferret_query query
     results = @index_mutex.synchronize { @index.search ferret_query, :limit => (query[:limit] || :all) }
-    results.hits.map { |hit| yield hit.doc }
-  end
-    
-  def each_message query={}
-    each_docid query do |docid|
-      yield build_message(docid)
-    end
+    results.hits.map { |hit| yield @index[hit.doc][:message_id] }
   end
 
   def optimize
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index be0e870..45382f1 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -177,14 +177,16 @@ EOS
     unimplemented
   end
 
-  ## Yield each docid matching query
-  def each_docid query={}
+  ## Yield each message-id matching query
+  def each_id query={}
     unimplemented
   end
     
-  ## Yield each messages matching query
-  def each_message query={}
-    unimplemented
+  ## Yield each message matching query
+  def each_message query={}, &b
+    each_id query do |id|
+      yield build_message(id)
+    end
   end
 
   ## Implementation-specific optimization step
-- 
1.6.0.4



  reply	other threads:[~2009-06-20 20:50 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-20 20:49 [sup-talk] [PATCH 0/18] Xapian-based index Rich Lane
2009-06-20 20:50 ` [sup-talk] [PATCH 01/18] remove load_entry_for_id call in sup-recover-sources Rich Lane
2009-06-20 20:50   ` [sup-talk] [PATCH 02/18] remove load_entry_for_id call in DraftManager.discard Rich Lane
2009-06-20 20:50     ` [sup-talk] [PATCH 03/18] remove ferret entry from poll/sync interface Rich Lane
2009-06-20 20:50       ` [sup-talk] [PATCH 04/18] index: remove unused method load_entry_for_id Rich Lane
2009-06-20 20:50         ` [sup-talk] [PATCH 05/18] switch DraftManager to use Message.build_from_source Rich Lane
2009-06-20 20:50           ` [sup-talk] [PATCH 06/18] index: move has_any_from_source_with_label? to sup-sync-back Rich Lane
2009-06-20 20:50             ` [sup-talk] [PATCH 07/18] move source-related methods to SourceManager Rich Lane
2009-06-20 20:50               ` [sup-talk] [PATCH 08/18] index: remove unused method fresh_thread_id Rich Lane
2009-06-20 20:50                 ` [sup-talk] [PATCH 09/18] index: revert overeager opts->query rename in each_message_in_thread_for Rich Lane
2009-06-20 20:50                   ` [sup-talk] [PATCH 10/18] index: make wrap_subj methods private Rich Lane
2009-06-20 20:50                     ` [sup-talk] [PATCH 11/18] index: move Ferret-specific code to ferret_index.rb Rich Lane
2009-06-20 20:50                       ` Rich Lane [this message]
2009-06-20 20:50                         ` [sup-talk] [PATCH 13/18] add Message.indexable_{body, chunks, subject} Rich Lane
2009-06-20 20:50                           ` [sup-talk] [PATCH 14/18] index: choose index implementation with config entry or environment variable Rich Lane
2009-06-20 20:50                             ` [sup-talk] [PATCH 15/18] index: add xapian implementation Rich Lane
2009-06-20 20:50                               ` [sup-talk] [PATCH 16/18] fix String#ord monkeypatch Rich Lane
2009-06-20 20:50                                 ` [sup-talk] [PATCH 17/18] add limit argument to author_names_and_newness_for_thread Rich Lane
2009-06-20 20:50                                   ` [sup-talk] [PATCH 18/18] dont using SavingHash#[] for membership test Rich Lane
2009-06-22 14:46                                     ` Andrei Thorp
2009-06-24 16:30 ` [sup-talk] [PATCH 0/18] Xapian-based index William Morgan
2009-06-24 17:33   ` William Morgan
2009-06-26  2:00     ` Olly Betts
2009-06-26 13:49       ` William Morgan
2009-07-17 23:42         ` Richard Heycock
2009-07-23 10:23           ` Adeodato Simó
2009-07-25  4:53             ` Rich Lane
2009-07-25  9:21               ` Adeodato Simó
2009-07-25 19:59                 ` Rich Lane
2009-07-25 23:28                   ` Ingmar Vanhassel
2009-07-27 15:48                   ` William Morgan
2009-07-27 16:56                     ` Ingmar Vanhassel
2009-09-01  8:07                       ` Ingmar Vanhassel
2009-09-03 16:52                         ` Rich Lane
2009-07-27 17:06                     ` Rich Lane
2009-07-31 16:20                       ` Rich Lane
2009-08-12 13:05                         ` Ingmar Vanhassel
2009-08-12 14:32                           ` Nicolas Pouillard
2009-08-14  5:23                           ` Rich Lane
2009-07-27 15:46               ` William Morgan
2009-07-28 16:53                 ` Olly Betts
2009-07-28 17:01                   ` William Morgan
2009-07-28 13:47         ` Olly Betts
2009-07-28 15:07           ` William Morgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245531017-9907-13-git-send-email-rlane@club.cc.cmu.edu \
    --to=rlane@club.cc.cmu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox