// used by IndexWriterConfig internal LiveIndexWriterConfig(Analyzer analyzer, LuceneVersion matchVersion) { this.analyzer = analyzer; this.matchVersion = matchVersion; ramBufferSizeMB = IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB; maxBufferedDocs = IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS; maxBufferedDeleteTerms = IndexWriterConfig.DEFAULT_MAX_BUFFERED_DELETE_TERMS; readerTermsIndexDivisor = IndexWriterConfig.DEFAULT_READER_TERMS_INDEX_DIVISOR; mergedSegmentWarmer = null; termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL; // TODO: this should be private to the codec, not settable here delPolicy = new KeepOnlyLastCommitDeletionPolicy(); commit = null; useCompoundFile = IndexWriterConfig.DEFAULT_USE_COMPOUND_FILE_SYSTEM; openMode = Index.OpenMode.CREATE_OR_APPEND; similarity = IndexSearcher.DefaultSimilarity; #if !FEATURE_CONCURRENTMERGESCHEDULER mergeScheduler = new TaskMergeScheduler(); #else mergeScheduler = new ConcurrentMergeScheduler(); #endif writeLockTimeout = IndexWriterConfig.WRITE_LOCK_TIMEOUT; indexingChain = DocumentsWriterPerThread.DefaultIndexingChain; codec = Codec.Default; if (codec == null) { throw new NullReferenceException(); } infoStream = Util.InfoStream.Default; mergePolicy = new TieredMergePolicy(); flushPolicy = new FlushByRamOrCountsPolicy(); readerPooling = IndexWriterConfig.DEFAULT_READER_POOLING; indexerThreadPool = new DocumentsWriterPerThreadPool(IndexWriterConfig.DEFAULT_MAX_THREAD_STATES); perThreadHardLimitMB = IndexWriterConfig.DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB; }
/// <summary> /// Creates a new config that that handles the live <see cref="IndexWriter"/> /// settings. /// </summary> internal LiveIndexWriterConfig(IndexWriterConfig config) { maxBufferedDeleteTerms = config.MaxBufferedDeleteTerms; maxBufferedDocs = config.MaxBufferedDocs; mergedSegmentWarmer = config.MergedSegmentWarmer; ramBufferSizeMB = config.RAMBufferSizeMB; readerTermsIndexDivisor = config.ReaderTermsIndexDivisor; termIndexInterval = config.TermIndexInterval; matchVersion = config.matchVersion; analyzer = config.Analyzer; delPolicy = config.IndexDeletionPolicy; commit = config.IndexCommit; openMode = config.OpenMode; similarity = config.Similarity; mergeScheduler = config.MergeScheduler; writeLockTimeout = config.WriteLockTimeout; indexingChain = config.IndexingChain; codec = config.Codec; infoStream = config.InfoStream; mergePolicy = config.MergePolicy; indexerThreadPool = config.IndexerThreadPool; readerPooling = config.UseReaderPooling; flushPolicy = config.FlushPolicy; perThreadHardLimitMB = config.RAMPerThreadHardLimitMB; useCompoundFile = config.UseCompoundFile; checkIntegrityAtMerge = config.CheckIntegrityAtMerge; }
public virtual void TestClone() { IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())); IndexWriterConfig clone = (IndexWriterConfig)conf.Clone(); // Make sure parameters that can't be reused are cloned IndexDeletionPolicy delPolicy = conf.DelPolicy; IndexDeletionPolicy delPolicyClone = clone.DelPolicy; Assert.IsTrue(delPolicy.GetType() == delPolicyClone.GetType() && (delPolicy != delPolicyClone || delPolicy.Clone() == delPolicyClone.Clone())); FlushPolicy flushPolicy = conf.FlushPolicy; FlushPolicy flushPolicyClone = clone.FlushPolicy; Assert.IsTrue(flushPolicy.GetType() == flushPolicyClone.GetType() && (flushPolicy != flushPolicyClone || flushPolicy.Clone() == flushPolicyClone.Clone())); DocumentsWriterPerThreadPool pool = conf.IndexerThreadPool; DocumentsWriterPerThreadPool poolClone = clone.IndexerThreadPool; Assert.IsTrue(pool.GetType() == poolClone.GetType() && (pool != poolClone || pool.Clone() == poolClone.Clone())); MergePolicy mergePolicy = conf.MergePolicy; MergePolicy mergePolicyClone = clone.MergePolicy; Assert.IsTrue(mergePolicy.GetType() == mergePolicyClone.GetType() && (mergePolicy != mergePolicyClone || mergePolicy.Clone() == mergePolicyClone.Clone())); IMergeScheduler mergeSched = conf.MergeScheduler; IMergeScheduler mergeSchedClone = clone.MergeScheduler; Assert.IsTrue(mergeSched.GetType() == mergeSchedClone.GetType() && (mergeSched != mergeSchedClone || mergeSched.Clone() == mergeSchedClone.Clone())); conf.SetMergeScheduler(new SerialMergeScheduler()); Assert.AreEqual(typeof(ConcurrentMergeScheduler), clone.MergeScheduler.GetType()); }
/// <summary> /// Expert: Controls when segments are flushed to disk during indexing. /// The <seealso cref="FlushPolicy"/> initialized during <seealso cref="IndexWriter"/> instantiation and once initialized /// the given instance is bound to this <seealso cref="IndexWriter"/> and should not be used with another writer. </summary> /// <seealso cref= #setMaxBufferedDeleteTerms(int) </seealso> /// <seealso cref= #setMaxBufferedDocs(int) </seealso> /// <seealso cref= #setRAMBufferSizeMB(double) </seealso> public IndexWriterConfig SetFlushPolicy(FlushPolicy flushPolicy) { if (flushPolicy == null) { throw new System.ArgumentException("flushPolicy must not be null"); } this.flushPolicy = flushPolicy; return(this); }
internal DocumentsWriterFlushControl(DocumentsWriter documentsWriter, LiveIndexWriterConfig config, BufferedUpdatesStream bufferedUpdatesStream) { this.infoStream = config.InfoStream; this.stallControl = new DocumentsWriterStallControl(); this.perThreadPool = documentsWriter.perThreadPool; this.flushPolicy = documentsWriter.flushPolicy; this.config = config; this.hardMaxBytesPerDWPT = config.RAMPerThreadHardLimitMB * 1024 * 1024; this.documentsWriter = documentsWriter; this.bufferedUpdatesStream = bufferedUpdatesStream; }
internal DocumentsWriter(IndexWriter writer, LiveIndexWriterConfig config, Directory directory) { this.directory = directory; this.config = config; this.infoStream = config.InfoStream; this.perThreadPool = config.IndexerThreadPool; flushPolicy = config.FlushPolicy; this.writer = writer; this.events = new ConcurrentQueue <IEvent>(); flushControl = new DocumentsWriterFlushControl(this, config, writer.bufferedUpdatesStream); }
internal DocumentsWriterFlushControl(DocumentsWriter documentsWriter, LiveIndexWriterConfig config, BufferedUpdatesStream bufferedUpdatesStream) { this.InfoStream_Renamed = config.InfoStream; this.StallControl = new DocumentsWriterStallControl(); this.PerThreadPool = documentsWriter.PerThreadPool; this.FlushPolicy = documentsWriter.FlushPolicy; this.Config = config; this.HardMaxBytesPerDWPT = config.RAMPerThreadHardLimitMB * 1024 * 1024; this.DocumentsWriter = documentsWriter; this.BufferedUpdatesStream = bufferedUpdatesStream; }
internal DocumentsWriter(IndexWriter writer, LiveIndexWriterConfig config, Directory directory) { this.Directory = directory; this.LIWConfig = config; this.InfoStream = config.InfoStream; this.PerThreadPool = config.IndexerThreadPool; FlushPolicy = config.FlushPolicy; this.Writer = writer; this.Events = new ConcurrentQueue <Event>(); FlushControl = new DocumentsWriterFlushControl(this, config, writer.BufferedUpdatesStream); }
/// <summary> /// Expert: Controls when segments are flushed to disk during indexing. /// The <seealso cref="FlushPolicy"/> initialized during <seealso cref="IndexWriter"/> instantiation and once initialized /// the given instance is bound to this <seealso cref="IndexWriter"/> and should not be used with another writer. </summary> /// <seealso cref= #setMaxBufferedDeleteTerms(int) </seealso> /// <seealso cref= #setMaxBufferedDocs(int) </seealso> /// <seealso cref= #setRAMBufferSizeMB(double) </seealso> public IndexWriterConfig SetFlushPolicy(FlushPolicy flushPolicy) { if (flushPolicy == null) { throw new System.ArgumentException("flushPolicy must not be null"); } this.flushPolicy = flushPolicy; return this; }
internal DocumentsWriter(IndexWriter writer, LiveIndexWriterConfig config, Directory directory) { this.Directory = directory; this.LIWConfig = config; this.InfoStream = config.InfoStream; this.PerThreadPool = config.IndexerThreadPool; FlushPolicy = config.FlushPolicy; this.Writer = writer; this.Events = new ConcurrentQueue<Event>(); FlushControl = new DocumentsWriterFlushControl(this, config, writer.BufferedUpdatesStream); }
/// <summary> /// Creates a new config that that handles the live <seealso cref="IndexWriter"/> /// settings. /// </summary> internal LiveIndexWriterConfig(IndexWriterConfig config) { maxBufferedDeleteTerms = config.MaxBufferedDeleteTerms; maxBufferedDocs = config.MaxBufferedDocs; mergedSegmentWarmer = config.MergedSegmentWarmer; RamBufferSizeMB = config.RAMBufferSizeMB; readerTermsIndexDivisor = config.ReaderTermsIndexDivisor; termIndexInterval = config.TermIndexInterval; MatchVersion = config.MatchVersion; analyzer = config.Analyzer; delPolicy = config.DelPolicy; Commit = config.IndexCommit; openMode = config.OpenMode; similarity = config.Similarity; mergeScheduler = config.MergeScheduler; writeLockTimeout = config.WriteLockTimeout; indexingChain = config.IndexingChain; codec = config.Codec; infoStream = config.InfoStream; mergePolicy = config.MergePolicy; indexerThreadPool = config.IndexerThreadPool; readerPooling = config.ReaderPooling; flushPolicy = config.FlushPolicy; PerThreadHardLimitMB = config.RAMPerThreadHardLimitMB; useCompoundFile = config.UseCompoundFile; checkIntegrityAtMerge = config.CheckIntegrityAtMerge; }
// used by IndexWriterConfig internal LiveIndexWriterConfig(Analyzer analyzer, Version matchVersion) { this.analyzer = analyzer; this.MatchVersion = matchVersion; RamBufferSizeMB = IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB; maxBufferedDocs = IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS; maxBufferedDeleteTerms = IndexWriterConfig.DEFAULT_MAX_BUFFERED_DELETE_TERMS; readerTermsIndexDivisor = IndexWriterConfig.DEFAULT_READER_TERMS_INDEX_DIVISOR; mergedSegmentWarmer = null; termIndexInterval = IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL; // TODO: this should be private to the codec, not settable here delPolicy = new KeepOnlyLastCommitDeletionPolicy(); Commit = null; useCompoundFile = IndexWriterConfig.DEFAULT_USE_COMPOUND_FILE_SYSTEM; openMode = OpenMode_e.CREATE_OR_APPEND; similarity = IndexSearcher.DefaultSimilarity; mergeScheduler = new ConcurrentMergeScheduler(); writeLockTimeout = IndexWriterConfig.WRITE_LOCK_TIMEOUT; indexingChain = DocumentsWriterPerThread.defaultIndexingChain; codec = Codec.Default; if (codec == null) { throw new System.NullReferenceException(); } infoStream = Util.InfoStream.Default; mergePolicy = new TieredMergePolicy(); flushPolicy = new FlushByRamOrCountsPolicy(); readerPooling = IndexWriterConfig.DEFAULT_READER_POOLING; indexerThreadPool = new ThreadAffinityDocumentsWriterThreadPool(IndexWriterConfig.DEFAULT_MAX_THREAD_STATES); PerThreadHardLimitMB = IndexWriterConfig.DEFAULT_RAM_PER_THREAD_HARD_LIMIT_MB; }