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