当前位置: 首页>>代码示例>>C#>>正文


C# IndexWriter.GetSegmentCount方法代码示例

本文整理汇总了C#中Lucene.Net.Index.IndexWriter.GetSegmentCount方法的典型用法代码示例。如果您正苦于以下问题:C# IndexWriter.GetSegmentCount方法的具体用法?C# IndexWriter.GetSegmentCount怎么用?C# IndexWriter.GetSegmentCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Index.IndexWriter的用法示例。


在下文中一共展示了IndexWriter.GetSegmentCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestNoOverMerge

 public virtual void  TestNoOverMerge()
 {
     Directory dir = new RAMDirectory();
     
     IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
     writer.SetMaxBufferedDocs(10);
     writer.MergeFactor = 10;
     writer.SetMergePolicy(new LogDocMergePolicy(writer));
     
     bool noOverMerge = false;
     for (int i = 0; i < 100; i++)
     {
         AddDoc(writer);
         CheckInvariants(writer);
         if (writer.GetNumBufferedDocuments() + writer.GetSegmentCount() >= 18)
         {
             noOverMerge = true;
         }
     }
     Assert.IsTrue(noOverMerge);
     
     writer.Close();
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:23,代码来源:TestIndexWriterMergePolicy.cs

示例2: TestRAMDeletes

		public virtual void  TestRAMDeletes()
		{
			for (int pass = 0; pass < 2; pass++)
			{
				for (int t = 0; t < 2; t++)
				{
					bool autoCommit = (0 == pass);
					Directory dir = new MockRAMDirectory();
					IndexWriter modifier = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true);
					modifier.SetMaxBufferedDocs(4);
					modifier.SetMaxBufferedDeleteTerms(4);
					
					int id = 0;
					int value_Renamed = 100;
					
					AddDoc(modifier, ++id, value_Renamed);
					if (0 == t)
						modifier.DeleteDocuments(new Term("value", System.Convert.ToString(value_Renamed)));
					else
						modifier.DeleteDocuments(new TermQuery(new Term("value", System.Convert.ToString(value_Renamed))));
					AddDoc(modifier, ++id, value_Renamed);
					if (0 == t)
					{
						modifier.DeleteDocuments(new Term("value", System.Convert.ToString(value_Renamed)));
						Assert.AreEqual(2, modifier.GetNumBufferedDeleteTerms());
						Assert.AreEqual(1, modifier.GetBufferedDeleteTermsSize());
					}
					else
						modifier.DeleteDocuments(new TermQuery(new Term("value", System.Convert.ToString(value_Renamed))));
					
					AddDoc(modifier, ++id, value_Renamed);
					Assert.AreEqual(0, modifier.GetSegmentCount());
					modifier.Flush();
					
					modifier.Commit();
					
					IndexReader reader = IndexReader.Open(dir);
					Assert.AreEqual(1, reader.NumDocs());
					
					int hitCount = GetHitCount(dir, new Term("id", System.Convert.ToString(id)));
					Assert.AreEqual(1, hitCount);
					reader.Close();
					modifier.Close();
					dir.Close();
				}
			}
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:47,代码来源:TestIndexWriterDelete.cs

示例3: TestNonRAMDelete

		public virtual void  TestNonRAMDelete()
		{
			for (int pass = 0; pass < 2; pass++)
			{
				bool autoCommit = (0 == pass);
				
				Directory dir = new MockRAMDirectory();
				IndexWriter modifier = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true);
				modifier.SetMaxBufferedDocs(2);
				modifier.SetMaxBufferedDeleteTerms(2);
				
				int id = 0;
				int value_Renamed = 100;
				
				for (int i = 0; i < 7; i++)
				{
					AddDoc(modifier, ++id, value_Renamed);
				}
				modifier.Commit();
				
				Assert.AreEqual(0, modifier.GetNumBufferedDocuments());
				Assert.IsTrue(0 < modifier.GetSegmentCount());
				
				modifier.Commit();
				
				IndexReader reader = IndexReader.Open(dir);
				Assert.AreEqual(7, reader.NumDocs());
				reader.Close();
				
				modifier.DeleteDocuments(new Term("value", System.Convert.ToString(value_Renamed)));
				
				modifier.Commit();
				
				reader = IndexReader.Open(dir);
				Assert.AreEqual(0, reader.NumDocs());
				reader.Close();
				modifier.Close();
				dir.Close();
			}
		}
开发者ID:Mpdreamz,项目名称:lucene.net,代码行数:40,代码来源:TestIndexWriterDelete.cs

示例4: CheckInvariants

 private void  CheckInvariants(IndexWriter writer)
 {
     writer.WaitForMerges();
     int maxBufferedDocs = writer.GetMaxBufferedDocs();
     int mergeFactor = writer.MergeFactor;
     int maxMergeDocs = writer.MaxMergeDocs;
     
     int ramSegmentCount = writer.GetNumBufferedDocuments();
     Assert.IsTrue(ramSegmentCount < maxBufferedDocs);
     
     int lowerBound = - 1;
     int upperBound = maxBufferedDocs;
     int numSegments = 0;
     
     int segmentCount = writer.GetSegmentCount();
     for (int i = segmentCount - 1; i >= 0; i--)
     {
         int docCount = writer.GetDocCount(i);
         Assert.IsTrue(docCount > lowerBound);
         
         if (docCount <= upperBound)
         {
             numSegments++;
         }
         else
         {
             if (upperBound * mergeFactor <= maxMergeDocs)
             {
                 Assert.IsTrue(numSegments < mergeFactor, "maxMergeDocs=" + maxMergeDocs + "; numSegments=" + numSegments + "; upperBound=" + upperBound + "; mergeFactor=" + mergeFactor);
             }
             
             do 
             {
                 lowerBound = upperBound;
                 upperBound *= mergeFactor;
             }
             while (docCount > upperBound);
             numSegments = 1;
         }
     }
     if (upperBound * mergeFactor <= maxMergeDocs)
     {
         Assert.IsTrue(numSegments < mergeFactor);
     }
 }
开发者ID:Nangal,项目名称:lucene.net,代码行数:45,代码来源:TestIndexWriterMergePolicy.cs

示例5: CheckInvariants

		private void  CheckInvariants(IndexWriter writer)
		{
			_TestUtil.SyncConcurrentMerges(writer);
			int maxBufferedDocs = writer.GetMaxBufferedDocs();
			int mergeFactor = writer.GetMergeFactor();
			int maxMergeDocs = writer.GetMaxMergeDocs();
			
			int ramSegmentCount = writer.GetNumBufferedDocuments();
			Assert.IsTrue(ramSegmentCount < maxBufferedDocs);
			
			int lowerBound = - 1;
			int upperBound = maxBufferedDocs;
			int numSegments = 0;
			
			int segmentCount = writer.GetSegmentCount();
			for (int i = segmentCount - 1; i >= 0; i--)
			{
				int docCount = writer.GetDocCount(i);
				Assert.IsTrue(docCount > lowerBound);
				
				if (docCount <= upperBound)
				{
					numSegments++;
				}
				else
				{
					if (upperBound * mergeFactor <= maxMergeDocs)
					{
						Assert.IsTrue(numSegments < mergeFactor);
					}
					
					do 
					{
						lowerBound = upperBound;
						upperBound *= mergeFactor;
					}
					while (docCount > upperBound);
					numSegments = 1;
				}
			}
			if (upperBound * mergeFactor <= maxMergeDocs)
			{
				Assert.IsTrue(numSegments < mergeFactor);
			}
			
			System.String[] files = writer.GetDirectory().ListAll();
			int segmentCfsCount = 0;
			for (int i = 0; i < files.Length; i++)
			{
				if (files[i].EndsWith(".cfs"))
				{
					segmentCfsCount++;
				}
			}
			Assert.AreEqual(segmentCount, segmentCfsCount);
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:56,代码来源:TestIndexWriterMergePolicy.cs

示例6: PrintSegmentDocCounts

		private void  PrintSegmentDocCounts(IndexWriter writer)
		{
			int segmentCount = writer.GetSegmentCount();
			System.Console.Out.WriteLine("" + segmentCount + " segments total");
			for (int i = 0; i < segmentCount; i++)
			{
				System.Console.Out.WriteLine("  segment " + i + " has " + writer.GetDocCount(i) + " docs");
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:9,代码来源:TestIndexWriterMergePolicy.cs


注:本文中的Lucene.Net.Index.IndexWriter.GetSegmentCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。