You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2014/11/07 06:39:12 UTC
[1/6] lucenenet git commit: More compilation fixes to
Lucene.Net.Queries
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 <it...@code972.com>
Authored: Fri Nov 7 06:27:29 2014 +0200
Committer: Itamar Syn-Hershko <it...@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>
[3/6] lucenenet git commit: Cannot reference "this" in ctor redirects
Posted by sy...@apache.org.
Cannot reference "this" in ctor redirects
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/f6387ca3
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/f6387ca3
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/f6387ca3
Branch: refs/heads/master
Commit: f6387ca3443cee7aa09c88245c32d616ec1b2cc8
Parents: 4c20661
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Fri Nov 7 07:34:56 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Fri Nov 7 07:34:56 2014 +0200
----------------------------------------------------------------------
src/Lucene.Net.Queries/TermsFilter.cs | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f6387ca3/src/Lucene.Net.Queries/TermsFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/TermsFilter.cs b/src/Lucene.Net.Queries/TermsFilter.cs
index 1585cdd..5731ec1 100644
--- a/src/Lucene.Net.Queries/TermsFilter.cs
+++ b/src/Lucene.Net.Queries/TermsFilter.cs
@@ -57,19 +57,16 @@ namespace Lucene.Net.Queries
/// can contain duplicate terms and multiple fields.
/// </summary>
public TermsFilter(List<Term> terms)
- : this(new FieldAndTermEnumAnonymousInnerClassHelper(this, terms), terms.Count)
+ : this(new FieldAndTermEnumAnonymousInnerClassHelper(terms), terms.Count)
{
}
private class FieldAndTermEnumAnonymousInnerClassHelper : FieldAndTermEnum
- {
- private readonly TermsFilter outerInstance;
-
+ {
private IList<Term> terms;
- public FieldAndTermEnumAnonymousInnerClassHelper(TermsFilter outerInstance, List<Term> terms)
+ public FieldAndTermEnumAnonymousInnerClassHelper(List<Term> terms)
{
- this.outerInstance = outerInstance;
this.terms = terms;
terms.Sort();
iter = terms.GetEnumerator();
@@ -94,20 +91,17 @@ namespace Lucene.Net.Queries
/// a single field.
/// </summary>
public TermsFilter(string field, List<BytesRef> terms)
- : this(new FieldAndTermEnumAnonymousInnerClassHelper2(this, field, terms), terms.Count)
+ : this(new FieldAndTermEnumAnonymousInnerClassHelper2(field, terms), terms.Count)
{
}
private class FieldAndTermEnumAnonymousInnerClassHelper2 : FieldAndTermEnum
{
- private readonly TermsFilter outerInstance;
-
private IList<BytesRef> terms;
- public FieldAndTermEnumAnonymousInnerClassHelper2(TermsFilter outerInstance, string field, List<BytesRef> terms)
+ public FieldAndTermEnumAnonymousInnerClassHelper2(string field, List<BytesRef> terms)
: base(field)
{
- this.outerInstance = outerInstance;
this.terms = terms;
terms.Sort();
iter = terms.GetEnumerator();
@@ -147,6 +141,8 @@ namespace Lucene.Net.Queries
private TermsFilter(FieldAndTermEnum iter, int length)
{
+ iter.OuterInstance = this; // .NET specific, since "this" can't be used in ctor redirection
+
// TODO: maybe use oal.index.PrefixCodedTerms instead?
// If number of terms is more than a few hundred it
// should be a win
@@ -382,15 +378,17 @@ namespace Lucene.Net.Queries
private abstract class FieldAndTermEnum
{
- protected internal string field;
+ public TermsFilter OuterInstance { get; internal set; }
+
+ protected string field;
public abstract BytesRef Next();
- public FieldAndTermEnum()
+ protected FieldAndTermEnum()
{
}
- public FieldAndTermEnum(string field)
+ protected FieldAndTermEnum(string field)
{
this.field = field;
}
[5/6] lucenenet git commit: Fixing compilation
Posted by sy...@apache.org.
Fixing compilation
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/dc90e168
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/dc90e168
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/dc90e168
Branch: refs/heads/master
Commit: dc90e16808aceb9123fbb68d46728eddb1f3a264
Parents: e27e761
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Fri Nov 7 07:38:29 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Fri Nov 7 07:38:29 2014 +0200
----------------------------------------------------------------------
src/Lucene.Net.Queries/Function/BoostedQuery.cs | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/dc90e168/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 95343b2..5573a03 100644
--- a/src/Lucene.Net.Queries/Function/BoostedQuery.cs
+++ b/src/Lucene.Net.Queries/Function/BoostedQuery.cs
@@ -146,8 +146,7 @@ namespace Lucene.Net.Queries.Function
}
}
-
- private class CustomScorer : Scorer
+ private sealed class CustomScorer : Scorer
{
private readonly BoostedQuery outerInstance;
@@ -157,7 +156,7 @@ namespace Lucene.Net.Queries.Function
private readonly FunctionValues vals;
private readonly AtomicReaderContext readerContext;
- private CustomScorer(BoostedQuery outerInstance, AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs)
+ public CustomScorer(BoostedQuery outerInstance, AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs)
: base(w)
{
this.outerInstance = outerInstance;
@@ -206,7 +205,7 @@ namespace Lucene.Net.Queries.Function
}
}
- public virtual Explanation Explain(int doc)
+ public Explanation Explain(int doc)
{
var subQueryExpl = weight.qWeight.Explain(readerContext, doc);
if (!subQueryExpl.IsMatch)
[6/6] lucenenet git commit: Add Lucene.Net.Queries to main solution
Posted by sy...@apache.org.
Add Lucene.Net.Queries to main solution
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/3ec43cbd
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/3ec43cbd
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/3ec43cbd
Branch: refs/heads/master
Commit: 3ec43cbd1f54352aefa9f85faa1b69af5cfdca10
Parents: dc90e16
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Fri Nov 7 07:38:45 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Fri Nov 7 07:38:45 2014 +0200
----------------------------------------------------------------------
Lucene.Net.sln | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/3ec43cbd/Lucene.Net.sln
----------------------------------------------------------------------
diff --git a/Lucene.Net.sln b/Lucene.Net.sln
index bcb39c8..5da27b0 100644
--- a/Lucene.Net.sln
+++ b/Lucene.Net.sln
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Tests", "src\Luc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.TestFramework", "src\Lucene.Net.TestFramework\Lucene.Net.TestFramework.csproj", "{B2C0D749-CE34-4F62-A15E-00CB2FF5DDB3}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Queries", "src\Lucene.Net.Queries\Lucene.Net.Queries.csproj", "{69D7956C-C2CC-4708-B399-A188FEC384C4}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -50,6 +52,16 @@ Global
{B2C0D749-CE34-4F62-A15E-00CB2FF5DDB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B2C0D749-CE34-4F62-A15E-00CB2FF5DDB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B2C0D749-CE34-4F62-A15E-00CB2FF5DDB3}.Release|x86.ActiveCfg = Release|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {69D7956C-C2CC-4708-B399-A188FEC384C4}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
[4/6] lucenenet git commit: Restructure classes
Posted by sy...@apache.org.
Restructure classes
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/e27e761d
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/e27e761d
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/e27e761d
Branch: refs/heads/master
Commit: e27e761df0a9eb3d2d73a8a130d1032aab9edb2a
Parents: f6387ca
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Fri Nov 7 07:35:12 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Fri Nov 7 07:35:12 2014 +0200
----------------------------------------------------------------------
src/Lucene.Net.Queries/CustomScoreQuery.cs | 244 ++++++++++++------------
1 file changed, 123 insertions(+), 121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/e27e761d/src/Lucene.Net.Queries/CustomScoreQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/CustomScoreQuery.cs b/src/Lucene.Net.Queries/CustomScoreQuery.cs
index 8ac3636..94e7895 100644
--- a/src/Lucene.Net.Queries/CustomScoreQuery.cs
+++ b/src/Lucene.Net.Queries/CustomScoreQuery.cs
@@ -9,22 +9,22 @@ using Lucene.Net.Util;
namespace Lucene.Net.Queries
{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
/// <summary>
/// Query that sets document score as a programmatic function of several (sub) scores:
@@ -46,7 +46,8 @@ namespace Lucene.Net.Queries
/// <summary>
/// Create a CustomScoreQuery over input subQuery. </summary>
/// <param name="subQuery"> the sub query whose scored is being customized. Must not be null. </param>
- public CustomScoreQuery(Query subQuery) : this(subQuery, new FunctionQuery[0])
+ public CustomScoreQuery(Query subQuery)
+ : this(subQuery, new FunctionQuery[0])
{
}
@@ -56,8 +57,8 @@ namespace Lucene.Net.Queries
/// <param name="scoringQuery"> a value source query whose scores are used in the custom score
/// computation. This parameter is optional - it can be null. </param>
public CustomScoreQuery(Query subQuery, FunctionQuery scoringQuery)
- : this(subQuery, scoringQuery != null ? new FunctionQuery[] {scoringQuery} : new FunctionQuery[0])
- // don't want an array that contains a single null..
+ : this(subQuery, scoringQuery != null ? new FunctionQuery[] { scoringQuery } : new FunctionQuery[0])
+ // don't want an array that contains a single null..
{
}
@@ -116,7 +117,7 @@ namespace Lucene.Net.Queries
public override object Clone()
{
- var clone = (CustomScoreQuery) base.Clone();
+ var clone = (CustomScoreQuery)base.Clone();
clone.subQuery = (Query)subQuery.Clone();
clone.scoringQueries = new Query[scoringQueries.Length];
for (int i = 0; i < scoringQueries.Length; i++)
@@ -157,7 +158,7 @@ namespace Lucene.Net.Queries
{
return false;
}
- var other = (CustomScoreQuery) o;
+ var other = (CustomScoreQuery)o;
if (this.Boost != other.Boost || !this.subQuery.Equals(other.subQuery) || this.strict != other.strict ||
this.scoringQueries.Length != other.scoringQueries.Length)
{
@@ -225,7 +226,7 @@ namespace Lucene.Net.Queries
if (qStrict)
{
var _ = valSrcWeight.ValueForNormalization;
- // do not include ValueSource part in the query normalization
+ // do not include ValueSource part in the query normalization
}
else
{
@@ -301,7 +302,7 @@ namespace Lucene.Net.Queries
Explanation res = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");
res.AddDetail(customExp);
res.AddDetail(new Explanation(outerInstance.Boost, "queryBoost"));
- // actually using the q boost as q weight (== weight value)
+ // actually using the q boost as q weight (== weight value)
return res;
}
@@ -310,131 +311,132 @@ namespace Lucene.Net.Queries
return false;
}
+ }
+ //=========================== S C O R E R ============================
- //=========================== S C O R E R ============================
-
- /// <summary>
- /// A scorer that applies a (callback) function on scores of the subQuery.
- /// </summary>
- private class CustomScorer : Scorer
- {
- private readonly CustomScoreQuery outerInstance;
+ /// <summary>
+ /// A scorer that applies a (callback) function on scores of the subQuery.
+ /// </summary>
+ private class CustomScorer : Scorer
+ {
+ private readonly CustomScoreQuery outerInstance;
- private readonly float qWeight;
- private readonly Scorer subQueryScorer;
- private readonly Scorer[] valSrcScorers;
- private readonly CustomScoreProvider provider;
- private readonly float[] vScores; // reused in score() to avoid allocating this array for each doc
+ private readonly float qWeight;
+ private readonly Scorer subQueryScorer;
+ private readonly Scorer[] valSrcScorers;
+ private readonly CustomScoreProvider provider;
+ private readonly float[] vScores; // reused in score() to avoid allocating this array for each doc
- // constructor
- internal CustomScorer(CustomScoreQuery outerInstance, CustomScoreProvider provider, CustomWeight w,
- float qWeight, Scorer subQueryScorer, Scorer[] valSrcScorers) : base(w)
- {
- this.outerInstance = outerInstance;
- this.qWeight = qWeight;
- this.subQueryScorer = subQueryScorer;
- this.valSrcScorers = valSrcScorers;
- this.vScores = new float[valSrcScorers.Length];
- this.provider = provider;
- }
+ // constructor
+ internal CustomScorer(CustomScoreQuery outerInstance, CustomScoreProvider provider, CustomWeight w,
+ float qWeight, Scorer subQueryScorer, Scorer[] valSrcScorers)
+ : base(w)
+ {
+ this.outerInstance = outerInstance;
+ this.qWeight = qWeight;
+ this.subQueryScorer = subQueryScorer;
+ this.valSrcScorers = valSrcScorers;
+ this.vScores = new float[valSrcScorers.Length];
+ this.provider = provider;
+ }
- public override int NextDoc()
+ public override int NextDoc()
+ {
+ int doc = subQueryScorer.NextDoc();
+ if (doc != NO_MORE_DOCS)
{
- int doc = subQueryScorer.NextDoc();
- if (doc != NO_MORE_DOCS)
+ foreach (Scorer valSrcScorer in valSrcScorers)
{
- foreach (Scorer valSrcScorer in valSrcScorers)
- {
- valSrcScorer.Advance(doc);
- }
+ valSrcScorer.Advance(doc);
}
- return doc;
}
+ return doc;
+ }
- public override int DocID()
- {
- return subQueryScorer.DocID();
- }
+ public override int DocID()
+ {
+ return subQueryScorer.DocID();
+ }
- /*(non-Javadoc) @see org.apache.lucene.search.Scorer#score() */
+ /*(non-Javadoc) @see org.apache.lucene.search.Scorer#score() */
- public override float Score()
+ public override float Score()
+ {
+ for (int i = 0; i < valSrcScorers.Length; i++)
{
- for (int i = 0; i < valSrcScorers.Length; i++)
- {
- vScores[i] = valSrcScorers[i].Score();
- }
- return qWeight*provider.CustomScore(subQueryScorer.DocID(), subQueryScorer.Score(), vScores);
+ vScores[i] = valSrcScorers[i].Score();
}
+ return qWeight * provider.CustomScore(subQueryScorer.DocID(), subQueryScorer.Score(), vScores);
+ }
- public override int Freq()
- {
- return subQueryScorer.Freq();
- }
+ public override int Freq()
+ {
+ return subQueryScorer.Freq();
+ }
- public override ICollection<ChildScorer> Children
- {
- get { return Collections.Singleton(new ChildScorer(subQueryScorer, "CUSTOM")); }
- }
+ public override ICollection<ChildScorer> Children
+ {
+ get { return Collections.Singleton(new ChildScorer(subQueryScorer, "CUSTOM")); }
+ }
- public override int Advance(int target)
+ public override int Advance(int target)
+ {
+ int doc = subQueryScorer.Advance(target);
+ if (doc != NO_MORE_DOCS)
{
- int doc = subQueryScorer.Advance(target);
- if (doc != NO_MORE_DOCS)
+ foreach (Scorer valSrcScorer in valSrcScorers)
{
- foreach (Scorer valSrcScorer in valSrcScorers)
- {
- valSrcScorer.Advance(doc);
- }
+ valSrcScorer.Advance(doc);
}
- return doc;
- }
-
- public override long Cost()
- {
- return subQueryScorer.Cost();
}
+ return doc;
}
-// public override Weight CreateWeight(IndexSearcher searcher)
-// {
-// return new CustomWeight(this, searcher);
-// }
-
- /// <summary>
- /// Checks if this is strict custom scoring.
- /// In strict custom scoring, the <seealso cref="ValueSource"/> part does not participate in weight normalization.
- /// This may be useful when one wants full control over how scores are modified, and does
- /// not care about normalizing by the <seealso cref="ValueSource"/> part.
- /// One particular case where this is useful if for testing this query.
- /// <P>
- /// Note: only has effect when the <seealso cref="ValueSource"/> part is not null.
- /// </summary>
- public virtual bool Strict { get; set; }
-
-
- /// <summary>
- /// The sub-query that CustomScoreQuery wraps, affecting both the score and which documents match. </summary>
- public virtual Query SubQuery
+ public override long Cost()
{
- get { return outerInstance.subQuery; }
+ return subQueryScorer.Cost();
}
+ }
- /// <summary>
- /// The scoring queries that only affect the score of CustomScoreQuery. </summary>
- public virtual Query[] ScoringQueries
- {
- get { return outerInstance.scoringQueries; }
- }
+ // public override Weight CreateWeight(IndexSearcher searcher)
+ // {
+ // return new CustomWeight(this, searcher);
+ // }
- /// <summary>
- /// A short name of this query, used in <seealso cref="#toString(String)"/>.
- /// </summary>
- public virtual string Name
- {
- get { return "custom"; }
- }
+ /// <summary>
+ /// Checks if this is strict custom scoring.
+ /// In strict custom scoring, the <seealso cref="ValueSource"/> part does not participate in weight normalization.
+ /// This may be useful when one wants full control over how scores are modified, and does
+ /// not care about normalizing by the <seealso cref="ValueSource"/> part.
+ /// One particular case where this is useful if for testing this query.
+ /// <P>
+ /// Note: only has effect when the <seealso cref="ValueSource"/> part is not null.
+ /// </summary>
+ public virtual bool Strict { get; set; }
+
+
+ /// <summary>
+ /// The sub-query that CustomScoreQuery wraps, affecting both the score and which documents match. </summary>
+ public virtual Query SubQuery
+ {
+ get { return subQuery; }
}
+
+ /// <summary>
+ /// The scoring queries that only affect the score of CustomScoreQuery. </summary>
+ public virtual Query[] ScoringQueries
+ {
+ get { return scoringQueries; }
+ }
+
+ /// <summary>
+ /// A short name of this query, used in <seealso cref="#toString(String)"/>.
+ /// </summary>
+ public virtual string Name
+ {
+ get { return "custom"; }
+ }
+
}
}
\ No newline at end of file
[2/6] lucenenet git commit: More compilation fixes
Posted by sy...@apache.org.
More compilation fixes
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/4c206612
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/4c206612
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/4c206612
Branch: refs/heads/master
Commit: 4c206612581afeb28497cb201c28a81589733da4
Parents: f52cf1a
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Fri Nov 7 07:11:07 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Fri Nov 7 07:11:07 2014 +0200
----------------------------------------------------------------------
src/Lucene.Net.Core/Support/IdentityComparer.cs | 16 +++++++++++++++-
src/Lucene.Net.Queries/BoostingQuery.cs | 2 +-
src/Lucene.Net.Queries/CustomScoreQuery.cs | 8 ++++----
src/Lucene.Net.Queries/Function/BoostedQuery.cs | 4 ++--
src/Lucene.Net.Queries/Function/ValueSource.cs | 7 ++++---
.../Function/ValueSources/EnumFieldSource.cs | 4 ++--
6 files changed, 28 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4c206612/src/Lucene.Net.Core/Support/IdentityComparer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/IdentityComparer.cs b/src/Lucene.Net.Core/Support/IdentityComparer.cs
index ae71e06..27d6798 100644
--- a/src/Lucene.Net.Core/Support/IdentityComparer.cs
+++ b/src/Lucene.Net.Core/Support/IdentityComparer.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System.Collections;
+using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace Lucene.Net.Support
@@ -15,4 +16,17 @@ namespace Lucene.Net.Support
return RuntimeHelpers.GetHashCode(obj);
}
}
+
+ public class IdentityComparer : IEqualityComparer
+ {
+ public new bool Equals(object x, object y)
+ {
+ return ReferenceEquals(x, y);
+ }
+
+ public int GetHashCode(object obj)
+ {
+ return RuntimeHelpers.GetHashCode(obj);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4c206612/src/Lucene.Net.Queries/BoostingQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/BoostingQuery.cs b/src/Lucene.Net.Queries/BoostingQuery.cs
index bf0e762..125deed 100644
--- a/src/Lucene.Net.Queries/BoostingQuery.cs
+++ b/src/Lucene.Net.Queries/BoostingQuery.cs
@@ -78,7 +78,7 @@ namespace Lucene.Net.Queries
private readonly BooleanQueryAnonymousInnerClassHelper outerInstance;
public BooleanWeightAnonymousInnerClassHelper(BooleanQueryAnonymousInnerClassHelper outerInstance, IndexSearcher searcher)
- : base(searcher, false)
+ : base(outerInstance, searcher, false)
{
this.outerInstance = outerInstance;
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4c206612/src/Lucene.Net.Queries/CustomScoreQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/CustomScoreQuery.cs b/src/Lucene.Net.Queries/CustomScoreQuery.cs
index 00522c3..8ac3636 100644
--- a/src/Lucene.Net.Queries/CustomScoreQuery.cs
+++ b/src/Lucene.Net.Queries/CustomScoreQuery.cs
@@ -397,10 +397,10 @@ namespace Lucene.Net.Queries
}
}
- public override Weight CreateWeight(IndexSearcher searcher)
- {
- return new CustomWeight(this, searcher);
- }
+// public override Weight CreateWeight(IndexSearcher searcher)
+// {
+// return new CustomWeight(this, searcher);
+// }
/// <summary>
/// Checks if this is strict custom scoring.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4c206612/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 db52a35..95343b2 100644
--- a/src/Lucene.Net.Queries/Function/BoostedQuery.cs
+++ b/src/Lucene.Net.Queries/Function/BoostedQuery.cs
@@ -84,7 +84,7 @@ namespace Lucene.Net.Queries.Function
private readonly BoostedQuery outerInstance;
private readonly IndexSearcher searcher;
- private readonly Weight qWeight;
+ internal readonly Weight qWeight;
internal readonly IDictionary fcontext;
public BoostedWeight(BoostedQuery outerInstance, IndexSearcher searcher)
@@ -208,7 +208,7 @@ namespace Lucene.Net.Queries.Function
public virtual Explanation Explain(int doc)
{
- Explanation subQueryExpl = weight.qWeight.Explain(readerContext, doc);
+ var subQueryExpl = weight.qWeight.Explain(readerContext, doc);
if (!subQueryExpl.IsMatch)
{
return subQueryExpl;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4c206612/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 85a85c3..70e8562 100644
--- a/src/Lucene.Net.Queries/Function/ValueSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSource.cs
@@ -1,4 +1,5 @@
-using System.Collections;
+using System;
+using System.Collections;
using System.Collections.Generic;
using Lucene.Net.Index;
using Lucene.Net.Search;
@@ -66,9 +67,9 @@ namespace Lucene.Net.Queries.Function
/// <summary>
/// Returns a new non-threadsafe context map.
/// </summary>
- public static IDictionary<string, IndexSearcher> NewContext(IndexSearcher searcher)
+ public static IDictionary NewContext(IndexSearcher searcher)
{
- var context = new IdentityHashMap<string, IndexSearcher>();
+ var context = new Hashtable(new IdentityComparer());
context["searcher"] = searcher;
return context;
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4c206612/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs
index cf2c366..6ff23fa 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs
@@ -214,7 +214,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
int ll = lower.Value;
int uu = upper.Value;
- return new ValueSourceScorerAnonymousInnerClassHelper(this, reader, this, ll, uu);
+ return new ValueSourceScorerAnonymousInnerClassHelper(this, reader, outerInstance, ll, uu);
}
private class ValueSourceScorerAnonymousInnerClassHelper : ValueSourceScorer
@@ -225,7 +225,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
private readonly int uu;
public ValueSourceScorerAnonymousInnerClassHelper(IntDocValuesAnonymousInnerClassHelper outerInstance, IndexReader reader, EnumFieldSource @this, int ll, int uu)
- : base(reader, @this)
+ : base(reader, outerInstance)
{
this.outerInstance = outerInstance;
this.ll = ll;