1 /*------------------------------------------------------------------------------ 2 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 3 * 4 * Distributable under the terms of either the Apache License (Version 2.0) or 5 * the GNU Lesser General Public License, as specified in the COPYING file. 6 ------------------------------------------------------------------------------*/ 7 #ifndef _lucene_index_SegmentTermEnum_ 8 #define _lucene_index_SegmentTermEnum_ 9 10 11 //#include "Terms.h" 12 //#include "FieldInfos.h" 13 //#include "TermInfo.h" 14 CL_NS_DEF(index)15CL_NS_DEF(index) 16 17 /** 18 * SegmentTermEnum is an enumeration of all Terms and TermInfos 19 */ 20 class SegmentTermEnum:public TermEnum{ 21 private: 22 Term* _term; ///points to the current Term in the enumeration 23 TermInfo* termInfo; ///points to the TermInfo matching the current Term in the enumeration 24 25 bool isIndex; ///Indicates if the Segment is a an index 26 bool isClone; ///Indicates if SegmentTermEnum is an orignal instance or 27 ///a clone of another SegmentTermEnum 28 29 TCHAR* buffer; ///The buffer that contains the data read from the Term Infos File 30 uint32_t bufferLength; ///Length of the buffer 31 32 int32_t format; 33 int32_t formatM1SkipInterval; 34 35 CL_NS(store)::IndexInput* input; ///The IndexInput that reads from the Term Infos File 36 FieldInfos* fieldInfos; ///contains the Field Infos for the segment 37 int64_t size; ///The size of the enumeration 38 int64_t position; ///The position of the current (term) in the enumeration 39 int64_t indexPointer; 40 Term* prev; ///The previous current 41 int32_t indexInterval; 42 int32_t skipInterval; 43 int32_t maxSkipLevels; 44 45 friend class TermInfosReader; 46 friend class SegmentTermDocs; 47 protected: 48 49 /** 50 * Constructor. 51 * The instance is created by cloning all properties of clone 52 */ 53 SegmentTermEnum( const SegmentTermEnum& clone); 54 55 public: 56 ///Constructor 57 SegmentTermEnum(CL_NS(store)::IndexInput* i, FieldInfos* fis, const bool isi ); 58 59 ///Destructor 60 ~SegmentTermEnum(); 61 62 /** 63 * Moves the current of the set to the next in the set 64 */ 65 bool next(); 66 67 /** 68 * Returns the current term. 69 */ 70 Term* term(bool pointer=true); 71 72 /** 73 * Scan for Term term without allocating new Terms 74 */ 75 void scanTo(const Term *term); 76 77 /** 78 * Closes the enumeration to further activity, freeing resources. 79 */ 80 void close(); 81 82 /** 83 * Returns the document frequency of the current term in the set 84 */ 85 int32_t docFreq() const; 86 87 /** 88 * Repositions term and termInfo within the enumeration 89 */ 90 void seek(const int64_t pointer, const int32_t p, Term* t, TermInfo* ti); 91 92 /** 93 * Returns a clone of the current termInfo 94 */ 95 TermInfo* getTermInfo()const; 96 97 /** 98 * Retrieves a clone of termInfo through the reference ti 99 */ 100 void getTermInfo(TermInfo* ti)const; 101 102 /** 103 * Returns the freqPointer from the current TermInfo in the enumeration. 104 */ 105 int64_t freqPointer() const; 106 107 /** 108 * Returns the proxPointer from the current TermInfo in the enumeration. 109 */ 110 int64_t proxPointer() const; 111 112 /** 113 * Returns a clone of this instance 114 */ 115 SegmentTermEnum* clone() const; 116 117 const char* getObjectName() const; 118 static const char* getClassName(); 119 120 private: 121 /** 122 * Reads the next term in the enumeration 123 */ 124 Term* readTerm(Term* reuse); 125 /** 126 * Instantiate a buffer of length length+1 127 * TODO: deprecate this... 128 */ 129 void growBuffer(const uint32_t length, bool force_copy); 130 131 }; 132 CL_NS_END 133 #endif 134