From: rlane@club.cc.cmu.edu (Rich Lane)
Subject: [sup-talk] [PATCH 2/2] xapian index format versioning
Date: Sun, 16 Aug 2009 16:28:56 -0400 [thread overview]
Message-ID: <1250453934-sup-9651@zyrg.net> (raw)
In-Reply-To: <20090816200116.GA17272@chistera.yi.org>
---
How's this wording?
I've been thinking about a label log that would store every label
modification along with the timestamp, etc. This would make the awkward
downgrade-dump-upgrade step unnecessary. We could also flush it to disk
more often than the full index.
lib/sup/xapian_index.rb | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb
index 825e7a3..18b5050 100644
--- a/lib/sup/xapian_index.rb
+++ b/lib/sup/xapian_index.rb
@@ -8,6 +8,7 @@ module Redwood
# for searching due to precomputing thread membership.
class XapianIndex < BaseIndex
STEM_LANGUAGE = "english"
+ INDEX_VERSION = '1'
## dates are converted to integers for xapian, and are used for document ids,
## so we must ensure they're reasonably valid. this typically only affect
@@ -22,7 +23,18 @@ class XapianIndex < BaseIndex
end
def load_index
- @xapian = Xapian::WritableDatabase.new(File.join(@dir, "xapian"), Xapian::DB_CREATE_OR_OPEN)
+ path = File.join(@dir, 'xapian')
+ if File.exists? path
+ @xapian = Xapian::WritableDatabase.new(path, Xapian::DB_OPEN)
+ db_version = @xapian.get_metadata 'version'
+ db_version = '0' if db_version.empty?
+ if db_version != INDEX_VERSION
+ fail "This Sup version expects a v#{INDEX_VERSION} index, but you have an existing v#{db_version} index. Please downgrade to your previous version and dump your labels before upgrading to this version (then run sup-sync --restore)."
+ end
+ else
+ @xapian = Xapian::WritableDatabase.new(path, Xapian::DB_CREATE)
+ @xapian.set_metadata 'version', INDEX_VERSION
+ end
@term_generator = Xapian::TermGenerator.new()
@term_generator.stemmer = Xapian::Stem.new(STEM_LANGUAGE)
@enquire = Xapian::Enquire.new @xapian
--
1.6.4
next prev parent reply other threads:[~2009-08-16 20:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-16 19:35 [sup-talk] [PATCH 1/2] move all GDBM data into Xapian Rich Lane
2009-08-16 19:35 ` [sup-talk] [PATCH 2/2] xapian index format versioning Rich Lane
2009-08-16 20:01 ` Adeodato Simó
2009-08-16 20:28 ` Rich Lane [this message]
2009-08-17 16:08 ` Adeodato Simó
2009-08-22 14:35 ` William Morgan
2009-08-24 12:41 ` Nicolas Pouillard
2009-08-25 1:03 ` Rich Lane
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=1250453934-sup-9651@zyrg.net \
--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