From: Rich Lane <rlane@club.cc.cmu.edu>
To: sup-talk@rubyforge.org
Subject: [sup-talk] [PATCH] xapian: replace DocumentMethods module with plain monkeypatching
Date: Mon, 19 Oct 2009 23:14:07 -0700 [thread overview]
Message-ID: <1256019247-6046-1-git-send-email-rlane@club.cc.cmu.edu> (raw)
In-Reply-To: <20091012223449.GB31940@tilus.net>
---
lib/sup/xapian_index.rb | 47 ++++++++++++++++++++++-------------------------
1 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
index ad45b0e..34d67d5 100644
--- a/lib/sup/xapian_index.rb
+++ b/lib/sup/xapian_index.rb
@@ -565,35 +565,32 @@ EOS
raise "Invalid term type #{type}"
end
end
+end
- module DocumentMethods
- def entry
- Marshal.load data
- end
-
- def entry=(x)
- self.data = Marshal.dump x
- end
+end
- def index_text text, prefix, weight=1
- term_generator = Xapian::TermGenerator.new
- term_generator.stemmer = Xapian::Stem.new(STEM_LANGUAGE)
- term_generator.document = self
- term_generator.index_text text, weight, prefix
- end
+class Xapian::Document
+ def entry
+ Marshal.load data
+ end
- def add_term term
- if term.length <= MAX_TERM_LENGTH
- super term
- else
- warn "dropping excessively long term #{term}"
- end
- end
+ def entry=(x)
+ self.data = Marshal.dump x
end
-end
-end
+ def index_text text, prefix, weight=1
+ term_generator = Xapian::TermGenerator.new
+ term_generator.stemmer = Xapian::Stem.new(Redwood::XapianIndex::STEM_LANGUAGE)
+ term_generator.document = self
+ term_generator.index_text text, weight, prefix
+ end
-class Xapian::Document
- include Redwood::XapianIndex::DocumentMethods
+ alias old_add_term add_term
+ def add_term term
+ if term.length <= Redwood::XapianIndex::MAX_TERM_LENGTH
+ old_add_term term
+ else
+ warn "dropping excessively long term #{term}"
+ end
+ end
end
--
1.6.4.2
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk
next prev parent reply other threads:[~2009-10-20 6:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-12 22:34 [sup-talk] Xapian: Term too long Tero Tilus
2009-10-15 12:59 ` William Morgan
2009-10-20 5:34 ` [sup-talk] [PATCH] xapian: replace DocumentMethods module with plain monkeypatching Rich Lane
2009-10-20 6:13 ` Rich Lane
2009-10-20 6:14 ` Rich Lane [this message]
2009-11-02 19:28 ` 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=1256019247-6046-1-git-send-email-rlane@club.cc.cmu.edu \
--to=rlane@club.cc.cmu.edu \
--cc=sup-talk@rubyforge.org \
/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