/// <summary>This method is unused, it is just here to make sure that the function signatures don't change.</summary> /// <remarks> /// This method is unused, it is just here to make sure that the function signatures don't change. /// If this method fails to compile, you also have to change the byte code generator to correctly /// use the <see cref="FunctionValues"/> class. /// </remarks> #pragma warning disable IDE0051 // Remove unused private members private static void UnusedTestCompile() #pragma warning restore IDE0051 // Remove unused private members { FunctionValues f = null; /*double ret = */ f.DoubleVal(2); // LUCENENET: IDE0059: Remove unnecessary value assignment }
public override double DoubleVal(int doc) { int key = docBase + doc; if (!cache.TryGetValue(key, out double v)) { v = values.DoubleVal(doc); cache[key] = v; } return(v); }
public virtual void TestTypes() { Expression expr = JavascriptCompiler.Compile("2*popularity"); SimpleBindings bindings = new SimpleBindings(); bindings.Add(new SortField("popularity", SortFieldType.INT64)); ValueSource vs = expr.GetValueSource(bindings); Assert.AreEqual(1, reader.Leaves.Count); AtomicReaderContext leaf = reader.Leaves[0]; FunctionValues values = vs.GetValues(new Dictionary <string, object>(), leaf); Assert.AreEqual(10, values.DoubleVal(0), 0); Assert.AreEqual(10, values.SingleVal(0), 0); Assert.AreEqual(10, values.Int64Val(0)); Assert.AreEqual(10, values.Int32Val(0)); Assert.AreEqual(10, values.Int16Val(0)); Assert.AreEqual((byte)10, values.ByteVal(0)); Assert.AreEqual("10.0", values.StrVal(0)); Assert.AreEqual(J2N.Numerics.Double.GetInstance(10), values.ObjectVal(0)); Assert.AreEqual(40, values.DoubleVal(1), 0); Assert.AreEqual(40, values.SingleVal(1), 0); Assert.AreEqual(40, values.Int64Val(1)); Assert.AreEqual(40, values.Int32Val(1)); Assert.AreEqual(40, values.Int16Val(1)); Assert.AreEqual((byte)40, values.ByteVal(1)); Assert.AreEqual("40.0", values.StrVal(1)); Assert.AreEqual(J2N.Numerics.Double.GetInstance(40), values.ObjectVal(1)); Assert.AreEqual(4, values.DoubleVal(2), 0); Assert.AreEqual(4, values.SingleVal(2), 0); Assert.AreEqual(4, values.Int64Val(2)); Assert.AreEqual(4, values.Int32Val(2)); Assert.AreEqual(4, values.Int16Val(2)); Assert.AreEqual((byte)4, values.ByteVal(2)); Assert.AreEqual("4.0", values.StrVal(2)); Assert.AreEqual(J2N.Numerics.Double.GetInstance(4), values.ObjectVal(2)); }
public virtual void TestTypes() { Expression expr = JavascriptCompiler.Compile("2*popularity"); SimpleBindings bindings = new SimpleBindings(); bindings.Add(new SortField("popularity", SortField.Type_e.LONG)); ValueSource vs = expr.GetValueSource(bindings); AreEqual(1, reader.Leaves.Count); AtomicReaderContext leaf = reader.Leaves[0]; FunctionValues values = vs.GetValues(new Dictionary <string, object>(), leaf); AreEqual(10, values.DoubleVal(0), 0); AreEqual(10, values.FloatVal(0), 0); AreEqual(10, values.LongVal(0)); AreEqual(10, values.IntVal(0)); AreEqual(10, values.ShortVal(0)); AreEqual(10, values.ByteVal(0)); AreEqual("10", values.StrVal(0)); AreEqual(System.Convert.ToDouble(10), values.ObjectVal(0)); AreEqual(40, values.DoubleVal(1), 0); AreEqual(40, values.FloatVal(1), 0); AreEqual(40, values.LongVal(1)); AreEqual(40, values.IntVal(1)); AreEqual(40, values.ShortVal(1)); AreEqual(40, values.ByteVal(1)); AreEqual("40", values.StrVal(1)); AreEqual(System.Convert.ToDouble(40), values.ObjectVal(1)); AreEqual(4, values.DoubleVal(2), 0); AreEqual(4, values.FloatVal(2), 0); AreEqual(4, values.LongVal(2)); AreEqual(4, values.IntVal(2)); AreEqual(4, values.ShortVal(2)); AreEqual(4, values.ByteVal(2)); AreEqual("4", values.StrVal(2)); AreEqual(System.Convert.ToDouble(4), values.ObjectVal(2)); }
private void SumValues(IList <MatchingDocs> matchingDocs, bool keepScores, ValueSource valueSource) { FakeScorer scorer = new FakeScorer(); IDictionary context = new Dictionary <string, Scorer>(); if (keepScores) { context["scorer"] = scorer; } Int32sRef scratch = new Int32sRef(); foreach (MatchingDocs hits in matchingDocs) { OrdinalsReader.OrdinalsSegmentReader ords = ordinalsReader.GetReader(hits.Context); int scoresIdx = 0; float[] scores = hits.Scores; FunctionValues functionValues = valueSource.GetValues(context, hits.Context); DocIdSetIterator docs = hits.Bits.GetIterator(); int doc; while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { ords.Get(doc, scratch); if (keepScores) { scorer.docID = doc; scorer.score = scores[scoresIdx++]; } float value = (float)functionValues.DoubleVal(doc); for (int i = 0; i < scratch.Length; i++) { m_values[scratch.Int32s[i]] += value; } } } Rollup(); }
public override double DoubleVal(int doc) { return(ifVals.BoolVal(doc) ? trueVals.DoubleVal(doc) : falseVals.DoubleVal(doc)); }
protected override bool Match(int doc) { double val = values.DoubleVal(doc); return(val >= outerInstance.min && val <= outerInstance.max); }
public override int CompareBottom(int doc) { // LUCENENET specific - use JCG comparer to get the same logic as Java return(JCG.Comparer <double> .Default.Compare(bottom, scores.DoubleVal(doc))); }
public override void DoubleVal(int doc, double[] vals) { vals[0] = x.DoubleVal(doc); vals[1] = y.DoubleVal(doc); }
/// <summary>This method is unused, it is just here to make sure that the function signatures don't change.</summary> /// <remarks> /// This method is unused, it is just here to make sure that the function signatures don't change. /// If this method fails to compile, you also have to change the byte code generator to correctly /// use the <see cref="FunctionValues"/> class. /// </remarks> private static void UnusedTestCompile() { FunctionValues f = null; double ret = f.DoubleVal(2); }
public override int CompareBottom(int doc) { return(bottom.CompareTo(scores.DoubleVal(doc))); }
private void Count(ValueSource valueSource, IEnumerable <MatchingDocs> matchingDocs) { DoubleRange[] ranges = (DoubleRange[])this.m_ranges; Int64Range[] longRanges = new Int64Range[ranges.Length]; for (int i = 0; i < ranges.Length; i++) { DoubleRange range = ranges[i]; longRanges[i] = new Int64Range(range.Label, NumericUtils.DoubleToSortableInt64(range.minIncl), true, NumericUtils.DoubleToSortableInt64(range.maxIncl), true); } Int64RangeCounter counter = new Int64RangeCounter(longRanges); int missingCount = 0; foreach (MatchingDocs hits in matchingDocs) { FunctionValues fv = valueSource.GetValues(new Dictionary <string, object>(), hits.Context); m_totCount += hits.TotalHits; IBits bits; if (m_fastMatchFilter != null) { DocIdSet dis = m_fastMatchFilter.GetDocIdSet(hits.Context, null); if (dis == null) { // No documents match continue; } bits = dis.Bits; if (bits == null) { throw new System.ArgumentException("fastMatchFilter does not implement DocIdSet.bits"); } } else { bits = null; } DocIdSetIterator docs = hits.Bits.GetIterator(); int doc; while ((doc = docs.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { if (bits != null && bits.Get(doc) == false) { doc++; continue; } // Skip missing docs: if (fv.Exists(doc)) { counter.Add(NumericUtils.DoubleToSortableInt64(fv.DoubleVal(doc))); } else { missingCount++; } } } missingCount += counter.FillCounts(m_counts); m_totCount -= missingCount; }
public override bool Match(int doc) { double val = values.DoubleVal(doc); return(val >= enclosingFilter.min && val <= enclosingFilter.max); }