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 16:19:46 UTC
[13/21] git commit: Moving ValueSource -> ValueSources to avoid name
conflicts
Moving ValueSource -> ValueSources to avoid name conflicts
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2b55e53c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2b55e53c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2b55e53c
Branch: refs/heads/master
Commit: 2b55e53c47beb47458abe54e1d4bfd2ab4736141
Parents: 7b2da40
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Fri Sep 19 10:44:49 2014 +0300
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Fri Sep 19 10:44:49 2014 +0300
----------------------------------------------------------------------
.../Function/ValueSource/BoolFunction.cs | 30 --
.../Function/ValueSource/ByteFieldSource.cs | 142 --------
.../Function/ValueSource/BytesRefFieldSource.cs | 140 --------
.../Function/ValueSource/ConstNumberSource.cs | 34 --
.../Function/ValueSource/ConstValueSource.cs | 156 ---------
.../Function/ValueSource/DefFunction.cs | 153 ---------
.../Function/ValueSource/DivFloatFunction.cs | 44 ---
.../Function/ValueSource/DocFreqValueSource.cs | 186 ----------
.../ValueSource/DoubleConstValueSource.cs | 166 ---------
.../Function/ValueSource/DoubleFieldSource.cs | 149 --------
.../Function/ValueSource/DualFloatFunction.cs | 121 -------
.../Function/ValueSource/EnumFieldSource.cs | 343 -------------------
.../Function/ValueSource/FieldCacheSource.cs | 77 -----
.../Function/ValueSource/FloatFieldSource.cs | 152 --------
.../Function/ValueSource/IDFValueSource.cs | 85 -----
.../Function/ValueSource/IfFunction.cs | 186 ----------
.../Function/ValueSource/IntFieldSource.cs | 183 ----------
.../ValueSource/JoinDocFreqValueSource.cs | 134 --------
.../Function/ValueSource/LinearFloatFunction.cs | 113 ------
.../Function/ValueSource/LiteralValueSource.cs | 117 -------
.../Function/ValueSource/LongFieldSource.cs | 184 ----------
.../Function/ValueSource/MaxDocValueSource.cs | 70 ----
.../Function/ValueSource/MaxFloatFunction.cs | 53 ---
.../Function/ValueSource/MinFloatFunction.cs | 53 ---
.../Function/ValueSource/MultiBoolFunction.cs | 148 --------
.../Function/ValueSource/MultiFloatFunction.cs | 146 --------
.../Function/ValueSource/MultiFunction.cs | 161 ---------
.../Function/ValueSource/MultiValueSource.cs | 32 --
.../Function/ValueSource/NormValueSource.cs | 125 -------
.../Function/ValueSource/NumDocsValueSource.cs | 63 ----
.../Function/ValueSource/OrdFieldSource.cs | 175 ----------
.../Function/ValueSource/PowFloatFunction.cs | 48 ---
.../ValueSource/ProductFloatFunction.cs | 47 ---
.../Function/ValueSource/QueryValueSource.cs | 328 ------------------
.../ValueSource/RangeMapFloatFunction.cs | 138 --------
.../ValueSource/ReciprocalFloatFunction.cs | 130 -------
.../ValueSource/ReverseOrdFieldSource.cs | 135 --------
.../Function/ValueSource/ScaleFloatFunction.cs | 200 -----------
.../Function/ValueSource/ShortFieldSource.cs | 137 --------
.../Function/ValueSource/SimpleBoolFunction.cs | 108 ------
.../Function/ValueSource/SimpleFloatFunction.cs | 71 ----
.../Function/ValueSource/SingleFunction.cs | 67 ----
.../Function/ValueSource/SumFloatFunction.cs | 46 ---
.../ValueSource/SumTotalTermFreqValueSource.cs | 132 -------
.../Function/ValueSource/TFValueSource.cs | 197 -----------
.../Function/ValueSource/TermFreqValueSource.cs | 186 ----------
.../ValueSource/TotalTermFreqValueSource.cs | 127 -------
.../Function/ValueSource/VectorValueSource.cs | 293 ----------------
.../Function/ValueSources/BoolFunction.cs | 30 ++
.../Function/ValueSources/ByteFieldSource.cs | 138 ++++++++
.../ValueSources/BytesRefFieldSource.cs | 131 +++++++
.../Function/ValueSources/ConstNumberSource.cs | 34 ++
.../Function/ValueSources/ConstValueSource.cs | 152 ++++++++
.../Function/ValueSources/DefFunction.cs | 148 ++++++++
.../Function/ValueSources/DivFloatFunction.cs | 46 +++
.../Function/ValueSources/DocFreqValueSource.cs | 177 ++++++++++
.../ValueSources/DoubleConstValueSource.cs | 162 +++++++++
.../Function/ValueSources/DoubleFieldSource.cs | 140 ++++++++
.../Function/ValueSources/DualFloatFunction.cs | 116 +++++++
.../Function/ValueSources/EnumFieldSource.cs | 335 ++++++++++++++++++
.../Function/ValueSources/FieldCacheSource.cs | 74 ++++
.../Function/ValueSources/FloatFieldSource.cs | 144 ++++++++
.../Function/ValueSources/IDFValueSource.cs | 76 ++++
.../Function/ValueSources/IfFunction.cs | 177 ++++++++++
.../Function/ValueSources/IntFieldSource.cs | 174 ++++++++++
.../ValueSources/JoinDocFreqValueSource.cs | 122 +++++++
.../ValueSources/LinearFloatFunction.cs | 108 ++++++
.../Function/ValueSources/LiteralValueSource.cs | 112 ++++++
.../Function/ValueSources/LongFieldSource.cs | 175 ++++++++++
.../Function/ValueSources/MaxDocValueSource.cs | 68 ++++
.../Function/ValueSources/MaxFloatFunction.cs | 53 +++
.../Function/ValueSources/MinFloatFunction.cs | 53 +++
.../Function/ValueSources/MultiBoolFunction.cs | 143 ++++++++
.../Function/ValueSources/MultiFloatFunction.cs | 141 ++++++++
.../Function/ValueSources/MultiFunction.cs | 156 +++++++++
.../Function/ValueSources/MultiValueSource.cs | 32 ++
.../Function/ValueSources/NormValueSource.cs | 118 +++++++
.../Function/ValueSources/NumDocsValueSource.cs | 59 ++++
.../Function/ValueSources/OrdFieldSource.cs | 162 +++++++++
.../Function/ValueSources/PowFloatFunction.cs | 48 +++
.../ValueSources/ProductFloatFunction.cs | 49 +++
.../Function/ValueSources/QueryValueSource.cs | 319 +++++++++++++++++
.../ValueSources/RangeMapFloatFunction.cs | 133 +++++++
.../ValueSources/ReciprocalFloatFunction.cs | 125 +++++++
.../ValueSources/ReverseOrdFieldSource.cs | 124 +++++++
.../Function/ValueSources/ScaleFloatFunction.cs | 195 +++++++++++
.../Function/ValueSources/ShortFieldSource.cs | 132 +++++++
.../Function/ValueSources/SimpleBoolFunction.cs | 103 ++++++
.../ValueSources/SimpleFloatFunction.cs | 64 ++++
.../Function/ValueSources/SingleFunction.cs | 62 ++++
.../Function/ValueSources/SumFloatFunction.cs | 48 +++
.../ValueSources/SumTotalTermFreqValueSource.cs | 124 +++++++
.../Function/ValueSources/TFValueSource.cs | 190 ++++++++++
.../ValueSources/TermFreqValueSource.cs | 180 ++++++++++
.../ValueSources/TotalTermFreqValueSource.cs | 120 +++++++
.../Function/ValueSources/VectorValueSource.cs | 288 ++++++++++++++++
.../Lucene.Net.Queries.csproj | 96 +++---
97 files changed, 6108 insertions(+), 6359 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/BoolFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/BoolFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/BoolFunction.cs
deleted file mode 100644
index 85399df..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/BoolFunction.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- /// <summary>
- /// Abstract parent class for those <seealso cref="ValueSource"/> implementations which
- /// apply boolean logic to their values
- /// </summary>
- public abstract class BoolFunction : ValueSource
- {
- // TODO: placeholder to return type, among other common future functionality
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/ByteFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/ByteFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/ByteFieldSource.cs
deleted file mode 100644
index 0e2ffc6..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/ByteFieldSource.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using System;
-using System.Collections;
-
-namespace org.apache.lucene.queries.function.valuesource
-{
- /*
- * 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.
- */
-
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using FieldCache = org.apache.lucene.search.FieldCache;
-
- /// <summary>
- /// Obtains int field values from the <seealso cref="org.apache.lucene.search.FieldCache"/>
- /// using <code>getInts()</code>
- /// and makes those values available as other numeric types, casting as needed. *
- ///
- ///
- /// </summary>
- [Obsolete]
- public class ByteFieldSource : FieldCacheSource
- {
-
- private readonly FieldCache.ByteParser parser;
-
- public ByteFieldSource(string field) : this(field, null)
- {
- }
-
- public ByteFieldSource(string field, FieldCache.ByteParser parser) : base(field)
- {
- this.parser = parser;
- }
-
- public override string description()
- {
- return "byte(" + 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.Bytes arr = cache.getBytes(readerContext.reader(), field, parser, false);
- FieldCache.Bytes arr = cache.getBytes(readerContext.reader(), field, parser, false);
-
- return new FunctionValuesAnonymousInnerClassHelper(this, arr);
- }
-
- private class FunctionValuesAnonymousInnerClassHelper : FunctionValues
- {
- private readonly ByteFieldSource outerInstance;
-
- private FieldCache.Bytes arr;
-
- public FunctionValuesAnonymousInnerClassHelper(ByteFieldSource outerInstance, FieldCache.Bytes arr)
- {
- this.outerInstance = outerInstance;
- this.arr = arr;
- }
-
- public override sbyte byteVal(int doc)
- {
- return arr.get(doc);
- }
-
- public override short shortVal(int doc)
- {
- return (short) arr.get(doc);
- }
-
- public override float floatVal(int doc)
- {
- return (float) arr.get(doc);
- }
-
- public override int intVal(int doc)
- {
- return (int) arr.get(doc);
- }
-
- public override long longVal(int doc)
- {
- return (long) arr.get(doc);
- }
-
- public override double doubleVal(int doc)
- {
- return (double) arr.get(doc);
- }
-
- public override string strVal(int doc)
- {
- return Convert.ToString(arr.get(doc));
- }
-
- public override string ToString(int doc)
- {
- return outerInstance.description() + '=' + byteVal(doc);
- }
-
- public override object objectVal(int doc)
- {
- return arr.get(doc); // TODO: valid?
- }
-
- }
-
- public override bool Equals(object o)
- {
- if (o.GetType() != typeof(ByteFieldSource))
- {
- return false;
- }
- ByteFieldSource other = (ByteFieldSource) 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(sbyte?).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/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/BytesRefFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/BytesRefFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/BytesRefFieldSource.cs
deleted file mode 100644
index f091aee..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/BytesRefFieldSource.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System.Collections;
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- /*
- * 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.
- */
-
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using BinaryDocValues = org.apache.lucene.index.BinaryDocValues;
- using FieldInfo = org.apache.lucene.index.FieldInfo;
- using DocValuesType = org.apache.lucene.index.FieldInfo.DocValuesType;
- using DocTermsIndexDocValues = org.apache.lucene.queries.function.docvalues.DocTermsIndexDocValues;
- using FieldCache = org.apache.lucene.search.FieldCache;
- using Bits = org.apache.lucene.util.Bits;
- using BytesRef = org.apache.lucene.util.BytesRef;
-
- /// <summary>
- /// An implementation for retrieving <seealso cref="FunctionValues"/> instances for string based fields.
- /// </summary>
- public class BytesRefFieldSource : FieldCacheSource
- {
-
- public BytesRefFieldSource(string field) : base(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.index.FieldInfo fieldInfo = readerContext.reader().getFieldInfos().fieldInfo(field);
- FieldInfo fieldInfo = readerContext.reader().FieldInfos.fieldInfo(field);
- // To be sorted or not to be sorted, that is the question
- // TODO: do it cleaner?
- if (fieldInfo != null && fieldInfo.DocValuesType == FieldInfo.DocValuesType.BINARY)
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.index.BinaryDocValues binaryValues = org.apache.lucene.search.FieldCache.DEFAULT.getTerms(readerContext.reader(), field, true);
- BinaryDocValues binaryValues = FieldCache.DEFAULT.getTerms(readerContext.reader(), field, true);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.util.Bits docsWithField = org.apache.lucene.search.FieldCache.DEFAULT.getDocsWithField(readerContext.reader(), field);
- Bits docsWithField = FieldCache.DEFAULT.getDocsWithField(readerContext.reader(), field);
- return new FunctionValuesAnonymousInnerClassHelper(this, binaryValues, docsWithField);
- }
- else
- {
- return new DocTermsIndexDocValuesAnonymousInnerClassHelper(this, this, readerContext, field);
- }
- }
-
- private class FunctionValuesAnonymousInnerClassHelper : FunctionValues
- {
- private readonly BytesRefFieldSource outerInstance;
-
- private BinaryDocValues binaryValues;
- private Bits docsWithField;
-
- public FunctionValuesAnonymousInnerClassHelper(BytesRefFieldSource outerInstance, BinaryDocValues binaryValues, Bits docsWithField)
- {
- this.outerInstance = outerInstance;
- this.binaryValues = binaryValues;
- this.docsWithField = docsWithField;
- }
-
-
- public override bool exists(int doc)
- {
- return docsWithField.get(doc);
- }
-
- public override bool bytesVal(int doc, BytesRef target)
- {
- binaryValues.get(doc, target);
- return target.length > 0;
- }
-
- public override string strVal(int doc)
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.util.BytesRef bytes = new org.apache.lucene.util.BytesRef();
- BytesRef bytes = new BytesRef();
- return bytesVal(doc, bytes) ? bytes.utf8ToString() : null;
- }
-
- public override object objectVal(int doc)
- {
- return strVal(doc);
- }
-
- public override string ToString(int doc)
- {
- return outerInstance.description() + '=' + strVal(doc);
- }
- }
-
- private class DocTermsIndexDocValuesAnonymousInnerClassHelper : DocTermsIndexDocValues
- {
- private readonly BytesRefFieldSource outerInstance;
-
- public DocTermsIndexDocValuesAnonymousInnerClassHelper(BytesRefFieldSource outerInstance, org.apache.lucene.queries.function.valuesource.BytesRefFieldSource this, AtomicReaderContext readerContext, string field) : base(this, readerContext, field)
- {
- this.outerInstance = outerInstance;
- }
-
-
- protected internal override string toTerm(string readableValue)
- {
- return readableValue;
- }
-
- public override object objectVal(int doc)
- {
- return strVal(doc);
- }
-
- public override string ToString(int doc)
- {
- return outerInstance.description() + '=' + strVal(doc);
- }
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/ConstNumberSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/ConstNumberSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/ConstNumberSource.cs
deleted file mode 100644
index 33a0aa0..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/ConstNumberSource.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- /// <summary>
- /// <code>ConstNumberSource</code> is the base class for all constant numbers
- /// </summary>
- public abstract class ConstNumberSource : ValueSource
- {
- public abstract int Int {get;}
- public abstract long Long {get;}
- public abstract float Float {get;}
- public abstract double Double {get;}
- 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/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/ConstValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/ConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/ConstValueSource.cs
deleted file mode 100644
index 9933f13..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/ConstValueSource.cs
+++ /dev/null
@@ -1,156 +0,0 @@
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using FloatDocValues = org.apache.lucene.queries.function.docvalues.FloatDocValues;
-
-
- /// <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, org.apache.lucene.queries.function.valuesource.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 float.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;
- }
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/DefFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/DefFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/DefFunction.cs
deleted file mode 100644
index 48a67d4..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/DefFunction.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-
-namespace org.apache.lucene.queries.function.valuesource
-{
- /*
- * 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.
- */
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
- using BytesRef = org.apache.lucene.util.BytesRef;
-
-
- /// <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";
- }
-
-
-//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 fcontext, org.apache.lucene.index.AtomicReaderContext readerContext) throws java.io.IOException
- 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;
- }
-
- public override ValueFiller ValueFiller
- {
- get
- {
- // TODO: need ValueSource.type() to determine correct type
- return base.ValueFiller;
- }
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/DivFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/DivFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/DivFloatFunction.cs
deleted file mode 100644
index 08912e5..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/DivFloatFunction.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
-
- /// <summary>
- /// Function to divide "a" by "b"
- /// </summary>
- public class DivFloatFunction : DualFloatFunction
- {
- /// <param name="a"> the numerator. </param>
- /// <param name="b"> the denominator. </param>
- public DivFloatFunction(ValueSource a, ValueSource b) : base(a,b)
- {
- }
-
- protected internal override string name()
- {
- return "div";
- }
-
- protected internal override float func(int doc, FunctionValues aVals, FunctionValues bVals)
- {
- return aVals.floatVal(doc) / bVals.floatVal(doc);
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/DocFreqValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/DocFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/DocFreqValueSource.cs
deleted file mode 100644
index 56ea07d..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/DocFreqValueSource.cs
+++ /dev/null
@@ -1,186 +0,0 @@
-using System;
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using Term = org.apache.lucene.index.Term;
- using DoubleDocValues = org.apache.lucene.queries.function.docvalues.DoubleDocValues;
- using IntDocValues = org.apache.lucene.queries.function.docvalues.IntDocValues;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
- using BytesRef = org.apache.lucene.util.BytesRef;
-
-
-
- internal class ConstIntDocValues : IntDocValues
- {
- internal readonly int ival;
- internal readonly float fval;
- internal readonly double dval;
- internal readonly long lval;
- internal readonly string sval;
- internal readonly ValueSource parent;
-
- internal ConstIntDocValues(int val, ValueSource parent) : base(parent)
- {
- ival = val;
- fval = val;
- dval = val;
- lval = val;
- sval = Convert.ToString(val);
- this.parent = parent;
- }
-
- public override float floatVal(int doc)
- {
- return fval;
- }
- public override int intVal(int doc)
- {
- return ival;
- }
- public override long longVal(int doc)
- {
- return lval;
- }
- public override double doubleVal(int doc)
- {
- return dval;
- }
- public override string strVal(int doc)
- {
- return sval;
- }
- public override string ToString(int doc)
- {
- return parent.description() + '=' + sval;
- }
- }
-
- internal class ConstDoubleDocValues : DoubleDocValues
- {
- internal readonly int ival;
- internal readonly float fval;
- internal readonly double dval;
- internal readonly long lval;
- internal readonly string sval;
- internal readonly ValueSource parent;
-
- internal ConstDoubleDocValues(double val, ValueSource parent) : base(parent)
- {
- ival = (int)val;
- fval = (float)val;
- dval = val;
- lval = (long)val;
- sval = Convert.ToString(val);
- this.parent = parent;
- }
-
- public override float floatVal(int doc)
- {
- return fval;
- }
- public override int intVal(int doc)
- {
- return ival;
- }
- public override long longVal(int doc)
- {
- return lval;
- }
- public override double doubleVal(int doc)
- {
- return dval;
- }
- public override string strVal(int doc)
- {
- return sval;
- }
- public override string ToString(int doc)
- {
- return parent.description() + '=' + sval;
- }
- }
-
-
- /// <summary>
- /// <code>DocFreqValueSource</code> returns the number of documents containing the term.
- /// @lucene.internal
- /// </summary>
- public class DocFreqValueSource : ValueSource
- {
- protected internal readonly string field;
- protected internal readonly string indexedField;
- protected internal readonly string val;
- protected internal readonly BytesRef indexedBytes;
-
- public DocFreqValueSource(string field, string val, string indexedField, BytesRef indexedBytes)
- {
- this.field = field;
- this.val = val;
- this.indexedField = indexedField;
- this.indexedBytes = indexedBytes;
- }
-
- public virtual string name()
- {
- return "docfreq";
- }
-
- public override string description()
- {
- return name() + '(' + field + ',' + val + ')';
- }
-
-//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)
- {
- IndexSearcher searcher = (IndexSearcher)context["searcher"];
- int docfreq = searcher.IndexReader.docFreq(new Term(indexedField, indexedBytes));
- return new ConstIntDocValues(docfreq, this);
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void createWeight(java.util.Map context, org.apache.lucene.search.IndexSearcher searcher) throws java.io.IOException
- public override void createWeight(IDictionary context, IndexSearcher searcher)
- {
- context["searcher"] = searcher;
- }
-
- public override int GetHashCode()
- {
- return this.GetType().GetHashCode() + indexedField.GetHashCode() * 29 + indexedBytes.GetHashCode();
- }
-
- public override bool Equals(object o)
- {
- if (this.GetType() != o.GetType())
- {
- return false;
- }
- DocFreqValueSource other = (DocFreqValueSource)o;
- return this.indexedField.Equals(other.indexedField) && this.indexedBytes.Equals(other.indexedBytes);
- }
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/DoubleConstValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/DoubleConstValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/DoubleConstValueSource.cs
deleted file mode 100644
index e21be0c..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/DoubleConstValueSource.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-using System;
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using DoubleDocValues = org.apache.lucene.queries.function.docvalues.DoubleDocValues;
-
-
- /// <summary>
- /// Function that returns a constant double value for every document.
- /// </summary>
- public class DoubleConstValueSource : ConstNumberSource
- {
- internal readonly double constant;
- private readonly float fv;
- private readonly long lv;
-
- public DoubleConstValueSource(double constant)
- {
- this.constant = constant;
- this.fv = (float)constant;
- this.lv = (long)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 DoubleDocValuesAnonymousInnerClassHelper(this, this);
- }
-
- private class DoubleDocValuesAnonymousInnerClassHelper : DoubleDocValues
- {
- private readonly DoubleConstValueSource outerInstance;
-
- public DoubleDocValuesAnonymousInnerClassHelper(DoubleConstValueSource outerInstance, org.apache.lucene.queries.function.valuesource.DoubleConstValueSource this) : base(this)
- {
- this.outerInstance = outerInstance;
- }
-
- public override float floatVal(int doc)
- {
- return outerInstance.fv;
- }
-
- public override int intVal(int doc)
- {
- return (int) outerInstance.lv;
- }
-
- public override long longVal(int doc)
- {
- return outerInstance.lv;
- }
-
- public override double doubleVal(int doc)
- {
- return outerInstance.constant;
- }
-
- public override string strVal(int doc)
- {
- return Convert.ToString(outerInstance.constant);
- }
-
- public override object objectVal(int doc)
- {
- return outerInstance.constant;
- }
-
- public override string ToString(int doc)
- {
- return outerInstance.description();
- }
- }
-
- public override int GetHashCode()
- {
- long bits = double.doubleToRawLongBits(constant);
- return (int)(bits ^ ((long)((ulong)bits >> 32)));
- }
-
- public override bool Equals(object o)
- {
- if (!(o is DoubleConstValueSource))
- {
- return false;
- }
- DoubleConstValueSource other = (DoubleConstValueSource) o;
- return this.constant == other.constant;
- }
-
- public override int Int
- {
- get
- {
- return (int)lv;
- }
- }
-
- public override long Long
- {
- get
- {
- return lv;
- }
- }
-
- public override float Float
- {
- get
- {
- return fv;
- }
- }
-
- public override double Double
- {
- get
- {
- return constant;
- }
- }
-
- public override Number Number
- {
- get
- {
- return constant;
- }
- }
-
- public override bool Bool
- {
- get
- {
- return constant != 0;
- }
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/DoubleFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/DoubleFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/DoubleFieldSource.cs
deleted file mode 100644
index 188974f..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/DoubleFieldSource.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using IndexReader = org.apache.lucene.index.IndexReader;
- using DoubleDocValues = org.apache.lucene.queries.function.docvalues.DoubleDocValues;
- using FieldCache = org.apache.lucene.search.FieldCache;
- using Bits = org.apache.lucene.util.Bits;
- using MutableValue = org.apache.lucene.util.mutable.MutableValue;
- using MutableValueDouble = org.apache.lucene.util.mutable.MutableValueDouble;
-
- /// <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
- {
-
- protected internal readonly FieldCache.DoubleParser parser;
-
- public DoubleFieldSource(string field) : this(field, null)
- {
- }
-
- public DoubleFieldSource(string field, FieldCache.DoubleParser parser) : base(field)
- {
- this.parser = parser;
- }
-
- public override string description()
- {
- 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);
- Bits 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, org.apache.lucene.queries.function.valuesource.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 : ValueFiller
- {
- 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;
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/DualFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/DualFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/DualFloatFunction.cs
deleted file mode 100644
index 9a9c069..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/DualFloatFunction.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using FloatDocValues = org.apache.lucene.queries.function.docvalues.FloatDocValues;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
-
-
- /// <summary>
- /// Abstract <seealso cref="ValueSource"/> implementation which wraps two ValueSources
- /// and applies an extendible float function to their values.
- ///
- /// </summary>
- public abstract class DualFloatFunction : ValueSource
- {
- protected internal readonly ValueSource a;
- protected internal readonly ValueSource b;
-
- /// <param name="a"> the base. </param>
- /// <param name="b"> the exponent. </param>
- public DualFloatFunction(ValueSource a, ValueSource b)
- {
- this.a = a;
- this.b = b;
- }
-
- protected internal abstract string name();
- protected internal abstract float func(int doc, FunctionValues aVals, FunctionValues bVals);
-
- public override string description()
- {
- return name() + "(" + a.description() + "," + b.description() + ")";
- }
-
-//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.queries.function.FunctionValues aVals = a.getValues(context, readerContext);
- FunctionValues aVals = a.getValues(context, readerContext);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.queries.function.FunctionValues bVals = b.getValues(context, readerContext);
- FunctionValues bVals = b.getValues(context, readerContext);
- return new FloatDocValuesAnonymousInnerClassHelper(this, this, aVals, bVals);
- }
-
- private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
- {
- private readonly DualFloatFunction outerInstance;
-
- private FunctionValues aVals;
- private FunctionValues bVals;
-
- public FloatDocValuesAnonymousInnerClassHelper(DualFloatFunction outerInstance, org.apache.lucene.queries.function.valuesource.DualFloatFunction this, FunctionValues aVals, FunctionValues bVals) : base(this)
- {
- this.outerInstance = outerInstance;
- this.aVals = aVals;
- this.bVals = bVals;
- }
-
- public override float floatVal(int doc)
- {
- return outerInstance.func(doc, aVals, bVals);
- }
-
- public override string ToString(int doc)
- {
- return outerInstance.name() + '(' + aVals.ToString(doc) + ',' + bVals.ToString(doc) + ')';
- }
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void createWeight(java.util.Map context, org.apache.lucene.search.IndexSearcher searcher) throws java.io.IOException
- public override void createWeight(IDictionary context, IndexSearcher searcher)
- {
- a.createWeight(context,searcher);
- b.createWeight(context,searcher);
- }
-
- public override int GetHashCode()
- {
- int h = a.GetHashCode();
- h ^= (h << 13) | ((int)((uint)h >> 20));
- h += b.GetHashCode();
- h ^= (h << 23) | ((int)((uint)h >> 10));
- h += name().GetHashCode();
- return h;
- }
-
- public override bool Equals(object o)
- {
- if (this.GetType() != o.GetType())
- {
- return false;
- }
- DualFloatFunction other = (DualFloatFunction)o;
- return this.a.Equals(other.a) && this.b.Equals(other.b);
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/EnumFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/EnumFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/EnumFieldSource.cs
deleted file mode 100644
index cbdf2cb..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/EnumFieldSource.cs
+++ /dev/null
@@ -1,343 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- /*
- * 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.
- */
-
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using IndexReader = org.apache.lucene.index.IndexReader;
- using IntDocValues = org.apache.lucene.queries.function.docvalues.IntDocValues;
- using FieldCache = org.apache.lucene.search.FieldCache;
- using Bits = org.apache.lucene.util.Bits;
- using MutableValue = org.apache.lucene.util.mutable.MutableValue;
- using MutableValueInt = org.apache.lucene.util.mutable.MutableValueInt;
-
- /// <summary>
- /// Obtains int field values from <seealso cref="FieldCache#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>
- public class EnumFieldSource : FieldCacheSource
- {
- internal const int? DEFAULT_VALUE = -1;
-
- internal readonly FieldCache.IntParser 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)
- {
- this.parser = parser;
- this.enumIntToStringMap = enumIntToStringMap;
- this.enumStringToIntMap = enumStringToIntMap;
- }
-
- private static int? tryParseInt(string valueStr)
- {
- int? intValue = null;
- try
- {
- intValue = Convert.ToInt32(valueStr);
- }
- catch (NumberFormatException)
- {
- }
- return intValue;
- }
-
- private string intValueToStringValue(int? intVal)
- {
- if (intVal == null)
- {
- 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)
- {
- return enumString;
- }
- // can't find matching enum name - return DEFAULT_VALUE.toString()
- return DEFAULT_VALUE.ToString();
- }
-
- private int? stringValueToIntValue(string stringVal)
- {
- if (stringVal == null)
- {
- return null;
- }
-
- 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
- {
- return enumInt;
- }
-
- //enum int not found for string
- intValue = tryParseInt(stringVal);
- if (intValue == null) //not Integer
- {
- 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
- {
- return intValue;
- }
-
- return DEFAULT_VALUE;
- }
-
- public override string description()
- {
- return "enum(" + 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.Ints arr = cache.getInts(readerContext.reader(), field, parser, true);
- FieldCache.Ints arr = cache.getInts(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);
- Bits valid = cache.getDocsWithField(readerContext.reader(), field);
-
- return new IntDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
- }
-
- private class IntDocValuesAnonymousInnerClassHelper : IntDocValues
- {
- private readonly EnumFieldSource outerInstance;
-
- private FieldCache.Ints arr;
- private Bits valid;
-
- public IntDocValuesAnonymousInnerClassHelper(EnumFieldSource outerInstance, org.apache.lucene.queries.function.valuesource.EnumFieldSource this, FieldCache.Ints arr, Bits valid) : base(this)
- {
- this.outerInstance = outerInstance;
- this.arr = arr;
- this.valid = valid;
- val = new MutableValueInt();
- }
-
- internal readonly MutableValueInt val;
-
- public override float floatVal(int doc)
- {
- return (float) arr.get(doc);
- }
-
- public override int intVal(int doc)
- {
- return arr.get(doc);
- }
-
- public override long longVal(int doc)
- {
- return (long) arr.get(doc);
- }
-
- public override double doubleVal(int doc)
- {
- return (double) arr.get(doc);
- }
-
- public override string strVal(int doc)
- {
- int? intValue = arr.get(doc);
- return outerInstance.intValueToStringValue(intValue);
- }
-
- public override object objectVal(int doc)
- {
- return valid.get(doc) ? arr.get(doc) : null;
- }
-
- public override bool exists(int doc)
- {
- return valid.get(doc);
- }
-
- public override string ToString(int doc)
- {
- return outerInstance.description() + '=' + strVal(doc);
- }
-
-
- public override ValueSourceScorer getRangeScorer(IndexReader reader, string lowerVal, string upperVal, bool includeLower, bool includeUpper)
- {
- int? lower = outerInstance.stringValueToIntValue(lowerVal);
- int? upper = outerInstance.stringValueToIntValue(upperVal);
-
- // instead of using separate comparison functions, adjust the endpoints.
-
- if (lower == null)
- {
- lower = int.MinValue;
- }
- else
- {
- if (!includeLower && lower < int.MaxValue)
- {
- lower++;
- }
- }
-
- if (upper == null)
- {
- upper = int.MaxValue;
- }
- else
- {
- if (!includeUpper && upper > int.MinValue)
- {
- upper--;
- }
- }
-
-//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);
- }
-
- private class ValueSourceScorerAnonymousInnerClassHelper : ValueSourceScorer
- {
- private readonly IntDocValuesAnonymousInnerClassHelper outerInstance;
-
- private int ll;
- private int uu;
-
- public ValueSourceScorerAnonymousInnerClassHelper(IntDocValuesAnonymousInnerClassHelper outerInstance, IndexReader reader, org.apache.lucene.queries.function.valuesource.EnumFieldSource this, int ll, int uu) : base(reader, this)
- {
- this.outerInstance = outerInstance;
- this.ll = ll;
- this.uu = uu;
- }
-
- public override bool matchesValue(int 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
- {
- get
- {
- return new ValueFillerAnonymousInnerClassHelper(this);
- }
- }
-
- private class ValueFillerAnonymousInnerClassHelper : ValueFiller
- {
- private readonly IntDocValuesAnonymousInnerClassHelper outerInstance;
-
- public ValueFillerAnonymousInnerClassHelper(IntDocValuesAnonymousInnerClassHelper outerInstance)
- {
- this.outerInstance = outerInstance;
- mval = new MutableValueInt();
- }
-
- private readonly MutableValueInt mval;
-
- public override MutableValue Value
- {
- get
- {
- return mval;
- }
- }
-
- public override void fillValue(int doc)
- {
- mval.value = outerInstance.arr.get(doc);
- mval.exists = outerInstance.valid.get(doc);
- }
- }
-
-
- }
-
- public override bool Equals(object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || this.GetType() != o.GetType())
- {
- return false;
- }
- if (!base.Equals(o))
- {
- return false;
- }
-
- EnumFieldSource that = (EnumFieldSource) o;
-
- if (!enumIntToStringMap.Equals(that.enumIntToStringMap))
- {
- return false;
- }
- if (!enumStringToIntMap.Equals(that.enumStringToIntMap))
- {
- return false;
- }
- if (!parser.Equals(that.parser))
- {
- return false;
- }
-
- return true;
- }
-
- public override int GetHashCode()
- {
- int result = base.GetHashCode();
- result = 31 * result + parser.GetHashCode();
- result = 31 * result + enumIntToStringMap.GetHashCode();
- result = 31 * result + enumStringToIntMap.GetHashCode();
- return result;
- }
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/FieldCacheSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/FieldCacheSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/FieldCacheSource.cs
deleted file mode 100644
index 92c2cb4..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/FieldCacheSource.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- using FieldCache = org.apache.lucene.search.FieldCache;
-
- /// <summary>
- /// A base class for ValueSource implementations that retrieve values for
- /// a single field from the <seealso cref="org.apache.lucene.search.FieldCache"/>.
- ///
- ///
- /// </summary>
- public abstract class FieldCacheSource : ValueSource
- {
- protected internal readonly string field;
- protected internal readonly FieldCache cache = FieldCache.DEFAULT;
-
- public FieldCacheSource(string field)
- {
- this.field = field;
- }
-
- public virtual FieldCache FieldCache
- {
- get
- {
- return cache;
- }
- }
-
- public virtual string Field
- {
- get
- {
- return field;
- }
- }
-
- public override string description()
- {
- return field;
- }
-
- public override bool Equals(object o)
- {
- if (!(o is FieldCacheSource))
- {
- return false;
- }
- FieldCacheSource other = (FieldCacheSource)o;
- return this.field.Equals(other.field) && this.cache == other.cache;
- }
-
- public override int GetHashCode()
- {
- return cache.GetHashCode() + field.GetHashCode();
- }
-
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/FloatFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/FloatFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/FloatFieldSource.cs
deleted file mode 100644
index c60d99f..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/FloatFieldSource.cs
+++ /dev/null
@@ -1,152 +0,0 @@
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using FloatDocValues = org.apache.lucene.queries.function.docvalues.FloatDocValues;
- using FieldCache = org.apache.lucene.search.FieldCache;
- using Bits = org.apache.lucene.util.Bits;
- using MutableValue = org.apache.lucene.util.mutable.MutableValue;
- using MutableValueFloat = org.apache.lucene.util.mutable.MutableValueFloat;
-
- /// <summary>
- /// Obtains float field values from <seealso cref="FieldCache#getFloats"/> and makes those
- /// values available as other numeric types, casting as needed.
- /// </summary>
- public class FloatFieldSource : FieldCacheSource
- {
-
- protected internal readonly FieldCache.FloatParser parser;
-
- public FloatFieldSource(string field) : this(field, null)
- {
- }
-
- public FloatFieldSource(string field, FieldCache.FloatParser parser) : base(field)
- {
- this.parser = parser;
- }
-
- public override string description()
- {
- 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
- 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.Floats arr = cache.getFloats(readerContext.reader(), field, parser, true);
- FieldCache.Floats arr = cache.getFloats(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);
- Bits valid = cache.getDocsWithField(readerContext.reader(), field);
-
- return new FloatDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
- }
-
- private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
- {
- private readonly FloatFieldSource outerInstance;
-
- private FieldCache.Floats arr;
- private Bits valid;
-
- public FloatDocValuesAnonymousInnerClassHelper(FloatFieldSource outerInstance, org.apache.lucene.queries.function.valuesource.FloatFieldSource this, FieldCache.Floats arr, Bits valid) : base(this)
- {
- this.outerInstance = outerInstance;
- this.arr = arr;
- this.valid = valid;
- }
-
- public override float floatVal(int doc)
- {
- return arr.get(doc);
- }
-
- public override object objectVal(int doc)
- {
- return valid.get(doc) ? arr.get(doc) : null;
- }
-
- 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 : ValueFiller
- {
- private readonly FloatDocValuesAnonymousInnerClassHelper outerInstance;
-
- public ValueFillerAnonymousInnerClassHelper(FloatDocValuesAnonymousInnerClassHelper outerInstance)
- {
- this.outerInstance = outerInstance;
- mval = new MutableValueFloat();
- }
-
- private readonly MutableValueFloat 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(FloatFieldSource))
- {
- return false;
- }
- FloatFieldSource other = (FloatFieldSource)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(float?).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/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/IDFValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/IDFValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/IDFValueSource.cs
deleted file mode 100644
index 13456ff..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/IDFValueSource.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- using org.apache.lucene.index;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
- using PerFieldSimilarityWrapper = org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
- using Similarity = org.apache.lucene.search.similarities.Similarity;
- using TFIDFSimilarity = org.apache.lucene.search.similarities.TFIDFSimilarity;
- using BytesRef = org.apache.lucene.util.BytesRef;
-
-
- /// <summary>
- /// Function that returns <seealso cref="TFIDFSimilarity #idf(long, long)"/>
- /// for every document.
- /// <para>
- /// Note that the configured Similarity for the field must be
- /// a subclass of <seealso cref="TFIDFSimilarity"/>
- /// @lucene.internal
- /// </para>
- /// </summary>
- public class IDFValueSource : DocFreqValueSource
- {
- public IDFValueSource(string field, string val, string indexedField, BytesRef indexedBytes) : base(field, val, indexedField, indexedBytes)
- {
- }
-
- public override string name()
- {
- return "idf";
- }
-
-//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, AtomicReaderContext readerContext) throws java.io.IOException
- public override FunctionValues getValues(IDictionary context, AtomicReaderContext readerContext)
- {
- IndexSearcher searcher = (IndexSearcher)context["searcher"];
- TFIDFSimilarity sim = asTFIDF(searcher.Similarity, field);
- if (sim == null)
- {
- throw new System.NotSupportedException("requires a TFIDFSimilarity (such as DefaultSimilarity)");
- }
- int docfreq = searcher.IndexReader.docFreq(new Term(indexedField, indexedBytes));
- float idf = sim.idf(docfreq, searcher.IndexReader.maxDoc());
- return new ConstDoubleDocValues(idf, this);
- }
-
- // tries extra hard to cast the sim to TFIDFSimilarity
- internal static TFIDFSimilarity asTFIDF(Similarity sim, string field)
- {
- while (sim is PerFieldSimilarityWrapper)
- {
- sim = ((PerFieldSimilarityWrapper)sim).get(field);
- }
- if (sim is TFIDFSimilarity)
- {
- return (TFIDFSimilarity)sim;
- }
- else
- {
- return null;
- }
- }
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/IfFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/IfFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/IfFunction.cs
deleted file mode 100644
index a62c801..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/IfFunction.cs
+++ /dev/null
@@ -1,186 +0,0 @@
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using IndexReader = org.apache.lucene.index.IndexReader;
- using Explanation = org.apache.lucene.search.Explanation;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
- using BytesRef = org.apache.lucene.util.BytesRef;
-
-
-
- /// <summary>
- /// Depending on the boolean value of the <code>ifSource</code> function,
- /// returns the value of the <code>trueSource</code> or <code>falseSource</code> function.
- /// </summary>
- public class IfFunction : BoolFunction
- {
- private readonly ValueSource ifSource;
- private readonly ValueSource trueSource;
- private readonly ValueSource falseSource;
-
-
- public IfFunction(ValueSource ifSource, ValueSource trueSource, ValueSource falseSource)
- {
- this.ifSource = ifSource;
- this.trueSource = trueSource;
- this.falseSource = falseSource;
- }
-
-//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.queries.function.FunctionValues ifVals = ifSource.getValues(context, readerContext);
- FunctionValues ifVals = ifSource.getValues(context, readerContext);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.queries.function.FunctionValues trueVals = trueSource.getValues(context, readerContext);
- FunctionValues trueVals = trueSource.getValues(context, readerContext);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.queries.function.FunctionValues falseVals = falseSource.getValues(context, readerContext);
- FunctionValues falseVals = falseSource.getValues(context, readerContext);
-
- return new FunctionValuesAnonymousInnerClassHelper(this, ifVals, trueVals, falseVals);
-
- }
-
- private class FunctionValuesAnonymousInnerClassHelper : FunctionValues
- {
- private readonly IfFunction outerInstance;
-
- private FunctionValues ifVals;
- private FunctionValues trueVals;
- private FunctionValues falseVals;
-
- public FunctionValuesAnonymousInnerClassHelper(IfFunction outerInstance, FunctionValues ifVals, FunctionValues trueVals, FunctionValues falseVals)
- {
- this.outerInstance = outerInstance;
- this.ifVals = ifVals;
- this.trueVals = trueVals;
- this.falseVals = falseVals;
- }
-
- public override sbyte byteVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.byteVal(doc) : falseVals.byteVal(doc);
- }
-
- public override short shortVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.shortVal(doc) : falseVals.shortVal(doc);
- }
-
- public override float floatVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.floatVal(doc) : falseVals.floatVal(doc);
- }
-
- public override int intVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.intVal(doc) : falseVals.intVal(doc);
- }
-
- public override long longVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.longVal(doc) : falseVals.longVal(doc);
- }
-
- public override double doubleVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.doubleVal(doc) : falseVals.doubleVal(doc);
- }
-
- public override string strVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.strVal(doc) : falseVals.strVal(doc);
- }
-
- public override bool boolVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.boolVal(doc) : falseVals.boolVal(doc);
- }
-
- public override bool bytesVal(int doc, BytesRef target)
- {
- return ifVals.boolVal(doc) ? trueVals.bytesVal(doc, target) : falseVals.bytesVal(doc, target);
- }
-
- public override object objectVal(int doc)
- {
- return ifVals.boolVal(doc) ? trueVals.objectVal(doc) : falseVals.objectVal(doc);
- }
-
- public override bool exists(int doc)
- {
- return true; // TODO: flow through to any sub-sources?
- }
-
- public override ValueFiller ValueFiller
- {
- get
- {
- // TODO: we need types of trueSource / falseSource to handle this
- // for now, use float.
- return base.ValueFiller;
- }
- }
-
- public override string ToString(int doc)
- {
- return "if(" + ifVals.ToString(doc) + ',' + trueVals.ToString(doc) + ',' + falseVals.ToString(doc) + ')';
- }
- }
-
- public override string description()
- {
- return "if(" + ifSource.description() + ',' + trueSource.description() + ',' + falseSource + ')';
- }
-
- public override int GetHashCode()
- {
- int h = ifSource.GetHashCode();
- h = h * 31 + trueSource.GetHashCode();
- h = h * 31 + falseSource.GetHashCode();
- return h;
- }
-
- public override bool Equals(object o)
- {
- if (!(o is IfFunction))
- {
- return false;
- }
- IfFunction other = (IfFunction)o;
- return ifSource.Equals(other.ifSource) && trueSource.Equals(other.trueSource) && falseSource.Equals(other.falseSource);
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void createWeight(java.util.Map context, org.apache.lucene.search.IndexSearcher searcher) throws java.io.IOException
- public override void createWeight(IDictionary context, IndexSearcher searcher)
- {
- ifSource.createWeight(context, searcher);
- trueSource.createWeight(context, searcher);
- falseSource.createWeight(context, searcher);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/IntFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/IntFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/IntFieldSource.cs
deleted file mode 100644
index bb6cf35..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/IntFieldSource.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-using System;
-using System.Collections;
-
-/*
- * 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.
- */
-
-namespace org.apache.lucene.queries.function.valuesource
-{
-
-
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using IndexReader = org.apache.lucene.index.IndexReader;
- using IntDocValues = org.apache.lucene.queries.function.docvalues.IntDocValues;
- using FieldCache = org.apache.lucene.search.FieldCache;
- using Bits = org.apache.lucene.util.Bits;
- using MutableValue = org.apache.lucene.util.mutable.MutableValue;
- using MutableValueInt = org.apache.lucene.util.mutable.MutableValueInt;
-
- /// <summary>
- /// Obtains int field values from <seealso cref="FieldCache#getInts"/> and makes those
- /// values available as other numeric types, casting as needed.
- /// </summary>
- public class IntFieldSource : FieldCacheSource
- {
- internal readonly FieldCache.IntParser parser;
-
- public IntFieldSource(string field) : this(field, null)
- {
- }
-
- public IntFieldSource(string field, FieldCache.IntParser parser) : base(field)
- {
- this.parser = parser;
- }
-
- public override string description()
- {
- return "int(" + 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.Ints arr = cache.getInts(readerContext.reader(), field, parser, true);
- FieldCache.Ints arr = cache.getInts(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);
- Bits valid = cache.getDocsWithField(readerContext.reader(), field);
-
- return new IntDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
- }
-
- private class IntDocValuesAnonymousInnerClassHelper : IntDocValues
- {
- private readonly IntFieldSource outerInstance;
-
- private FieldCache.Ints arr;
- private Bits valid;
-
- public IntDocValuesAnonymousInnerClassHelper(IntFieldSource outerInstance, org.apache.lucene.queries.function.valuesource.IntFieldSource this, FieldCache.Ints arr, Bits valid) : base(this)
- {
- this.outerInstance = outerInstance;
- this.arr = arr;
- this.valid = valid;
- val = new MutableValueInt();
- }
-
- internal readonly MutableValueInt val;
-
- public override float floatVal(int doc)
- {
- return (float)arr.get(doc);
- }
-
- public override int intVal(int doc)
- {
- return arr.get(doc);
- }
-
- public override long longVal(int doc)
- {
- return (long)arr.get(doc);
- }
-
- public override double doubleVal(int doc)
- {
- return (double)arr.get(doc);
- }
-
- public override string strVal(int doc)
- {
- return Convert.ToString(arr.get(doc));
- }
-
- public override object objectVal(int doc)
- {
- return valid.get(doc) ? arr.get(doc) : null;
- }
-
- public override bool exists(int doc)
- {
- return arr.get(doc) != 0 || valid.get(doc);
- }
-
- public override string ToString(int doc)
- {
- return outerInstance.description() + '=' + intVal(doc);
- }
-
- public override ValueFiller ValueFiller
- {
- get
- {
- return new ValueFillerAnonymousInnerClassHelper(this);
- }
- }
-
- private class ValueFillerAnonymousInnerClassHelper : ValueFiller
- {
- private readonly IntDocValuesAnonymousInnerClassHelper outerInstance;
-
- public ValueFillerAnonymousInnerClassHelper(IntDocValuesAnonymousInnerClassHelper outerInstance)
- {
- this.outerInstance = outerInstance;
- mval = new MutableValueInt();
- }
-
- private readonly MutableValueInt 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(IntFieldSource))
- {
- return false;
- }
- IntFieldSource other = (IntFieldSource)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(int?).GetHashCode() : parser.GetType().GetHashCode();
- h += base.GetHashCode();
- return h;
- }
- }
-
-}
\ No newline at end of file