00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <config.h>
00023
00024 #include "xapian/weight.h"
00025
00026 #include "weightinternal.h"
00027
00028 #include "debuglog.h"
00029
00030 #include "xapian/error.h"
00031
00032 using namespace std;
00033
00034 namespace Xapian {
00035
00036 void
00037 Weight::init_(const Internal & stats, Xapian::termcount query_length)
00038 {
00039 LOGCALL_VOID(MATCH, "Weight::init_", stats | query_length);
00040 collection_size_ = stats.collection_size;
00041 rset_size_ = stats.rset_size;
00042 if (stats_needed & AVERAGE_LENGTH)
00043 average_length_ = stats.get_average_length();
00044 if (stats_needed & DOC_LENGTH_MAX)
00045 doclength_upper_bound_ = stats.db.get_doclength_upper_bound();
00046 if (stats_needed & DOC_LENGTH_MIN)
00047 doclength_lower_bound_ = stats.db.get_doclength_lower_bound();
00048 wdf_upper_bound_ = 0;
00049 termfreq_ = 0;
00050 reltermfreq_ = 0;
00051 query_length_ = query_length;
00052 wqf_ = 1;
00053 }
00054
00055 void
00056 Weight::init_(const Internal & stats, Xapian::termcount query_length,
00057 const string & term, Xapian::termcount wqf, double factor)
00058 {
00059 LOGCALL_VOID(MATCH, "Weight::init_", stats | query_length | term | wqf | factor);
00060 collection_size_ = stats.collection_size;
00061 rset_size_ = stats.rset_size;
00062 if (stats_needed & AVERAGE_LENGTH)
00063 average_length_ = stats.get_average_length();
00064 if (stats_needed & DOC_LENGTH_MAX)
00065 doclength_upper_bound_ = stats.db.get_doclength_upper_bound();
00066 if (stats_needed & DOC_LENGTH_MIN)
00067 doclength_lower_bound_ = stats.db.get_doclength_lower_bound();
00068 if (stats_needed & WDF_MAX)
00069 wdf_upper_bound_ = stats.db.get_wdf_upper_bound(term);
00070 if (stats_needed & TERMFREQ)
00071 termfreq_ = stats.get_termfreq(term);
00072 if (stats_needed & RELTERMFREQ)
00073 reltermfreq_ = stats.get_reltermfreq(term);
00074 query_length_ = query_length;
00075 wqf_ = wqf;
00076 init(factor);
00077 }
00078
00079 void
00080 Weight::init_(const Internal & stats, Xapian::termcount query_length,
00081 double factor, Xapian::doccount termfreq,
00082 Xapian::doccount reltermfreq)
00083 {
00084 LOGCALL_VOID(MATCH, "Weight::init_", stats | query_length | factor | termfreq | reltermfreq);
00085
00086 collection_size_ = stats.collection_size;
00087 rset_size_ = stats.rset_size;
00088 if (stats_needed & AVERAGE_LENGTH)
00089 average_length_ = stats.get_average_length();
00090 if (stats_needed & DOC_LENGTH_MAX)
00091 doclength_upper_bound_ = stats.db.get_doclength_upper_bound();
00092 if (stats_needed & DOC_LENGTH_MIN)
00093 doclength_lower_bound_ = stats.db.get_doclength_lower_bound();
00094
00095
00096
00097
00098
00099
00100
00101 if (stats_needed & WDF_MAX)
00102 wdf_upper_bound_ = stats.db.get_doclength_upper_bound();
00103
00104 termfreq_ = termfreq;
00105 reltermfreq_ = reltermfreq;
00106 query_length_ = query_length;
00107 wqf_ = 1;
00108 init(factor);
00109 }
00110
00111 Weight::~Weight() { }
00112
00113 string
00114 Weight::name() const
00115 {
00116 return string();
00117 }
00118
00119 string
00120 Weight::serialise() const
00121 {
00122 throw Xapian::UnimplementedError("serialise() not supported for this Xapian::Weight subclass");
00123 }
00124
00125 Weight *
00126 Weight::unserialise(const string &) const
00127 {
00128 throw Xapian::UnimplementedError("unserialise() not supported for this Xapian::Weight subclass");
00129 }
00130
00131 }