From: Carl Worth Date: Tue, 13 Oct 2009 15:50:20 +0000 (-0700) Subject: xapian-dump: Add values to the dump as well. X-Git-Tag: 0.1~893 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=76e15cf673106758e33cc9a709da74dff3b5d4af;p=notmuch.git xapian-dump: Add values to the dump as well. --- diff --git a/xapian-dump.cc b/xapian-dump.cc index 9049b452..79a018d6 100644 --- a/xapian-dump.cc +++ b/xapian-dump.cc @@ -1,4 +1,4 @@ -/* xapian-dump: Dump document IDs and associated terms from a Xapian database +/* xapian-dump: Create a textual dump of a Xapian database. * * Copyright © 2009 Carl Worth * @@ -18,6 +18,20 @@ * Author: Carl Worth */ +/* Currently the dumped data includes: + * + * All document IDs + * + * And for each document ID: + * + * All terms + * All values + * + * Things not yet dumped include: + * + * Data associated with a document. + */ + #include #include @@ -26,16 +40,41 @@ using namespace std; static void -print_document (Xapian::Database db, Xapian::docid id) +print_document_terms (Xapian::Document doc) { Xapian::TermIterator i; - printf ("Document %u:\n", id); + printf ("Terms:\n"); - for (i = db.termlist_begin (id); i != db.termlist_end (id); i++) + for (i = doc.termlist_begin (); i != doc.termlist_end (); i++) cout << "\t" << *i << endl; } +static void +print_document_values (Xapian::Document doc) +{ + Xapian::ValueIterator i; + + printf ("Values:\n"); + + for (i = doc.values_begin (); i != doc.values_end (); i++) + cout << "\t" << i.get_valueno() << ": " << *i << endl; +} + +static void +print_document (Xapian::Database db, Xapian::docid id) +{ + Xapian::Document doc; + + printf ("Document %u:\n", id); + + doc = db.get_document (id); + + print_document_terms (doc); + + print_document_values (doc); +} + int main (int argc, char *argv[]) {