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:45 UTC
[12/21] Moving ValueSource -> ValueSources to avoid name conflicts
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/JoinDocFreqValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/JoinDocFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/JoinDocFreqValueSource.cs
deleted file mode 100644
index 46cc5c7..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/JoinDocFreqValueSource.cs
+++ /dev/null
@@ -1,134 +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 BinaryDocValues = org.apache.lucene.index.BinaryDocValues;
- using IndexReader = org.apache.lucene.index.IndexReader;
- using MultiFields = org.apache.lucene.index.MultiFields;
- using ReaderUtil = org.apache.lucene.index.ReaderUtil;
- using Terms = org.apache.lucene.index.Terms;
- using TermsEnum = org.apache.lucene.index.TermsEnum;
- using IntDocValues = org.apache.lucene.queries.function.docvalues.IntDocValues;
- using BytesRef = org.apache.lucene.util.BytesRef;
- using PackedInts = org.apache.lucene.util.packed.PackedInts;
-
- /// <summary>
- /// Use a field value and find the Document Frequency within another field.
- ///
- /// @since solr 4.0
- /// </summary>
- public class JoinDocFreqValueSource : FieldCacheSource
- {
-
- public const string NAME = "joindf";
-
- protected internal readonly string qfield;
-
- public JoinDocFreqValueSource(string field, string qfield) : base(field)
- {
- this.qfield = qfield;
- }
-
- public override string description()
- {
- return NAME + "(" + field + ":(" + qfield + "))";
- }
-
-//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.BinaryDocValues terms = cache.getTerms(readerContext.reader(), field, false, org.apache.lucene.util.packed.PackedInts.FAST);
- BinaryDocValues terms = cache.getTerms(readerContext.reader(), field, false, PackedInts.FAST);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.index.IndexReader top = org.apache.lucene.index.ReaderUtil.getTopLevelContext(readerContext).reader();
- IndexReader top = ReaderUtil.getTopLevelContext(readerContext).reader();
- Terms t = MultiFields.getTerms(top, qfield);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.index.TermsEnum termsEnum = t == null ? org.apache.lucene.index.TermsEnum.EMPTY : t.iterator(null);
- TermsEnum termsEnum = t == null ? TermsEnum.EMPTY : t.iterator(null);
-
- return new IntDocValuesAnonymousInnerClassHelper(this, this, terms, termsEnum);
- }
-
- private class IntDocValuesAnonymousInnerClassHelper : IntDocValues
- {
- private readonly JoinDocFreqValueSource outerInstance;
-
- private BinaryDocValues terms;
- private TermsEnum termsEnum;
-
- public IntDocValuesAnonymousInnerClassHelper(JoinDocFreqValueSource outerInstance, org.apache.lucene.queries.function.valuesource.JoinDocFreqValueSource this, BinaryDocValues terms, TermsEnum termsEnum) : base(this)
- {
- this.outerInstance = outerInstance;
- this.terms = terms;
- this.termsEnum = termsEnum;
- @ref = new BytesRef();
- }
-
- internal readonly BytesRef @ref;
-
- public override int intVal(int doc)
- {
- try
- {
- terms.get(doc, @ref);
- if (termsEnum.seekExact(@ref))
- {
- return termsEnum.docFreq();
- }
- else
- {
- return 0;
- }
- }
- catch (IOException e)
- {
- throw new Exception("caught exception in function " + outerInstance.description() + " : doc=" + doc, e);
- }
- }
- }
-
- public override bool Equals(object o)
- {
- if (o.GetType() != typeof(JoinDocFreqValueSource))
- {
- return false;
- }
- JoinDocFreqValueSource other = (JoinDocFreqValueSource)o;
- if (!qfield.Equals(other.qfield))
- {
- return false;
- }
- return base.Equals(other);
- }
-
- public override int GetHashCode()
- {
- return qfield.GetHashCode() + base.GetHashCode();
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/LinearFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/LinearFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/LinearFloatFunction.cs
deleted file mode 100644
index a03268c..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/LinearFloatFunction.cs
+++ /dev/null
@@ -1,113 +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>
- /// <code>LinearFloatFunction</code> implements a linear function over
- /// another <seealso cref="ValueSource"/>.
- /// <br>
- /// Normally Used as an argument to a <seealso cref="org.apache.lucene.queries.function.FunctionQuery"/>
- ///
- ///
- /// </summary>
- public class LinearFloatFunction : ValueSource
- {
- protected internal readonly ValueSource source;
- protected internal readonly float slope;
- protected internal readonly float intercept;
-
- public LinearFloatFunction(ValueSource source, float slope, float intercept)
- {
- this.source = source;
- this.slope = slope;
- this.intercept = intercept;
- }
-
- public override string description()
- {
- return slope + "*float(" + source.description() + ")+" + intercept;
- }
-
-//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 vals = source.getValues(context, readerContext);
- FunctionValues vals = source.getValues(context, readerContext);
- return new FloatDocValuesAnonymousInnerClassHelper(this, this, vals);
- }
-
- private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
- {
- private readonly LinearFloatFunction outerInstance;
-
- private FunctionValues vals;
-
- public FloatDocValuesAnonymousInnerClassHelper(LinearFloatFunction outerInstance, org.apache.lucene.queries.function.valuesource.LinearFloatFunction this, FunctionValues vals) : base(this)
- {
- this.outerInstance = outerInstance;
- this.vals = vals;
- }
-
- public override float floatVal(int doc)
- {
- return vals.floatVal(doc) * outerInstance.slope + outerInstance.intercept;
- }
- public override string ToString(int doc)
- {
- return outerInstance.slope + "*float(" + vals.ToString(doc) + ")+" + outerInstance.intercept;
- }
- }
-
-//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)
- {
- source.createWeight(context, searcher);
- }
-
- public override int GetHashCode()
- {
- int h = float.floatToIntBits(slope);
- h = ((int)((uint)h >> 2)) | (h << 30);
- h += float.floatToIntBits(intercept);
- h ^= (h << 14) | ((int)((uint)h >> 19));
- return h + source.GetHashCode();
- }
-
- public override bool Equals(object o)
- {
- if (typeof(LinearFloatFunction) != o.GetType())
- {
- return false;
- }
- LinearFloatFunction other = (LinearFloatFunction)o;
- return this.slope == other.slope && this.intercept == other.intercept && this.source.Equals(other.source);
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/LiteralValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/LiteralValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/LiteralValueSource.cs
deleted file mode 100644
index 6107a28..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/LiteralValueSource.cs
+++ /dev/null
@@ -1,117 +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 StrDocValues = org.apache.lucene.queries.function.docvalues.StrDocValues;
- using BytesRef = org.apache.lucene.util.BytesRef;
-
-
-
- /// <summary>
- /// Pass a the field value through as a String, no matter the type // Q: doesn't this mean it's a "string"?
- ///
- ///
- /// </summary>
- public class LiteralValueSource : ValueSource
- {
- protected internal readonly string @string;
- protected internal readonly BytesRef bytesRef;
-
- public LiteralValueSource(string @string)
- {
- this.@string = @string;
- this.bytesRef = new BytesRef(@string);
- }
-
- /// <summary>
- /// returns the literal value </summary>
- public virtual string Value
- {
- get
- {
- return @string;
- }
- }
-
-//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 StrDocValuesAnonymousInnerClassHelper(this, this);
- }
-
- private class StrDocValuesAnonymousInnerClassHelper : StrDocValues
- {
- private readonly LiteralValueSource outerInstance;
-
- public StrDocValuesAnonymousInnerClassHelper(LiteralValueSource outerInstance, org.apache.lucene.queries.function.valuesource.LiteralValueSource this) : base(this)
- {
- this.outerInstance = outerInstance;
- }
-
- public override string strVal(int doc)
- {
- return outerInstance.@string;
- }
-
- public override bool bytesVal(int doc, BytesRef target)
- {
- target.copyBytes(outerInstance.bytesRef);
- return true;
- }
-
- public override string ToString(int doc)
- {
- return outerInstance.@string;
- }
- }
-
- public override string description()
- {
- return "literal(" + @string + ")";
- }
-
- public override bool Equals(object o)
- {
- if (this == o)
- {
- return true;
- }
- if (!(o is LiteralValueSource))
- {
- return false;
- }
-
- LiteralValueSource that = (LiteralValueSource) o;
-
- return @string.Equals(that.@string);
-
- }
-
- public static readonly int hash = typeof(LiteralValueSource).GetHashCode();
- public override int GetHashCode()
- {
- return hash + @string.GetHashCode();
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/LongFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/LongFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/LongFieldSource.cs
deleted file mode 100644
index d831ebd..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/LongFieldSource.cs
+++ /dev/null
@@ -1,184 +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 LongDocValues = org.apache.lucene.queries.function.docvalues.LongDocValues;
- using FieldCache = org.apache.lucene.search.FieldCache;
- using Bits = org.apache.lucene.util.Bits;
- using MutableValue = org.apache.lucene.util.mutable.MutableValue;
- using MutableValueLong = org.apache.lucene.util.mutable.MutableValueLong;
-
- /// <summary>
- /// Obtains long field values from <seealso cref="FieldCache#getLongs"/> and makes those
- /// values available as other numeric types, casting as needed.
- /// </summary>
- public class LongFieldSource : FieldCacheSource
- {
-
- protected internal readonly FieldCache.LongParser parser;
-
- public LongFieldSource(string field) : this(field, null)
- {
- }
-
- public LongFieldSource(string field, FieldCache.LongParser parser) : base(field)
- {
- this.parser = parser;
- }
-
- public override string description()
- {
- return "long(" + field + ')';
- }
-
- public virtual long externalToLong(string extVal)
- {
- return Convert.ToInt64(extVal);
- }
-
- public virtual object longToObject(long val)
- {
- return val;
- }
-
- public virtual string longToString(long val)
- {
- return longToObject(val).ToString();
- }
-
-//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.Longs arr = cache.getLongs(readerContext.reader(), field, parser, true);
- FieldCache.Longs arr = cache.getLongs(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 LongDocValuesAnonymousInnerClassHelper(this, this, arr, valid);
- }
-
- private class LongDocValuesAnonymousInnerClassHelper : LongDocValues
- {
- private readonly LongFieldSource outerInstance;
-
- private FieldCache.Longs arr;
- private Bits valid;
-
- public LongDocValuesAnonymousInnerClassHelper(LongFieldSource outerInstance, org.apache.lucene.queries.function.valuesource.LongFieldSource this, FieldCache.Longs arr, Bits valid) : base(this)
- {
- this.outerInstance = outerInstance;
- this.arr = arr;
- this.valid = valid;
- }
-
- public override long longVal(int doc)
- {
- return arr.get(doc);
- }
-
- public override bool exists(int doc)
- {
- return arr.get(doc) != 0 || valid.get(doc);
- }
-
- public override object objectVal(int doc)
- {
- return valid.get(doc) ? outerInstance.longToObject(arr.get(doc)) : null;
- }
-
- public override string strVal(int doc)
- {
- return valid.get(doc) ? outerInstance.longToString(arr.get(doc)) : null;
- }
-
- protected internal override long externalToLong(string extVal)
- {
- return outerInstance.externalToLong(extVal);
- }
-
- public override ValueFiller ValueFiller
- {
- get
- {
- return new ValueFillerAnonymousInnerClassHelper(this);
- }
- }
-
- private class ValueFillerAnonymousInnerClassHelper : ValueFiller
- {
- private readonly LongDocValuesAnonymousInnerClassHelper outerInstance;
-
- public ValueFillerAnonymousInnerClassHelper(LongDocValuesAnonymousInnerClassHelper outerInstance)
- {
- this.outerInstance = outerInstance;
- mval = outerInstance.outerInstance.newMutableValueLong();
- }
-
- private readonly MutableValueLong 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);
- }
- }
-
- }
-
- protected internal virtual MutableValueLong newMutableValueLong()
- {
- return new MutableValueLong();
- }
-
- public override bool Equals(object o)
- {
- if (o.GetType() != this.GetType())
- {
- return false;
- }
- LongFieldSource other = (LongFieldSource) 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 ? this.GetType().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/MaxDocValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/MaxDocValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/MaxDocValueSource.cs
deleted file mode 100644
index 0e00953..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/MaxDocValueSource.cs
+++ /dev/null
@@ -1,70 +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; // javadocs
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
-
-
- /// <summary>
- /// Returns the value of <seealso cref="IndexReader#maxDoc()"/>
- /// for every document. This is the number of documents
- /// including deletions.
- /// </summary>
- public class MaxDocValueSource : ValueSource
- {
- public virtual string name()
- {
- return "maxdoc";
- }
-
- public override string description()
- {
- return name() + "()";
- }
-
-//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;
- }
-
-//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"];
- return new ConstIntDocValues(searcher.IndexReader.maxDoc(), this);
- }
-
- public override bool Equals(object o)
- {
- return this.GetType() == o.GetType();
- }
-
- public override int GetHashCode()
- {
- return this.GetType().GetHashCode();
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/MaxFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/MaxFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/MaxFloatFunction.cs
deleted file mode 100644
index 24034c3..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/MaxFloatFunction.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-
-/*
- * 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>MaxFloatFunction</code> returns the max of it's components.
- /// </summary>
- public class MaxFloatFunction : MultiFloatFunction
- {
- public MaxFloatFunction(ValueSource[] sources) : base(sources)
- {
- }
-
- protected internal override string name()
- {
- return "max";
- }
-
- protected internal override float func(int doc, FunctionValues[] valsArr)
- {
- if (valsArr.Length == 0)
- {
- return 0.0f;
- }
- float val = float.NegativeInfinity;
- foreach (FunctionValues vals in valsArr)
- {
- val = Math.Max(vals.floatVal(doc), val);
- }
- return val;
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/MinFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/MinFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/MinFloatFunction.cs
deleted file mode 100644
index f4abce7..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/MinFloatFunction.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-
-/*
- * 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>MinFloatFunction</code> returns the min of it's components.
- /// </summary>
- public class MinFloatFunction : MultiFloatFunction
- {
- public MinFloatFunction(ValueSource[] sources) : base(sources)
- {
- }
-
- protected internal override string name()
- {
- return "min";
- }
-
- protected internal override float func(int doc, FunctionValues[] valsArr)
- {
- if (valsArr.Length == 0)
- {
- return 0.0f;
- }
- float val = float.PositiveInfinity;
- foreach (FunctionValues vals in valsArr)
- {
- val = Math.Min(vals.floatVal(doc), val);
- }
- return val;
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/MultiBoolFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/MultiBoolFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/MultiBoolFunction.cs
deleted file mode 100644
index 56810a3..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/MultiBoolFunction.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-/*
- * 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 BoolDocValues = org.apache.lucene.queries.function.docvalues.BoolDocValues;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
-
-
- /// <summary>
- /// Abstract <seealso cref="ValueSource"/> implementation which wraps multiple ValueSources
- /// and applies an extendible boolean function to their values.
- ///
- /// </summary>
- public abstract class MultiBoolFunction : BoolFunction
- {
- protected internal readonly IList<ValueSource> sources;
-
- public MultiBoolFunction(IList<ValueSource> sources)
- {
- this.sources = sources;
- }
-
- protected internal abstract string name();
-
- protected internal abstract bool func(int doc, FunctionValues[] vals);
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public org.apache.lucene.queries.function.docvalues.BoolDocValues getValues(java.util.Map context, org.apache.lucene.index.AtomicReaderContext readerContext) throws java.io.IOException
- public override BoolDocValues 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[] vals = new org.apache.lucene.queries.function.FunctionValues[sources.size()];
- FunctionValues[] vals = new FunctionValues[sources.Count];
- int i = 0;
- foreach (ValueSource source in sources)
- {
- vals[i++] = source.getValues(context, readerContext);
- }
-
- return new BoolDocValuesAnonymousInnerClassHelper(this, this, vals);
- }
-
- private class BoolDocValuesAnonymousInnerClassHelper : BoolDocValues
- {
- private readonly MultiBoolFunction outerInstance;
-
- private FunctionValues[] vals;
-
- public BoolDocValuesAnonymousInnerClassHelper(MultiBoolFunction outerInstance, org.apache.lucene.queries.function.valuesource.MultiBoolFunction this, FunctionValues[] vals) : base(this)
- {
- this.outerInstance = outerInstance;
- this.vals = vals;
- }
-
- public override bool boolVal(int doc)
- {
- return outerInstance.func(doc, vals);
- }
-
- public override string ToString(int doc)
- {
- StringBuilder sb = new StringBuilder(outerInstance.name());
- sb.Append('(');
- bool first = true;
- foreach (FunctionValues dv in vals)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- sb.Append(',');
- }
- sb.Append(dv.ToString(doc));
- }
- return sb.ToString();
- }
- }
-
- public override string description()
- {
- StringBuilder sb = new StringBuilder(name());
- sb.Append('(');
- bool first = true;
- foreach (ValueSource source in sources)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- sb.Append(',');
- }
- sb.Append(source.description());
- }
- return sb.ToString();
- }
-
- public override int GetHashCode()
- {
- return sources.GetHashCode() + name().GetHashCode();
- }
-
- public override bool Equals(object o)
- {
- if (this.GetType() != o.GetType())
- {
- return false;
- }
- MultiBoolFunction other = (MultiBoolFunction)o;
- return this.sources.Equals(other.sources);
- }
-
-//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)
- {
- foreach (ValueSource source in sources)
- {
- source.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/MultiFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/MultiFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/MultiFloatFunction.cs
deleted file mode 100644
index 90b56ff..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/MultiFloatFunction.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using System.Collections;
-using System.Text;
-
-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 FloatDocValues = org.apache.lucene.queries.function.docvalues.FloatDocValues;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
-
-
-
- /// <summary>
- /// Abstract <seealso cref="ValueSource"/> implementation which wraps multiple ValueSources
- /// and applies an extendible float function to their values.
- ///
- /// </summary>
- public abstract class MultiFloatFunction : ValueSource
- {
- protected internal readonly ValueSource[] sources;
-
- public MultiFloatFunction(ValueSource[] sources)
- {
- this.sources = sources;
- }
-
- protected internal abstract string name();
- protected internal abstract float func(int doc, FunctionValues[] valsArr);
-
- public override string description()
- {
- StringBuilder sb = new StringBuilder();
- sb.Append(name()).Append('(');
- bool firstTime = true;
- foreach (ValueSource source in sources)
- {
- if (firstTime)
- {
- firstTime = false;
- }
- else
- {
- sb.Append(',');
- }
- sb.Append(source);
- }
- sb.Append(')');
- return sb.ToString();
- }
-
-//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[] valsArr = new org.apache.lucene.queries.function.FunctionValues[sources.length];
- FunctionValues[] valsArr = new FunctionValues[sources.Length];
- for (int i = 0; i < sources.Length; i++)
- {
- valsArr[i] = sources[i].getValues(context, readerContext);
- }
-
- return new FloatDocValuesAnonymousInnerClassHelper(this, this, valsArr);
- }
-
- private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
- {
- private readonly MultiFloatFunction outerInstance;
-
- private FunctionValues[] valsArr;
-
- public FloatDocValuesAnonymousInnerClassHelper(MultiFloatFunction outerInstance, org.apache.lucene.queries.function.valuesource.MultiFloatFunction this, FunctionValues[] valsArr) : base(this)
- {
- this.outerInstance = outerInstance;
- this.valsArr = valsArr;
- }
-
- public override float floatVal(int doc)
- {
- return outerInstance.func(doc, valsArr);
- }
- public override string ToString(int doc)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append(outerInstance.name()).Append('(');
- bool firstTime = true;
- foreach (FunctionValues vals in valsArr)
- {
- if (firstTime)
- {
- firstTime = false;
- }
- else
- {
- sb.Append(',');
- }
- sb.Append(vals.ToString(doc));
- }
- sb.Append(')');
- return sb.ToString();
- }
- }
-
-//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)
- {
- foreach (ValueSource source in sources)
- {
- source.createWeight(context, searcher);
- }
- }
-
- public override int GetHashCode()
- {
- return Arrays.GetHashCode(sources) + name().GetHashCode();
- }
-
- public override bool Equals(object o)
- {
- if (this.GetType() != o.GetType())
- {
- return false;
- }
- MultiFloatFunction other = (MultiFloatFunction)o;
- return this.name().Equals(other.name()) && Arrays.Equals(this.sources, other.sources);
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/MultiFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/MultiFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/MultiFunction.cs
deleted file mode 100644
index 089d21c..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/MultiFunction.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using System.Text;
-
-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>
- /// Abstract parent class for <seealso cref="ValueSource"/> implementations that wrap multiple
- /// ValueSources and apply their own logic.
- /// </summary>
- public abstract class MultiFunction : ValueSource
- {
- protected internal readonly IList<ValueSource> sources;
-
- public MultiFunction(IList<ValueSource> sources)
- {
- this.sources = sources;
- }
-
- protected internal abstract string name();
-
- public override string description()
- {
- return description(name(), sources);
- }
-
- public static string description(string name, IList<ValueSource> sources)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append(name).Append('(');
- bool firstTime = true;
- foreach (ValueSource source in sources)
- {
- if (firstTime)
- {
- firstTime = false;
- }
- else
- {
- sb.Append(',');
- }
- sb.Append(source);
- }
- sb.Append(')');
- return sb.ToString();
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public static org.apache.lucene.queries.function.FunctionValues[] valsArr(java.util.List<org.apache.lucene.queries.function.ValueSource> sources, java.util.Map fcontext, org.apache.lucene.index.AtomicReaderContext readerContext) throws java.io.IOException
- public static FunctionValues[] valsArr(IList<ValueSource> sources, IDictionary fcontext, AtomicReaderContext readerContext)
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.queries.function.FunctionValues[] valsArr = new org.apache.lucene.queries.function.FunctionValues[sources.size()];
- FunctionValues[] valsArr = new FunctionValues[sources.Count];
- int i = 0;
- foreach (ValueSource source in sources)
- {
- valsArr[i++] = source.getValues(fcontext, readerContext);
- }
- return valsArr;
- }
-
- public class Values : FunctionValues
- {
- private readonly MultiFunction outerInstance;
-
- internal readonly FunctionValues[] valsArr;
-
- public Values(MultiFunction outerInstance, FunctionValues[] valsArr)
- {
- this.outerInstance = outerInstance;
- this.valsArr = valsArr;
- }
-
- public override string ToString(int doc)
- {
- return MultiFunction.ToString(outerInstance.name(), valsArr, doc);
- }
-
- public override ValueFiller ValueFiller
- {
- get
- {
- // TODO: need ValueSource.type() to determine correct type
- return base.ValueFiller;
- }
- }
- }
-
-
- public static string ToString(string name, FunctionValues[] valsArr, int doc)
- {
- StringBuilder sb = new StringBuilder();
- sb.Append(name).Append('(');
- bool firstTime = true;
- foreach (FunctionValues vals in valsArr)
- {
- if (firstTime)
- {
- firstTime = false;
- }
- else
- {
- sb.Append(',');
- }
- sb.Append(vals.ToString(doc));
- }
- sb.Append(')');
- return sb.ToString();
- }
-
-//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)
- {
- foreach (ValueSource source in sources)
- {
- source.createWeight(context, searcher);
- }
- }
-
- public override int GetHashCode()
- {
- return sources.GetHashCode() + name().GetHashCode();
- }
-
- public override bool Equals(object o)
- {
- if (this.GetType() != o.GetType())
- {
- return false;
- }
- MultiFunction other = (MultiFunction)o;
- return this.sources.Equals(other.sources);
- }
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/MultiValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/MultiValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/MultiValueSource.cs
deleted file mode 100644
index 908eae9..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/MultiValueSource.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-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.
- */
-
-
- /// <summary>
- /// A <seealso cref="ValueSource"/> that abstractly represents <seealso cref="ValueSource"/>s for
- /// poly fields, and other things.
- ///
- /// </summary>
- public abstract class MultiValueSource : ValueSource
- {
-
- public abstract int dimension();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/NormValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/NormValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/NormValueSource.cs
deleted file mode 100644
index d0de6c1..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/NormValueSource.cs
+++ /dev/null
@@ -1,125 +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 NumericDocValues = org.apache.lucene.index.NumericDocValues;
- using FloatDocValues = org.apache.lucene.queries.function.docvalues.FloatDocValues;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
- using TFIDFSimilarity = org.apache.lucene.search.similarities.TFIDFSimilarity;
-
-
- /// <summary>
- /// Function that returns <seealso cref="TFIDFSimilarity#decodeNormValue(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 NormValueSource : ValueSource
- {
- protected internal readonly string field;
- public NormValueSource(string field)
- {
- this.field = field;
- }
-
- public virtual string name()
- {
- return "norm";
- }
-
- public override string description()
- {
- return name() + '(' + field + ')';
- }
-
-//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;
- }
-
-//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"];
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.search.similarities.TFIDFSimilarity similarity = IDFValueSource.asTFIDF(searcher.getSimilarity(), field);
- TFIDFSimilarity similarity = IDFValueSource.asTFIDF(searcher.Similarity, field);
- if (similarity == null)
- {
- throw new System.NotSupportedException("requires a TFIDFSimilarity (such as DefaultSimilarity)");
- }
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.index.NumericDocValues norms = readerContext.reader().getNormValues(field);
- NumericDocValues norms = readerContext.reader().getNormValues(field);
-
- if (norms == null)
- {
- return new ConstDoubleDocValues(0.0, this);
- }
-
- return new FloatDocValuesAnonymousInnerClassHelper(this, this, similarity, norms);
- }
-
- private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
- {
- private readonly NormValueSource outerInstance;
-
- private TFIDFSimilarity similarity;
- private NumericDocValues norms;
-
- public FloatDocValuesAnonymousInnerClassHelper(NormValueSource outerInstance, org.apache.lucene.queries.function.valuesource.NormValueSource this, TFIDFSimilarity similarity, NumericDocValues norms) : base(this)
- {
- this.outerInstance = outerInstance;
- this.similarity = similarity;
- this.norms = norms;
- }
-
- public override float floatVal(int doc)
- {
- return similarity.decodeNormValue(norms.get(doc));
- }
- }
-
- public override bool Equals(object o)
- {
- if (this.GetType() != o.GetType())
- {
- return false;
- }
- return this.field.Equals(((NormValueSource)o).field);
- }
-
- public override int GetHashCode()
- {
- return this.GetType().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/NumDocsValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/NumDocsValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/NumDocsValueSource.cs
deleted file mode 100644
index b5e6669..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/NumDocsValueSource.cs
+++ /dev/null
@@ -1,63 +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 ReaderUtil = org.apache.lucene.index.ReaderUtil;
-
-
- /// <summary>
- /// Returns the value of <seealso cref="IndexReader#numDocs()"/>
- /// for every document. This is the number of documents
- /// excluding deletions.
- /// </summary>
- public class NumDocsValueSource : ValueSource
- {
- public virtual string name()
- {
- return "numdocs";
- }
-
- public override string description()
- {
- return name() + "()";
- }
-
-//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)
- {
- // Searcher has no numdocs so we must use the reader instead
- return new ConstIntDocValues(ReaderUtil.getTopLevelContext(readerContext).reader().numDocs(), this);
- }
-
- public override bool Equals(object o)
- {
- return this.GetType() == o.GetType();
- }
-
- public override int GetHashCode()
- {
- return this.GetType().GetHashCode();
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/OrdFieldSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/OrdFieldSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/OrdFieldSource.cs
deleted file mode 100644
index 123327f..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/OrdFieldSource.cs
+++ /dev/null
@@ -1,175 +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 AtomicReader = org.apache.lucene.index.AtomicReader;
- using AtomicReaderContext = org.apache.lucene.index.AtomicReaderContext;
- using CompositeReader = org.apache.lucene.index.CompositeReader;
- using IndexReader = org.apache.lucene.index.IndexReader;
- using ReaderUtil = org.apache.lucene.index.ReaderUtil;
- using SlowCompositeReaderWrapper = org.apache.lucene.index.SlowCompositeReaderWrapper;
- using SortedDocValues = org.apache.lucene.index.SortedDocValues;
- using IntDocValues = org.apache.lucene.queries.function.docvalues.IntDocValues;
- using FieldCache = org.apache.lucene.search.FieldCache;
- using MutableValue = org.apache.lucene.util.mutable.MutableValue;
- using MutableValueInt = org.apache.lucene.util.mutable.MutableValueInt;
-
- /// <summary>
- /// Obtains the ordinal of the field value from the default Lucene <seealso cref="org.apache.lucene.search.FieldCache"/> using getStringIndex().
- /// <br>
- /// The native lucene index order is used to assign an ordinal value for each field value.
- /// <br>Field values (terms) are lexicographically ordered by unicode value, and numbered starting at 1.
- /// <br>
- /// Example:<br>
- /// If there were only three field values: "apple","banana","pear"
- /// <br>then ord("apple")=1, ord("banana")=2, ord("pear")=3
- /// <para>
- /// WARNING: ord() depends on the position in an index and can thus change when other documents are inserted or deleted,
- /// or if a MultiSearcher is used.
- /// <br>WARNING: as of Solr 1.4, ord() and rord() can cause excess memory use since they must use a FieldCache entry
- /// at the top level reader, while sorting and function queries now use entries at the segment level. Hence sorting
- /// or using a different function query, in addition to ord()/rord() will double memory use.
- ///
- /// </para>
- /// </summary>
-
- public class OrdFieldSource : ValueSource
- {
- protected internal readonly string field;
-
- public OrdFieldSource(string field)
- {
- this.field = field;
- }
-
- public override string description()
- {
- return "ord(" + field + ')';
- }
-
-
- // TODO: this is trappy? perhaps this query instead should make you pass a slow reader yourself?
-//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 int off = readerContext.docBase;
- int off = readerContext.docBase;
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.index.IndexReader topReader = org.apache.lucene.index.ReaderUtil.getTopLevelContext(readerContext).reader();
- IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.index.AtomicReader r = org.apache.lucene.index.SlowCompositeReaderWrapper.wrap(topReader);
- AtomicReader r = SlowCompositeReaderWrapper.wrap(topReader);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.index.SortedDocValues sindex = org.apache.lucene.search.FieldCache.DEFAULT.getTermsIndex(r, field);
- SortedDocValues sindex = FieldCache.DEFAULT.getTermsIndex(r, field);
- return new IntDocValuesAnonymousInnerClassHelper(this, this, off, sindex);
- }
-
- private class IntDocValuesAnonymousInnerClassHelper : IntDocValues
- {
- private readonly OrdFieldSource outerInstance;
-
- private int off;
- private SortedDocValues sindex;
-
- public IntDocValuesAnonymousInnerClassHelper(OrdFieldSource outerInstance, org.apache.lucene.queries.function.valuesource.OrdFieldSource this, int off, SortedDocValues sindex) : base(this)
- {
- this.outerInstance = outerInstance;
- this.off = off;
- this.sindex = sindex;
- }
-
- protected internal virtual string toTerm(string readableValue)
- {
- return readableValue;
- }
- public override int intVal(int doc)
- {
- return sindex.getOrd(doc + off);
- }
- public override int ordVal(int doc)
- {
- return sindex.getOrd(doc + off);
- }
- public override int numOrd()
- {
- return sindex.ValueCount;
- }
-
- public override bool exists(int doc)
- {
- return sindex.getOrd(doc + off) != 0;
- }
-
- 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.sindex.getOrd(doc);
- mval.exists = mval.value != 0;
- }
- }
- }
-
- public override bool Equals(object o)
- {
- return o != null && o.GetType() == typeof(OrdFieldSource) && this.field.Equals(((OrdFieldSource)o).field);
- }
-
- private static readonly int hcode = typeof(OrdFieldSource).GetHashCode();
- public override int GetHashCode()
- {
- return hcode + 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/PowFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/PowFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/PowFloatFunction.cs
deleted file mode 100644
index 99b4c42..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/PowFloatFunction.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-
-/*
- * 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 raise the base "a" to the power "b"
- /// </summary>
- public class PowFloatFunction : DualFloatFunction
- {
- /// <param name="a"> the base. </param>
- /// <param name="b"> the exponent. </param>
- public PowFloatFunction(ValueSource a, ValueSource b) : base(a,b)
- {
- }
-
- protected internal override string name()
- {
- return "pow";
- }
-
- protected internal override float func(int doc, FunctionValues aVals, FunctionValues bVals)
- {
- return (float)Math.Pow(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/ProductFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/ProductFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/ProductFloatFunction.cs
deleted file mode 100644
index 92cc4d7..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/ProductFloatFunction.cs
+++ /dev/null
@@ -1,47 +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>ProductFloatFunction</code> returns the product of it's components.
- /// </summary>
- public class ProductFloatFunction : MultiFloatFunction
- {
- public ProductFloatFunction(ValueSource[] sources) : base(sources)
- {
- }
-
- protected internal override string name()
- {
- return "product";
- }
-
- protected internal override float func(int doc, FunctionValues[] valsArr)
- {
- float val = 1.0f;
- foreach (FunctionValues vals in valsArr)
- {
- val *= vals.floatVal(doc);
- }
- return val;
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/QueryValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/QueryValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSource/QueryValueSource.cs
deleted file mode 100644
index 9abc198..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/QueryValueSource.cs
+++ /dev/null
@@ -1,328 +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 ReaderUtil = org.apache.lucene.index.ReaderUtil;
- using FloatDocValues = org.apache.lucene.queries.function.docvalues.FloatDocValues;
- using org.apache.lucene.search;
- using Bits = org.apache.lucene.util.Bits;
- using MutableValue = org.apache.lucene.util.mutable.MutableValue;
- using MutableValueFloat = org.apache.lucene.util.mutable.MutableValueFloat;
-
-
- /// <summary>
- /// <code>QueryValueSource</code> returns the relevance score of the query
- /// </summary>
- public class QueryValueSource : ValueSource
- {
- internal readonly Query q;
- internal readonly float defVal;
-
- public QueryValueSource(Query q, float defVal)
- {
- this.q = q;
- this.defVal = defVal;
- }
-
- public virtual Query Query
- {
- get
- {
- return q;
- }
- }
- public virtual float DefaultValue
- {
- get
- {
- return defVal;
- }
- }
-
- public override string description()
- {
- return "query(" + q + ",def=" + defVal + ")";
- }
-
-//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 QueryDocValues(this, readerContext, fcontext);
- }
-
- public override int GetHashCode()
- {
- return q.GetHashCode() * 29;
- }
-
- public override bool Equals(object o)
- {
- if (typeof(QueryValueSource) != o.GetType())
- {
- return false;
- }
- QueryValueSource other = (QueryValueSource)o;
- return this.q.Equals(other.q) && this.defVal == other.defVal;
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void createWeight(java.util.Map context, IndexSearcher searcher) throws java.io.IOException
- public override void createWeight(IDictionary context, IndexSearcher searcher)
- {
- Weight w = searcher.createNormalizedWeight(q);
- context[this] = w;
- }
- }
-
-
- internal class QueryDocValues : FloatDocValues
- {
- internal readonly AtomicReaderContext readerContext;
- internal readonly Bits acceptDocs;
- internal readonly Weight weight;
- internal readonly float defVal;
- internal readonly IDictionary fcontext;
- internal readonly Query q;
-
- internal Scorer scorer;
- internal int scorerDoc; // the document the scorer is on
- internal bool noMatches = false;
-
- // the last document requested... start off with high value
- // to trigger a scorer reset on first access.
- internal int lastDocRequested = int.MaxValue;
-
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: public QueryDocValues(QueryValueSource vs, org.apache.lucene.index.AtomicReaderContext readerContext, java.util.Map fcontext) throws java.io.IOException
- public QueryDocValues(QueryValueSource vs, AtomicReaderContext readerContext, IDictionary fcontext) : base(vs)
- {
-
- this.readerContext = readerContext;
- this.acceptDocs = readerContext.reader().LiveDocs;
- this.defVal = vs.defVal;
- this.q = vs.q;
- this.fcontext = fcontext;
-
- Weight w = fcontext == null ? null : (Weight)fcontext[vs];
- if (w == null)
- {
- IndexSearcher weightSearcher;
- if (fcontext == null)
- {
- weightSearcher = new IndexSearcher(ReaderUtil.getTopLevelContext(readerContext));
- }
- else
- {
- weightSearcher = (IndexSearcher)fcontext["searcher"];
- if (weightSearcher == null)
- {
- weightSearcher = new IndexSearcher(ReaderUtil.getTopLevelContext(readerContext));
- }
- }
- vs.createWeight(fcontext, weightSearcher);
- w = (Weight)fcontext[vs];
- }
- weight = w;
- }
-
- public override float floatVal(int doc)
- {
- try
- {
- if (doc < lastDocRequested)
- {
- if (noMatches)
- {
- return defVal;
- }
- scorer = weight.scorer(readerContext, acceptDocs);
- if (scorer == null)
- {
- noMatches = true;
- return defVal;
- }
- scorerDoc = -1;
- }
- lastDocRequested = doc;
-
- if (scorerDoc < doc)
- {
- scorerDoc = scorer.advance(doc);
- }
-
- if (scorerDoc > doc)
- {
- // query doesn't match this document... either because we hit the
- // end, or because the next doc is after this doc.
- return defVal;
- }
-
- // a match!
- return scorer.score();
- }
- catch (IOException e)
- {
- throw new Exception("caught exception in QueryDocVals(" + q + ") doc=" + doc, e);
- }
- }
-
- public override bool exists(int doc)
- {
- try
- {
- if (doc < lastDocRequested)
- {
- if (noMatches)
- {
- return false;
- }
- scorer = weight.scorer(readerContext, acceptDocs);
- scorerDoc = -1;
- if (scorer == null)
- {
- noMatches = true;
- return false;
- }
- }
- lastDocRequested = doc;
-
- if (scorerDoc < doc)
- {
- scorerDoc = scorer.advance(doc);
- }
-
- if (scorerDoc > doc)
- {
- // query doesn't match this document... either because we hit the
- // end, or because the next doc is after this doc.
- return false;
- }
-
- // a match!
- return true;
- }
- catch (IOException e)
- {
- throw new Exception("caught exception in QueryDocVals(" + q + ") doc=" + doc, e);
- }
- }
-
- public override object objectVal(int doc)
- {
- try
- {
- return exists(doc) ? scorer.score() : null;
- }
- catch (IOException e)
- {
- throw new Exception("caught exception in QueryDocVals(" + q + ") doc=" + doc, e);
- }
- }
-
- public override ValueFiller ValueFiller
- {
- get
- {
- //
- // TODO: if we want to support more than one value-filler or a value-filler in conjunction with
- // the FunctionValues, then members like "scorer" should be per ValueFiller instance.
- // Or we can say that the user should just instantiate multiple FunctionValues.
- //
- return new ValueFillerAnonymousInnerClassHelper(this);
- }
- }
-
- private class ValueFillerAnonymousInnerClassHelper : ValueFiller
- {
- private readonly QueryDocValues outerInstance;
-
- public ValueFillerAnonymousInnerClassHelper(QueryDocValues outerInstance)
- {
- this.outerInstance = outerInstance;
- mval = new MutableValueFloat();
- }
-
- private readonly MutableValueFloat mval;
-
- public override MutableValue Value
- {
- get
- {
- return mval;
- }
- }
-
- public override void fillValue(int doc)
- {
- try
- {
- if (outerInstance.noMatches)
- {
- mval.value = outerInstance.defVal;
- mval.exists = false;
- return;
- }
- outerInstance.scorer = outerInstance.weight.scorer(outerInstance.readerContext, outerInstance.acceptDocs);
- outerInstance.scorerDoc = -1;
- if (outerInstance.scorer == null)
- {
- outerInstance.noMatches = true;
- mval.value = outerInstance.defVal;
- mval.exists = false;
- return;
- }
- outerInstance.lastDocRequested = doc;
-
- if (outerInstance.scorerDoc < doc)
- {
- outerInstance.scorerDoc = outerInstance.scorer.advance(doc);
- }
-
- if (outerInstance.scorerDoc > doc)
- {
- // query doesn't match this document... either because we hit the
- // end, or because the next doc is after this doc.
- mval.value = outerInstance.defVal;
- mval.exists = false;
- return;
- }
-
- // a match!
- mval.value = outerInstance.scorer.score();
- mval.exists = true;
- }
- catch (IOException e)
- {
- throw new Exception("caught exception in QueryDocVals(" + outerInstance.q + ") doc=" + doc, e);
- }
- }
- }
-
- public override string ToString(int doc)
- {
- return "query(" + q + ",def=" + defVal + ")=" + 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/RangeMapFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/RangeMapFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/RangeMapFloatFunction.cs
deleted file mode 100644
index d6cf6df..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/RangeMapFloatFunction.cs
+++ /dev/null
@@ -1,138 +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>
- /// <code>RangeMapFloatFunction</code> implements a map function over
- /// another <seealso cref="ValueSource"/> whose values fall within min and max inclusive to target.
- /// <br>
- /// Normally Used as an argument to a <seealso cref="org.apache.lucene.queries.function.FunctionQuery"/>
- ///
- ///
- /// </summary>
- public class RangeMapFloatFunction : ValueSource
- {
- protected internal readonly ValueSource source;
- protected internal readonly float min;
- protected internal readonly float max;
- protected internal readonly ValueSource target;
- protected internal readonly ValueSource defaultVal;
-
- public RangeMapFloatFunction(ValueSource source, float min, float max, float target, float? def) : this(source, min, max, new ConstValueSource(target), def == null ? null : new ConstValueSource(def.Value))
- {
- }
-
- public RangeMapFloatFunction(ValueSource source, float min, float max, ValueSource target, ValueSource def)
- {
- this.source = source;
- this.min = min;
- this.max = max;
- this.target = target;
- this.defaultVal = def;
- }
-
- public override string description()
- {
- return "map(" + source.description() + "," + min + "," + max + "," + target.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 vals = source.getValues(context, readerContext);
- FunctionValues vals = source.getValues(context, readerContext);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.queries.function.FunctionValues targets = target.getValues(context, readerContext);
- FunctionValues targets = target.getValues(context, readerContext);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final org.apache.lucene.queries.function.FunctionValues defaults = (this.defaultVal == null) ? null : defaultVal.getValues(context, readerContext);
- FunctionValues defaults = (this.defaultVal == null) ? null : defaultVal.getValues(context, readerContext);
- return new FloatDocValuesAnonymousInnerClassHelper(this, this, vals, targets, defaults);
- }
-
- private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
- {
- private readonly RangeMapFloatFunction outerInstance;
-
- private FunctionValues vals;
- private FunctionValues targets;
- private FunctionValues defaults;
-
- public FloatDocValuesAnonymousInnerClassHelper(RangeMapFloatFunction outerInstance, org.apache.lucene.queries.function.valuesource.RangeMapFloatFunction this, FunctionValues vals, FunctionValues targets, FunctionValues defaults) : base(this)
- {
- this.outerInstance = outerInstance;
- this.vals = vals;
- this.targets = targets;
- this.defaults = defaults;
- }
-
- public override float floatVal(int doc)
- {
- float val = vals.floatVal(doc);
- return (val >= outerInstance.min && val <= outerInstance.max) ? targets.floatVal(doc) : (outerInstance.defaultVal == null ? val : defaults.floatVal(doc));
- }
- public override string ToString(int doc)
- {
- return "map(" + vals.ToString(doc) + ",min=" + outerInstance.min + ",max=" + outerInstance.max + ",target=" + targets.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)
- {
- source.createWeight(context, searcher);
- }
-
- public override int GetHashCode()
- {
- int h = source.GetHashCode();
- h ^= (h << 10) | ((int)((uint)h >> 23));
- h += float.floatToIntBits(min);
- h ^= (h << 14) | ((int)((uint)h >> 19));
- h += float.floatToIntBits(max);
- h += target.GetHashCode();
- if (defaultVal != null)
- {
- h += defaultVal.GetHashCode();
- }
- return h;
- }
-
- public override bool Equals(object o)
- {
- if (typeof(RangeMapFloatFunction) != o.GetType())
- {
- return false;
- }
- RangeMapFloatFunction other = (RangeMapFloatFunction)o;
- return this.min == other.min && this.max == other.max && this.target.Equals(other.target) && this.source.Equals(other.source) && (this.defaultVal == other.defaultVal || (this.defaultVal != null && this.defaultVal.Equals(other.defaultVal)));
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSource/ReciprocalFloatFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSource/ReciprocalFloatFunction.cs b/src/Lucene.Net.Queries/Function/ValueSource/ReciprocalFloatFunction.cs
deleted file mode 100644
index 9fcf24c..0000000
--- a/src/Lucene.Net.Queries/Function/ValueSource/ReciprocalFloatFunction.cs
+++ /dev/null
@@ -1,130 +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 FloatDocValues = org.apache.lucene.queries.function.docvalues.FloatDocValues;
- using IndexSearcher = org.apache.lucene.search.IndexSearcher;
-
-
- /// <summary>
- /// <code>ReciprocalFloatFunction</code> implements a reciprocal function f(x) = a/(mx+b), based on
- /// the float value of a field or function as exported by <seealso cref="org.apache.lucene.queries.function.ValueSource"/>.
- /// <br>
- ///
- /// When a and b are equal, and x>=0, this function has a maximum value of 1 that drops as x increases.
- /// Increasing the value of a and b together results in a movement of the entire function to a flatter part of the curve.
- /// <para>These properties make this an idea function for boosting more recent documents.
- /// </para>
- /// <para>Example:<code> recip(ms(NOW,mydatefield),3.16e-11,1,1)</code>
- /// </para>
- /// <para>A multiplier of 3.16e-11 changes the units from milliseconds to years (since there are about 3.16e10 milliseconds
- /// per year). Thus, a very recent date will yield a value close to 1/(0+1) or 1,
- /// a date a year in the past will get a multiplier of about 1/(1+1) or 1/2,
- /// and date two years old will yield 1/(2+1) or 1/3.
- ///
- /// </para>
- /// </summary>
- /// <seealso cref= org.apache.lucene.queries.function.FunctionQuery
- ///
- /// </seealso>
- public class ReciprocalFloatFunction : ValueSource
- {
- protected internal readonly ValueSource source;
- protected internal readonly float m;
- protected internal readonly float a;
- protected internal readonly float b;
-
- /// <summary>
- /// f(source) = a/(m*float(source)+b)
- /// </summary>
- public ReciprocalFloatFunction(ValueSource source, float m, float a, float b)
- {
- this.source = source;
- this.m = m;
- this.a = a;
- this.b = b;
- }
-
-//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 vals = source.getValues(context, readerContext);
- FunctionValues vals = source.getValues(context, readerContext);
- return new FloatDocValuesAnonymousInnerClassHelper(this, this, vals);
- }
-
- private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
- {
- private readonly ReciprocalFloatFunction outerInstance;
-
- private FunctionValues vals;
-
- public FloatDocValuesAnonymousInnerClassHelper(ReciprocalFloatFunction outerInstance, org.apache.lucene.queries.function.valuesource.ReciprocalFloatFunction this, FunctionValues vals) : base(this)
- {
- this.outerInstance = outerInstance;
- this.vals = vals;
- }
-
- public override float floatVal(int doc)
- {
- return outerInstance.a / (outerInstance.m * vals.floatVal(doc) + outerInstance.b);
- }
- public override string ToString(int doc)
- {
- return Convert.ToString(outerInstance.a) + "/(" + outerInstance.m + "*float(" + vals.ToString(doc) + ')' + '+' + outerInstance.b + ')';
- }
- }
-
-//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)
- {
- source.createWeight(context, searcher);
- }
-
- public override string description()
- {
- return Convert.ToString(a) + "/(" + m + "*float(" + source.description() + ")" + "+" + b + ')';
- }
-
- public override int GetHashCode()
- {
- int h = float.floatToIntBits(a) + float.floatToIntBits(m);
- h ^= (h << 13) | ((int)((uint)h >> 20));
- return h + (float.floatToIntBits(b)) + source.GetHashCode();
- }
-
- public override bool Equals(object o)
- {
- if (typeof(ReciprocalFloatFunction) != o.GetType())
- {
- return false;
- }
- ReciprocalFloatFunction other = (ReciprocalFloatFunction)o;
- return this.m == other.m && this.a == other.a && this.b == other.b && this.source.Equals(other.source);
- }
- }
-
-}
\ No newline at end of file