Exemplo n.º 1
0
		public override FunctionValues GetValues(IDictionary context, AtomicReaderContext
			 readerContext)
		{
			IDictionary<string, FunctionValues> valuesCache = (IDictionary<string, FunctionValues>)context["valuesCache"];
			if (valuesCache == null)
			{
				valuesCache = new Dictionary<string, FunctionValues>();
				context = new Hashtable(context);
				context["valuesCache"] = valuesCache;
			}
			FunctionValues[] externalValues = new FunctionValues[expression.variables.Length];
			for (int i = 0; i < variables.Length; ++i)
			{
				string externalName = expression.variables[i];
				FunctionValues values;
				if (!valuesCache.TryGetValue(externalName,out values))
				{
					values = variables[i].GetValues(context, readerContext);
					if (values == null)
					{
						throw new SystemException("Internal error. External (" + externalName + ") does not exist.");
					}
					valuesCache[externalName] = values;
				}
				externalValues[i] = values;
			}
			return new ExpressionFunctionValues(this, expression, externalValues);
		}
Exemplo n.º 2
0
 public ValueSourceScorerAnonymousInnerClassHelper4(FunctionValues outerInstance, IndexReader reader,
                                                    FunctionValues @this, float l, float u)
     : base(reader, @this)
 {
     this.outerInstance = outerInstance;
     this.l             = l;
     this.u             = u;
 }
Exemplo n.º 3
0
 protected internal ValueSourceScorer(IndexReader reader, FunctionValues values)
     : base(null)
 {
     this.reader   = reader;
     this.maxDoc   = reader.MaxDoc;
     this.values   = values;
     CheckDeletes  = true;
     this.liveDocs = MultiFields.GetLiveDocs(reader);
 }
Exemplo n.º 4
0
 protected internal ValueSourceScorer(IndexReader reader, FunctionValues values)
     : base(null)
 {
     this.reader = reader;
     this.maxDoc = reader.MaxDoc;
     this.values = values;
     CheckDeletes = true;
     this.liveDocs = MultiFields.GetLiveDocs(reader);
 }
Exemplo n.º 5
0
 public CustomScorer(BoostedQuery outerInstance, AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs)
     : base(w)
 {
     this.outerInstance = outerInstance;
     this.weight        = w;
     this.qWeight       = qWeight;
     this.scorer        = scorer;
     this.readerContext = readerContext;
     this.vals          = vs.GetValues(weight.fcontext, readerContext);
 }
Exemplo n.º 6
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public AllScorer(org.apache.lucene.index.AtomicReaderContext context, org.apache.lucene.util.Bits acceptDocs, FunctionWeight w, float qWeight) throws java.io.IOException
 public AllScorer(FunctionQuery outerInstance, AtomicReaderContext context, Bits acceptDocs, FunctionWeight w, float qWeight)
     : base(w)
 {
     this.outerInstance = outerInstance;
     this.weight        = w;
     this.qWeight       = qWeight;
     this.reader        = context.Reader;
     this.maxDoc        = reader.MaxDoc;
     this.acceptDocs    = acceptDocs;
     vals = outerInstance.func.GetValues(weight.context, context);
 }
 internal ExpressionFunctionValues(ValueSource parent, Expression expression, FunctionValues
     [] functionValues)
     : base(parent)
 {
     if (expression == null)
     {
         throw new ArgumentNullException();
     }
     if (functionValues == null)
     {
         throw new ArgumentNullException();
     }
     this.expression = expression;
     this.functionValues = functionValues;
 }
Exemplo n.º 8
0
            public override Explanation Explain(AtomicReaderContext readerContext, int doc)
            {
                Explanation subQueryExpl = qWeight.Explain(readerContext, doc);

                if (!subQueryExpl.IsMatch)
                {
                    return(subQueryExpl);
                }
                FunctionValues vals = outerInstance.boostVal.GetValues(fcontext, readerContext);
                float          sc   = subQueryExpl.Value * vals.SingleVal(doc);
                Explanation    res  = new ComplexExplanation(true, sc, outerInstance.ToString() + ", product of:");

                res.AddDetail(subQueryExpl);
                res.AddDetail(vals.Explain(doc));
                return(res);
            }
Exemplo n.º 9
0
 /// <summary>Evaluates the expression for the given document.</summary>
 /// <remarks>Evaluates the expression for the given document.</remarks>
 /// <param name="document"><code>docId</code> of the document to compute a value for</param>
 /// <param name="functionValues">
 /// 
 /// <see cref="Lucene.Net.Queries.Function.FunctionValues">Lucene.Net.Queries.Function.FunctionValues
 /// 	</see>
 /// for each element of
 /// <see cref="variables">variables</see>
 /// .
 /// </param>
 /// <returns>The computed value of the expression for the given document.</returns>
 public abstract double Evaluate(int document, FunctionValues[] functionValues);
Exemplo n.º 10
0
 public DoubleDocValuesAnonymousHelper(DistanceToShapeValueSource outerInstance, FunctionValues shapeValues)
     : base(outerInstance)
 {
     this.outerInstance = outerInstance;
     this.shapeValues = shapeValues;
 }
Exemplo n.º 11
0
 public AnonymousValueSourceScorer(IndexReader reader, FunctionValues functionValues, Func <int, bool> matchesValue)
     : base(reader, functionValues)
 {
     this.matchesValue = matchesValue ?? throw new ArgumentNullException(nameof(matchesValue));
 }
Exemplo n.º 12
0
 public CustomScorer(BoostedQuery outerInstance, AtomicReaderContext readerContext, BoostedQuery.BoostedWeight w, float qWeight, Scorer scorer, ValueSource vs)
     : base(w)
 {
     this.outerInstance = outerInstance;
     this.weight = w;
     this.qWeight = qWeight;
     this.scorer = scorer;
     this.readerContext = readerContext;
     this.vals = vs.GetValues(weight.fcontext, readerContext);
 }
Exemplo n.º 13
0
 public ValueFillerAnonymousInnerClassHelper(FunctionValues outerInstance)
 {
     this.outerInstance = outerInstance;
     mval = new MutableValueFloat();
 }
Exemplo n.º 14
0
 public ValueSourceScorerAnonymousInnerClassHelper4(FunctionValues outerInstance, IndexReader reader,
     FunctionValues @this, float l, float u)
     : base(reader, @this)
 {
     this.outerInstance = outerInstance;
     this.l = l;
     this.u = u;
 }
Exemplo n.º 15
0
 public ValueFillerAnonymousInnerClassHelper(FunctionValues outerInstance)
 {
     this.outerInstance = outerInstance;
     mval = new MutableValueFloat();
 }
Exemplo n.º 16
0
 public BoolDocValuesAnonymousHelper(ShapePredicateValueSource outerInstance, FunctionValues shapeValues)
     : base(outerInstance)
 {
     this.outerInstance = outerInstance;
     this.shapeValues = shapeValues;
 }
 /// <summary>
 /// Returns the weight for the current <paramref name="docId"/> as computed 
 /// by the <see cref="weightsValueSource"/>
 /// </summary>
 protected internal override long GetWeight(Document doc, int docId)
 {
     if (currentWeightValues == null)
     {
         return 0;
     }
     int subIndex = ReaderUtil.SubIndex(docId, starts);
     if (subIndex != currentLeafIndex)
     {
         currentLeafIndex = subIndex;
         try
         {
             currentWeightValues = outerInstance.weightsValueSource.GetValues(new Dictionary<string, object>(), leaves[currentLeafIndex]);
         }
         catch (IOException)
         {
             throw new Exception();
         }
     }
     return currentWeightValues.LongVal(docId - starts[subIndex]);
 }
 public DocumentValueSourceInputIterator(DocumentValueSourceDictionary outerInstance, bool hasPayloads, bool hasContexts)
     : base(outerInstance, hasPayloads, hasContexts)
 {
     this.outerInstance = outerInstance;
     leaves = outerInstance.reader.Leaves;
     starts = new int[leaves.Count + 1];
     for (int i = 0; i < leaves.Count; i++)
     {
         starts[i] = leaves[i].DocBase;
     }
     starts[leaves.Count] = outerInstance.reader.MaxDoc;
     currentWeightValues = (leaves.Count > 0) ? outerInstance.weightsValueSource.GetValues(new Dictionary<string, object>(), leaves[currentLeafIndex]) : null;
 }
Exemplo n.º 19
0
 public CachingDoubleFunctionValue(int docBase, FunctionValues vals, IDictionary<int, double> cache)
 {
     this.docBase = docBase;
     values = vals;
     this.cache = cache;
 }
Exemplo n.º 20
0
 public BitsAnonymousHelper(DocIdSetAnonymousHelper outerInstance, FunctionValues predFuncValues, AtomicReaderContext context, Bits acceptDocs)
 {
     this.outerInstance = outerInstance;
     this.predFuncValues = predFuncValues;
     this.context = context;
     this.acceptDocs = acceptDocs;
 }
Exemplo n.º 21
0
 public override FieldComparer SetNextReader(AtomicReaderContext context)
 {
     docVals = outerInstance.GetValues(fcontext, context);
     return(this);
 }
Exemplo n.º 22
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public AllScorer(org.apache.lucene.index.AtomicReaderContext context, org.apache.lucene.util.Bits acceptDocs, FunctionWeight w, float qWeight) throws java.io.IOException
 public AllScorer(FunctionQuery outerInstance, AtomicReaderContext context, Bits acceptDocs, FunctionWeight w, float qWeight)
     : base(w)
 {
     this.outerInstance = outerInstance;
     this.weight = w;
     this.qWeight = qWeight;
     this.reader = context.Reader;
     this.maxDoc = reader.MaxDoc;
     this.acceptDocs = acceptDocs;
     vals = outerInstance.func.GetValues(weight.context, context);
 }