00001
00002
00003
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_record.h"
00024 #include "flint_utils.h"
00025 #include "str.h"
00026 #include <xapian/error.h>
00027 #include "debuglog.h"
00028 #include "omassert.h"
00029
00030 using std::string;
00031
00032 string
00033 FlintRecordTable::get_record(Xapian::docid did) const
00034 {
00035 LOGCALL(DB, string, "FlintRecordTable::get_record", did);
00036 string tag;
00037
00038 if (!get_exact_entry(flint_docid_to_key(did), tag)) {
00039 throw Xapian::DocNotFoundError("Document " + str(did) + " not found.");
00040 }
00041
00042 RETURN(tag);
00043 }
00044
00045 Xapian::doccount
00046 FlintRecordTable::get_doccount() const
00047 {
00048 LOGCALL(DB, Xapian::doccount, "FlintRecordTable::get_doccount", NO_ARGS);
00049 STATIC_ASSERT_TYPE_DOMINATES(Xapian::doccount, flint_tablesize_t);
00050 RETURN(get_entry_count());
00051 }
00052
00053 void
00054 FlintRecordTable::replace_record(const string & data, Xapian::docid did)
00055 {
00056 LOGCALL_VOID(DB, "FlintRecordTable::replace_record", data | did);
00057 add(flint_docid_to_key(did), data);
00058 }
00059
00060 void
00061 FlintRecordTable::delete_record(Xapian::docid did)
00062 {
00063 LOGCALL_VOID(DB, "FlintRecordTable::delete_record", did);
00064 if (!del(flint_docid_to_key(did)))
00065 throw Xapian::DocNotFoundError("Can't delete non-existent document #" + str(did));
00066 }