FirteX-高性能全文索引和检索平台API Documentation |
00001 // 00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 00003 // All rights reserved. 00004 // This file is part of FirteX (www.firtex.org) 00005 // 00006 // Use of the FirteX is subject to the terms of the software license set forth in 00007 // the LICENSE file included with this software, and also available at 00008 // http://www.firtex.org/license.html 00009 // 00010 // Author : 郭瑞杰(GuoRuijie) 00011 // Email : ruijieguo@software.ict.ac.cn 00012 // Created : 2006/1/4 00013 // 00014 #ifndef _MULTITERMDOCS_H 00015 #define _MULTITERMDOCS_H 00016 00017 #if _MSC_VER > 1000 00018 #pragma once 00019 #endif // _MSC_VER > 1000 00020 00021 00022 #include "TermDocs.h" 00023 #include "BarrelsInfo.h" 00024 #include "../utility/PriorityQueue.h" 00025 #include <list> 00026 using namespace firtex::utility; 00027 using namespace std; 00028 00029 namespace firtex 00030 { 00031 namespace index 00032 { 00033 class CBarrelTermDocsEntry 00034 { 00035 public: 00036 CBarrelTermDocsEntry(CBarrelInfo* barrelInfoA,CTermDocs* termDocsA) 00037 { 00038 barrelInfo = new CBarrelInfo(*barrelInfoA); 00039 termDocs = termDocsA; 00040 } 00041 ~CBarrelTermDocsEntry() 00042 { 00043 delete barrelInfo; 00044 delete termDocs; 00045 } 00046 protected: 00047 CBarrelTermDocsEntry(){} 00048 public: 00049 CBarrelInfo* barrelInfo; 00050 CTermDocs* termDocs; 00051 00052 friend class CMultiTermDocs; 00053 }; 00054 00055 class CMultiTermDocs : public CTermDocs 00056 { 00057 class CTermDocsQueue:public CPriorityQueue<CBarrelTermDocsEntry*> 00058 { 00059 public: 00060 CTermDocsQueue(size_t size) 00061 { 00062 initialize(size,false); 00063 } 00064 protected: 00065 bool lessThan(CBarrelTermDocsEntry* o1, CBarrelTermDocsEntry* o2) 00066 { 00067 return (o1->barrelInfo->minDocID() + o1->termDocs->doc()) < (o2->barrelInfo->minDocID() + o2->termDocs->doc()); 00068 } 00069 }; 00070 public: 00071 CMultiTermDocs(void); 00072 virtual ~CMultiTermDocs(void); 00073 public: 00077 bool seek(CTerm* term); 00078 00082 docid_t doc(); 00083 00087 count_t freq(); 00088 00093 bool next(); 00094 00102 count_t next(docid_t*& docs, count_t*& freqs); 00103 00111 bool skipTo(docid_t target,docid_t& nearTarget); 00112 00113 freq_t docFreq(); 00114 00118 void close(); 00119 00124 void add(CBarrelInfo* pBarrelInfo,CTermDocs* pTermDocs); 00125 protected: 00126 void initQueue(); 00127 protected: 00128 list<CBarrelTermDocsEntry*> m_barrelTermDocs; 00129 CBarrelTermDocsEntry* m_current; 00130 int m_cursor; 00131 CTermDocsQueue* m_pTermDocsQueue; 00132 }; 00133 00134 } 00135 } 00136 00137 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex