You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2011/11/09 22:03:52 UTC
[Lucene.Net] svn commit: r1199962 [9/14] - in
/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/core/
src/core/Analysis/ src/core/Analysis/Standard/ src/core/Document/
src/core/Index/ src/core/QueryParser/ src/core/Search/
src/core/Search/Function/ src/cor...
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanScorer2.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanScorer2.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanScorer2.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/BooleanScorer2.cs Wed Nov 9 21:03:47 2011
@@ -28,7 +28,7 @@ namespace Lucene.Net.Search
/// <br/>Implements skipTo(), and has no limitations on the numbers of added scorers.
/// <br/>Uses ConjunctionScorer, DisjunctionScorer, ReqOptScorer and ReqExclScorer.
/// </summary>
- class BooleanScorer2:Scorer
+ class BooleanScorer2 : Scorer
{
private class AnonymousClassDisjunctionSumScorer:DisjunctionSumScorer
{
@@ -45,7 +45,8 @@ namespace Lucene.Net.Search
}
}
- internal AnonymousClassDisjunctionSumScorer(BooleanScorer2 enclosingInstance, System.Collections.IList Param1, int Param2):base(Param1, Param2)
+ internal AnonymousClassDisjunctionSumScorer(BooleanScorer2 enclosingInstance, System.Collections.Generic.IList<Scorer> scorers, int minNrShouldMatch)
+ : base(scorers, minNrShouldMatch)
{
InitBlock(enclosingInstance);
}
@@ -85,7 +86,8 @@ namespace Lucene.Net.Search
}
}
- internal AnonymousClassConjunctionScorer(int requiredNrMatchers, BooleanScorer2 enclosingInstance, Lucene.Net.Search.Similarity Param1, System.Collections.ICollection Param2):base(Param1, Param2)
+ internal AnonymousClassConjunctionScorer(int requiredNrMatchers, BooleanScorer2 enclosingInstance, Lucene.Net.Search.Similarity defaultSimilarity, System.Collections.Generic.IList<Scorer> requiredScorers)
+ : base(defaultSimilarity, requiredScorers)
{
InitBlock(requiredNrMatchers, enclosingInstance);
}
@@ -112,10 +114,10 @@ namespace Lucene.Net.Search
return lastDocScore;
}
}
-
- private System.Collections.IList requiredScorers;
- private System.Collections.IList optionalScorers;
- private System.Collections.IList prohibitedScorers;
+
+ private System.Collections.Generic.List<Scorer> requiredScorers;
+ private System.Collections.Generic.List<Scorer> optionalScorers;
+ private System.Collections.Generic.List<Scorer> prohibitedScorers;
private class Coordinator
{
@@ -181,7 +183,11 @@ namespace Lucene.Net.Search
/// </param>
/// <param name="optional">the list of optional scorers.
/// </param>
- public BooleanScorer2(Similarity similarity, int minNrShouldMatch, System.Collections.IList required, System.Collections.IList prohibited, System.Collections.IList optional):base(similarity)
+ public BooleanScorer2(Similarity similarity, int minNrShouldMatch,
+ System.Collections.Generic.List<Scorer> required,
+ System.Collections.Generic.List<Scorer> prohibited,
+ System.Collections.Generic.List<Scorer> optional)
+ : base(similarity)
{
if (minNrShouldMatch < 0)
{
@@ -243,46 +249,24 @@ namespace Lucene.Net.Search
}
return lastDocScore;
}
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead. ")]
- public override int Doc()
- {
- return scorer.Doc();
- }
+
public override int DocID()
{
return scorer.DocID();
}
- /// <deprecated> use <see cref="NextDoc()" /> instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead. ")]
- public override bool Next()
- {
- return scorer.NextDoc() != NO_MORE_DOCS;
- }
+
public override int NextDoc()
{
return scorer.NextDoc();
}
- /// <deprecated> use <see cref="Advance(int)" /> instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead. ")]
- public override bool SkipTo(int docNr)
- {
- return scorer.Advance(docNr) != NO_MORE_DOCS;
- }
+
public override int Advance(int target)
{
return scorer.Advance(target);
}
- public override Explanation Explain(int docNr)
- {
- return scorer.Explain(docNr);
- }
}
- private Scorer CountingDisjunctionSumScorer(System.Collections.IList scorers, int minNrShouldMatch)
+ private Scorer CountingDisjunctionSumScorer(System.Collections.Generic.List<Scorer> scorers, int minNrShouldMatch)
{
// each scorer from the list counted as a single matcher
return new AnonymousClassDisjunctionSumScorer(this, scorers, minNrShouldMatch);
@@ -290,7 +274,7 @@ namespace Lucene.Net.Search
private static readonly Similarity defaultSimilarity;
- private Scorer CountingConjunctionSumScorer(System.Collections.IList requiredScorers)
+ private Scorer CountingConjunctionSumScorer(System.Collections.Generic.List<Scorer> requiredScorers)
{
// each scorer from the list counted as a single matcher
int requiredNrMatchers = requiredScorers.Count;
@@ -325,7 +309,7 @@ namespace Lucene.Net.Search
if (optionalScorers.Count > nrOptRequired)
requiredCountingSumScorer = CountingDisjunctionSumScorer(optionalScorers, nrOptRequired);
else if (optionalScorers.Count == 1)
- requiredCountingSumScorer = new SingleMatchScorer(this, (Scorer) optionalScorers[0]);
+ requiredCountingSumScorer = new SingleMatchScorer(this, optionalScorers[0]);
else
requiredCountingSumScorer = CountingConjunctionSumScorer(optionalScorers);
return AddProhibitedScorers(requiredCountingSumScorer);
@@ -337,14 +321,17 @@ namespace Lucene.Net.Search
if (optionalScorers.Count == minNrShouldMatch)
{
// all optional scorers also required.
- System.Collections.ArrayList allReq = new System.Collections.ArrayList(requiredScorers);
+ var allReq = new System.Collections.Generic.List<Scorer>(requiredScorers);
allReq.AddRange(optionalScorers);
return AddProhibitedScorers(CountingConjunctionSumScorer(allReq));
}
else
{
// optionalScorers.size() > minNrShouldMatch, and at least one required scorer
- Scorer requiredCountingSumScorer = requiredScorers.Count == 1?new SingleMatchScorer(this, (Scorer) requiredScorers[0]):CountingConjunctionSumScorer(requiredScorers);
+ Scorer requiredCountingSumScorer =
+ requiredScorers.Count == 1
+ ? new SingleMatchScorer(this, requiredScorers[0])
+ : CountingConjunctionSumScorer(requiredScorers);
if (minNrShouldMatch > 0)
{
// use a required disjunction scorer over the optional scorers
@@ -353,7 +340,10 @@ namespace Lucene.Net.Search
else
{
// minNrShouldMatch == 0
- return new ReqOptSumScorer(AddProhibitedScorers(requiredCountingSumScorer), optionalScorers.Count == 1?new SingleMatchScorer(this, (Scorer) optionalScorers[0]):CountingDisjunctionSumScorer(optionalScorers, 1));
+ return new ReqOptSumScorer(AddProhibitedScorers(requiredCountingSumScorer),
+ optionalScorers.Count == 1
+ ? new SingleMatchScorer(this, optionalScorers[0])
+ : CountingDisjunctionSumScorer(optionalScorers, 1));
}
}
}
@@ -365,25 +355,16 @@ namespace Lucene.Net.Search
/// </param>
private Scorer AddProhibitedScorers(Scorer requiredCountingSumScorer)
{
- return (prohibitedScorers.Count == 0)?requiredCountingSumScorer:new ReqExclScorer(requiredCountingSumScorer, ((prohibitedScorers.Count == 1)?(Scorer) prohibitedScorers[0]:new DisjunctionSumScorer(prohibitedScorers)));
- }
-
- /// <summary>Scores and collects all matching documents.</summary>
- /// <param name="hc">The collector to which all matching documents are passed through
- /// <see cref="HitCollector.Collect(int, float)" />.
- /// <br/>When this method is used the <see cref="Explain(int)" /> method should not be used.
- /// </param>
- /// <deprecated> use <see cref="Score(Collector)" /> instead.
- /// </deprecated>
- [Obsolete("use Score(Collector) instead.")]
- public override void Score(HitCollector hc)
- {
- Score(new HitCollectorWrapper(hc));
+ return (prohibitedScorers.Count == 0)
+ ? requiredCountingSumScorer
+ : new ReqExclScorer(requiredCountingSumScorer,
+ ((prohibitedScorers.Count == 1)
+ ? prohibitedScorers[0]
+ : new DisjunctionSumScorer(prohibitedScorers)));
}
/// <summary>Scores and collects all matching documents.</summary>
/// <param name="collector">The collector to which all matching documents are passed through.
- /// <br/>When this method is used the <see cref="Explain(int)" /> method should not be used.
/// </param>
public override void Score(Collector collector)
{
@@ -394,25 +375,6 @@ namespace Lucene.Net.Search
}
}
- /// <summary>Expert: Collects matching documents in a range.
- /// <br/>Note that <see cref="Next()" /> must be called once before this method is
- /// called for the first time.
- /// </summary>
- /// <param name="hc">The collector to which all matching documents are passed through
- /// <see cref="HitCollector.Collect(int, float)" />.
- /// </param>
- /// <param name="max">Do not score documents past this.
- /// </param>
- /// <returns> true if more matching documents may remain.
- /// </returns>
- /// <deprecated> use <see cref="Score(Collector, int, int)" /> instead.
- /// </deprecated>
- [Obsolete("use Score(Collector, int, int) instead.")]
- protected internal override bool Score(HitCollector hc, int max)
- {
- return Score(new HitCollectorWrapper(hc), max, DocID());
- }
-
public /*protected internal*/ override bool Score(Collector collector, int max, int firstDocID)
{
doc = firstDocID;
@@ -425,27 +387,11 @@ namespace Lucene.Net.Search
return doc != NO_MORE_DOCS;
}
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead. ")]
- public override int Doc()
- {
- return countingSumScorer.Doc();
- }
-
public override int DocID()
{
return doc;
}
- /// <deprecated> use <see cref="NextDoc()" /> instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead. ")]
- public override bool Next()
- {
- return NextDoc() != NO_MORE_DOCS;
- }
-
public override int NextDoc()
{
return doc = countingSumScorer.NextDoc();
@@ -458,33 +404,11 @@ namespace Lucene.Net.Search
return sum * coordinator.coordFactors[coordinator.nrMatchers];
}
- /// <deprecated> use <see cref="Advance(int)" /> instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead. ")]
- public override bool SkipTo(int target)
- {
- return Advance(target) != NO_MORE_DOCS;
- }
-
public override int Advance(int target)
{
return doc = countingSumScorer.Advance(target);
}
- /// <summary>Throws an UnsupportedOperationException.
- /// TODO: Implement an explanation of the coordination factor.
- /// </summary>
- /// <param name="doc">The document number for the explanation.
- /// </param>
- /// <throws> UnsupportedOperationException </throws>
- public override Explanation Explain(int doc)
- {
- throw new System.NotSupportedException();
- /* How to explain the coordination factor?
- initCountingSumScorer();
- return countingSumScorer.explain(doc); // misses coord factor.
- */
- }
static BooleanScorer2()
{
defaultSimilarity = Similarity.GetDefault();
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingSpanFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingSpanFilter.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingSpanFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingSpanFilter.cs Wed Nov 9 21:03:47 2011
@@ -29,11 +29,11 @@ namespace Lucene.Net.Search
[Serializable]
public class CachingSpanFilter:SpanFilter
{
- protected internal SpanFilter filter;
+ private SpanFilter filter;
- /// <summary> A transient Filter cache.</summary>
+ /// <summary> A transient Filter cache (internal because of test)</summary>
[NonSerialized]
- internal CachingWrapperFilter.FilterCache cache;
+ internal CachingWrapperFilter.FilterCache<SpanFilterResult> cache;
/// <summary>
/// New deletions always result in a cache miss, by default
@@ -59,26 +59,17 @@ namespace Lucene.Net.Search
this.cache = new AnonymousFilterCache(deletesMode);
}
- class AnonymousFilterCache : CachingWrapperFilter.FilterCache
+ class AnonymousFilterCache : CachingWrapperFilter.FilterCache<SpanFilterResult>
{
public AnonymousFilterCache(CachingWrapperFilter.DeletesMode deletesMode) : base(deletesMode)
{
}
- protected override object MergeDeletes(IndexReader reader, object docIdSet)
+ protected override SpanFilterResult MergeDeletes(IndexReader reader, SpanFilterResult docIdSet)
{
throw new System.ArgumentException("DeletesMode.DYNAMIC is not supported");
}
}
-
- /// <deprecated> Use <see cref="GetDocIdSet(IndexReader)" /> instead.
- /// </deprecated>
- [Obsolete("Use GetDocIdSet(IndexReader) instead.")]
- public override System.Collections.BitArray Bits(IndexReader reader)
- {
- SpanFilterResult result = GetCachedResult(reader);
- return result != null?result.GetBits():null;
- }
public override DocIdSet GetDocIdSet(IndexReader reader)
{
@@ -94,7 +85,7 @@ namespace Lucene.Net.Search
object coreKey = reader.GetFieldCacheKey();
object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;
- SpanFilterResult result = (SpanFilterResult) cache.Get(reader, coreKey, delCoreKey);
+ SpanFilterResult result = cache.Get(reader, coreKey, delCoreKey);
if (result != null) {
hitCount++;
return result;
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/CachingWrapperFilter.cs Wed Nov 9 21:03:47 2011
@@ -18,9 +18,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.Runtime.InteropServices;
using IndexReader = Lucene.Net.Index.IndexReader;
-using DocIdBitSet = Lucene.Net.Util.DocIdBitSet;
using OpenBitSetDISI = Lucene.Net.Util.OpenBitSetDISI;
using Lucene.Net.Util;
@@ -33,7 +31,7 @@ namespace Lucene.Net.Search
[Serializable]
public class CachingWrapperFilter:Filter
{
- protected internal Filter filter;
+ internal Filter filter;
///
/// Expert: Specifies how new deletions against a reopened
@@ -56,28 +54,19 @@ namespace Lucene.Net.Search
/// use DYNAMIC to dynamically intersect deleted docs (fast
/// reopen time but some hit to search performance).</para>
///
- [Serializable]
- public class DeletesMode : Parameter
- {
- private DeletesMode(String name) : base(name)
- {
- }
- public static DeletesMode IGNORE = new DeletesMode("IGNORE");
- public static DeletesMode RECACHE = new DeletesMode("RECACHE");
- public static DeletesMode DYNAMIC = new DeletesMode("DYNAMIC");
- }
+ public enum DeletesMode { IGNORE, RECACHE, DYNAMIC }
- internal FilterCache cache;
+ internal FilterCache<DocIdSet> cache;
[Serializable]
- abstract internal class FilterCache
+ abstract internal class FilterCache<T> where T : class
{
/**
* A transient Filter cache (package private because of test)
*/
// NOTE: not final so that we can dynamically re-init
// after de-serialize
- volatile IDictionary cache;
+ volatile IDictionary<Object, T> cache;
private DeletesMode deletesMode;
@@ -86,15 +75,15 @@ namespace Lucene.Net.Search
this.deletesMode = deletesMode;
}
- public Object Get(IndexReader reader, object coreKey, object delCoreKey)
+ public T Get(IndexReader reader, object coreKey, object delCoreKey)
{
lock (this)
{
- object value;
+ T value;
if (cache == null)
{
- cache = new SupportClass.WeakHashTable();
+ cache = new SupportClass.WeakHashMap<object, T>();
}
if (deletesMode == DeletesMode.IGNORE)
@@ -131,22 +120,25 @@ namespace Lucene.Net.Search
}
- protected abstract object MergeDeletes(IndexReader reader, object value);
+ protected abstract T MergeDeletes(IndexReader reader, T value);
- public void Put(object coreKey, object delCoreKey, object value)
+ public void Put(object coreKey, object delCoreKey, T value)
{
- if (deletesMode == DeletesMode.IGNORE)
- {
- cache[coreKey]= value;
- }
- else if (deletesMode == DeletesMode.RECACHE)
- {
- cache[delCoreKey]=value;
- }
- else
+ lock (this)
{
- cache[coreKey]= value;
- cache[delCoreKey]= value;
+ if (deletesMode == DeletesMode.IGNORE)
+ {
+ cache[coreKey] = value;
+ }
+ else if (deletesMode == DeletesMode.RECACHE)
+ {
+ cache[delCoreKey] = value;
+ }
+ else
+ {
+ cache[coreKey] = value;
+ cache[delCoreKey] = value;
+ }
}
}
}
@@ -191,7 +183,7 @@ namespace Lucene.Net.Search
//};
}
- class AnonymousFilterCache : FilterCache
+ class AnonymousFilterCache : FilterCache<DocIdSet>
{
class AnonymousFilteredDocIdSet : FilteredDocIdSet
{
@@ -207,46 +199,14 @@ namespace Lucene.Net.Search
}
public AnonymousFilterCache(DeletesMode deletesMode) : base(deletesMode)
- {
- }
+ { }
- protected override object MergeDeletes(IndexReader reader, object docIdSet)
+ protected override DocIdSet MergeDeletes(IndexReader reader, DocIdSet docIdSet)
{
- return new AnonymousFilteredDocIdSet((DocIdSet)docIdSet, reader);
+ return new AnonymousFilteredDocIdSet(docIdSet, reader);
}
}
- /// <deprecated> Use <see cref="GetDocIdSet(IndexReader)" /> instead.
- /// </deprecated>
- [Obsolete("Use GetDocIdSet(IndexReader) instead.")]
- public override System.Collections.BitArray Bits(IndexReader reader)
- {
- object coreKey = reader.GetFieldCacheKey();
- object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;
-
- object cached = cache.Get(reader, coreKey, delCoreKey);
-
- if (cached != null)
- {
- if (cached is System.Collections.BitArray)
- {
- return (System.Collections.BitArray) cached;
- }
- else if (cached is DocIdBitSet)
- return ((DocIdBitSet) cached).GetBitSet();
- // It would be nice to handle the DocIdSet case, but that's not really possible
- }
-
- System.Collections.BitArray bits = filter.Bits(reader);
-
- if (bits != null)
- {
- cache.Put(coreKey, delCoreKey, bits);
- }
-
- return bits;
- }
-
/// <summary>Provide the DocIdSet to be cached, using the DocIdSet provided
/// by the wrapped Filter.
/// This implementation returns the given DocIdSet.
@@ -279,25 +239,22 @@ namespace Lucene.Net.Search
object coreKey = reader.GetFieldCacheKey();
object delCoreKey = reader.HasDeletions() ? reader.GetDeletesCacheKey() : coreKey;
- object cached = cache.Get(reader, coreKey, delCoreKey);
-
- if (cached != null)
+ DocIdSet docIdSet = cache.Get(reader, coreKey, delCoreKey);
+
+ if (docIdSet != null)
{
hitCount++;
- if (cached is DocIdSet)
- return (DocIdSet) cached;
- else
- return new DocIdBitSet((System.Collections.BitArray) cached);
+ return docIdSet;
}
missCount++;
// cache miss
- DocIdSet docIdSet = DocIdSetToCache(filter.GetDocIdSet(reader), reader);
+ docIdSet = DocIdSetToCache(filter.GetDocIdSet(reader), reader);
if (docIdSet != null)
{
cache.Put(coreKey, delCoreKey, docIdSet);
}
-
+
return docIdSet;
}
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConjunctionScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConjunctionScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConjunctionScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConjunctionScorer.cs Wed Nov 9 21:03:47 2011
@@ -16,6 +16,7 @@
*/
using System;
+using System.Linq;
namespace Lucene.Net.Search
{
@@ -23,41 +24,16 @@ namespace Lucene.Net.Search
/// <summary>Scorer for conjunctions, sets of queries, all of which are required. </summary>
class ConjunctionScorer:Scorer
{
- private class AnonymousClassComparator : System.Collections.IComparer
- {
- public AnonymousClassComparator(ConjunctionScorer enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(ConjunctionScorer enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private ConjunctionScorer enclosingInstance;
- public ConjunctionScorer Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
- // sort the array
- public virtual int Compare(System.Object o1, System.Object o2)
- {
- return ((Scorer) o1).DocID() - ((Scorer) o2).DocID();
- }
- }
-
private Scorer[] scorers;
private float coord;
private int lastDoc = - 1;
- public ConjunctionScorer(Similarity similarity, System.Collections.ICollection scorers):this(similarity, (Scorer[]) new System.Collections.ArrayList(scorers).ToArray(typeof(Scorer)))
+ public ConjunctionScorer(Similarity similarity, System.Collections.Generic.ICollection<Scorer> scorers)
+ : this(similarity, scorers.ToArray())
{
}
- public ConjunctionScorer(Similarity similarity, Scorer[] scorers):base(similarity)
+ public ConjunctionScorer(Similarity similarity, params Scorer[] scorers):base(similarity)
{
this.scorers = scorers;
coord = similarity.Coord(scorers.Length, scorers.Length);
@@ -78,7 +54,7 @@ namespace Lucene.Net.Search
// it will already start off sorted (all scorers on same doc).
// note that this comparator is not consistent with equals!
- System.Array.Sort(scorers, new AnonymousClassComparator(this));
+ System.Array.Sort(scorers, (a, b) => a.DocID() - b.DocID());
// NOTE: doNext() must be called before the re-sorting of the array later on.
// The reason is this: assume there are 5 scorers, whose first docs are 1,
@@ -88,7 +64,7 @@ namespace Lucene.Net.Search
// However, if we re-sort before doNext() is called, the order will be 5, 3,
// 2, 1, 5 and then doNext() will stop immediately, since the first scorer's
// docs equals the last one. So the invariant that after calling doNext()
- // all scorers are on the same doc ID is broken.
+ // all scorers are on the same doc ID is broken.);
if (DoNext() == NO_MORE_DOCS)
{
// The scorers did not agree on any document.
@@ -139,32 +115,11 @@ namespace Lucene.Net.Search
return lastDoc = DoNext();
}
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead.")]
- public override int Doc()
- {
- return lastDoc;
- }
-
public override int DocID()
{
return lastDoc;
}
- public override Explanation Explain(int doc)
- {
- throw new System.NotSupportedException();
- }
-
- /// <deprecated> use <see cref="NextDoc()" /> instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead.")]
- public override bool Next()
- {
- return NextDoc() != NO_MORE_DOCS;
- }
-
public override int NextDoc()
{
if (lastDoc == NO_MORE_DOCS)
@@ -188,13 +143,5 @@ namespace Lucene.Net.Search
}
return sum * coord;
}
-
- /// <deprecated> use <see cref="Advance(int)" /> instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead.")]
- public override bool SkipTo(int target)
- {
- return Advance(target) != NO_MORE_DOCS;
- }
}
}
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConstantScoreQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConstantScoreQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConstantScoreQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ConstantScoreQuery.cs Wed Nov 9 21:03:47 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using Lucene.Net.Index;
using IndexReader = Lucene.Net.Index.IndexReader;
namespace Lucene.Net.Search
@@ -24,11 +24,7 @@ namespace Lucene.Net.Search
/// <summary> A query that wraps a filter and simply returns a constant score equal to the
/// query boost for every document in the filter.
- ///
- ///
/// </summary>
- /// <version> $Id: ConstantScoreQuery.java 807180 2009-08-24 12:26:43Z markrmiller $
- /// </version>
[Serializable]
public class ConstantScoreQuery:Query
{
@@ -50,7 +46,7 @@ namespace Lucene.Net.Search
return this;
}
- public override void ExtractTerms(System.Collections.Hashtable terms)
+ public override void ExtractTerms(System.Collections.Generic.ISet<Term> terms)
{
// OK to not add any terms when used for MultiSearcher,
// but may not be OK for highlighting
@@ -137,7 +133,7 @@ namespace Lucene.Net.Search
}
}
- protected internal class ConstantScorer:Scorer
+ protected internal class ConstantScorer : Scorer
{
private void InitBlock(ConstantScoreQuery enclosingInstance)
{
@@ -179,27 +175,11 @@ namespace Lucene.Net.Search
}
}
- /// <deprecated> use <see cref="NextDoc()" /> instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead.")]
- public override bool Next()
- {
- return docIdSetIterator.NextDoc() != NO_MORE_DOCS;
- }
-
public override int NextDoc()
{
return docIdSetIterator.NextDoc();
}
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead. ")]
- public override int Doc()
- {
- return docIdSetIterator.Doc();
- }
-
public override int DocID()
{
return docIdSetIterator.DocID();
@@ -210,23 +190,10 @@ namespace Lucene.Net.Search
return theScore;
}
- /// <deprecated> use <see cref="Advance(int)" /> instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead. ")]
- public override bool SkipTo(int target)
- {
- return docIdSetIterator.Advance(target) != NO_MORE_DOCS;
- }
-
public override int Advance(int target)
{
return docIdSetIterator.Advance(target);
}
-
- public override Explanation Explain(int doc)
- {
- throw new System.NotSupportedException();
- }
}
public override Weight CreateWeight(Searcher searcher)
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxQuery.cs Wed Nov 9 21:03:47 2011
@@ -16,7 +16,7 @@
*/
using System;
-
+using Lucene.Net.Index;
using IndexReader = Lucene.Net.Index.IndexReader;
namespace Lucene.Net.Search
@@ -36,7 +36,7 @@ namespace Lucene.Net.Search
/// in the multiple fields.
/// </summary>
[Serializable]
- public class DisjunctionMaxQuery:Query, System.ICloneable
+ public class DisjunctionMaxQuery : Query, System.Collections.Generic.IEnumerable<Query>, System.ICloneable
{
/* The subqueries */
@@ -61,7 +61,7 @@ namespace Lucene.Net.Search
/// </param>
/// <param name="tieBreakerMultiplier"> the weight to give to each matching non-maximum disjunct
/// </param>
- public DisjunctionMaxQuery(System.Collections.ICollection disjuncts, float tieBreakerMultiplier)
+ public DisjunctionMaxQuery(System.Collections.Generic.ICollection<Query> disjuncts, float tieBreakerMultiplier)
{
this.tieBreakerMultiplier = tieBreakerMultiplier;
Add(disjuncts);
@@ -78,16 +78,21 @@ namespace Lucene.Net.Search
/// <summary>Add a collection of disjuncts to this disjunction
/// via Iterable
/// </summary>
- public virtual void Add(System.Collections.ICollection disjuncts)
+ public virtual void Add(System.Collections.Generic.ICollection<Query> disjuncts)
{
this.disjuncts.AddRange(disjuncts);
}
/// <summary>An Iterator<Query> over the disjuncts </summary>
- public virtual System.Collections.IEnumerator Iterator()
+ public virtual System.Collections.Generic.IEnumerator<Query> GetEnumerator()
{
return disjuncts.GetEnumerator();
}
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
/// <summary> Expert: the Weight for DisjunctionMaxQuery, used to
/// normalize, score and explain these queries.
@@ -115,16 +120,16 @@ namespace Lucene.Net.Search
protected internal Similarity similarity;
/// <summary>The Weights for our subqueries, in 1-1 correspondence with disjuncts </summary>
- protected internal System.Collections.ArrayList weights = new System.Collections.ArrayList(); // The Weight's for our subqueries, in 1-1 correspondence with disjuncts
+ protected internal System.Collections.Generic.List<Weight> weights = new System.Collections.Generic.List<Weight>(); // The Weight's for our subqueries, in 1-1 correspondence with disjuncts
/* Construct the Weight for this Query searched by searcher. Recursively construct subquery weights. */
public DisjunctionMaxWeight(DisjunctionMaxQuery enclosingInstance, Searcher searcher)
{
InitBlock(enclosingInstance);
this.similarity = searcher.GetSimilarity();
- for (System.Collections.IEnumerator iter = Enclosing_Instance.disjuncts.GetEnumerator(); iter.MoveNext(); )
+ foreach(Query disjunctQuery in enclosingInstance.disjuncts)
{
- weights.Add(((Query) iter.Current).CreateWeight(searcher));
+ weights.Add(disjunctQuery.CreateWeight(searcher));
}
}
@@ -144,9 +149,9 @@ namespace Lucene.Net.Search
public override float SumOfSquaredWeights()
{
float max = 0.0f, sum = 0.0f;
- for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext(); )
+ foreach(Weight currentWeight in weights)
{
- float sub = ((Weight) iter.Current).SumOfSquaredWeights();
+ float sub = currentWeight.SumOfSquaredWeights();
sum += sub;
max = System.Math.Max(max, sub);
}
@@ -158,9 +163,9 @@ namespace Lucene.Net.Search
public override void Normalize(float norm)
{
norm *= Enclosing_Instance.GetBoost(); // Incorporate our boost
- for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext(); )
+ foreach(Weight wt in weights)
{
- ((Weight) iter.Current).Normalize(norm);
+ wt.Normalize(norm);
}
}
@@ -169,9 +174,8 @@ namespace Lucene.Net.Search
{
Scorer[] scorers = new Scorer[weights.Count];
int idx = 0;
- for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext(); )
+ foreach(Weight w in weights)
{
- Weight w = (Weight) iter.Current;
Scorer subScorer = w.Scorer(reader, true, false);
if (subScorer != null && subScorer.NextDoc() != DocIdSetIterator.NO_MORE_DOCS)
{
@@ -188,13 +192,13 @@ namespace Lucene.Net.Search
public override Explanation Explain(IndexReader reader, int doc)
{
if (Enclosing_Instance.disjuncts.Count == 1)
- return ((Weight) weights[0]).Explain(reader, doc);
+ return weights[0].Explain(reader, doc);
ComplexExplanation result = new ComplexExplanation();
float max = 0.0f, sum = 0.0f;
result.SetDescription(Enclosing_Instance.tieBreakerMultiplier == 0.0f?"max of:":"max plus " + Enclosing_Instance.tieBreakerMultiplier + " times others of:");
- for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext(); )
+ foreach(Weight wt in weights)
{
- Explanation e = ((Weight) iter.Current).Explain(reader, doc);
+ Explanation e = wt.Explain(reader, doc);
if (e.IsMatch())
{
System.Boolean tempAux = true;
@@ -225,7 +229,7 @@ namespace Lucene.Net.Search
int numDisjunctions = disjuncts.Count;
if (numDisjunctions == 1)
{
- Query singleton = (Query) disjuncts[0];
+ Query singleton = disjuncts[0];
Query result = singleton.Rewrite(reader);
if (GetBoost() != 1.0f)
{
@@ -238,7 +242,7 @@ namespace Lucene.Net.Search
DisjunctionMaxQuery clone = null;
for (int i = 0; i < numDisjunctions; i++)
{
- Query clause = (Query) disjuncts[i];
+ Query clause = disjuncts[i];
Query rewrite = clause.Rewrite(reader);
if (rewrite != clause)
{
@@ -264,11 +268,11 @@ namespace Lucene.Net.Search
}
// inherit javadoc
- public override void ExtractTerms(System.Collections.Hashtable terms)
+ public override void ExtractTerms(System.Collections.Generic.ISet<Term> terms)
{
- for (System.Collections.IEnumerator iter = disjuncts.GetEnumerator(); iter.MoveNext(); )
+ foreach(Query query in disjuncts)
{
- ((Query) iter.Current).ExtractTerms(terms);
+ query.ExtractTerms(terms);
}
}
@@ -284,7 +288,7 @@ namespace Lucene.Net.Search
int numDisjunctions = disjuncts.Count;
for (int i = 0; i < numDisjunctions; i++)
{
- Query subquery = (Query) disjuncts[i];
+ Query subquery = disjuncts[i];
if (subquery is BooleanQuery)
{
// wrap sub-bools in parens
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionMaxScorer.cs Wed Nov 9 21:03:47 2011
@@ -62,19 +62,6 @@ namespace Lucene.Net.Search
Heapify();
}
- /// <summary> Generate the next document matching our associated DisjunctionMaxQuery.
- ///
- /// </summary>
- /// <returns> true iff there is a next document
- /// </returns>
- /// <deprecated> use <see cref="NextDoc()" /> instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead.")]
- public override bool Next()
- {
- return NextDoc() != NO_MORE_DOCS;
- }
-
public override int NextDoc()
{
if (numScorers == 0)
@@ -98,14 +85,6 @@ namespace Lucene.Net.Search
return doc = subScorers[0].DocID();
}
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead. ")]
- public override int Doc()
- {
- return subScorers[0].Doc();
- }
-
public override int DocID()
{
return doc;
@@ -137,23 +116,6 @@ namespace Lucene.Net.Search
}
}
- /// <summary> Advance to the first document beyond the current whose number is greater
- /// than or equal to target.
- ///
- /// </summary>
- /// <param name="target">the minimum number of the next desired document
- /// </param>
- /// <returns> true iff there is a document to be generated whose number is at
- /// least target
- /// </returns>
- /// <deprecated> use <see cref="Advance(int)" /> instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead.")]
- public override bool SkipTo(int target)
- {
- return Advance(target) != NO_MORE_DOCS;
- }
-
public override int Advance(int target)
{
if (numScorers == 0)
@@ -176,16 +138,6 @@ namespace Lucene.Net.Search
return doc = subScorers[0].DocID();
}
- /// <summary>Explain a score that we computed. UNSUPPORTED -- see explanation capability in DisjunctionMaxQuery.</summary>
- /// <param name="doc">the number of a document we scored
- /// </param>
- /// <returns> the Explanation for our score
- /// </returns>
- public override Explanation Explain(int doc)
- {
- throw new System.NotSupportedException();
- }
-
// Organize subScorers into a min heap with scorers generating the earliest document on top.
private void Heapify()
{
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionSumScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionSumScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionSumScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DisjunctionSumScorer.cs Wed Nov 9 21:03:47 2011
@@ -23,8 +23,7 @@ namespace Lucene.Net.Search
{
/// <summary>A Scorer for OR like queries, counterpart of <c>ConjunctionScorer</c>.
- /// This Scorer implements <see cref="DocIdSetIterator.SkipTo(int)" /> and uses skipTo() on the given Scorers.
- /// TODO: Implement score(HitCollector, int).
+ /// This Scorer implements <see cref="DocIdSetIterator.SkipTo(int)" /> and uses skipTo() on the given Scorers.
/// </summary>
class DisjunctionSumScorer:Scorer
{
@@ -32,7 +31,7 @@ namespace Lucene.Net.Search
private int nrScorers;
/// <summary>The subscorers. </summary>
- protected internal System.Collections.IList subScorers;
+ protected internal System.Collections.Generic.IList<Scorer> subScorers;
/// <summary>The minimum number of scorers that should match. </summary>
private int minimumNrMatchers;
@@ -70,7 +69,7 @@ namespace Lucene.Net.Search
/// <br/>When minimumNrMatchers equals the number of subScorers,
/// it more efficient to use <c>ConjunctionScorer</c>.
/// </param>
- public DisjunctionSumScorer(System.Collections.IList subScorers, int minimumNrMatchers):base(null)
+ public DisjunctionSumScorer(System.Collections.Generic.IList<Scorer> subScorers, int minimumNrMatchers):base(null)
{
nrScorers = subScorers.Count;
@@ -93,7 +92,8 @@ namespace Lucene.Net.Search
/// <summary>Construct a <c>DisjunctionScorer</c>, using one as the minimum number
/// of matching subscorers.
/// </summary>
- public DisjunctionSumScorer(System.Collections.IList subScorers):this(subScorers, 1)
+ public DisjunctionSumScorer(System.Collections.Generic.IList<Scorer> subScorers)
+ : this(subScorers, 1)
{
}
@@ -102,11 +102,9 @@ namespace Lucene.Net.Search
/// </summary>
private void InitScorerDocQueue()
{
- System.Collections.IEnumerator si = subScorers.GetEnumerator();
scorerDocQueue = new ScorerDocQueue(nrScorers);
- while (si.MoveNext())
+ foreach(Scorer se in subScorers)
{
- Scorer se = (Scorer) si.Current;
if (se.NextDoc() != NO_MORE_DOCS)
{
// doc() method will be used in scorerDocQueue.
@@ -116,19 +114,6 @@ namespace Lucene.Net.Search
}
/// <summary>Scores and collects all matching documents.</summary>
- /// <param name="hc">The collector to which all matching documents are passed through
- /// <see cref="HitCollector.Collect(int, float)" />.
- /// <br/>When this method is used the <see cref="Explain(int)" /> method should not be used.
- /// </param>
- /// <deprecated> use <see cref="Score(Collector)" /> instead.
- /// </deprecated>
- [Obsolete("use Score(Collector) instead.")]
- public override void Score(HitCollector hc)
- {
- Score(new HitCollectorWrapper(hc));
- }
-
- /// <summary>Scores and collects all matching documents.</summary>
/// <param name="collector">The collector to which all matching documents are passed through.
/// <br/>When this method is used the <see cref="Explain(int)" /> method should not be used.
/// </param>
@@ -140,25 +125,6 @@ namespace Lucene.Net.Search
collector.Collect(currentDoc);
}
}
-
- /// <summary>Expert: Collects matching documents in a range. Hook for optimization.
- /// Note that <see cref="Next()" /> must be called once before this method is called
- /// for the first time.
- /// </summary>
- /// <param name="hc">The collector to which all matching documents are passed through
- /// <see cref="HitCollector.Collect(int, float)" />.
- /// </param>
- /// <param name="max">Do not score documents past this.
- /// </param>
- /// <returns> true if more matching documents may remain.
- /// </returns>
- /// <deprecated> use <see cref="Score(Collector, int, int)" /> instead.
- /// </deprecated>
- [Obsolete("use Score(Collector, int, int) instead.")]
- protected internal override bool Score(HitCollector hc, int max)
- {
- return Score(new HitCollectorWrapper(hc), max, DocID());
- }
/// <summary>Expert: Collects matching documents in a range. Hook for optimization.
/// Note that <see cref="Next()" /> must be called once before this method is called
@@ -186,14 +152,6 @@ namespace Lucene.Net.Search
return true;
}
- /// <deprecated> use <see cref="NextDoc()" /> instead.
- /// </deprecated>
- [Obsolete("use NextDoc() instead. ")]
- public override bool Next()
- {
- return NextDoc() != NO_MORE_DOCS;
- }
-
public override int NextDoc()
{
if (scorerDocQueue.Size() < minimumNrMatchers || !AdvanceAfterCurrent())
@@ -269,14 +227,6 @@ namespace Lucene.Net.Search
return currentScore;
}
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead. ")]
- public override int Doc()
- {
- return currentDoc;
- }
-
public override int DocID()
{
return currentDoc;
@@ -290,29 +240,8 @@ namespace Lucene.Net.Search
return nrMatchers;
}
- /// <summary> Skips to the first match beyond the current whose document number is
- /// greater than or equal to a given target. <br/>
- /// When this method is used the <see cref="Explain(int)" /> method should not be
- /// used. <br/>
- /// The implementation uses the skipTo() method on the subscorers.
- ///
- /// </summary>
- /// <param name="target">The target document number.
- /// </param>
- /// <returns> true iff there is such a match.
- /// </returns>
- /// <deprecated> use <see cref="Advance(int)" /> instead.
- /// </deprecated>
- [Obsolete("use Advance(int) instead.")]
- public override bool SkipTo(int target)
- {
- return Advance(target) != NO_MORE_DOCS;
- }
-
/// <summary> Advances to the first match beyond the current whose document number is
/// greater than or equal to a given target. <br/>
- /// When this method is used the <see cref="Explain(int)" /> method should not be
- /// used. <br/>
/// The implementation uses the skipTo() method on the subscorers.
///
/// </summary>
@@ -347,37 +276,5 @@ namespace Lucene.Net.Search
}
while (true);
}
-
- /// <returns> An explanation for the score of a given document.
- /// </returns>
- public override Explanation Explain(int doc)
- {
- Explanation res = new Explanation();
- System.Collections.IEnumerator ssi = subScorers.GetEnumerator();
- float sumScore = 0.0f;
- int nrMatches = 0;
- while (ssi.MoveNext())
- {
- Explanation es = ((Scorer) ssi.Current).Explain(doc);
- if (es.GetValue() > 0.0f)
- {
- // indicates match
- sumScore += es.GetValue();
- nrMatches++;
- }
- res.AddDetail(es);
- }
- if (nrMatchers >= minimumNrMatchers)
- {
- res.SetValue(sumScore);
- res.SetDescription("sum over at least " + minimumNrMatchers + " of " + subScorers.Count + ":");
- }
- else
- {
- res.SetValue(0.0f);
- res.SetDescription(nrMatches + " match(es) but at least " + minimumNrMatchers + " of " + subScorers.Count + " needed");
- }
- return res;
- }
}
}
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DocIdSetIterator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DocIdSetIterator.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DocIdSetIterator.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/DocIdSetIterator.cs Wed Nov 9 21:03:47 2011
@@ -28,134 +28,69 @@ namespace Lucene.Net.Search
/// </summary>
public abstract class DocIdSetIterator
{
-
- // TODO (3.0): review the javadocs and remove any references to '3.0'.
private int doc = - 1;
/// <summary> When returned by <see cref="NextDoc()" />, <see cref="Advance(int)" /> and
- /// <see cref="Doc()" /> it means there are no more docs in the iterator.
+ /// <see cref="DocID()" /> it means there are no more docs in the iterator.
/// </summary>
public static readonly int NO_MORE_DOCS = System.Int32.MaxValue;
-
- /// <summary> Unsupported anymore. Call <see cref="DocID()" /> instead. This method throws
- /// <see cref="NotSupportedException" /> if called.
- ///
- /// </summary>
- /// <deprecated> use <see cref="DocID()" /> instead.
- /// </deprecated>
- [Obsolete("use DocID() instead.")]
- public virtual int Doc()
- {
- throw new System.NotSupportedException("Call docID() instead.");
- }
-
- /// <summary> Returns the following:
- /// <list type="bullet">
- /// <item>-1 or <see cref="NO_MORE_DOCS" /> if <see cref="NextDoc()" /> or
- /// <see cref="Advance(int)" /> were not called yet.</item>
- /// <item><see cref="NO_MORE_DOCS" /> if the iterator has exhausted.</item>
- /// <item>Otherwise it should return the doc ID it is currently on.</item>
- /// </list>
- /// <p/>
- /// <b>NOTE:</b> in 3.0, this method will become abstract.
- ///
- /// </summary>
- /// <since> 2.9
- /// </since>
- public virtual int DocID()
- {
- return doc;
- }
-
- /// <summary> Unsupported anymore. Call <see cref="NextDoc()" /> instead. This method throws
- /// <see cref="NotSupportedException" /> if called.
- ///
- /// </summary>
- /// <deprecated> use <see cref="NextDoc()" /> instead. This will be removed in 3.0
- /// </deprecated>
- [Obsolete("use NextDoc() instead. This will be removed in 3.0")]
- public virtual bool Next()
- {
- throw new System.NotSupportedException("Call nextDoc() instead.");
- }
-
- /// <summary> Unsupported anymore. Call <see cref="Advance(int)" /> instead. This method throws
- /// <see cref="NotSupportedException" /> if called.
- ///
- /// </summary>
- /// <deprecated> use <see cref="Advance(int)" /> instead. This will be removed in 3.0
- /// </deprecated>
- [Obsolete("use Advance(int) instead. This will be removed in 3.0")]
- public virtual bool SkipTo(int target)
- {
- throw new System.NotSupportedException("Call advance() instead.");
- }
-
- /// <summary> Advances to the next document in the set and returns the doc it is
- /// currently on, or <see cref="NO_MORE_DOCS" /> if there are no more docs in the
- /// set.<br/>
- ///
- /// <b>NOTE:</b> in 3.0 this method will become abstract, following the removal
- /// of <see cref="Next()" />. For backward compatibility it is implemented as:
- ///
- /// <code>
- /// public int nextDoc() throws IOException {
- /// return next() ? doc() : NO_MORE_DOCS;
- /// }
- /// </code>
- ///
- /// <b>NOTE:</b> after the iterator has exhausted you should not call this
- /// method, as it may result in unpredicted behavior.
- ///
- /// </summary>
- /// <since> 2.9
- /// </since>
- public virtual int NextDoc()
- {
- return doc = Next()?Doc():NO_MORE_DOCS;
- }
-
- /// <summary> Advances to the first beyond the current whose document number is greater
- /// than or equal to <i>target</i>. Returns the current document number or
- /// <see cref="NO_MORE_DOCS" /> if there are no more docs in the set.
- /// <p/>
- /// Behaves as if written:
- ///
- /// <code>
- /// int advance(int target) {
- /// int doc;
- /// while ((doc = nextDoc()) < target) {
- /// }
- /// return doc;
- /// }
- /// </code>
- ///
- /// Some implementations are considerably more efficient than that.
- /// <p/>
- /// <b>NOTE:</b> certain implemenations may return a different value (each
- /// time) if called several times in a row with the same target.
- /// <p/>
- /// <b>NOTE:</b> this method may be called with <see cref="NO_MORE_DOCS"/> for
- /// efficiency by some Scorers. If your implementation cannot efficiently
- /// determine that it should exhaust, it is recommended that you check for that
- /// value in each call to this method.
- /// <p/>
- /// <b>NOTE:</b> after the iterator has exhausted you should not call this
- /// method, as it may result in unpredicted behavior.
- /// <p/>
- /// <b>NOTE:</b> in 3.0 this method will become abstract, following the removal
- /// of <see cref="SkipTo(int)" />.
- ///
- /// </summary>
- /// <since> 2.9
- /// </since>
- public virtual int Advance(int target)
- {
- if (target == NO_MORE_DOCS)
- {
- return doc = NO_MORE_DOCS;
- }
- return doc = SkipTo(target)?Doc():NO_MORE_DOCS;
- }
+
+ /// <summary> Returns the following:
+ /// <list type="bullet">
+ /// <item>-1 or <see cref="NO_MORE_DOCS" /> if <see cref="NextDoc()" /> or
+ /// <see cref="Advance(int)" /> were not called yet.</item>
+ /// <item><see cref="NO_MORE_DOCS" /> if the iterator has exhausted.</item>
+ /// <item>Otherwise it should return the doc ID it is currently on.</item>
+ /// </list>
+ /// <p/>
+ /// <b>NOTE:</b> in 3.0, this method will become abstract.
+ /// </summary>
+ /// <since>2.9</since>
+ public abstract int DocID();
+
+ /// <summary> Advances to the next document in the set and returns the doc it is
+ /// currently on, or <see cref="NO_MORE_DOCS" /> if there are no more docs in the
+ /// set.<br/>
+ ///
+ /// <b>NOTE:</b> after the iterator has exhausted you should not call this
+ /// method, as it may result in unpredicted behavior.
+ ///
+ /// </summary>
+ /// <since> 2.9
+ /// </since>
+ public abstract int NextDoc();
+
+ /// <summary> Advances to the first beyond the current whose document number is greater
+ /// than or equal to <i>target</i>. Returns the current document number or
+ /// <see cref="NO_MORE_DOCS" /> if there are no more docs in the set.
+ /// <p/>
+ /// Behaves as if written:
+ ///
+ /// <code>
+ /// int advance(int target) {
+ /// int doc;
+ /// while ((doc = nextDoc()) < target) {
+ /// }
+ /// return doc;
+ /// }
+ /// </code>
+ ///
+ /// Some implementations are considerably more efficient than that.
+ /// <p/>
+ /// <b>NOTE:</b> certain implemenations may return a different value (each
+ /// time) if called several times in a row with the same target.
+ /// <p/>
+ /// <b>NOTE:</b> this method may be called with <see cref="NO_MORE_DOCS"/> for
+ /// efficiency by some Scorers. If your implementation cannot efficiently
+ /// determine that it should exhaust, it is recommended that you check for that
+ /// value in each call to this method.
+ /// <p/>
+ /// <b>NOTE:</b> after the iterator has exhausted you should not call this
+ /// method, as it may result in unpredicted behavior.
+ /// <p/>
+ ///
+ /// </summary>
+ /// <since>2.9</since>
+ public abstract int Advance(int target);
}
}
\ No newline at end of file
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ExactPhraseScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ExactPhraseScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ExactPhraseScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ExactPhraseScorer.cs Wed Nov 9 21:03:47 2011
@@ -36,7 +36,7 @@ namespace Lucene.Net.Search
for (PhrasePositions pp = first; pp != null; pp = pp.next)
{
pp.FirstPosition();
- pq.Put(pp); // build pq from list
+ pq.Add(pp); // build pq from list
}
PqToList(); // rebuild list from pq
Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Explanation.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Explanation.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Explanation.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Explanation.cs Wed Nov 9 21:03:47 2011
@@ -16,6 +16,7 @@
*/
using System;
+using System.Collections.Generic;
namespace Lucene.Net.Search
{
@@ -24,9 +25,9 @@ namespace Lucene.Net.Search
[Serializable]
public class Explanation
{
- private float value_Renamed; // the value of this node
- private System.String description; // what it represents
- private System.Collections.ArrayList details; // sub-explanations
+ private float value_Renamed; // the value of this node
+ private System.String description; // what it represents
+ private List<Explanation> details; // sub-explanations
public Explanation()
{
@@ -88,14 +89,14 @@ namespace Lucene.Net.Search
{
if (details == null)
return null;
- return (Explanation[]) details.ToArray(typeof(Explanation));
+ return details.ToArray();
}
/// <summary>Adds a sub-node to this explanation node. </summary>
public virtual void AddDetail(Explanation detail)
{
if (details == null)
- details = new System.Collections.ArrayList();
+ details = new List<Explanation>();
details.Add(detail);
}