00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <config.h>
00024
00025 #include <xapian/error.h>
00026 #include <xapian/types.h>
00027
00028 #include "flint_spellingwordslist.h"
00029 #include "flint_utils.h"
00030 #include "stringutils.h"
00031
00032 FlintSpellingWordsList::~FlintSpellingWordsList()
00033 {
00034 DEBUGCALL(DB, void, "~FlintSpellingWordsList", "");
00035 delete cursor;
00036 }
00037
00038 string
00039 FlintSpellingWordsList::get_termname() const
00040 {
00041 DEBUGCALL(DB, string, "FlintSpellingWordsList::get_termname", "");
00042 Assert(cursor);
00043 Assert(!at_end());
00044 Assert(!cursor->current_key.empty());
00045 Assert(cursor->current_key[0] == 'W');
00046 RETURN(cursor->current_key.substr(1));
00047 }
00048
00049 Xapian::doccount
00050 FlintSpellingWordsList::get_termfreq() const
00051 {
00052 DEBUGCALL(DB, string, "FlintSpellingWordsList::get_termfreq", "");
00053 Assert(cursor);
00054 Assert(!at_end());
00055 Assert(!cursor->current_key.empty());
00056 Assert(cursor->current_key[0] == 'W');
00057 cursor->read_tag();
00058
00059 Xapian::termcount freq;
00060 const char *p = cursor->current_tag.data();
00061 if (!unpack_uint_last(&p, p + cursor->current_tag.size(), &freq)) {
00062 throw Xapian::DatabaseCorruptError("Bad spelling word freq");
00063 }
00064 return freq;
00065 }
00066
00067 Xapian::termcount
00068 FlintSpellingWordsList::get_collection_freq() const
00069 {
00070 throw Xapian::InvalidOperationError("FlintSpellingWordsList::get_collection_freq() not meaningful");
00071 }
00072
00073 TermList *
00074 FlintSpellingWordsList::next()
00075 {
00076 DEBUGCALL(DB, TermList *, "FlintSpellingWordsList::next", "");
00077 Assert(!at_end());
00078
00079 cursor->next();
00080 if (!cursor->after_end() && !startswith(cursor->current_key, 'W')) {
00081
00082 cursor->to_end();
00083 }
00084
00085 RETURN(NULL);
00086 }
00087
00088 TermList *
00089 FlintSpellingWordsList::skip_to(const string &tname)
00090 {
00091 DEBUGCALL(DB, TermList *, "FlintSpellingWordsList::skip_to", tname);
00092 Assert(!at_end());
00093
00094 if (!cursor->find_entry_ge("W" + tname)) {
00095
00096
00097 if (!cursor->after_end() && !startswith(cursor->current_key, 'W')) {
00098
00099 cursor->to_end();
00100 }
00101 }
00102 RETURN(NULL);
00103 }
00104
00105 bool
00106 FlintSpellingWordsList::at_end() const
00107 {
00108 DEBUGCALL(DB, bool, "FlintSpellingWordsList::at_end", "");
00109 RETURN(cursor->after_end());
00110 }