CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_index_Terms_ 00008 #define _lucene_index_Terms_ 00009 00010 //#include "Term.h" 00011 CL_NS_DEF(index) 00012 00013 class Term; 00014 class TermEnum; //predefine 00015 class TermPositions; 00016 00025 class TermDocs: LUCENE_BASE { 00026 public: 00027 virtual ~TermDocs(){ 00028 } 00029 00030 // Sets this to the data for a term. 00031 // The enumeration is reset to the start of the data for this term. 00032 virtual void seek(Term* term)=0; 00033 00037 virtual void seek(TermEnum* termEnum)=0; 00038 00039 // Returns the current document number. <p> This is invalid until {@link 00040 // #next()} is called for the first time. 00041 virtual int32_t doc() const=0; 00042 00043 // Returns the frequency of the term within the current document. <p> This 00044 // is invalid until {@link #next()} is called for the first time. 00045 virtual int32_t freq() const=0; 00046 00047 // Moves to the next pair in the enumeration. <p> Returns true iff there is 00048 // such a next pair in the enumeration. 00049 virtual bool next() =0; 00050 00051 // Attempts to read multiple entries from the enumeration, up to length of 00052 // <i>docs</i>. Document numbers are stored in <i>docs</i>, and term 00053 // frequencies are stored in <i>freqs</i>. The <i>freqs</i> array must be as 00054 // int64_t as the <i>docs</i> array. 00055 // 00056 // <p>Returns the number of entries read. Zero is only returned when the 00057 // stream has been exhausted. 00058 virtual int32_t read(int32_t* docs, int32_t* freqs, int32_t length)=0; 00059 00060 // Skips entries to the first beyond the current whose document number is 00061 // greater than or equal to <i>target</i>. <p>Returns true iff there is such 00062 // an entry. <p>Behaves as if written: <pre> 00063 // bool skipTo(int32_t target) { 00064 // do { 00065 // if (!next()) 00066 // return false; 00067 // } while (target > doc()); 00068 // return true; 00069 // } 00070 // </pre> 00071 // Some implementations are considerably more efficient than that. 00072 virtual bool skipTo(const int32_t target)=0; 00073 00074 // Frees associated resources. 00075 virtual void close() = 0; 00076 00077 00081 virtual TermPositions* __asTermPositions()=0; 00082 }; 00083 00084 00085 // Abstract class for enumerating terms. 00086 // 00087 //<p>Term enumerations are always ordered by Term.compareTo(). Each term in 00088 //the enumeration is greater than all that precede it. 00089 class CLUCENE_EXPORT TermEnum: LUCENE_BASE { 00090 public: 00091 // Increments the enumeration to the next element. True if one exists. 00092 virtual bool next()=0; 00093 00094 // Returns a pointer to the current Term in the enumeration. 00095 virtual Term* term()=0; 00096 00097 // Returns the current Term in the enumeration. 00098 virtual Term* term(bool pointer); 00099 00100 // Returns the docFreq of the current Term in the enumeration. 00101 virtual int32_t docFreq() const=0; 00102 00103 // Closes the enumeration to further activity, freeing resources. 00104 virtual void close() =0; 00105 00106 virtual ~TermEnum(); 00107 00108 // Term Vector support 00122 virtual bool skipTo(Term* target); 00123 00127 virtual const char* getObjectName() = 0; 00128 }; 00129 00130 00131 00140 class TermPositions: public virtual TermDocs { 00141 public: 00148 virtual int32_t nextPosition() = 0; 00149 00150 virtual ~TermPositions(); 00151 00158 virtual int32_t getPayloadLength() const = 0; 00159 00176 virtual uint8_t* getPayload(uint8_t* data, int32_t offset) = 0; 00177 00186 virtual bool isPayloadAvailable() const = 0; 00187 00191 virtual TermDocs* __asTermDocs()=0; 00192 virtual TermPositions* __asTermPositions()=0; 00193 }; 00194 CL_NS_END 00195 #endif