FirteX-高性能全文索引和检索平台

API Documentation


首页 | 名字空间列表 | 类继承关系 | 组合类型列表 | $(BL\录(B | 文件列表 | 名字空间成员 | 组合类型成员 | 文件成员

MultiTermPositions.h

浏览该文件的文档。
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 _MULTITERMPOSITIONS_H
00015 #define _MULTITERMPOSITIONS_H
00016 
00017 #include "TermPositions.h"
00018 #include "BarrelsInfo.h"
00019 #include "../utility/PriorityQueue.h"
00020 #include <list>
00021 using namespace std;
00022 using namespace firtex::utility;
00023 
00024 namespace firtex
00025 {
00026         namespace index
00027         {               
00028                 class CBarrelTermPositionsEntry
00029                 {
00030                 public:
00031                         CBarrelTermPositionsEntry(CBarrelInfo*  barrelInfoA,CTermPositions*     termPositionsA)
00032                         {
00033                                 barrelInfo = new CBarrelInfo(*barrelInfoA);
00034                                 termPositions = termPositionsA;
00035                         }
00036                         ~CBarrelTermPositionsEntry()
00037                         {
00038                                 delete barrelInfo;
00039                                 delete termPositions;
00040                         }
00041                 protected:
00042                         CBarrelTermPositionsEntry(){}
00043                 public:
00044                         CBarrelInfo*    barrelInfo;
00045                         CTermPositions* termPositions;
00046 
00047                         friend class CMultiTermPositions;                       
00048                 };
00049 
00050                 class CMultiTermPositions :     public CTermPositions
00051                 {
00052                         class CTermPositionQueue:public CPriorityQueue<CBarrelTermPositionsEntry*>
00053                         {
00054                         public:
00055                                 CTermPositionQueue(size_t size) 
00056                                 {
00057                                         initialize(size,false);
00058                                 }
00059                         protected:
00060                                 bool lessThan(CBarrelTermPositionsEntry* o1, CBarrelTermPositionsEntry* o2) 
00061                                 {
00062                                         return (o1->barrelInfo->minDocID() + o1->termPositions->doc()) < (o2->barrelInfo->minDocID() + o2->termPositions->doc());
00063                                 }
00064                         };
00065                 public:
00066                         CMultiTermPositions(void);
00067                         virtual ~CMultiTermPositions(void);
00068                 public:
00072                         bool  seek(CTerm* term);
00073                                                 
00077                         docid_t doc();
00078 
00082                         count_t freq();
00083 
00088                         bool next();
00089 
00097                         count_t next(docid_t*& docs, count_t*& freqs);
00098 
00107                         bool skipTo(docid_t target,docid_t& nearTarget);
00108 
00116                         bool skipToPosition(loc_t target,loc_t& nearTarget);
00117 
00118                         freq_t docFreq();
00119 
00123                         void  close();
00124                         
00128                         loc_t nextPosition();
00129                         
00136                         count_t nextPositions(loc_t*& positions);
00137 
00142                         void    add(CBarrelInfo* pBarrelInfo,CTermPositions* pTermPositions);
00143                 protected:
00144                         void    initQueue();
00145                 protected:
00146                         list<CBarrelTermPositionsEntry*>        m_TermPositions;                        
00147                         CBarrelTermPositionsEntry*              m_current;
00148                         CTermPositionQueue*                             m_pTermPositionQueue;
00149                 };
00150         }
00151 }
00152 
00153 
00154 #endif
00155 

http://www.firtex.org http://www.sourceforge.net/projects/firtex