00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <config.h>
00026 #include "flint_record.h"
00027 #include "flint_utils.h"
00028 #include "utils.h"
00029 #include <xapian/error.h>
00030 #include "omassert.h"
00031 #include "omdebug.h"
00032
00033 using std::string;
00034
00035 string
00036 FlintRecordTable::get_record(Xapian::docid did) const
00037 {
00038 DEBUGCALL(DB, string, "FlintRecordTable::get_record", did);
00039 string tag;
00040
00041 if (!get_exact_entry(flint_docid_to_key(did), tag)) {
00042 throw Xapian::DocNotFoundError("Document " + om_tostring(did) + " not found.");
00043 }
00044
00045 RETURN(tag);
00046 }
00047
00048
00049 Xapian::doccount
00050 FlintRecordTable::get_doccount() const
00051 {
00052 DEBUGCALL(DB, Xapian::doccount, "FlintRecordTable::get_doccount", "");
00053
00054
00055
00056 CASSERT(sizeof(Xapian::doccount) >= sizeof(flint_tablesize_t));
00057 CASSERT_TYPE_UNSIGNED(Xapian::doccount);
00058 CASSERT_TYPE_UNSIGNED(flint_tablesize_t);
00059 RETURN(get_entry_count());
00060 }
00061
00062 void
00063 FlintRecordTable::replace_record(const string & data, Xapian::docid did)
00064 {
00065 DEBUGCALL(DB, void, "FlintRecordTable::replace_record", data << ", " << did);
00066 add(flint_docid_to_key(did), data);
00067 }
00068
00069 void
00070 FlintRecordTable::delete_record(Xapian::docid did)
00071 {
00072 DEBUGCALL(DB, void, "FlintRecordTable::delete_record", did);
00073 if (!del(flint_docid_to_key(did)))
00074 throw Xapian::DocNotFoundError("Can't delete non-existent document #" + om_tostring(did));
00075 }