00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023 #include "flint_metadata.h"
00024
00025 #include "database.h"
00026 #include "omassert.h"
00027 #include "stringutils.h"
00028
00029 using namespace std;
00030
00031 FlintMetadataTermList::FlintMetadataTermList(
00032 Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> database_,
00033 FlintCursor * cursor_,
00034 const string &prefix_)
00035 : database(database_), cursor(cursor_), prefix(string("\x00\xc0", 2) + prefix_)
00036 {
00037 DEBUGCALL(DB, void, "FlintMetadataTermList", "<database>, <cursor>");
00038 Assert(cursor);
00039
00040 cursor->find_entry_lt(prefix);
00041 }
00042
00043 FlintMetadataTermList::~FlintMetadataTermList()
00044 {
00045 DEBUGCALL(DB, void, "~FlintMetadataTermList", "");
00046 delete cursor;
00047 }
00048
00049 string
00050 FlintMetadataTermList::get_termname() const
00051 {
00052 DEBUGCALL(DB, string, "FlintMetadataTermList::get_termname", "");
00053 Assert(!at_end());
00054 Assert(!cursor->current_key.empty());
00055 Assert(startswith(cursor->current_key, prefix));
00056 RETURN(cursor->current_key.substr(2));
00057 }
00058
00059 Xapian::doccount
00060 FlintMetadataTermList::get_termfreq() const
00061 {
00062 throw Xapian::InvalidOperationError("FlintMetadataTermList::get_termfreq() not meaningful");
00063 }
00064
00065 Xapian::termcount
00066 FlintMetadataTermList::get_collection_freq() const
00067 {
00068 throw Xapian::InvalidOperationError("FlintMetadataTermList::get_collection_freq() not meaningful");
00069 }
00070
00071 TermList *
00072 FlintMetadataTermList::next()
00073 {
00074 DEBUGCALL(DB, TermList *, "FlintMetadataTermList::next", "");
00075 Assert(!at_end());
00076
00077 cursor->next();
00078 if (!cursor->after_end() && !startswith(cursor->current_key, prefix)) {
00079
00080 cursor->to_end();
00081 }
00082
00083 RETURN(NULL);
00084 }
00085
00086 TermList *
00087 FlintMetadataTermList::skip_to(const string &tname)
00088 {
00089 DEBUGCALL(DB, TermList *, "FlintMetadataTermList::skip_to", tname);
00090 Assert(!at_end());
00091
00092 if (!cursor->find_entry_ge(tname)) {
00093
00094
00095 if (!cursor->after_end() && !startswith(cursor->current_key, prefix)) {
00096
00097 cursor->to_end();
00098 }
00099 }
00100 RETURN(NULL);
00101 }
00102
00103 bool
00104 FlintMetadataTermList::at_end() const
00105 {
00106 DEBUGCALL(DB, bool, "FlintMetadataTermList::at_end", "");
00107 RETURN(cursor->after_end());
00108 }