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


C# Mono.Lucene.Net.Index.IndexReader.MaxDoc方法代码示例

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


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

示例1: BitSpans

		public override SpanFilterResult BitSpans(IndexReader reader)
		{
			
			OpenBitSet bits = new OpenBitSet(reader.MaxDoc());
			Mono.Lucene.Net.Search.Spans.Spans spans = query.GetSpans(reader);
			System.Collections.IList tmp = new System.Collections.ArrayList(20);
			int currentDoc = - 1;
			SpanFilterResult.PositionInfo currentInfo = null;
			while (spans.Next())
			{
				int doc = spans.Doc();
				bits.Set(doc);
				if (currentDoc != doc)
				{
					currentInfo = new SpanFilterResult.PositionInfo(doc);
					tmp.Add(currentInfo);
					currentDoc = doc;
				}
				currentInfo.AddPosition(spans.Start(), spans.End());
			}
			return new SpanFilterResult(bits, tmp);
		}
开发者ID:carrie901,项目名称:mono,代码行数:22,代码来源:SpanQueryFilter.cs

示例2: Rewrite

			public override Query Rewrite(IndexReader reader, MultiTermQuery query)
			{
				// Get the enum and start visiting terms.  If we
				// exhaust the enum before hitting either of the
				// cutoffs, we use ConstantBooleanQueryRewrite; else,
				// ConstantFilterRewrite:
				System.Collections.ArrayList pendingTerms = new System.Collections.ArrayList();
				int docCountCutoff = (int) ((docCountPercent / 100.0) * reader.MaxDoc());
				int termCountLimit = System.Math.Min(BooleanQuery.GetMaxClauseCount(), termCountCutoff);
				int docVisitCount = 0;
				
				FilteredTermEnum enumerator = query.GetEnum(reader);
				try
				{
					while (true)
					{
						Term t = enumerator.Term();
						if (t != null)
						{
							pendingTerms.Add(t);
							// Loading the TermInfo from the terms dict here
							// should not be costly, because 1) the
							// query/filter will load the TermInfo when it
							// runs, and 2) the terms dict has a cache:
							docVisitCount += reader.DocFreq(t);
						}
						
						if (pendingTerms.Count >= termCountLimit || docVisitCount >= docCountCutoff)
						{
							// Too many terms -- make a filter.
							Query result = new ConstantScoreQuery(new MultiTermQueryWrapperFilter(query));
							result.SetBoost(query.GetBoost());
							return result;
						}
						else if (!enumerator.Next())
						{
							// Enumeration is done, and we hit a small
							// enough number of terms & docs -- just make a
							// BooleanQuery, now
							System.Collections.IEnumerator it = pendingTerms.GetEnumerator();
							BooleanQuery bq = new BooleanQuery(true);
							while (it.MoveNext())
							{
								TermQuery tq = new TermQuery((Term) it.Current);
								bq.Add(tq, BooleanClause.Occur.SHOULD);
							}
							// Strip scores
							Query result = new ConstantScoreQuery(new QueryWrapperFilter(bq));
							result.SetBoost(query.GetBoost());
							query.IncTotalNumberOfTerms(pendingTerms.Count);
							return result;
						}
					}
				}
				finally
				{
					enumerator.Close();
				}
			}
开发者ID:carrie901,项目名称:mono,代码行数:59,代码来源:MultiTermQuery.cs

示例3: Bits

		public override System.Collections.BitArray Bits(IndexReader reader)
		{
			System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
			
			new IndexSearcher(reader).Search(query, new AnonymousClassCollector(bits, this));
			return bits;
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:QueryWrapperFilter.cs

示例4: DocIdSetToCache

		/// <summary>Provide the DocIdSet to be cached, using the DocIdSet provided
		/// by the wrapped Filter.
		/// This implementation returns the given DocIdSet.
		/// </summary>
		protected internal virtual DocIdSet DocIdSetToCache(DocIdSet docIdSet, IndexReader reader)
		{
            if (docIdSet == null)
            {
                // this is better than returning null, as the nonnull result can be cached
                return DocIdSet.EMPTY_DOCIDSET;
            }
            else if (docIdSet.IsCacheable()) {
				return docIdSet;
			}
			else
			{
				DocIdSetIterator it = docIdSet.Iterator();
				// null is allowed to be returned by iterator(),
				// in this case we wrap with the empty set,
				// which is cacheable.
				return (it == null) ? DocIdSet.EMPTY_DOCIDSET : new OpenBitSetDISI(it, reader.MaxDoc());
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:23,代码来源:CachingWrapperFilter.cs

示例5: GetDocIdSet

		/// <summary> Returns a DocIdSet with documents that should be
		/// permitted in search results.
		/// </summary>
		//@Override
		public override DocIdSet GetDocIdSet(IndexReader reader)
		{
			TermEnum enumerator = query.GetEnum(reader);
			try
			{
				// if current term in enum is null, the enum is empty -> shortcut
				if (enumerator.Term() == null)
					return DocIdSet.EMPTY_DOCIDSET;
				// else fill into a OpenBitSet
				OpenBitSet bitSet = new OpenBitSet(reader.MaxDoc());
				new AnonymousClassTermGenerator1(bitSet, this).Generate(query, reader, enumerator);
				return bitSet;
			}
			finally
			{
				enumerator.Close();
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:22,代码来源:MultiTermQueryWrapperFilter.cs

示例6: Bits

		public override System.Collections.BitArray Bits(IndexReader reader)
		{
			TermEnum enumerator = query.GetEnum(reader);
			try
			{
				System.Collections.BitArray bitSet = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
				new AnonymousClassTermGenerator(bitSet, this).Generate(query, reader, enumerator);
				return bitSet;
			}
			finally
			{
				enumerator.Close();
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:14,代码来源:MultiTermQueryWrapperFilter.cs

示例7: CreateValue

			protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
			{
				System.String field = StringHelper.Intern((System.String) entryKey.field);
				int[] retArray = new int[reader.MaxDoc()];
				System.String[] mterms = new System.String[reader.MaxDoc() + 1];
				TermDocs termDocs = reader.TermDocs();
				TermEnum termEnum = reader.Terms(new Term(field));
				int t = 0; // current term number
				
				// an entry for documents that have no terms in this field
				// should a document with no terms be at top or bottom?
				// this puts them at the top - if it is changed, FieldDocSortedHitQueue
				// needs to change as well.
				mterms[t++] = null;
				
				try
				{
					do 
					{
						Term term = termEnum.Term();
                        if (term == null || term.Field() != field || t >= mterms.Length) break;
						
						// store term text
						mterms[t] = term.Text();
						
						termDocs.Seek(termEnum);
						while (termDocs.Next())
						{
							retArray[termDocs.Doc()] = t;
						}
						
						t++;
					}
					while (termEnum.Next());
				}
				finally
				{
					termDocs.Close();
					termEnum.Close();
				}
				
				if (t == 0)
				{
					// if there are no terms, make the term array
					// have a single null entry
					mterms = new System.String[1];
				}
				else if (t < mterms.Length)
				{
					// if there are less terms than documents,
					// trim off the dead array space
					System.String[] terms = new System.String[t];
					Array.Copy(mterms, 0, terms, 0, t);
					mterms = terms;
				}
				
				StringIndex value_Renamed = new StringIndex(retArray, mterms);
				return value_Renamed;
			}
开发者ID:carrie901,项目名称:mono,代码行数:59,代码来源:FieldCacheImpl.cs


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