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/09/19 17:05:41 UTC
[3/3] git commit: More Lucene.Net.Queries work
More Lucene.Net.Queries work
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a8538877
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a8538877
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a8538877
Branch: refs/heads/master
Commit: a8538877258713c0a4a32505be7432a46f9b61bc
Parents: ddec100
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Fri Sep 19 18:05:03 2014 +0300
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Fri Sep 19 18:05:03 2014 +0300
----------------------------------------------------------------------
src/Lucene.Net.Queries/CustomScoreProvider.cs | 2 +-
.../DocValues/DocTermsIndexDocValues.cs | 2 +-
.../Function/DocValues/LongDocValues.cs | 4 +-
.../Function/DocValues/StrDocValues.cs | 2 +-
.../Function/ValueSources/ByteFieldSource.cs | 10 +-
.../ValueSources/BytesRefFieldSource.cs | 8 +-
.../Function/ValueSources/ConstNumberSource.cs | 1 -
.../Function/ValueSources/ConstValueSource.cs | 257 +++++++++----------
.../Function/ValueSources/DefFunction.cs | 248 +++++++++---------
.../Function/ValueSources/DivFloatFunction.cs | 2 -
.../ValueSources/DoubleConstValueSource.cs | 2 +-
.../Function/ValueSources/DoubleFieldSource.cs | 208 ++++++++-------
.../Function/ValueSources/EnumFieldSource.cs | 80 +++---
.../Function/ValueSources/FieldCacheSource.cs | 6 +-
.../Function/ValueSources/FloatFieldSource.cs | 24 +-
.../Function/ValueSources/IDFValueSource.cs | 4 +-
16 files changed, 420 insertions(+), 440 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/CustomScoreProvider.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/CustomScoreProvider.cs b/src/Lucene.Net.Queries/CustomScoreProvider.cs
index d365695..42736a5 100644
--- a/src/Lucene.Net.Queries/CustomScoreProvider.cs
+++ b/src/Lucene.Net.Queries/CustomScoreProvider.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Queries
/// <para>Since Lucene 2.9, queries operate on each segment of an index separately,
/// so the protected <seealso cref="#context"/> field can be used to resolve doc IDs,
/// as the supplied <code>doc</code> ID is per-segment and without knowledge
- /// of the IndexReader you cannot access the document or <seealso cref="FieldCache"/>.
+ /// of the IndexReader you cannot access the document or <seealso cref="IFieldCache"/>.
///
/// @lucene.experimental
/// @since 2.9.2
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs
index 832e921..672ec6b 100644
--- a/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs
+++ b/src/Lucene.Net.Queries/Function/DocValues/DocTermsIndexDocValues.cs
@@ -38,7 +38,7 @@ namespace Lucene.Net.Queries.Function.DocValues
{
try
{
- termsIndex = FieldCache_Fields.DEFAULT.GetTermsIndex(context.AtomicReader, field);
+ termsIndex = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, field);
}
catch (Exception e)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs
index 18700b2..5f21381 100644
--- a/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs
+++ b/src/Lucene.Net.Queries/Function/DocValues/LongDocValues.cs
@@ -128,8 +128,8 @@ namespace Lucene.Net.Queries.Function.DocValues
{
private readonly LongDocValues outerInstance;
- private long ll;
- private long uu;
+ private readonly long ll;
+ private readonly long uu;
public ValueSourceScorerAnonymousInnerClassHelper(LongDocValues outerInstance, IndexReader reader, LongDocValues @this, long ll, long uu)
: base(reader, @this)
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs b/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs
index 41f520a..ab13a95 100644
--- a/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs
+++ b/src/Lucene.Net.Queries/Function/DocValues/StrDocValues.cs
@@ -27,7 +27,7 @@ namespace Lucene.Net.Queries.Function.DocValues
{
protected internal readonly ValueSource vs;
- public StrDocValues(ValueSource vs)
+ protected StrDocValues(ValueSource vs)
{
this.vs = vs;
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs
index 2b8bc7e..88c5559 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/ByteFieldSource.cs
@@ -32,14 +32,14 @@ namespace Lucene.Net.Queries.Function.ValueSources
public class ByteFieldSource : FieldCacheSource
{
- private readonly FieldCache_Fields.IByteParser parser;
+ private readonly FieldCache.IByteParser parser;
public ByteFieldSource(string field)
: this(field, null)
{
}
- public ByteFieldSource(string field, FieldCache_Fields.IByteParser parser)
+ public ByteFieldSource(string field, FieldCache.IByteParser parser)
: base(field)
{
this.parser = parser;
@@ -52,7 +52,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
public override FunctionValues GetValues(IDictionary context, AtomicReaderContext readerContext)
{
- FieldCache_Fields.Bytes arr = cache.GetBytes(readerContext.AtomicReader, field, parser, false);
+ FieldCache.Bytes arr = cache.GetBytes(readerContext.AtomicReader, field, parser, false);
return new FunctionValuesAnonymousInnerClassHelper(this, arr);
}
@@ -60,9 +60,9 @@ namespace Lucene.Net.Queries.Function.ValueSources
private class FunctionValuesAnonymousInnerClassHelper : FunctionValues
{
private readonly ByteFieldSource outerInstance;
- private readonly FieldCache_Fields.Bytes arr;
+ private readonly FieldCache.Bytes arr;
- public FunctionValuesAnonymousInnerClassHelper(ByteFieldSource outerInstance, FieldCache_Fields.Bytes arr)
+ public FunctionValuesAnonymousInnerClassHelper(ByteFieldSource outerInstance, FieldCache.Bytes arr)
{
this.outerInstance = outerInstance;
this.arr = arr;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs
index 0ed87a8..a277bb2 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/BytesRefFieldSource.cs
@@ -41,8 +41,8 @@ namespace Lucene.Net.Queries.Function.ValueSources
// TODO: do it cleaner?
if (fieldInfo != null && fieldInfo.DocValuesType == FieldInfo.DocValuesType_e.BINARY)
{
- BinaryDocValues binaryValues = FieldCache_Fields.DEFAULT.GetTerms(readerContext.AtomicReader, field, true);
- Bits docsWithField = FieldCache_Fields.DEFAULT.GetDocsWithField(readerContext.AtomicReader, field);
+ BinaryDocValues binaryValues = Search.FieldCache.DEFAULT.GetTerms(readerContext.AtomicReader, field, true);
+ Bits docsWithField = Search.FieldCache.DEFAULT.GetDocsWithField(readerContext.AtomicReader, field);
return new FunctionValuesAnonymousInnerClassHelper(this, binaryValues, docsWithField);
}
else
@@ -55,8 +55,8 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
private readonly BytesRefFieldSource outerInstance;
- private BinaryDocValues binaryValues;
- private Bits docsWithField;
+ private readonly BinaryDocValues binaryValues;
+ private readonly Bits docsWithField;
public FunctionValuesAnonymousInnerClassHelper(BytesRefFieldSource outerInstance, BinaryDocValues binaryValues, Bits docsWithField)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs
index d179c4d..d208c92 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/ConstNumberSource.cs
@@ -32,5 +32,4 @@ namespace Lucene.Net.Queries.Function.ValueSources
public abstract Number Number { get; }
public abstract bool Bool { get; }
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs
index 36ab51e..e27c869 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/ConstValueSource.cs
@@ -15,138 +15,137 @@
* limitations under the License.
*/
using System.Collections;
+using Lucene.Net.Index;
using Lucene.Net.Queries.Function.DocValues;
-using org.apache.lucene.queries.function;
+using Lucene.Net.Support;
namespace Lucene.Net.Queries.Function.ValueSources
{
/// <summary>
- /// <code>ConstValueSource</code> returns a constant for all documents
- /// </summary>
- public class ConstValueSource : ConstNumberSource
- {
- internal readonly float constant;
- private readonly double dv;
-
- public ConstValueSource(float constant)
- {
- this.constant = constant;
- this.dv = constant;
- }
-
- public override string description()
- {
- return "const(" + constant + ")";
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public org.apache.lucene.queries.function.FunctionValues GetValues(java.util.Map context, org.apache.lucene.index.AtomicReaderContext readerContext) throws java.io.IOException
- public override FunctionValues GetValues(IDictionary context, AtomicReaderContext readerContext)
- {
- return new FloatDocValuesAnonymousInnerClassHelper(this, this);
- }
-
- private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
- {
- private readonly ConstValueSource outerInstance;
-
- public FloatDocValuesAnonymousInnerClassHelper(ConstValueSource outerInstance, ConstValueSource this) : base(this)
- {
- this.outerInstance = outerInstance;
- }
-
- public override float FloatVal(int doc)
- {
- return outerInstance.constant;
- }
- public override int intVal(int doc)
- {
- return (int)outerInstance.constant;
- }
- public override long LongVal(int doc)
- {
- return (long)outerInstance.constant;
- }
- public override double DoubleVal(int doc)
- {
- return outerInstance.dv;
- }
- public override string ToString(int doc)
- {
- return outerInstance.description();
- }
- public override object objectVal(int doc)
- {
- return outerInstance.constant;
- }
- public override bool boolVal(int doc)
- {
- return outerInstance.constant != 0.0f;
- }
- }
-
- public override int GetHashCode()
- {
- return Number.FloatToIntBits(constant) * 31;
- }
-
- public override bool Equals(object o)
- {
- if (!(o is ConstValueSource))
- {
- return false;
- }
- ConstValueSource other = (ConstValueSource)o;
- return this.constant == other.constant;
- }
-
- public override int Int
- {
- get
- {
- return (int)constant;
- }
- }
-
- public override long Long
- {
- get
- {
- return (long)constant;
- }
- }
-
- public override float Float
- {
- get
- {
- return constant;
- }
- }
-
- public override double Double
- {
- get
- {
- return dv;
- }
- }
-
- public override Number Number
- {
- get
- {
- return constant;
- }
- }
-
- public override bool Bool
- {
- get
- {
- return constant != 0.0f;
- }
- }
- }
-
+ /// <code>ConstValueSource</code> returns a constant for all documents
+ /// </summary>
+ public class ConstValueSource : ConstNumberSource
+ {
+ internal readonly float constant;
+ private readonly double dv;
+
+ public ConstValueSource(float constant)
+ {
+ this.constant = constant;
+ this.dv = constant;
+ }
+
+ public override string Description
+ {
+ get { return "const(" + constant + ")"; }
+ }
+
+ public override FunctionValues GetValues(IDictionary context, AtomicReaderContext readerContext)
+ {
+ return new FloatDocValuesAnonymousInnerClassHelper(this, this);
+ }
+
+ private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
+ {
+ private readonly ConstValueSource outerInstance;
+
+ public FloatDocValuesAnonymousInnerClassHelper(ConstValueSource outerInstance, ConstValueSource @this)
+ : base(@this)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+ public override float FloatVal(int doc)
+ {
+ return outerInstance.constant;
+ }
+ public override int IntVal(int doc)
+ {
+ return (int)outerInstance.constant;
+ }
+ public override long LongVal(int doc)
+ {
+ return (long)outerInstance.constant;
+ }
+ public override double DoubleVal(int doc)
+ {
+ return outerInstance.dv;
+ }
+ public override string ToString(int doc)
+ {
+ return outerInstance.Description;
+ }
+ public override object ObjectVal(int doc)
+ {
+ return outerInstance.constant;
+ }
+ public override bool BoolVal(int doc)
+ {
+ return outerInstance.constant != 0.0f;
+ }
+ }
+
+ public override int GetHashCode()
+ {
+ return Number.FloatToIntBits(constant) * 31;
+ }
+
+ public override bool Equals(object o)
+ {
+ var other = o as ConstValueSource;
+ if (other == null)
+ {
+ return false;
+ }
+ return this.constant == other.constant;
+ }
+
+ public override int Int
+ {
+ get
+ {
+ return (int)constant;
+ }
+ }
+
+ public override long Long
+ {
+ get
+ {
+ return (long)constant;
+ }
+ }
+
+ public override float Float
+ {
+ get
+ {
+ return constant;
+ }
+ }
+
+ public override double Double
+ {
+ get
+ {
+ return dv;
+ }
+ }
+
+ public override Number Number
+ {
+ get
+ {
+ return constant;
+ }
+ }
+
+ public override bool Bool
+ {
+ get
+ {
+ return constant != 0.0f;
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs
index bbdbe2e..3c019be 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/DefFunction.cs
@@ -1,135 +1,131 @@
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
using Lucene.Net.Index;
using Lucene.Net.Util;
namespace Lucene.Net.Queries.Function.ValueSources
{
- /*
- * 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>
- /// <seealso cref="ValueSource"/> implementation which only returns the values from the provided
- /// ValueSources which are available for a particular docId. Consequently, when combined
- /// with a <seealso cref="ConstValueSource"/>, this function serves as a way to return a default
- /// value when the values for a field are unavailable.
- /// </summary>
- public class DefFunction : MultiFunction
- {
- public DefFunction(IList<ValueSource> sources) : base(sources)
- {
- }
-
- protected internal override string name()
- {
- return "def";
- }
-
- public override FunctionValues GetValues(IDictionary fcontext, AtomicReaderContext readerContext)
- {
- return new ValuesAnonymousInnerClassHelper(this, valsArr(sources, fcontext, readerContext));
- }
-
- private class ValuesAnonymousInnerClassHelper : Values
- {
- private readonly DefFunction outerInstance;
-
- public ValuesAnonymousInnerClassHelper(DefFunction outerInstance, FunctionValues[] valsArr) : base(outerInstance, valsArr)
- {
- this.outerInstance = outerInstance;
- upto = valsArr.Length - 1;
- }
-
- internal readonly int upto;
-
- private FunctionValues Get(int doc)
- {
- for (int i = 0; i < upto; i++)
- {
- FunctionValues vals = valsArr[i];
- if (vals.Exists(doc))
- {
- return vals;
- }
- }
- return valsArr[upto];
- }
-
- public override sbyte ByteVal(int doc)
- {
- return Get(doc).ByteVal(doc);
- }
-
- public override short ShortVal(int doc)
- {
- return Get(doc).ShortVal(doc);
- }
-
- public override float FloatVal(int doc)
- {
- return Get(doc).FloatVal(doc);
- }
-
- public override int IntVal(int doc)
- {
- return Get(doc).IntVal(doc);
- }
-
- public override long LongVal(int doc)
- {
- return Get(doc).LongVal(doc);
- }
-
- public override double DoubleVal(int doc)
- {
- return Get(doc).DoubleVal(doc);
- }
-
- public override string StrVal(int doc)
- {
- return Get(doc).StrVal(doc);
- }
-
- public override bool BoolVal(int doc)
- {
- return Get(doc).BoolVal(doc);
- }
-
- public override bool BytesVal(int doc, BytesRef target)
- {
- return Get(doc).BytesVal(doc, target);
- }
-
- public override object ObjectVal(int doc)
- {
- return Get(doc).ObjectVal(doc);
- }
-
- public override bool Exists(int doc)
- {
- // return true if any source is exists?
- foreach (FunctionValues vals in valsArr)
- {
- if (vals.Exists(doc))
- {
- return true;
- }
- }
- return false;
- }
- }
- }
+ /// <seealso cref="ValueSource"/> implementation which only returns the values from the provided
+ /// ValueSources which are available for a particular docId. Consequently, when combined
+ /// with a <seealso cref="ConstValueSource"/>, this function serves as a way to return a default
+ /// value when the values for a field are unavailable.
+ /// </summary>
+ public class DefFunction : MultiFunction
+ {
+ public DefFunction(IList<ValueSource> sources)
+ : base(sources)
+ {
+ }
+
+ protected override string Name
+ {
+ get { return "def"; }
+ }
+
+ public override FunctionValues GetValues(IDictionary fcontext, AtomicReaderContext readerContext)
+ {
+ return new ValuesAnonymousInnerClassHelper(this, ValsArr(sources, fcontext, readerContext));
+ }
+
+ private class ValuesAnonymousInnerClassHelper : Values
+ {
+ private readonly DefFunction outerInstance;
+
+ public ValuesAnonymousInnerClassHelper(DefFunction outerInstance, FunctionValues[] valsArr)
+ : base(outerInstance, valsArr)
+ {
+ this.outerInstance = outerInstance;
+ upto = valsArr.Length - 1;
+ }
+
+ private readonly int upto;
+
+ private FunctionValues Get(int doc)
+ {
+ for (int i = 0; i < upto; i++)
+ {
+ FunctionValues vals = valsArr[i];
+ if (vals.Exists(doc))
+ {
+ return vals;
+ }
+ }
+ return valsArr[upto];
+ }
+
+ public override sbyte ByteVal(int doc)
+ {
+ return Get(doc).ByteVal(doc);
+ }
+
+ public override short ShortVal(int doc)
+ {
+ return Get(doc).ShortVal(doc);
+ }
+
+ public override float FloatVal(int doc)
+ {
+ return Get(doc).FloatVal(doc);
+ }
+
+ public override int IntVal(int doc)
+ {
+ return Get(doc).IntVal(doc);
+ }
+
+ public override long LongVal(int doc)
+ {
+ return Get(doc).LongVal(doc);
+ }
+
+ public override double DoubleVal(int doc)
+ {
+ return Get(doc).DoubleVal(doc);
+ }
+
+ public override string StrVal(int doc)
+ {
+ return Get(doc).StrVal(doc);
+ }
+
+ public override bool BoolVal(int doc)
+ {
+ return Get(doc).BoolVal(doc);
+ }
+
+ public override bool BytesVal(int doc, BytesRef target)
+ {
+ return Get(doc).BytesVal(doc, target);
+ }
+
+ public override object ObjectVal(int doc)
+ {
+ return Get(doc).ObjectVal(doc);
+ }
+
+ public override bool Exists(int doc)
+ {
+ // return true if any source is exists?
+ return valsArr.Any(vals => vals.Exists(doc));
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs
index 9510bc2..ca89f47 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/DivFloatFunction.cs
@@ -17,8 +17,6 @@
namespace Lucene.Net.Queries.Function.ValueSources
{
-
-
/// <summary>
/// Function to divide "a" by "b"
/// </summary>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/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 7a738f7..fc2131a 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleConstValueSource.cs
@@ -94,7 +94,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
public override int GetHashCode()
{
- long bits = NumberUtil.DoubleToRawLongBits(constant);
+ long bits = Number.DoubleToRawLongBits(constant);
return (int)(bits ^ ((long)((ulong)bits >> 32)));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
index 3965bca..95c74fd 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/DoubleFieldSource.cs
@@ -24,120 +24,116 @@ using Lucene.Net.Util.Mutable;
namespace Lucene.Net.Queries.Function.ValueSources
{
/// <summary>
- /// Obtains double field values from <seealso cref="FieldCache#getDoubles"/> and makes
- /// those values available as other numeric types, casting as needed.
- /// </summary>
- public class DoubleFieldSource : FieldCacheSource
- {
+ /// Obtains double field values from <seealso cref="IFieldCache#getDoubles"/> and makes
+ /// those values available as other numeric types, casting as needed.
+ /// </summary>
+ public class DoubleFieldSource : FieldCacheSource
+ {
- protected internal readonly FieldCache_Fields.DoubleParser parser;
+ protected internal readonly FieldCache.IDoubleParser parser;
- public DoubleFieldSource(string field) : this(field, null)
- {
- }
+ public DoubleFieldSource(string field)
+ : this(field, null)
+ {
+ }
- public DoubleFieldSource(string field, FieldCache.DoubleParser parser) : base(field)
- {
- this.parser = parser;
- }
+ public DoubleFieldSource(string field, FieldCache.IDoubleParser parser)
+ : base(field)
+ {
+ this.parser = parser;
+ }
public override string Description
{
get { return "double(" + field + ')'; }
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public org.apache.lucene.queries.function.FunctionValues GetValues(java.util.Map context, org.apache.lucene.index.AtomicReaderContext readerContext) throws java.io.IOException
- public override FunctionValues GetValues(IDictionary context, AtomicReaderContext readerContext)
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.search.FieldCache.Doubles arr = cache.getDoubles(readerContext.reader(), field, parser, true);
- FieldCache.Doubles arr = cache.getDoubles(readerContext.reader(), field, parser, true);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.util.Bits valid = cache.getDocsWithField(readerContext.reader(), field);
- var valid = cache.getDocsWithField(readerContext.reader(), field);
- return new DoubleDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
-
- }
-
- private class DoubleDocValuesAnonymousInnerClassHelper : DoubleDocValues
- {
- private readonly DoubleFieldSource outerInstance;
-
- private FieldCache.Doubles arr;
- private Bits valid;
-
- public DoubleDocValuesAnonymousInnerClassHelper(DoubleFieldSource outerInstance, DoubleFieldSource this, FieldCache.Doubles arr, Bits valid) : base(this)
- {
- this.outerInstance = outerInstance;
- this.arr = arr;
- this.valid = valid;
- }
-
- public override double DoubleVal(int doc)
- {
- return arr.get(doc);
- }
-
- public override bool exists(int doc)
- {
- return arr.get(doc) != 0 || valid.get(doc);
- }
-
- public override ValueFiller ValueFiller
- {
- get
- {
- return new ValueFillerAnonymousInnerClassHelper(this);
- }
- }
-
- private class ValueFillerAnonymousInnerClassHelper : AbstractValueFiller
- {
- private readonly DoubleDocValuesAnonymousInnerClassHelper outerInstance;
-
- public ValueFillerAnonymousInnerClassHelper(DoubleDocValuesAnonymousInnerClassHelper outerInstance)
- {
- this.outerInstance = outerInstance;
- mval = new MutableValueDouble();
- }
-
- private readonly MutableValueDouble mval;
-
- public override MutableValue Value
- {
- get
- {
- return mval;
- }
- }
-
- public override void FillValue(int doc)
- {
- mval.Value = outerInstance.arr.Get(doc);
- mval.Exists = mval.Value != 0 || outerInstance.valid.Get(doc);
- }
- }
-
-
- }
-
- public override bool Equals(object o)
- {
- if (o.GetType() != typeof(DoubleFieldSource))
- {
- return false;
- }
- DoubleFieldSource other = (DoubleFieldSource) o;
- return base.Equals(other) && (this.parser == null ? other.parser == null : this.parser.GetType() == other.parser.GetType());
- }
-
- public override int GetHashCode()
- {
- int h = parser == null ? typeof(double?).GetHashCode() : parser.GetType().GetHashCode();
- h += base.GetHashCode();
- return h;
- }
- }
+ public override FunctionValues GetValues(IDictionary context, AtomicReaderContext readerContext)
+ {
+ var arr = cache.GetDoubles(readerContext.AtomicReader, field, parser, true);
+ var valid = cache.GetDocsWithField(readerContext.AtomicReader, field);
+ return new DoubleDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
+
+ }
+ private class DoubleDocValuesAnonymousInnerClassHelper : DoubleDocValues
+ {
+ private readonly DoubleFieldSource outerInstance;
+
+ private readonly FieldCache.Doubles arr;
+ private readonly Bits valid;
+
+ public DoubleDocValuesAnonymousInnerClassHelper(DoubleFieldSource outerInstance, DoubleFieldSource @this, FieldCache.Doubles arr, Bits valid)
+ : base(@this)
+ {
+ this.outerInstance = outerInstance;
+ this.arr = arr;
+ this.valid = valid;
+ }
+
+ public override double DoubleVal(int doc)
+ {
+ return arr.Get(doc);
+ }
+
+ public override bool Exists(int doc)
+ {
+ return arr.Get(doc) != 0 || valid.Get(doc);
+ }
+
+ public override AbstractValueFiller ValueFiller
+ {
+ get
+ {
+ return new ValueFillerAnonymousInnerClassHelper(this);
+ }
+ }
+
+ private class ValueFillerAnonymousInnerClassHelper : AbstractValueFiller
+ {
+ private readonly DoubleDocValuesAnonymousInnerClassHelper outerInstance;
+
+ public ValueFillerAnonymousInnerClassHelper(DoubleDocValuesAnonymousInnerClassHelper outerInstance)
+ {
+ this.outerInstance = outerInstance;
+ mval = new MutableValueDouble();
+ }
+
+ private readonly MutableValueDouble mval;
+
+ public override MutableValue Value
+ {
+ get
+ {
+ return mval;
+ }
+ }
+
+ public override void FillValue(int doc)
+ {
+ mval.Value = outerInstance.arr.Get(doc);
+ mval.Exists = mval.Value != 0 || outerInstance.valid.Get(doc);
+ }
+ }
+ }
+
+ public override bool Equals(object o)
+ {
+ var other = o as
+ DoubleFieldSource;
+ if (other == null)
+ {
+ return false;
+ }
+ return base.Equals(other) &&
+ (this.parser == null ? other.parser == null : this.parser.GetType() == other.parser.GetType());
+ }
+
+ public override int GetHashCode()
+ {
+ int h = parser == null ? typeof(double?).GetHashCode() : parser.GetType().GetHashCode();
+ h += base.GetHashCode();
+ return h;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/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 ada4ecb..7aa50d9 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/EnumFieldSource.cs
@@ -28,7 +28,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
* limitations under the License.
*/
/// <summary>
- /// Obtains int field values from <seealso cref="FieldCache#getInts"/> and makes
+ /// Obtains int field values from <seealso cref="IFieldCache#getInts"/> and makes
/// those values available as other numeric types, casting as needed.
/// StrVal of the value is not the int value, but its string (displayed) value
/// </summary>
@@ -36,11 +36,11 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
internal const int DEFAULT_VALUE = -1;
- internal readonly FieldCache_Fields.IntParser parser;
+ internal readonly FieldCache.IIntParser parser;
internal readonly IDictionary<int?, string> enumIntToStringMap;
internal readonly IDictionary<string, int?> enumStringToIntMap;
- public EnumFieldSource(string field, FieldCache.IntParser parser, IDictionary<int?, string> enumIntToStringMap, IDictionary<string, int?> enumStringToIntMap) : base(field)
+ public EnumFieldSource(string field, FieldCache.IIntParser parser, IDictionary<int?, string> enumIntToStringMap, IDictionary<string, int?> enumStringToIntMap) : base(field)
{
this.parser = parser;
this.enumIntToStringMap = enumIntToStringMap;
@@ -67,8 +67,6 @@ namespace Lucene.Net.Queries.Function.ValueSources
return null;
}
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final String enumString = enumIntToStringMap.get(intVal);
string enumString = enumIntToStringMap[intVal];
if (enumString != null)
{
@@ -86,8 +84,6 @@ namespace Lucene.Net.Queries.Function.ValueSources
}
int? intValue;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final Integer enumInt = enumStringToIntMap.get(stringVal);
int? enumInt = enumStringToIntMap[stringVal];
if (enumInt != null) //enum int found for string
{
@@ -100,8 +96,6 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
intValue = DEFAULT_VALUE;
}
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final String enumString = enumIntToStringMap.get(intValue);
string enumString = enumIntToStringMap[intValue];
if (enumString != null) //has matching string
{
@@ -111,10 +105,10 @@ namespace Lucene.Net.Queries.Function.ValueSources
return DEFAULT_VALUE;
}
- public override string description()
- {
- return "enum(" + field + ')';
- }
+ public override string Description
+ {
+ get { return "enum(" + field + ')'; }
+ }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
@@ -123,10 +117,10 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.search.FieldCache.Ints arr = cache.getInts(readerContext.reader(), field, parser, true);
- FieldCache.Ints arr = cache.getInts(readerContext.reader(), field, parser, true);
+ FieldCache.Ints arr = cache.GetInts(readerContext.AtomicReader, field, parser, true);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.Bits valid = cache.getDocsWithField(readerContext.reader(), field);
- Bits valid = cache.getDocsWithField(readerContext.reader(), field);
+ Bits valid = cache.GetDocsWithField(readerContext.AtomicReader, field);
return new IntDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
}
@@ -135,10 +129,10 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
private readonly EnumFieldSource outerInstance;
- private FieldCache.Ints arr;
- private Bits valid;
+ private readonly FieldCache.Ints arr;
+ private readonly Bits valid;
- public IntDocValuesAnonymousInnerClassHelper(EnumFieldSource outerInstance, EnumFieldSource this, FieldCache.Ints arr, Bits valid) : base(this)
+ public IntDocValuesAnonymousInnerClassHelper(EnumFieldSource outerInstance, EnumFieldSource @this, FieldCache.Ints arr, Bits valid) : base(@this)
{
this.outerInstance = outerInstance;
this.arr = arr;
@@ -146,47 +140,47 @@ namespace Lucene.Net.Queries.Function.ValueSources
val = new MutableValueInt();
}
- internal readonly MutableValueInt val;
+ private readonly MutableValueInt val;
public override float FloatVal(int doc)
{
- return (float) arr.get(doc);
+ return (float) arr.Get(doc);
}
- public override int intVal(int doc)
+ public override int IntVal(int doc)
{
- return arr.get(doc);
+ return arr.Get(doc);
}
public override long LongVal(int doc)
{
- return (long) arr.get(doc);
+ return (long) arr.Get(doc);
}
public override double DoubleVal(int doc)
{
- return (double) arr.get(doc);
+ return (double) arr.Get(doc);
}
public override string StrVal(int doc)
{
- int? intValue = arr.get(doc);
- return outerInstance.intValueToStringValue(intValue);
+ int? intValue = arr.Get(doc);
+ return outerInstance.IntValueToStringValue(intValue);
}
- public override object objectVal(int doc)
+ public override object ObjectVal(int doc)
{
- return valid.get(doc) ? arr.get(doc) : null;
+ return valid.Get(doc) ? (object) arr.Get(doc) : null;
}
- public override bool exists(int doc)
+ public override bool Exists(int doc)
{
- return valid.get(doc);
+ return valid.Get(doc);
}
public override string ToString(int doc)
{
- return outerInstance.description() + '=' + StrVal(doc);
+ return outerInstance.Description + '=' + StrVal(doc);
}
@@ -221,11 +215,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
}
}
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int ll = lower;
int ll = lower.Value;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int uu = upper;
int uu = upper.Value;
return new ValueSourceScorerAnonymousInnerClassHelper(this, reader, this, ll, uu);
@@ -235,10 +225,10 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
private readonly IntDocValuesAnonymousInnerClassHelper outerInstance;
- private int ll;
- private int uu;
+ private readonly int ll;
+ private readonly int uu;
- public ValueSourceScorerAnonymousInnerClassHelper(IntDocValuesAnonymousInnerClassHelper outerInstance, IndexReader reader, EnumFieldSource this, int ll, int uu) : base(reader, this)
+ public ValueSourceScorerAnonymousInnerClassHelper(IntDocValuesAnonymousInnerClassHelper outerInstance, IndexReader reader, EnumFieldSource @this, int ll, int uu) : base(reader, @this)
{
this.outerInstance = outerInstance;
this.ll = ll;
@@ -247,14 +237,14 @@ namespace Lucene.Net.Queries.Function.ValueSources
public override bool MatchesValue(int doc)
{
- int val = outerInstance.arr.get(doc);
+ int val = outerInstance.arr.Get(doc);
// only check for deleted if it's the default value
// if (val==0 && reader.isDeleted(doc)) return false;
return val >= ll && val <= uu;
}
}
- public override ValueFiller ValueFiller
+ public override AbstractValueFiller ValueFiller
{
get
{
@@ -262,7 +252,7 @@ namespace Lucene.Net.Queries.Function.ValueSources
}
}
- private class ValueFillerAnonymousInnerClassHelper : ValueFiller
+ private class ValueFillerAnonymousInnerClassHelper : AbstractValueFiller
{
private readonly IntDocValuesAnonymousInnerClassHelper outerInstance;
@@ -282,14 +272,12 @@ namespace Lucene.Net.Queries.Function.ValueSources
}
}
- public override void fillValue(int doc)
+ public override void FillValue(int doc)
{
- mval.value = outerInstance.arr.get(doc);
- mval.exists = outerInstance.valid.get(doc);
+ mval.Value = outerInstance.arr.Get(doc);
+ mval.Exists = outerInstance.valid.Get(doc);
}
}
-
-
}
public override bool Equals(object o)
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs
index 0d9b7ad..ebd3515 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/FieldCacheSource.cs
@@ -28,14 +28,14 @@ namespace Lucene.Net.Queries.Function.ValueSources
public abstract class FieldCacheSource : ValueSource
{
protected internal readonly string field;
- protected internal readonly FieldCache cache = FieldCache_Fields.DEFAULT;
+ protected internal readonly IFieldCache cache = Search.FieldCache.DEFAULT;
- public FieldCacheSource(string field)
+ protected FieldCacheSource(string field)
{
this.field = field;
}
- public virtual FieldCache FieldCache
+ public virtual IFieldCache FieldCache
{
get
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
index 023b12a..67c5c3d 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/FloatFieldSource.cs
@@ -15,13 +15,15 @@
* limitations under the License.
*/
using System.Collections;
+using Lucene.Net.Index;
using Lucene.Net.Queries.Function.DocValues;
-using org.apache.lucene.queries.function;
+using Lucene.Net.Search;
+using Lucene.Net.Util;
namespace Lucene.Net.Queries.Function.ValueSources
{
/// <summary>
- /// Obtains float field values from <seealso cref="FieldCache#getFloats"/> and makes those
+ /// Obtains float field values from <seealso cref="IFieldCache#getFloats"/> and makes those
/// values available as other numeric types, casting as needed.
/// </summary>
public class FloatFieldSource : FieldCacheSource
@@ -33,15 +35,15 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
}
- public FloatFieldSource(string field, FieldCache.FloatParser parser) : base(field)
+ public FloatFieldSource(string field, IFieldCache.FloatParser parser) : base(field)
{
this.parser = parser;
}
- public override string description()
- {
- return "float(" + field + ')';
- }
+ public override string Description
+ {
+ get { return "float(" + field + ')'; }
+ }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public org.apache.lucene.queries.function.FunctionValues GetValues(java.util.Map context, org.apache.lucene.index.AtomicReaderContext readerContext) throws java.io.IOException
@@ -49,10 +51,10 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.search.FieldCache.Floats arr = cache.getFloats(readerContext.reader(), field, parser, true);
- FieldCache.Floats arr = cache.getFloats(readerContext.reader(), field, parser, true);
+ FieldCache.Floats arr = cache.GetFloats(readerContext.AtomicReader, field, parser, true);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.Bits valid = cache.getDocsWithField(readerContext.reader(), field);
- Bits valid = cache.getDocsWithField(readerContext.reader(), field);
+ Bits valid = cache.GetDocsWithField(readerContext.AtomicReader, field);
return new FloatDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
}
@@ -61,8 +63,8 @@ namespace Lucene.Net.Queries.Function.ValueSources
{
private readonly FloatFieldSource outerInstance;
- private FieldCache.Floats arr;
- private Bits valid;
+ private readonly FieldCache.Floats arr;
+ private readonly Bits valid;
public FloatDocValuesAnonymousInnerClassHelper(FloatFieldSource outerInstance, FloatFieldSource this, FieldCache.Floats arr, Bits valid) : base(this)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a8538877/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs
index 80035fd..363cb60 100644
--- a/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs
+++ b/src/Lucene.Net.Queries/Function/ValueSources/IDFValueSource.cs
@@ -15,8 +15,10 @@
* limitations under the License.
*/
using System.Collections;
+using Lucene.Net.Index;
+using Lucene.Net.Search;
using Lucene.Net.Search.Similarities;
-using org.apache.lucene.queries.function;
+using Lucene.Net.Util;
namespace Lucene.Net.Queries.Function.ValueSources
{