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,ruijieguo@gmail.com 00012 // Created : 2005/12/27 00013 // 00014 #ifndef _HITS_H 00015 #define _HITS_H 00016 00017 #include "../utility/typedefs.h" 00018 #include "../document/Document.h" 00019 #include "HitCollector.h" 00020 00021 #include <vector> 00022 using namespace std; 00023 00024 using namespace firtex; 00025 00026 namespace firtex 00027 { 00028 namespace search 00029 { 00030 class CSearcher; 00031 class CQuery; 00032 //class CHitQueue; 00033 class CQueryHits 00034 { 00035 class CHitDoc 00036 { 00037 public: 00038 CHitDoc(docid_t i,score_t s) 00039 { 00040 score = s; 00041 docID = i; 00042 doc = NULL; 00043 } 00044 protected: 00045 score_t score; 00046 docid_t docID; 00047 document::CDocument* doc; 00048 00049 friend class CQueryHits; 00050 }; 00051 00052 public: 00053 CQueryHits(void); 00054 CQueryHits(CHitQueue* hq,CQuery* pQuery,CSearcher* pSearcher); 00055 virtual ~CQueryHits(void); 00056 public: 00061 document::CDocument* doc(int n); 00062 00067 score_t score(int n){return hitDoc(n)->score;} 00068 00073 docid_t docid(int n){return hitDoc(n)->docID;} 00074 00078 count_t getHitNum(){return m_totalHits;} 00079 00083 int length() 00084 { 00085 return (int)m_hitDocs.size(); 00086 } 00087 public: 00098 void startIterator(){m_iterator = m_hitDocs.begin()-1;} 00099 00103 bool hasNext(){return (++m_iterator<m_hitDocs.end());}; 00104 00109 document::CDocument* doc() 00110 { 00111 CHitDoc* pHitDoc = (*m_iterator); 00112 return pHitDoc->doc?pHitDoc->doc:getDoc(pHitDoc); 00113 }; 00114 00118 docid_t docid(){return (*m_iterator)->docID;} 00119 00123 score_t score(){return (*m_iterator)->score;} 00124 protected: 00125 void getTopDocs(int topk); 00126 void clear(); 00127 CQueryHits::CHitDoc* hitDoc(int n); 00128 document::CDocument* docByID(docid_t did); 00129 document::CDocument* getDoc(CHitDoc* pHitDoc); 00130 protected: 00131 vector<CHitDoc*> m_hitDocs; 00132 vector<CHitDoc*>::iterator m_iterator; 00133 00134 CQuery* m_pQuery; 00135 CSearcher* m_pSearcher; 00136 count_t m_totalHits; 00137 //private Filter filter = null; 00138 //private Sort sort = null; 00139 00140 //private int length; // the total number of hits 00141 00142 friend class CIndexSearcher; 00143 }; 00144 } 00145 } 00146 00147 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex