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 : 2006/3/23 00013 // 00014 #ifndef _HITCOLLECTOR_H 00015 #define _HITCOLLECTOR_H 00016 #include "../utility/typedefs.h" 00017 #include "ScoreDoc.h" 00018 #include "../utility/BitVector.h" 00019 #include "../utility/PriorityQueue.h" 00020 #include "HitQueue.h" 00021 using namespace firtex::utility; 00022 using namespace std; 00023 using namespace firtex; 00024 00025 namespace firtex 00026 { 00027 namespace search 00028 { 00029 class CHitCollector 00030 { 00031 public: 00032 CHitCollector(void) 00033 { 00034 } 00035 00036 virtual ~CHitCollector(void) 00037 { 00038 } 00039 public: 00040 virtual void collect(docid_t docid,score_t score)=0; 00041 virtual void collect(docid_t docid[],score_t score[],count_t size)=0; 00042 }; 00043 00044 struct ScoreDocLess 00045 { 00046 bool operator () (const CScoreDoc*& left,const CScoreDoc*& right) const 00047 { 00048 if (left->m_fScore == right->m_fScore) 00049 return left->m_docID < right->m_docID; 00050 else 00051 return left->m_fScore < right->m_fScore; 00052 } 00053 }; 00054 00055 //typedef priority_queue<CScoreDoc*,deque<CScoreDoc*>,ScoreDocLess> CHitQueue; 00056 00057 class CSimpleTopDocsCollector : public CHitCollector 00058 { 00059 public: 00060 CSimpleTopDocsCollector(CHitQueue* pHitQueue,count_t* totalHits,count_t nDoc,const CBitVector* pFilterBits = NULL,score_t ms=-1.0f); 00061 ~CSimpleTopDocsCollector(); 00062 00063 public: 00064 void collect(docid_t docid,score_t score); 00065 void collect(docid_t docid[],score_t score[],count_t size); 00066 public: 00067 count_t* m_pTotalHits; 00068 count_t m_maxDocs; //返回最大文档数 00069 CHitQueue* m_pHitQueue; 00070 const CBitVector* m_pFilterBits; 00071 00072 score_t m_minScore; 00073 }; 00074 00076 //CSortedTopDocsCollector 00077 class CSortedTopDocsCollector : public CHitCollector 00078 { 00079 public: 00080 CSortedTopDocsCollector(CFieldDocSortedHitQueue* pHitQueue,count_t* totalHits,count_t nDoc,const CBitVector* pFilterBits = NULL); 00081 ~CSortedTopDocsCollector(); 00082 00083 public: 00084 void collect(docid_t docid,score_t score); 00085 void collect(docid_t docid[],score_t score[],count_t size); 00086 public: 00087 count_t* m_pTotalHits; 00088 count_t m_maxDocs; //返回最大文档数 00089 CFieldDocSortedHitQueue* m_pHitQueue; 00090 const CBitVector* m_pFilterBits; 00091 }; 00092 } 00093 } 00094 00095 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex