00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _INVFPDOCLIST_HPP
00014 #define _INVFPDOCLIST_HPP
00015
00016
00017
00018
00019
00020
00021 #include <cmath>
00022 #include "common_headers.hpp"
00023 #include "DocInfoList.hpp"
00024 #include "InvFPDocInfo.hpp"
00025 #include "MemCache.hpp"
00026
00027 extern "C" {
00028 #include <cstdio>
00029 }
00030
00031 #define DEFAULT 9
00032
00033 class InvFPDocList: public DocInfoList {
00034 public:
00035 InvFPDocList();
00036
00039 InvFPDocList(int id, int len);
00041 InvFPDocList(MemCache* mc, int id, int len);
00042 InvFPDocList(MemCache* mc, int id, int len, int docid, int location);
00044 InvFPDocList(int id, int listlen, int* list, int fr, int* ldocid, int len);
00045 ~InvFPDocList();
00046
00052 void setList(int id, int listlen, int* list, int fr, int* ldocid=NULL, int len=0);
00053
00057 void setListSafe(int id, int listlen, int* list, int fr, int* ldocid, int len);
00058
00062 void reset();
00063
00066 void resetFree();
00067
00068 bool allocMem();
00069 bool hasNoMem();
00070 bool addLocation(int docid, LOC_T location);
00071
00072 void startIteration();
00073 bool hasMore();
00074 DocInfo* nextEntry();
00075 void nextEntry(InvFPDocInfo* info);
00076
00077 DOCID_T curDocID() { if (lastid == NULL) return -1; return *lastid; };
00078 int docFreq() { return df; };
00079 int length() { return end-begin; };
00080 int termID() { return uid; };
00081 int termLen() { return strlength; };
00082 int curDocIDdiff() { return lastid-begin; };
00083 int curDocIDtf() { return *(lastid+1); };
00084
00087 void binWrite(ofstream& of);
00088
00093 bool binRead(ifstream& inf);
00094
00095 private:
00099 bool getMoreMem();
00100 int logb2(int num);
00101
00102 int* begin;
00103 int* lastid;
00104 int* freq;
00105 int* end;
00106 int* iter;
00107 int size;
00108 int intsize;
00109 int strlength;
00110 TERMID_T uid;
00111 int df;
00112 MemCache* cache;
00113 bool hascache;
00114
00115 bool READ_ONLY;
00116 };
00117
00118 #endif