/// <summary>Expert: like {@link #getReader}, except you can /// specify which termInfosIndexDivisor should be used for /// any newly opened readers. /// </summary> /// <param name="termInfosIndexDivisor">Subsambles which indexed /// terms are loaded into RAM. This has the same effect as {@link /// IndexWriter#setTermIndexInterval} except that setting /// must be done at indexing time while this setting can be /// set per reader. When set to N, then one in every /// N*termIndexInterval terms in the index is loaded into /// memory. By setting this to a value > 1 you can reduce /// memory usage, at the expense of higher latency when /// loading a TermInfo. The default value is 1. Set this /// to -1 to skip loading the terms index entirely. /// </param> public virtual IndexReader GetReader(int termInfosIndexDivisor) { EnsureOpen(); if (infoStream != null) { Message("flush at getReader"); } // Do this up front before flushing so that the readers // obtained during this flush are pooled, the first time // this method is called: poolReaders = true; // Prevent segmentInfos from changing while opening the // reader; in theory we could do similar retry logic, // just like we do when loading segments_N IndexReader r; lock (this) { Flush(false, true, true); r = new ReadOnlyDirectoryReader(this, segmentInfos, termInfosIndexDivisor); } MaybeMerge(); return r; }
private DirectoryReader DoReopen(SegmentInfos infos, bool doClone, bool openReadOnly) { lock (this) { DirectoryReader reader; if (openReadOnly) { reader = new ReadOnlyDirectoryReader(internalDirectory, infos, subReaders, starts, normsCache, doClone, termInfosIndexDivisor); } else { reader = new DirectoryReader(internalDirectory, infos, subReaders, starts, normsCache, false, doClone, termInfosIndexDivisor); } return reader; } }