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:41 UTC
[08/21] Moving ValueSource -> ValueSources to avoid name conflicts
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSources/TFValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/TFValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/TFValueSource.cs
new file mode 100644
index 0000000..df6be4c
--- /dev/null
+++ b/src/Lucene.Net.Queries/Function/ValueSources/TFValueSource.cs
@@ -0,0 +1,190 @@
+using System;
+using System.Collections;
+using org.apache.lucene.queries.function;
+using org.apache.lucene.queries.function.docvalues;
+
+namespace Lucene.Net.Queries.Function.ValueSources
+{
+
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Function that returns <seealso cref="TFIDFSimilarity#tf(float)"/>
+ /// 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 TFValueSource : TermFreqValueSource
+ {
+ public TFValueSource(string field, string val, string indexedField, BytesRef indexedBytes) : base(field, val, indexedField, indexedBytes)
+ {
+ }
+
+ public override string name()
+ {
+ return "tf";
+ }
+
+//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)
+ {
+ Fields fields = readerContext.reader().fields();
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final Terms terms = fields.terms(indexedField);
+ Terms terms = fields.terms(indexedField);
+ 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(), indexedField);
+ TFIDFSimilarity similarity = IDFValueSource.asTFIDF(searcher.Similarity, indexedField);
+ if (similarity == null)
+ {
+ throw new System.NotSupportedException("requires a TFIDFSimilarity (such as DefaultSimilarity)");
+ }
+
+ return new FloatDocValuesAnonymousInnerClassHelper(this, this, terms, similarity);
+ }
+
+ private class FloatDocValuesAnonymousInnerClassHelper : FloatDocValues
+ {
+ private readonly TFValueSource outerInstance;
+
+ private Terms terms;
+ private TFIDFSimilarity similarity;
+
+ public FloatDocValuesAnonymousInnerClassHelper(TFValueSource outerInstance, TFValueSource this, Terms terms, TFIDFSimilarity similarity) : base(this)
+ {
+ this.outerInstance = outerInstance;
+ this.terms = terms;
+ this.similarity = similarity;
+ lastDocRequested = -1;
+ }
+
+ internal DocsEnum docs;
+ internal int atDoc;
+ internal int lastDocRequested;
+
+//JAVA TO C# CONVERTER TODO TASK: Initialization blocks declared within anonymous inner classes are not converted:
+ // {
+ // reset();
+ // }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void reset() throws java.io.IOException
+ public virtual void reset()
+ {
+ // no one should call us for deleted docs?
+
+ if (terms != null)
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final TermsEnum termsEnum = terms.iterator(null);
+ TermsEnum termsEnum = terms.iterator(null);
+ if (termsEnum.seekExact(outerInstance.indexedBytes))
+ {
+ docs = termsEnum.docs(null, null);
+ }
+ else
+ {
+ docs = null;
+ }
+ }
+ else
+ {
+ docs = null;
+ }
+
+ if (docs == null)
+ {
+ docs = new DocsEnumAnonymousInnerClassHelper(this);
+ }
+ atDoc = -1;
+ }
+
+ private class DocsEnumAnonymousInnerClassHelper : DocsEnum
+ {
+ private readonly FloatDocValuesAnonymousInnerClassHelper outerInstance;
+
+ public DocsEnumAnonymousInnerClassHelper(FloatDocValuesAnonymousInnerClassHelper outerInstance)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+ public override int freq()
+ {
+ return 0;
+ }
+
+ public override int docID()
+ {
+ return DocIdSetIterator.NO_MORE_DOCS;
+ }
+
+ public override int nextDoc()
+ {
+ return DocIdSetIterator.NO_MORE_DOCS;
+ }
+
+ public override int advance(int target)
+ {
+ return DocIdSetIterator.NO_MORE_DOCS;
+ }
+
+ public override long cost()
+ {
+ return 0;
+ }
+ }
+
+ public override float floatVal(int doc)
+ {
+ try
+ {
+ if (doc < lastDocRequested)
+ {
+ // out-of-order access.... reset
+ reset();
+ }
+ lastDocRequested = doc;
+
+ if (atDoc < doc)
+ {
+ atDoc = docs.advance(doc);
+ }
+
+ if (atDoc > doc)
+ {
+ // term doesn't match this document... either because we hit the
+ // end, or because the next doc is after this doc.
+ return similarity.tf(0);
+ }
+
+ // a match!
+ return similarity.tf(docs.freq());
+ }
+ catch (IOException e)
+ {
+ throw new Exception("caught exception in function " + outerInstance.description() + " : doc=" + doc, e);
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSources/TermFreqValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/TermFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/TermFreqValueSource.cs
new file mode 100644
index 0000000..3a70309
--- /dev/null
+++ b/src/Lucene.Net.Queries/Function/ValueSources/TermFreqValueSource.cs
@@ -0,0 +1,180 @@
+/*
+ * 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 System;
+using System.Collections;
+using org.apache.lucene.queries.function;
+using org.apache.lucene.queries.function.docvalues;
+
+namespace Lucene.Net.Queries.Function.ValueSources
+{
+ /// <summary>
+ /// Function that returns <seealso cref="DocsEnum#freq()"/> for the
+ /// supplied term in every document.
+ /// <para>
+ /// If the term does not exist in the document, returns 0.
+ /// If frequencies are omitted, returns 1.
+ /// </para>
+ /// </summary>
+ public class TermFreqValueSource : DocFreqValueSource
+ {
+ public TermFreqValueSource(string field, string val, string indexedField, BytesRef indexedBytes) : base(field, val, indexedField, indexedBytes)
+ {
+ }
+
+ public override string name()
+ {
+ return "termfreq";
+ }
+
+//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)
+ {
+ Fields fields = readerContext.reader().fields();
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final Terms terms = fields.terms(indexedField);
+ Terms terms = fields.terms(indexedField);
+
+ return new IntDocValuesAnonymousInnerClassHelper(this, this, terms);
+ }
+
+ private class IntDocValuesAnonymousInnerClassHelper : IntDocValues
+ {
+ private readonly TermFreqValueSource outerInstance;
+
+ private Terms terms;
+
+ public IntDocValuesAnonymousInnerClassHelper(TermFreqValueSource outerInstance, TermFreqValueSource this, Terms terms) : base(this)
+ {
+ this.outerInstance = outerInstance;
+ this.terms = terms;
+ lastDocRequested = -1;
+ }
+
+ internal DocsEnum docs;
+ internal int atDoc;
+ internal int lastDocRequested;
+
+//JAVA TO C# CONVERTER TODO TASK: Initialization blocks declared within anonymous inner classes are not converted:
+ // {
+ // reset();
+ // }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void reset() throws java.io.IOException
+ public virtual void reset()
+ {
+ // no one should call us for deleted docs?
+
+ if (terms != null)
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final TermsEnum termsEnum = terms.iterator(null);
+ TermsEnum termsEnum = terms.iterator(null);
+ if (termsEnum.seekExact(outerInstance.indexedBytes))
+ {
+ docs = termsEnum.docs(null, null);
+ }
+ else
+ {
+ docs = null;
+ }
+ }
+ else
+ {
+ docs = null;
+ }
+
+ if (docs == null)
+ {
+ docs = new DocsEnumAnonymousInnerClassHelper(this);
+ }
+ atDoc = -1;
+ }
+
+ private class DocsEnumAnonymousInnerClassHelper : DocsEnum
+ {
+ private readonly IntDocValuesAnonymousInnerClassHelper outerInstance;
+
+ public DocsEnumAnonymousInnerClassHelper(IntDocValuesAnonymousInnerClassHelper outerInstance)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+ public override int freq()
+ {
+ return 0;
+ }
+
+ public override int docID()
+ {
+ return DocIdSetIterator.NO_MORE_DOCS;
+ }
+
+ public override int nextDoc()
+ {
+ return DocIdSetIterator.NO_MORE_DOCS;
+ }
+
+ public override int advance(int target)
+ {
+ return DocIdSetIterator.NO_MORE_DOCS;
+ }
+
+ public override long cost()
+ {
+ return 0;
+ }
+ }
+
+ public override int intVal(int doc)
+ {
+ try
+ {
+ if (doc < lastDocRequested)
+ {
+ // out-of-order access.... reset
+ reset();
+ }
+ lastDocRequested = doc;
+
+ if (atDoc < doc)
+ {
+ atDoc = docs.advance(doc);
+ }
+
+ if (atDoc > doc)
+ {
+ // term doesn't match this document... either because we hit the
+ // end, or because the next doc is after this doc.
+ return 0;
+ }
+
+ // a match!
+ return docs.freq();
+ }
+ catch (IOException e)
+ {
+ throw new Exception("caught exception in function " + outerInstance.description() + " : doc=" + doc, e);
+ }
+ }
+ }
+ }
+
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Function/ValueSources/TotalTermFreqValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/TotalTermFreqValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/TotalTermFreqValueSource.cs
new file mode 100644
index 0000000..24a5684
--- /dev/null
+++ b/src/Lucene.Net.Queries/Function/ValueSources/TotalTermFreqValueSource.cs
@@ -0,0 +1,120 @@
+/*
+ * 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 System.Collections;
+using org.apache.lucene.queries.function;
+using org.apache.lucene.queries.function.docvalues;
+
+namespace Lucene.Net.Queries.Function.ValueSources
+{
+ /// <summary>
+ /// <code>TotalTermFreqValueSource</code> returns the total term freq
+ /// (sum of term freqs across all documents).
+ /// Returns -1 if frequencies were omitted for the field, or if
+ /// the codec doesn't support this statistic.
+ /// @lucene.internal
+ /// </summary>
+ public class TotalTermFreqValueSource : ValueSource
+ {
+ protected internal readonly string field;
+ protected internal readonly string indexedField;
+ protected internal readonly string val;
+ protected internal readonly BytesRef indexedBytes;
+
+ public TotalTermFreqValueSource(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 "totaltermfreq";
+ }
+
+ 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)
+ {
+ return (FunctionValues)context[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)
+ {
+ long totalTermFreq = 0;
+ foreach (AtomicReaderContext readerContext in searcher.TopReaderContext.leaves())
+ {
+ long val = readerContext.reader().totalTermFreq(new Term(indexedField, indexedBytes));
+ if (val == -1)
+ {
+ totalTermFreq = -1;
+ break;
+ }
+ else
+ {
+ totalTermFreq += val;
+ }
+ }
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final long ttf = totalTermFreq;
+ long ttf = totalTermFreq;
+ context[this] = new LongDocValuesAnonymousInnerClassHelper(this, this, ttf);
+ }
+
+ private class LongDocValuesAnonymousInnerClassHelper : LongDocValues
+ {
+ private readonly TotalTermFreqValueSource outerInstance;
+
+ private long ttf;
+
+ public LongDocValuesAnonymousInnerClassHelper(TotalTermFreqValueSource outerInstance, TotalTermFreqValueSource this, long ttf) : base(this)
+ {
+ this.outerInstance = outerInstance;
+ this.ttf = ttf;
+ }
+
+ public override long longVal(int doc)
+ {
+ return ttf;
+ }
+ }
+
+ 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;
+ }
+ TotalTermFreqValueSource other = (TotalTermFreqValueSource)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/ValueSources/VectorValueSource.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs b/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs
new file mode 100644
index 0000000..683e5df
--- /dev/null
+++ b/src/Lucene.Net.Queries/Function/ValueSources/VectorValueSource.cs
@@ -0,0 +1,288 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+using org.apache.lucene.queries.function;
+
+namespace Lucene.Net.Queries.Function.ValueSources
+{
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Converts individual ValueSource instances to leverage the FunctionValues *Val functions that work with multiple values,
+ /// i.e. <seealso cref="org.apache.lucene.queries.function.FunctionValues#doubleVal(int, double[])"/>
+ /// </summary>
+ //Not crazy about the name, but...
+ public class VectorValueSource : MultiValueSource
+ {
+ protected internal readonly IList<ValueSource> sources;
+
+
+ public VectorValueSource(IList<ValueSource> sources)
+ {
+ this.sources = sources;
+ }
+
+ public virtual IList<ValueSource> Sources
+ {
+ get
+ {
+ return sources;
+ }
+ }
+
+ public override int dimension()
+ {
+ return sources.Count;
+ }
+
+ public virtual string name()
+ {
+ return "vector";
+ }
+
+//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)
+ {
+ int size = sources.Count;
+
+ // special-case x,y and lat,lon since it's so common
+ if (size == 2)
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.queries.function.FunctionValues x = sources.get(0).getValues(context, readerContext);
+ FunctionValues x = sources[0].getValues(context, readerContext);
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.queries.function.FunctionValues y = sources.get(1).getValues(context, readerContext);
+ FunctionValues y = sources[1].getValues(context, readerContext);
+ return new FunctionValuesAnonymousInnerClassHelper(this, x, y);
+ }
+
+
+//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[size];
+ FunctionValues[] valsArr = new FunctionValues[size];
+ for (int i = 0; i < size; i++)
+ {
+ valsArr[i] = sources[i].getValues(context, readerContext);
+ }
+
+ return new FunctionValuesAnonymousInnerClassHelper2(this, valsArr);
+ }
+
+ private class FunctionValuesAnonymousInnerClassHelper : FunctionValues
+ {
+ private readonly VectorValueSource outerInstance;
+
+ private FunctionValues x;
+ private FunctionValues y;
+
+ public FunctionValuesAnonymousInnerClassHelper(VectorValueSource outerInstance, FunctionValues x, FunctionValues y)
+ {
+ this.outerInstance = outerInstance;
+ this.x = x;
+ this.y = y;
+ }
+
+ public override void byteVal(int doc, sbyte[] vals)
+ {
+ vals[0] = x.byteVal(doc);
+ vals[1] = y.byteVal(doc);
+ }
+
+ public override void shortVal(int doc, short[] vals)
+ {
+ vals[0] = x.shortVal(doc);
+ vals[1] = y.shortVal(doc);
+ }
+ public override void intVal(int doc, int[] vals)
+ {
+ vals[0] = x.intVal(doc);
+ vals[1] = y.intVal(doc);
+ }
+ public override void longVal(int doc, long[] vals)
+ {
+ vals[0] = x.longVal(doc);
+ vals[1] = y.longVal(doc);
+ }
+ public override void floatVal(int doc, float[] vals)
+ {
+ vals[0] = x.floatVal(doc);
+ vals[1] = y.floatVal(doc);
+ }
+ public override void doubleVal(int doc, double[] vals)
+ {
+ vals[0] = x.doubleVal(doc);
+ vals[1] = y.doubleVal(doc);
+ }
+ public override void strVal(int doc, string[] vals)
+ {
+ vals[0] = x.strVal(doc);
+ vals[1] = y.strVal(doc);
+ }
+ public override string ToString(int doc)
+ {
+ return outerInstance.name() + "(" + x.ToString(doc) + "," + y.ToString(doc) + ")";
+ }
+ }
+
+ private class FunctionValuesAnonymousInnerClassHelper2 : FunctionValues
+ {
+ private readonly VectorValueSource outerInstance;
+
+ private FunctionValues[] valsArr;
+
+ public FunctionValuesAnonymousInnerClassHelper2(VectorValueSource outerInstance, FunctionValues[] valsArr)
+ {
+ this.outerInstance = outerInstance;
+ this.valsArr = valsArr;
+ }
+
+ public override void byteVal(int doc, sbyte[] vals)
+ {
+ for (int i = 0; i < valsArr.Length; i++)
+ {
+ vals[i] = valsArr[i].byteVal(doc);
+ }
+ }
+
+ public override void shortVal(int doc, short[] vals)
+ {
+ for (int i = 0; i < valsArr.Length; i++)
+ {
+ vals[i] = valsArr[i].shortVal(doc);
+ }
+ }
+
+ public override void floatVal(int doc, float[] vals)
+ {
+ for (int i = 0; i < valsArr.Length; i++)
+ {
+ vals[i] = valsArr[i].floatVal(doc);
+ }
+ }
+
+ public override void intVal(int doc, int[] vals)
+ {
+ for (int i = 0; i < valsArr.Length; i++)
+ {
+ vals[i] = valsArr[i].intVal(doc);
+ }
+ }
+
+ public override void longVal(int doc, long[] vals)
+ {
+ for (int i = 0; i < valsArr.Length; i++)
+ {
+ vals[i] = valsArr[i].longVal(doc);
+ }
+ }
+
+ public override void doubleVal(int doc, double[] vals)
+ {
+ for (int i = 0; i < valsArr.Length; i++)
+ {
+ vals[i] = valsArr[i].doubleVal(doc);
+ }
+ }
+
+ public override void strVal(int doc, string[] vals)
+ {
+ for (int i = 0; i < valsArr.Length; i++)
+ {
+ vals[i] = valsArr[i].strVal(doc);
+ }
+ }
+
+ 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 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();
+ }
+
+ public override bool Equals(object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (!(o is VectorValueSource))
+ {
+ return false;
+ }
+
+ VectorValueSource that = (VectorValueSource) o;
+
+ return sources.Equals(that.sources);
+
+ }
+
+ public override int GetHashCode()
+ {
+ return sources.GetHashCode();
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2b55e53c/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj b/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj
index 6856c74..9818bc3 100644
--- a/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj
+++ b/src/Lucene.Net.Queries/Lucene.Net.Queries.csproj
@@ -58,54 +58,54 @@
<Compile Include="Function\FunctionValues.cs" />
<Compile Include="Function\ValueSource.cs" />
<Compile Include="Function\ValueSourceScorer.cs" />
- <Compile Include="Function\ValueSource\BoolFunction.cs" />
- <Compile Include="Function\ValueSource\ByteFieldSource.cs" />
- <Compile Include="Function\ValueSource\BytesRefFieldSource.cs" />
- <Compile Include="Function\ValueSource\ConstNumberSource.cs" />
- <Compile Include="Function\ValueSource\ConstValueSource.cs" />
- <Compile Include="Function\ValueSource\DefFunction.cs" />
- <Compile Include="Function\ValueSource\DivFloatFunction.cs" />
- <Compile Include="Function\ValueSource\DocFreqValueSource.cs" />
- <Compile Include="Function\ValueSource\DoubleConstValueSource.cs" />
- <Compile Include="Function\ValueSource\DoubleFieldSource.cs" />
- <Compile Include="Function\ValueSource\DualFloatFunction.cs" />
- <Compile Include="Function\ValueSource\EnumFieldSource.cs" />
- <Compile Include="Function\ValueSource\FieldCacheSource.cs" />
- <Compile Include="Function\ValueSource\FloatFieldSource.cs" />
- <Compile Include="Function\ValueSource\IDFValueSource.cs" />
- <Compile Include="Function\ValueSource\IfFunction.cs" />
- <Compile Include="Function\ValueSource\IntFieldSource.cs" />
- <Compile Include="Function\ValueSource\JoinDocFreqValueSource.cs" />
- <Compile Include="Function\ValueSource\LinearFloatFunction.cs" />
- <Compile Include="Function\ValueSource\LiteralValueSource.cs" />
- <Compile Include="Function\ValueSource\LongFieldSource.cs" />
- <Compile Include="Function\ValueSource\MaxDocValueSource.cs" />
- <Compile Include="Function\ValueSource\MaxFloatFunction.cs" />
- <Compile Include="Function\ValueSource\MinFloatFunction.cs" />
- <Compile Include="Function\ValueSource\MultiBoolFunction.cs" />
- <Compile Include="Function\ValueSource\MultiFloatFunction.cs" />
- <Compile Include="Function\ValueSource\MultiFunction.cs" />
- <Compile Include="Function\ValueSource\MultiValueSource.cs" />
- <Compile Include="Function\ValueSource\NormValueSource.cs" />
- <Compile Include="Function\ValueSource\NumDocsValueSource.cs" />
- <Compile Include="Function\ValueSource\OrdFieldSource.cs" />
- <Compile Include="Function\ValueSource\PowFloatFunction.cs" />
- <Compile Include="Function\ValueSource\ProductFloatFunction.cs" />
- <Compile Include="Function\ValueSource\QueryValueSource.cs" />
- <Compile Include="Function\ValueSource\RangeMapFloatFunction.cs" />
- <Compile Include="Function\ValueSource\ReciprocalFloatFunction.cs" />
- <Compile Include="Function\ValueSource\ReverseOrdFieldSource.cs" />
- <Compile Include="Function\ValueSource\ScaleFloatFunction.cs" />
- <Compile Include="Function\ValueSource\ShortFieldSource.cs" />
- <Compile Include="Function\ValueSource\SimpleBoolFunction.cs" />
- <Compile Include="Function\ValueSource\SimpleFloatFunction.cs" />
- <Compile Include="Function\ValueSource\SingleFunction.cs" />
- <Compile Include="Function\ValueSource\SumFloatFunction.cs" />
- <Compile Include="Function\ValueSource\SumTotalTermFreqValueSource.cs" />
- <Compile Include="Function\ValueSource\TermFreqValueSource.cs" />
- <Compile Include="Function\ValueSource\TFValueSource.cs" />
- <Compile Include="Function\ValueSource\TotalTermFreqValueSource.cs" />
- <Compile Include="Function\ValueSource\VectorValueSource.cs" />
+ <Compile Include="Function\ValueSources\BoolFunction.cs" />
+ <Compile Include="Function\ValueSources\ByteFieldSource.cs" />
+ <Compile Include="Function\ValueSources\BytesRefFieldSource.cs" />
+ <Compile Include="Function\ValueSources\ConstNumberSource.cs" />
+ <Compile Include="Function\ValueSources\ConstValueSource.cs" />
+ <Compile Include="Function\ValueSources\DefFunction.cs" />
+ <Compile Include="Function\ValueSources\DivFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\DocFreqValueSource.cs" />
+ <Compile Include="Function\ValueSources\DoubleConstValueSource.cs" />
+ <Compile Include="Function\ValueSources\DoubleFieldSource.cs" />
+ <Compile Include="Function\ValueSources\DualFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\EnumFieldSource.cs" />
+ <Compile Include="Function\ValueSources\FieldCacheSource.cs" />
+ <Compile Include="Function\ValueSources\FloatFieldSource.cs" />
+ <Compile Include="Function\ValueSources\IDFValueSource.cs" />
+ <Compile Include="Function\ValueSources\IfFunction.cs" />
+ <Compile Include="Function\ValueSources\IntFieldSource.cs" />
+ <Compile Include="Function\ValueSources\JoinDocFreqValueSource.cs" />
+ <Compile Include="Function\ValueSources\LinearFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\LiteralValueSource.cs" />
+ <Compile Include="Function\ValueSources\LongFieldSource.cs" />
+ <Compile Include="Function\ValueSources\MaxDocValueSource.cs" />
+ <Compile Include="Function\ValueSources\MaxFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\MinFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\MultiBoolFunction.cs" />
+ <Compile Include="Function\ValueSources\MultiFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\MultiFunction.cs" />
+ <Compile Include="Function\ValueSources\MultiValueSource.cs" />
+ <Compile Include="Function\ValueSources\NormValueSource.cs" />
+ <Compile Include="Function\ValueSources\NumDocsValueSource.cs" />
+ <Compile Include="Function\ValueSources\OrdFieldSource.cs" />
+ <Compile Include="Function\ValueSources\PowFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\ProductFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\QueryValueSource.cs" />
+ <Compile Include="Function\ValueSources\RangeMapFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\ReciprocalFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\ReverseOrdFieldSource.cs" />
+ <Compile Include="Function\ValueSources\ScaleFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\ShortFieldSource.cs" />
+ <Compile Include="Function\ValueSources\SimpleBoolFunction.cs" />
+ <Compile Include="Function\ValueSources\SimpleFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\SingleFunction.cs" />
+ <Compile Include="Function\ValueSources\SumFloatFunction.cs" />
+ <Compile Include="Function\ValueSources\SumTotalTermFreqValueSource.cs" />
+ <Compile Include="Function\ValueSources\TermFreqValueSource.cs" />
+ <Compile Include="Function\ValueSources\TFValueSource.cs" />
+ <Compile Include="Function\ValueSources\TotalTermFreqValueSource.cs" />
+ <Compile Include="Function\ValueSources\VectorValueSource.cs" />
<Compile Include="Mlt\MoreLikeThis.cs" />
<Compile Include="Mlt\MoreLikeThisQuery.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />