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