lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/6] lucenenet git commit: More compilation fixes to Lucene.Net.Queries
Date Fri, 07 Nov 2014 05:39:12 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master e07d11372 -> 3ec43cbd1


More compilation fixes to Lucene.Net.Queries


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/f52cf1ad
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/f52cf1ad
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/f52cf1ad

Branch: refs/heads/master
Commit: f52cf1ad9792863148b7b6f6953707e7aa87e670
Parents: e07d113
Author: Itamar Syn-Hershko <itamar@code972.com>
Authored: Fri Nov 7 06:27:29 2014 +0200
Committer: Itamar Syn-Hershko <itamar@code972.com>
Committed: Fri Nov 7 06:27:29 2014 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Queries/BooleanFilter.cs         |  2 +-
 src/Lucene.Net.Queries/ChainedFilter.cs         |  8 ++----
 src/Lucene.Net.Queries/CustomScoreQuery.cs      | 18 ++++++-------
 src/Lucene.Net.Queries/Function/BoostedQuery.cs | 17 ++++++------
 .../Function/FunctionQuery.cs                   |  4 +--
 src/Lucene.Net.Queries/Function/ValueSource.cs  |  2 +-
 .../ValueSources/DoubleConstValueSource.cs      |  2 +-
 src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs      | 28 +++++++++-----------
 8 files changed, 36 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f52cf1ad/src/Lucene.Net.Queries/BooleanFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/BooleanFilter.cs b/src/Lucene.Net.Queries/BooleanFilter.cs
index 7136fe1..61a20bc 100644
--- a/src/Lucene.Net.Queries/BooleanFilter.cs
+++ b/src/Lucene.Net.Queries/BooleanFilter.cs
@@ -118,7 +118,7 @@ namespace Lucene.Net.Queries
         {
             // we dont pass acceptDocs, we will filter at the end using an additional filter
             DocIdSet set = filter.GetDocIdSet(context, null);
-            return set == null ? null : set.GetEnumerator();
+            return set == null ? null : set.GetIterator();
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f52cf1ad/src/Lucene.Net.Queries/ChainedFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/ChainedFilter.cs b/src/Lucene.Net.Queries/ChainedFilter.cs
index e0c1112..2dd2e3a 100644
--- a/src/Lucene.Net.Queries/ChainedFilter.cs
+++ b/src/Lucene.Net.Queries/ChainedFilter.cs
@@ -118,7 +118,7 @@ namespace Lucene.Net.Queries
             }
             else
             {
-                DocIdSetIterator iter = docIdSet.GetEnumerator();
+                DocIdSetIterator iter = docIdSet.GetIterator();
                 if (iter == null)
                 {
                     return DocIdSetIterator.Empty();
@@ -235,11 +235,7 @@ namespace Lucene.Net.Queries
                 }
                 else
                 {
-                    disi = dis.GetEnumerator();
-                    if (disi == null)
-                    {
-                        disi = DocIdSetIterator.Empty();
-                    }
+                    disi = dis.GetIterator() ?? DocIdSetIterator.Empty();
                 }
 
                 switch (logic)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f52cf1ad/src/Lucene.Net.Queries/CustomScoreQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/CustomScoreQuery.cs b/src/Lucene.Net.Queries/CustomScoreQuery.cs
index a408361..00522c3 100644
--- a/src/Lucene.Net.Queries/CustomScoreQuery.cs
+++ b/src/Lucene.Net.Queries/CustomScoreQuery.cs
@@ -39,7 +39,7 @@ namespace Lucene.Net.Queries
     public class CustomScoreQuery : Query
     {
 
-        private Query subQuery;
+        internal Query subQuery;
         private Query[] scoringQueries; // never null (empty array if there are no valSrcQueries).
         private bool strict = false; // if true, valueSource part of query does not take
part in weights normalization.
 
@@ -257,7 +257,7 @@ namespace Lucene.Net.Queries
                         valSrcWeight.Normalize(norm, 1f);
                     }
                 }
-                queryWeight = topLevelBoost*Boost;
+                queryWeight = topLevelBoost * outerInstance.Boost;
             }
 
             public override Scorer Scorer(AtomicReaderContext context, Bits acceptDocs)
@@ -284,23 +284,23 @@ namespace Lucene.Net.Queries
 
             internal virtual Explanation DoExplain(AtomicReaderContext info, int doc)
             {
-                Explanation subQueryExpl = subQueryWeight.Explain(info, doc);
+                var subQueryExpl = subQueryWeight.Explain(info, doc);
                 if (!subQueryExpl.IsMatch)
                 {
                     return subQueryExpl;
                 }
                 // match
-                Explanation[] valSrcExpls = new Explanation[valSrcWeights.Length];
+                var valSrcExpls = new Explanation[valSrcWeights.Length];
                 for (int i = 0; i < valSrcWeights.Length; i++)
                 {
                     valSrcExpls[i] = valSrcWeights[i].Explain(info, doc);
                 }
                 Explanation customExp = outerInstance.GetCustomScoreProvider(info)
                     .CustomExplain(doc, subQueryExpl, valSrcExpls);
-                float sc = Boost*customExp.Value;
+                float sc = outerInstance.Boost * customExp.Value;
                 Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString()
+ ", product of:");
                 res.AddDetail(customExp);
-                res.AddDetail(new Explanation(Boost, "queryBoost"));
+                res.AddDetail(new Explanation(outerInstance.Boost, "queryBoost"));
                     // actually using the q boost as q weight (== weight value)
                 return res;
             }
@@ -365,7 +365,7 @@ namespace Lucene.Net.Queries
                     {
                         vScores[i] = valSrcScorers[i].Score();
                     }
-                    return qWeight*provider.CustomScore(subQueryScorer.DocID, subQueryScorer.Score,
vScores);
+                    return qWeight*provider.CustomScore(subQueryScorer.DocID(), subQueryScorer.Score(),
vScores);
                 }
 
                 public override int Freq()
@@ -418,14 +418,14 @@ namespace Lucene.Net.Queries
             /// The sub-query that CustomScoreQuery wraps, affecting both the score and which
documents match. </summary>
             public virtual Query SubQuery
             {
-                get { return subQuery; }
+                get { return outerInstance.subQuery; }
             }
 
             /// <summary>
             /// The scoring queries that only affect the score of CustomScoreQuery. </summary>
             public virtual Query[] ScoringQueries
             {
-                get { return scoringQueries; }
+                get { return outerInstance.scoringQueries; }
             }
 
             /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f52cf1ad/src/Lucene.Net.Queries/Function/BoostedQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/BoostedQuery.cs b/src/Lucene.Net.Queries/Function/BoostedQuery.cs
index fc078c7..db52a35 100644
--- a/src/Lucene.Net.Queries/Function/BoostedQuery.cs
+++ b/src/Lucene.Net.Queries/Function/BoostedQuery.cs
@@ -1,4 +1,5 @@
-´╗┐using System.Collections;
+´╗┐using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Text;
 using Lucene.Net.Index;
@@ -84,10 +85,8 @@ namespace Lucene.Net.Queries.Function
 
             private readonly IndexSearcher searcher;
             private readonly Weight qWeight;
-            private readonly IDictionary fcontext;
+            internal readonly IDictionary fcontext;
 
-            //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in
.NET:
-            //ORIGINAL LINE: public BoostedWeight(IndexSearcher searcher) throws java.io.IOException
             public BoostedWeight(BoostedQuery outerInstance, IndexSearcher searcher)
             {
                 this.outerInstance = outerInstance;
@@ -110,14 +109,14 @@ namespace Lucene.Net.Queries.Function
                 get
                 {
                     float sum = qWeight.ValueForNormalization;
-                    sum *= Boost * Boost;
+                    sum *= outerInstance.Boost * outerInstance.Boost;
                     return sum;
                 }
             }
 
             public override void Normalize(float norm, float topLevelBoost)
             {
-                topLevelBoost *= Boost;
+                topLevelBoost *= outerInstance.Boost;
                 qWeight.Normalize(norm, topLevelBoost);
             }
 
@@ -128,7 +127,7 @@ namespace Lucene.Net.Queries.Function
                 {
                     return null;
                 }
-                return new BoostedQuery.CustomScorer(outerInstance, context, this, Boost,
subQueryScorer, outerInstance.boostVal);
+                return new BoostedQuery.CustomScorer(outerInstance, context, this, outerInstance.Boost,
subQueryScorer, outerInstance.boostVal);
             }
 
             public override Explanation Explain(AtomicReaderContext readerContext, int doc)
@@ -207,10 +206,10 @@ namespace Lucene.Net.Queries.Function
                 }
             }
 
-            public virtual Explanation explain(int doc)
+            public virtual Explanation Explain(int doc)
             {
                 Explanation subQueryExpl = weight.qWeight.Explain(readerContext, doc);
-                if (!subQueryExpl.Match)
+                if (!subQueryExpl.IsMatch)
                 {
                     return subQueryExpl;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f52cf1ad/src/Lucene.Net.Queries/Function/FunctionQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/FunctionQuery.cs b/src/Lucene.Net.Queries/Function/FunctionQuery.cs
index b7b8735..9d596d4 100644
--- a/src/Lucene.Net.Queries/Function/FunctionQuery.cs
+++ b/src/Lucene.Net.Queries/Function/FunctionQuery.cs
@@ -89,7 +89,7 @@ namespace Lucene.Net.Queries.Function
             {
                 get
                 {
-                    queryWeight = Boost;
+                    queryWeight = outerInstance.Boost;
                     return queryWeight * queryWeight;
                 }
             }
@@ -197,7 +197,7 @@ namespace Lucene.Net.Queries.Function
                 Explanation result = new ComplexExplanation(true, sc, "FunctionQuery(" +
outerInstance.func + "), product of:");
 
                 result.AddDetail(vals.Explain(d));
-                result.AddDetail(new Explanation(Boost, "boost"));
+                result.AddDetail(new Explanation(outerInstance.Boost, "boost"));
                 result.AddDetail(new Explanation(weight.queryNorm, "queryNorm"));
                 return result;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f52cf1ad/src/Lucene.Net.Queries/Function/ValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource.cs
index ccfdc59..85a85c3 100644
--- a/src/Lucene.Net.Queries/Function/ValueSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSource.cs
@@ -98,7 +98,7 @@ namespace Lucene.Net.Queries.Function
             private readonly ValueSource outerInstance;
 
             public ValueSourceSortField(ValueSource outerInstance, bool reverse)
-                : base(outerInstance.Description, SortField.Type.REWRITEABLE, reverse)
+                : base(outerInstance.Description, SortField.Type_e.REWRITEABLE, reverse)
             {
                 this.outerInstance = outerInstance;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f52cf1ad/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs
index 52cb8ca..5cc6d09 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs
@@ -95,7 +95,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
 
         public override int GetHashCode()
         {
-            long bits = Number.DoubleToRawLongBits(constant);
+            long bits = Lucene.Net.Support.Number.DoubleToRawLongBits(constant);
             return (int)(bits ^ ((long)((ulong)bits >> 32)));
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f52cf1ad/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs b/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs
index 3e2dad5..afc8598 100644
--- a/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs
+++ b/src/Lucene.Net.Queries/Mlt/MoreLikeThis.cs
@@ -400,16 +400,16 @@ namespace Lucene.Net.Queries.Mlt
 
             while ((cur = q.Pop()) != null)
             {
-                object[] ar = (object[])cur;
-                TermQuery tq = new TermQuery(new Term((string)ar[1], (string)ar[0]));
+                var ar = (object[])cur;
+                var tq = new TermQuery(new Term((string)ar[1], (string)ar[0]));
 
                 if (Boost)
                 {
                     if (qterms == 0)
                     {
-                        bestScore = ((float?)ar[2]);
+                        bestScore = ((float)ar[2]);
                     }
-                    float myScore = ((float?)ar[2]);
+                    float myScore = ((float)ar[2]);
 
                     tq.Boost = boostFactor * myScore / bestScore;
                 }
@@ -707,22 +707,19 @@ namespace Lucene.Net.Queries.Mlt
         }
 
         /// <seealso cref= #retrieveInterestingTerms(java.io.Reader, String) </seealso>
-        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-        //ORIGINAL LINE: public String[] retrieveInterestingTerms(int docNum) throws IOException
         public string[] RetrieveInterestingTerms(int docNum)
         {
-            var al = new List<object>(MaxQueryTerms);
+            var al = new List<string>(MaxQueryTerms);
             var pq = RetrieveTerms(docNum);
             object cur;
             int lim = MaxQueryTerms; // have to be careful, retrieveTerms returns all words
but that's probably not useful to our caller...
             // we just want to return the top words
             while (((cur = pq.Pop()) != null) && lim-- > 0)
             {
-                object[] ar = (object[])cur;
-                al.Add(ar[0]); // the 1st entry is the interesting word
+                var ar = (object[])cur;
+                al.Add(ar[0].ToString()); // the 1st entry is the interesting word
             }
-            string[] res = new string[al.Count];
-            return al.ToArray(res);
+            return al.ToArray();
         }
 
         /// <summary>
@@ -736,18 +733,17 @@ namespace Lucene.Net.Queries.Mlt
         /// <seealso cref= #setMaxQueryTerms </seealso>
         public string[] RetrieveInterestingTerms(Reader r, string fieldName)
         {
-            List<object> al = new List<object>(MaxQueryTerms);
+            var al = new List<string>(MaxQueryTerms);
             PriorityQueue<object[]> pq = RetrieveTerms(r, fieldName);
             object cur;
             int lim = MaxQueryTerms; // have to be careful, retrieveTerms returns all words
but that's probably not useful to our caller...
             // we just want to return the top words
             while (((cur = pq.Pop()) != null) && lim-- > 0)
             {
-                object[] ar = (object[])cur;
-                al.Add(ar[0]); // the 1st entry is the interesting word
+                var ar = (object[])cur;
+                al.Add(ar[0].ToString()); // the 1st entry is the interesting word
             }
-            string[] res = new string[al.Count];
-            return al.ToArray(res);
+            return al.ToArray();
         }
 
         /// <summary>


Mime
View raw message