7#ifndef DIRECTORYREADER_H
8#define DIRECTORYREADER_H
30 bool doClone, int32_t termInfosIndexDivisor);
114 virtual ByteArray
norms(
const String& field);
117 virtual void norms(
const String& field, ByteArray norms, int32_t offset);
182 virtual void doSetNorm(int32_t doc,
const String& field, uint8_t value);
187 virtual void doCommit(MapStringString commitUserData);
192 friend class FindSegmentsReopen;
293 virtual ByteArray
getPayload(ByteArray data, int32_t offset);
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
An IndexReader which reads indexes with multiple segments.
Definition DirectoryReader.h:19
virtual int64_t getVersion()
Version number when this IndexReader was opened.
virtual IndexReaderPtr reopen(const IndexCommitPtr &commit)
Reopen this reader on a specific commit point. This always returns a readOnly reader....
virtual int32_t getTermInfosIndexDivisor()
For IndexReader implementations that use TermInfosReader to read terms, this returns the current inde...
virtual void doClose()
Implements close.
virtual void getTermFreqVector(int32_t docNumber, const TermVectorMapperPtr &mapper)
Map all the term vectors for all fields in a Document.
virtual bool hasDeletions()
Returns true if any documents have been deleted.
virtual MapStringString getCommitUserData()
Retrieve the String userData optionally passed to IndexWriter::commit.
Collection< int32_t > starts
Definition DirectoryReader.h:51
virtual TermPositionsPtr termPositions()
Returns an unpositioned TermPositions enumerator.
DirectoryReader(const DirectoryPtr &directory, const SegmentInfosPtr &sis, const IndexDeletionPolicyPtr &deletionPolicy, bool readOnly, int32_t termInfosIndexDivisor)
Construct reading the named set of readers.
bool rollbackHasChanges
Definition DirectoryReader.h:48
IndexReaderPtr doReopenNoWriter(bool openReadOnly, const IndexCommitPtr &commit)
IndexWriterWeakPtr _writer
Definition DirectoryReader.h:39
void _initialize(Collection< SegmentReaderPtr > subReaders)
virtual ~DirectoryReader()
virtual TermDocsPtr termDocs()
Returns an unpositioned TermDocs enumerator.
int32_t _numDocs
Definition DirectoryReader.h:54
virtual LuceneObjectPtr clone(bool openReadOnly, const LuceneObjectPtr &other=LuceneObjectPtr())
Clones the IndexReader and optionally changes readOnly. A readOnly reader cannot open a writable read...
DirectoryReader(const DirectoryPtr &directory, const SegmentInfosPtr &infos, Collection< SegmentReaderPtr > oldReaders, Collection< int32_t > oldStarts, MapStringByteArray oldNormsCache, bool readOnly, bool doClone, int32_t termInfosIndexDivisor)
This constructor is only used for reopen().
virtual ByteArray norms(const String &field)
Returns the byte-encoded normalization factor for the named field of every document.
virtual void norms(const String &field, ByteArray norms, int32_t offset)
Reads the byte-encoded normalization factor for the named field of every document.
virtual void doDelete(int32_t docNum)
Implements deletion of the document numbered docNum.
virtual DirectoryPtr directory()
Returns the directory this index resides in.
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Efficiently clones the IndexReader (sharing most internal state).
SegmentInfosPtr segmentInfosStart
Definition DirectoryReader.h:44
virtual Collection< IndexReaderPtr > getSequentialSubReaders()
Returns the sequential sub readers that this reader is logically composed of.
IndexDeletionPolicyPtr deletionPolicy
Definition DirectoryReader.h:40
HashSet< String > synced
Definition DirectoryReader.h:41
virtual void getTermFreqVector(int32_t docNumber, const String &field, const TermVectorMapperPtr &mapper)
Load the Term Vector into a user-defined data structure instead of relying on the parallel arrays of ...
virtual DocumentPtr document(int32_t n, const FieldSelectorPtr &fieldSelector)
Get the Document at the n'th position. The FieldSelector may be used to determine what Fields to load...
virtual bool isCurrent()
Check whether any new changes have occurred to the index since this reader was opened.
virtual bool isDeleted(int32_t n)
Returns true if document n has been deleted.
virtual IndexCommitPtr getIndexCommit()
Return the IndexCommit that this reader has opened.
static HashSet< String > getFieldNames(FieldOption fieldOption, Collection< IndexReaderPtr > subReaders)
bool stale
Definition DirectoryReader.h:45
IndexReaderPtr doReopenFromWriter(bool openReadOnly, const IndexCommitPtr &commit)
virtual TermFreqVectorPtr getTermFreqVector(int32_t docNumber, const String &field)
Return a term frequency vector for the specified document and field.
int64_t maxIndexVersion
Definition DirectoryReader.h:59
virtual HashSet< String > getFieldNames(FieldOption fieldOption)
Get a list of unique field names that exist in this index and have the specified field option informa...
virtual Collection< TermFreqVectorPtr > getTermFreqVectors(int32_t docNumber)
Return an array of term frequency vectors for the specified document.
virtual void doSetNorm(int32_t doc, const String &field, uint8_t value)
Implements setNorm in subclass.
static int32_t readerIndex(int32_t n, Collection< int32_t > starts, int32_t numSubReaders)
Find reader for doc n.
virtual TermEnumPtr terms()
Returns an enumeration of all the terms in the index.
bool readOnly
Definition DirectoryReader.h:38
virtual void doUndeleteAll()
Implements actual undeleteAll() in subclass.
int32_t _maxDoc
Definition DirectoryReader.h:53
MapStringByteArray normsCache
Definition DirectoryReader.h:52
virtual bool isOptimized()
Checks is the index is optimized (if it has a single segment and no deletions). Not implemented in th...
int32_t readerIndex(int32_t n)
virtual int32_t numDocs()
Returns the number of documents in this index.
SegmentInfosPtr segmentInfos
Definition DirectoryReader.h:43
DirectoryPtr _directory
Definition DirectoryReader.h:37
virtual IndexReaderPtr reopen(bool openReadOnly)
Just like reopen(), except you can change the readOnly of the original reader. If the index is unchan...
virtual int32_t docFreq(const TermPtr &t)
Returns the number of documents containing the term t.
virtual int32_t maxDoc()
Returns one greater than the largest possible document number.
LockPtr writeLock
Definition DirectoryReader.h:42
static Collection< IndexCommitPtr > listCommits(const DirectoryPtr &dir)
Returns all commit points that exist in the Directory.
IndexReaderPtr doReopen(bool openReadOnly, const IndexCommitPtr &commit)
static IndexReaderPtr open(const DirectoryPtr &directory, const IndexDeletionPolicyPtr &deletionPolicy, const IndexCommitPtr &commit, bool readOnly, int32_t termInfosIndexDivisor)
virtual TermEnumPtr terms(const TermPtr &t)
Returns an enumeration of all terms starting at a given term.
DirectoryReaderPtr doReopen(const SegmentInfosPtr &infos, bool doClone, bool openReadOnly)
DirectoryReader(const IndexWriterPtr &writer, const SegmentInfosPtr &infos, int32_t termInfosIndexDivisor)
Used by near real-time search.
int32_t termInfosIndexDivisor
Definition DirectoryReader.h:46
virtual IndexReaderPtr reopen()
Refreshes an IndexReader if the index has changed since this instance was (re)opened.
virtual void acquireWriteLock()
Tries to acquire the WriteLock on this directory. this method is only valid if this IndexReader is di...
virtual void doCommit(MapStringString commitUserData)
Commit changes resulting from delete, undeleteAll, or setNorm operations.
virtual bool hasNorms(const String &field)
Returns true if there are norms stored for this field.
bool _hasDeletions
Definition DirectoryReader.h:55
Collection< SegmentReaderPtr > subReaders
Definition DirectoryReader.h:50
Utility template class to handle hash set collections that can be safely copied and shared.
Definition HashSet.h:17
Represents a single commit into an index as seen by the IndexDeletionPolicy or IndexReader.
Definition IndexCommit.h:22
IndexReader is an abstract class, providing an interface for accessing an index. Search of an index i...
Definition IndexReader.h:39
FieldOption
Constants describing field properties, for example used for IndexReader#getFieldNames(FieldOption).
Definition IndexReader.h:48
Base class for all Lucene classes.
Definition LuceneObject.h:31
Definition DirectoryReader.h:225
virtual TermDocsPtr termDocs(int32_t i)
TermPtr term
Definition DirectoryReader.h:236
virtual bool skipTo(int32_t target)
Skips entries to the first beyond the current whose document number is greater than or equal to targe...
virtual bool next()
Moves to the next pair in the enumeration.
Collection< IndexReaderPtr > readers
Definition DirectoryReader.h:234
Collection< TermDocsPtr > readerTermDocs
Definition DirectoryReader.h:241
virtual void close()
Frees associated resources.
virtual void seek(const TermEnumPtr &termEnum)
Sets this to the data for the current term in a TermEnum.
virtual TermDocsPtr termDocs(const IndexReaderPtr &reader)
virtual int32_t read(Collection< int32_t > &docs, Collection< int32_t > &freqs)
Attempts to read multiple entries from the enumeration, up to length of docs. Optimized implementatio...
int32_t pointer
Definition DirectoryReader.h:239
virtual int32_t doc()
Returns the current document number.
int32_t matchingSegmentPos
Definition DirectoryReader.h:244
int32_t base
Definition DirectoryReader.h:238
virtual void seek(const TermPtr &term)
Sets this to the data for a term.
MultiTermDocs(const IndexReaderPtr &topReader, Collection< IndexReaderPtr > r, Collection< int32_t > s)
Collection< int32_t > starts
Definition DirectoryReader.h:235
virtual int32_t freq()
Returns the frequency of the term within the current document.
IndexReaderWeakPtr _topReader
Definition DirectoryReader.h:233
SegmentMergeInfoPtr smi
Definition DirectoryReader.h:245
MultiTermEnumPtr tenum
Definition DirectoryReader.h:243
TermDocsPtr current
Definition DirectoryReader.h:242
Definition DirectoryReader.h:278
virtual int32_t nextPosition()
Returns next position in the current document.
virtual int32_t getPayloadLength()
Returns the length of the payload at the current term position.
virtual ~MultiTermPositions()
virtual TermDocsPtr termDocs(const IndexReaderPtr &reader)
virtual bool isPayloadAvailable()
Checks if a payload can be loaded at this position.
MultiTermPositions(const IndexReaderPtr &topReader, Collection< IndexReaderPtr > r, Collection< int32_t > s)
virtual ByteArray getPayload(ByteArray data, int32_t offset)
Returns the payload data at the current term position.
Definition DirectoryReader.h:302
HashSet< String > files
Definition DirectoryReader.h:311
virtual HashSet< String > getFileNames()
Returns all index files referenced by this commit point.
int64_t generation
Definition DirectoryReader.h:313
ReaderCommit(const SegmentInfosPtr &infos, const DirectoryPtr &dir)
virtual String toString()
Returns a string representation of the object.
String segmentsFileName
Definition DirectoryReader.h:310
virtual String getSegmentsFileName()
Two IndexCommits are equal if both their Directory and versions are equal.
int64_t version
Definition DirectoryReader.h:314
bool _isOptimized
Definition DirectoryReader.h:315
virtual bool isOptimized()
Returns true if this commit is an optimized index.
virtual MapStringString getUserData()
Returns userData, previously passed to IndexWriter#commit(Map) for this commit.
MapStringString userData
Definition DirectoryReader.h:316
virtual int64_t getVersion()
Returns the version for this IndexCommit.
DirectoryPtr dir
Definition DirectoryReader.h:312
virtual int64_t getGeneration()
Returns the generation (the _N in segments_N) for this IndexCommit.
virtual DirectoryPtr getDirectory()
Returns the Directory for the index.
virtual void deleteCommit()
Delete this commit point. This only applies when using the commit point in the context of IndexWriter...
TermPositions provides an interface for enumerating the <document, frequency, <position>*> tuples for...
Definition TermPositions.h:18
Definition AbstractAllTermDocs.h:12
boost::shared_ptr< IndexCommit > IndexCommitPtr
Definition LuceneTypes.h:152
boost::shared_ptr< SegmentMergeInfo > SegmentMergeInfoPtr
Definition LuceneTypes.h:212
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
boost::shared_ptr< Lock > LockPtr
Definition LuceneTypes.h:496
boost::shared_ptr< TermPositions > TermPositionsPtr
Definition LuceneTypes.h:243
boost::shared_ptr< TermDocs > TermDocsPtr
Definition LuceneTypes.h:236
boost::weak_ptr< IndexWriter > IndexWriterWeakPtr
Definition LuceneTypes.h:160
boost::shared_ptr< DirectoryReader > DirectoryReaderPtr
Definition LuceneTypes.h:105
boost::shared_ptr< FieldSelector > FieldSelectorPtr
Definition LuceneTypes.h:77
boost::weak_ptr< IndexReader > IndexReaderWeakPtr
Definition LuceneTypes.h:157
boost::shared_ptr< Term > TermPtr
Definition LuceneTypes.h:233
boost::shared_ptr< MultiTermEnum > MultiTermEnumPtr
Definition LuceneTypes.h:183
boost::shared_ptr< TermVectorMapper > TermVectorMapperPtr
Definition LuceneTypes.h:254
boost::shared_ptr< Directory > DirectoryPtr
Definition LuceneTypes.h:489
boost::shared_ptr< IndexDeletionPolicy > IndexDeletionPolicyPtr
Definition LuceneTypes.h:153
boost::shared_ptr< TermEnum > TermEnumPtr
Definition LuceneTypes.h:235
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition LuceneTypes.h:157
boost::shared_ptr< TermFreqVector > TermFreqVectorPtr
Definition LuceneTypes.h:237
boost::shared_ptr< Document > DocumentPtr
Definition LuceneTypes.h:74
boost::shared_ptr< SegmentMergeQueue > SegmentMergeQueuePtr
Definition LuceneTypes.h:213
boost::shared_ptr< SegmentInfos > SegmentInfosPtr
Definition LuceneTypes.h:210
boost::shared_ptr< IndexWriter > IndexWriterPtr
Definition LuceneTypes.h:160