Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

InvFPDocList.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2001 Carnegie Mellon University.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.cs.cmu.edu/~lemur/license.html
00008  *
00009  *==========================================================================
00010 */
00011 
00012 
00013 #ifndef _INVFPDOCLIST_HPP
00014 #define _INVFPDOCLIST_HPP
00015 
00016 /*
00017  * NAME DATE - COMMENTS
00018  * tnt 03/2001 - created
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;           // pointer to the beginning of this list
00103   int* lastid;  // pointer to the most recent DocID added
00104   int* freq;            // pointer to the frequency of the last DocID
00105   int* end;               // pointer to the next free memory
00106   int* iter;    // pointer tells us where we are in iteration
00107   int  size;            // how big are we, increment in powers of 2, start at 16K
00108   int  intsize; // sizeof(int) value
00109   int  strlength;       // the character length of our corresponding string
00110   TERMID_T  uid;                          // a unique ID for our string
00111   int  df;                        // the document frequency for current term
00112   MemCache* cache;      // the cache to get memory from
00113   bool hascache;        // remember if we have our own cache
00114 
00115   bool READ_ONLY;    // flag for whether this list can be added
00116 };
00117 
00118 #endif

Generated at Fri Jul 26 18:22:26 2002 for LEMUR by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000