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 : 2005/12/27 00013 // 00014 00015 #ifndef _SEGMENTINFO_H 00016 #define _SEGMENTINFO_H 00017 00018 #include "../utility/StdHeader.h" 00019 #include "../store/Directory.h" 00020 #include "../utility/FXString.h" 00021 00022 #include <vector> 00023 using namespace std; 00024 using namespace firtex::store; 00025 using namespace firtex::utility; 00026 00027 #define BARRELS_INFONAME "barrels" 00028 00029 namespace firtex 00030 { 00031 namespace index 00032 { 00033 class CBarrelInfo 00034 { 00035 public: 00036 CBarrelInfo() 00037 { 00038 } 00039 CBarrelInfo(const string& name,docid_t minDID,count_t count) 00040 { 00041 m_minDocID = minDID; 00042 m_barrelName = name; 00043 m_docCount = count; 00044 } 00045 CBarrelInfo(const CBarrelInfo& bi) 00046 { 00047 m_minDocID = bi.m_minDocID; 00048 m_barrelName = bi.m_barrelName; 00049 m_docCount = bi.m_docCount; 00050 } 00051 ~CBarrelInfo() 00052 { 00053 } 00054 public: 00055 const string& name(){return m_barrelName;} 00056 void name(const string& name){m_barrelName = name;} 00057 00058 docid_t minDocID(){return m_minDocID;} 00059 void minDocID(docid_t did){m_minDocID = did;} 00060 00061 count_t docCount(){return m_docCount;} 00062 void docCount(count_t count){m_docCount = count;} 00063 00067 void remove(CDirectory* pDirectory); 00068 void rename(CDirectory* pDirectory,const string& newName); 00069 protected: 00070 string m_barrelName; 00071 docid_t m_minDocID; //文档编号基数 00072 count_t m_docCount; //包含的文档数目 00073 00074 friend class CBarrelsInfo; 00075 }; 00076 00077 class CBarrelsInfo 00078 { 00079 public: 00080 CBarrelsInfo(); 00081 ~CBarrelsInfo(void); 00082 public: 00086 const string newBarrel(); 00087 00094 void addBarrel(const string& name,docid_t minDID,count_t docCount); 00099 void addBarrel(CBarrelInfo* pBarrelInfo); 00100 00104 void read(CDirectory* pDirectory); 00108 void write(CDirectory* pDirectory); 00109 00113 void remove(CDirectory* pDirectory); 00114 00118 void removeBarrel(CDirectory* pDirectory,const string& barrelname); 00119 00123 int getBarrelCount(){return (int)m_barrelInfos.size();} 00124 00128 int getDocCount(); 00129 00133 count_t getDocCounter(){return m_docCounter;} 00134 void setDocCounter(count_t dcnt){m_docCounter = dcnt;} 00135 00139 const char* getVersion(){return (const char*)m_version;} 00140 void setVersion(const char* ver){m_version = ver;} 00141 00145 void clear(); 00146 00147 CBarrelInfo* operator [](int i){return m_barrelInfos[i];} 00148 public: 00149 void startIterator(); 00150 bool hasNext(); 00151 CBarrelInfo* next(); 00152 protected: 00153 CFXString m_version; 00154 count_t m_barrelCounter; //索引桶计数 00155 count_t m_docCounter; //文档计数器 00156 00157 vector<CBarrelInfo*> m_barrelInfos; 00158 vector<CBarrelInfo*>::iterator m_barrelsiterator; 00159 }; 00161 //Inline functions 00162 inline void CBarrelsInfo::startIterator() 00163 { 00164 m_barrelsiterator = m_barrelInfos.begin(); 00165 } 00166 inline bool CBarrelsInfo::hasNext() 00167 { 00168 return (m_barrelsiterator != m_barrelInfos.end()); 00169 } 00170 inline CBarrelInfo* CBarrelsInfo::next() 00171 { 00172 return *m_barrelsiterator++; 00173 } 00174 } 00175 } 00176 00177 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex