📄 indexreader.h
字号:
* depends on the hardware platform. Instead, a version number is maintained
* within the segments file, which is incremented everytime when the index is
* changed.</p>
*
* @deprecated Replaced by {@link #getCurrentVersion(String)}
*/
static uint64_t lastModified(const char* directory);
/**
* Returns the time the index in the named directory was last modified.
*
* <p>Synchronization of IndexReader and IndexWriter instances is
* no longer done via time stamps of the segments file since the time resolution
* depends on the hardware platform. Instead, a version number is maintained
* within the segments file, which is incremented everytime when the index is
* changed.</p>
*
* @deprecated Replaced by {@link #getCurrentVersion(Directory)}
* */
static uint64_t lastModified(const CL_NS(store)::Directory* directory);
/**
* Reads version number from segments files. The version number counts the
* number of changes of the index.
*
* @param directory where the index resides.
* @return version number.
* @throws IOException if segments file cannot be read.
*/
static int64_t getCurrentVersion(CL_NS(store)::Directory* directory);
/**
* Reads version number from segments files. The version number counts the
* number of changes of the index.
*
* @param directory where the index resides.
* @return version number.
* @throws IOException if segments file cannot be read
*/
static int64_t getCurrentVersion(const char* directory);
/** Return an array of term frequency vectors for the specified document.
* The array contains a vector for each vectorized field in the document.
* Each vector contains terms and frequencies for all terms
* in a given vectorized field.
* If no such fields existed, the method returns null.
*
* @see Field#isTermVectorStored()
*/
virtual TermFreqVector** getTermFreqVectors(int32_t docNumber) =0;
/** Return a term frequency vector for the specified document and field. The
* vector returned contains terms and frequencies for those terms in
* the specified field of this document, if the field had storeTermVector
* flag set. If the flag was not set, the method returns null.
*
* @see Field#isTermVectorStored()
*/
virtual TermFreqVector* getTermFreqVector(int32_t docNumber, const TCHAR* field) = 0;
///Checks if an index exists in the named directory
static bool indexExists(const char* directory);
//Checks if an index exists in the directory
static bool indexExists(const CL_NS(store)::Directory* directory);
///Returns the number of documents in this index.
virtual int32_t numDocs() = 0;
///Returns one greater than the largest possible document number.
///This may be used to, e.g., determine how big to allocate an array which
///will have an element for every document number in an index.
virtual int32_t maxDoc() const = 0;
///Returns the stored fields of the n-th Document in this index.
virtual CL_NS(document)::Document* document(const int32_t n) =0;
///Returns true if document n has been deleted
virtual bool isDeleted(const int32_t n) = 0;
/** Returns true if any documents have been deleted */
virtual bool hasDeletions() = 0;
///Returns an enumeration of all the terms in the index.
///The enumeration is ordered by Term.compareTo(). Each term
///is greater than all that precede it in the enumeration.
virtual TermEnum* terms() const =0;
///Returns an enumeration of all terms after a given term.
///The enumeration is ordered by Term.compareTo(). Each term
///is greater than all that precede it in the enumeration.
virtual TermEnum* terms(const Term* t) const = 0;
///Returns the number of documents containing the term t.
virtual int32_t docFreq(const Term* t) const = 0;
/// Returns an unpositioned TermPositions enumerator.
virtual TermPositions* termPositions() const = 0;
//Returns an enumeration of all the documents which contain term. For each
//document, in addition to the document number and frequency of the term in
//that document, a list of all of the ordinal positions of the term in the document
//is available.
TermPositions* termPositions(Term* term) const;
/// Returns an unpositioned TermDocs enumerator.
virtual TermDocs* termDocs() const = 0;
///Returns an enumeration of all the documents which contain term.
TermDocs* termDocs(Term* term) const;
///Deletes the document numbered docNum. Once a document is deleted it will not appear
///in TermDocs or TermPostitions enumerations. Attempts to read its field with the document
///method will result in an error. The presence of this document may still be reflected in
///the docFreq statistic, though this will be corrected eventually as the index is further modified.
///Note: API renamed, because delete is a reserved word in c++.
void deleteDocument(const int32_t docNum);
///@Deprecated. Use deleteDocument instead.
void deleteDoc(const int32_t docNum){ deleteDocument(docNum); }
///Deletes all documents containing term. Returns the number of deleted documents
int32_t deleteDocuments(Term* term);
///@Deprecated. Use deleteDocuments instead.
int32_t deleteTerm(Term* term){ return deleteDocuments(term); }
/**
* Closes files associated with this index and also saves any new deletions to disk.
* No other methods should be called after this has been called.
*/
void close();
///Checks if the index in the named directory is currently locked.
static bool isLocked(CL_NS(store)::Directory* directory);
///Checks if the index in the named directory is currently locked.
static bool isLocked(const char* directory);
///Forcibly unlocks the index in the named directory.
///Caution: this should only be used by failure recovery code,
///when it is known that no other process nor thread is in fact
///currently accessing this index.
static void unlock(CL_NS(store)::Directory* directory);
static void unlock(const char* path);
/** Returns the directory this index resides in. */
CL_NS(store)::Directory* getDirectory() { return directory; }
#ifndef LUCENE_HIDE_INTERNAL
//this should be protected, but MSVC 6 does not allow access
//to these fuctions in the protected classes IndexReaderLockWith
//which is wrong, since they themselves are members of the class!!
///for internal use. Public so that lock class can access it
SegmentInfos* segmentInfos;
/** Internal use. Implements commit. Public so that lock class can access it*/
virtual void doCommit() = 0;
#endif
/**
* For classes that need to know when the IndexReader closes (such as caches, etc),
* should pass their callback function to this.
*/
void addCloseCallback(CloseCallback callback, void* parameter);
protected:
class IndexReaderLockWith:public CL_NS(store)::LuceneLockWith{
public:
CL_NS(store)::Directory* directory;
IndexReader* indexReader;
//Constructor
IndexReaderLockWith(CL_NS(store)::LuceneLock* lock, CL_NS(store)::Directory* dir);
//Reads the segmentinfo file and depending on the number of segments found
//it returns a MultiReader or a SegmentReader
void* doBody();
};
class IndexReaderCommitLockWith:public CL_NS(store)::LuceneLockWith{
private:
IndexReader* reader;
public:
//Constructor
IndexReaderCommitLockWith( CL_NS(store)::LuceneLock* lock, IndexReader* r );
void* doBody();
};
};
CL_NS_END
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -