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


C# IndexReader.HasDeletions方法代码示例

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


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

示例1: Add

		/// <summary>Add an IndexReader whose stored fields will not be returned.  This can
		/// accellerate search when stored fields are only needed from a subset of
		/// the IndexReaders.
		/// 
		/// </summary>
		/// <throws>  IllegalArgumentException if not all indexes contain the same number  </throws>
		/// <summary>     of documents
		/// </summary>
		/// <throws>  IllegalArgumentException if not all indexes have the same value  </throws>
		/// <summary>     of {@link IndexReader#MaxDoc()}
		/// </summary>
		public virtual void  Add(IndexReader reader, bool ignoreStoredFields)
		{
			
			if (readers.Count == 0)
			{
				this.maxDoc = reader.MaxDoc();
				this.numDocs = reader.NumDocs();
				this.hasDeletions = reader.HasDeletions();
			}
			
			if (reader.MaxDoc() != maxDoc)
			// check compatibility
				throw new System.ArgumentException("All readers must have same maxDoc: " + maxDoc + "!=" + reader.MaxDoc());
			if (reader.NumDocs() != numDocs)
				throw new System.ArgumentException("All readers must have same numDocs: " + numDocs + "!=" + reader.NumDocs());
			
			System.Collections.IEnumerator i = reader.GetFieldNames(IndexReader.FieldOption.ALL).GetEnumerator();
			while (i.MoveNext())
			{
                System.Collections.DictionaryEntry fi = (System.Collections.DictionaryEntry) i.Current;

				// update fieldToReader map
				System.String field = fi.Key.ToString();
				if (fieldToReader[field] == null)
					fieldToReader[field] = reader;
			}
			
			if (!ignoreStoredFields)
				storedFieldReaders.Add(reader); // add to storedFieldReaders
			readers.Add(reader);
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:42,代码来源:ParallelReader.cs

示例2: Add

		/// <summary>Add an IndexReader whose stored fields will not be returned.  This can
		/// accellerate search when stored fields are only needed from a subset of
		/// the IndexReaders.
		/// 
		/// </summary>
		/// <throws>  IllegalArgumentException if not all indexes contain the same number </throws>
		/// <summary>     of documents
		/// </summary>
		/// <throws>  IllegalArgumentException if not all indexes have the same value </throws>
		/// <summary>     of {@link IndexReader#MaxDoc()}
		/// </summary>
		/// <throws>  IOException if there is a low-level IO error </throws>
		public virtual void  Add(IndexReader reader, bool ignoreStoredFields)
		{
			
			EnsureOpen();
			if (readers.Count == 0)
			{
				this.maxDoc = reader.MaxDoc();
				this.numDocs = reader.NumDocs();
				this.hasDeletions = reader.HasDeletions();
			}
			
			if (reader.MaxDoc() != maxDoc)
			// check compatibility
				throw new System.ArgumentException("All readers must have same maxDoc: " + maxDoc + "!=" + reader.MaxDoc());
			if (reader.NumDocs() != numDocs)
				throw new System.ArgumentException("All readers must have same numDocs: " + numDocs + "!=" + reader.NumDocs());
			
			System.Collections.Generic.ICollection<string> fields = reader.GetFieldNames(IndexReader.FieldOption.ALL);
			readerToFields[reader] = fields;
			System.Collections.IEnumerator i = fields.GetEnumerator();
			while (i.MoveNext())
			{
				// update fieldToReader map
				System.String field = (System.String) i.Current;
				if (fieldToReader[field] == null)
					fieldToReader[field] = reader;
			}
			
			if (!ignoreStoredFields)
				storedFieldReaders.Add(reader); // add to storedFieldReaders
			readers.Add(reader);
			
			if (incRefReaders)
			{
				reader.IncRef();
			}
			decrefOnClose.Add(incRefReaders);
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:50,代码来源:ParallelReader.cs

示例3: AssertIndexEquals

		public static void  AssertIndexEquals(IndexReader index1, IndexReader index2)
		{
			Assert.AreEqual(index1.NumDocs(), index2.NumDocs(), "IndexReaders have different values for numDocs.");
			Assert.AreEqual(index1.MaxDoc(), index2.MaxDoc(), "IndexReaders have different values for maxDoc.");
			Assert.AreEqual(index1.HasDeletions(), index2.HasDeletions(), "Only one IndexReader has deletions.");
			Assert.AreEqual(index1.IsOptimized(), index2.IsOptimized(), "Only one index is optimized.");
			
			// check field names
			System.Collections.ICollection fields1 = index1.GetFieldNames(FieldOption.ALL);
			System.Collections.ICollection fields2 = index2.GetFieldNames(FieldOption.ALL);
			Assert.AreEqual(fields1.Count, fields2.Count, "IndexReaders have different numbers of fields.");
            System.Collections.IEnumerator it1 = fields1.GetEnumerator();
            System.Collections.IEnumerator it2 = fields2.GetEnumerator();
            while (it1.MoveNext())
			{
				Assert.IsTrue(it2.MoveNext());
				Assert.AreEqual((System.String) it1.Current, (System.String) it2.Current, "Different field names.");
			}
			
			// check norms
            it1 = fields1.GetEnumerator();
            while (it1.MoveNext())
			{
				System.String curField = (System.String) it1.Current;
				byte[] norms1 = index1.Norms(curField);
				byte[] norms2 = index2.Norms(curField);
				Assert.AreEqual(norms1.Length, norms2.Length);
				for (int i = 0; i < norms1.Length; i++)
				{
					Assert.AreEqual(norms1[i], norms2[i], "Norm different for doc " + i + " and field '" + curField + "'.");
				}
			}
			
			// check deletions
			for (int i = 0; i < index1.MaxDoc(); i++)
			{
				Assert.AreEqual(index1.IsDeleted(i), index2.IsDeleted(i), "Doc " + i + " only deleted in one index.");
			}
			
			// check stored fields
			for (int i = 0; i < index1.MaxDoc(); i++)
			{
				if (!index1.IsDeleted(i))
				{
					Document doc1 = index1.Document(i);
					Document doc2 = index2.Document(i);
					fields1 = doc1.GetFields();
					fields2 = doc2.GetFields();
					Assert.AreEqual(fields1.Count, fields2.Count, "Different numbers of fields for doc " + i + ".");
					it1 = fields1.GetEnumerator();
					it2 = fields2.GetEnumerator();
					while (it1.MoveNext())
					{
						Assert.IsTrue(it2.MoveNext());
						Field curField1 = (Field) it1.Current;
						Field curField2 = (Field) it2.Current;
						Assert.AreEqual(curField1.Name(), curField2.Name(), "Different fields names for doc " + i + ".");
						Assert.AreEqual(curField1.StringValue(), curField2.StringValue(), "Different field values for doc " + i + ".");
					}
				}
			}
			
			// check dictionary and posting lists
			TermEnum enum1 = index1.Terms();
			TermEnum enum2 = index2.Terms();
			TermPositions tp1 = index1.TermPositions();
			TermPositions tp2 = index2.TermPositions();
			while (enum1.Next())
			{
				Assert.IsTrue(enum2.Next());
				Assert.AreEqual(enum1.Term(), enum2.Term(), "Different term in dictionary.");
				tp1.Seek(enum1.Term());
				tp2.Seek(enum1.Term());
				while (tp1.Next())
				{
					Assert.IsTrue(tp2.Next());
					Assert.AreEqual(tp1.Doc(), tp2.Doc(), "Different doc id in postinglist of term " + enum1.Term() + ".");
					Assert.AreEqual(tp1.Freq(), tp2.Freq(), "Different term frequence in postinglist of term " + enum1.Term() + ".");
					for (int i = 0; i < tp1.Freq(); i++)
					{
						Assert.AreEqual(tp1.NextPosition(), tp2.NextPosition(), "Different positions in postinglist of term " + enum1.Term() + ".");
					}
				}
			}
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:85,代码来源:TestIndexReader.cs

示例4: GetLiveDocs

 /// <summary>
 /// Returns a single <seealso cref="Bits"/> instance for this
 ///  reader, merging live Documents on the
 ///  fly.  this method will return null if the reader
 ///  has no deletions.
 ///
 ///  <p><b>NOTE</b>: this is a very slow way to access live docs.
 ///  For example, each Bits access will require a binary search.
 ///  It's better to get the sub-readers and iterate through them
 ///  yourself.
 /// </summary>
 public static Bits GetLiveDocs(IndexReader reader)
 {
     if (reader.HasDeletions())
     {
         IList<AtomicReaderContext> leaves = reader.Leaves();
         int size = leaves.Count;
         Debug.Assert(size > 0, "A reader with deletions must have at least one leave");
         if (size == 1)
         {
             return leaves[0].AtomicReader.LiveDocs;
         }
         Bits[] liveDocs = new Bits[size];
         int[] starts = new int[size + 1];
         for (int i = 0; i < size; i++)
         {
             // record all liveDocs, even if they are null
             AtomicReaderContext ctx = leaves[i];
             liveDocs[i] = ctx.AtomicReader.LiveDocs;
             starts[i] = ctx.DocBase;
         }
         starts[size] = reader.MaxDoc();
         return new MultiBits(liveDocs, starts, true);
     }
     else
     {
         return null;
     }
 }
开发者ID:joyanta,项目名称:lucene.net,代码行数:39,代码来源:MultiFields.cs


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