Class AbstractArrayContext
java.lang.Object
com.yahoo.searchlib.rankingexpression.evaluation.Context
com.yahoo.searchlib.rankingexpression.evaluation.AbstractArrayContext
- All Implemented Interfaces:
ContextIndex
,com.yahoo.tensor.evaluation.EvaluationContext<Reference>
,com.yahoo.tensor.evaluation.TypeContext<Reference>
,Cloneable
- Direct Known Subclasses:
ArrayContext
,DoubleOnlyArrayContext
Superclass of contexts which supports array index based lookup.
Instances may be reused indefinitely for evaluations of a single
ranking expression, in a single thread at the time.
- Author:
- bratseth
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractArrayContext
(RankingExpression expression) Create a fast lookup context for an expression.protected
AbstractArrayContext
(RankingExpression expression, boolean ignoreUnknownValues) protected
AbstractArrayContext
(RankingExpression expression, boolean ignoreUnknownValues, Value missingValue) Create a fast lookup context for an expression. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates a clone of this context suitable for evaluating against the same ranking expression in a different thread (i.e, name name to index map, different value set.protected final double[]
double
getDouble
(int index) Perform a fast lookup directly of the value as a double.final int
Returns the index from a name.protected final boolean
names()
Returns all the names available in this, or throws an UnsupportedOperationException if this operation is not supported.int
size()
Returns the max number of variables which may be set in thistoString()
Methods inherited from class com.yahoo.searchlib.rankingexpression.evaluation.Context
get, get, get, getTensor, getType, put, put
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.yahoo.searchlib.rankingexpression.evaluation.ContextIndex
get
Methods inherited from interface com.yahoo.tensor.evaluation.TypeContext
getType
-
Constructor Details
-
AbstractArrayContext
Create a fast lookup context for an expression. This instance should be reused indefinitely by a single thread. This will fail if unknown values are attempted added. -
AbstractArrayContext
-
AbstractArrayContext
protected AbstractArrayContext(RankingExpression expression, boolean ignoreUnknownValues, Value missingValue) Create a fast lookup context for an expression. This instance should be reused indefinitely by a single thread.- Parameters:
expression
- the expression to create a context forignoreUnknownValues
- whether attempts to put values not present in this expression should fail (false - the default), or be ignored (true)
-
-
Method Details
-
nameToIndex
-
doubleValues
protected final double[] doubleValues() -
ignoreUnknownValues
protected final boolean ignoreUnknownValues() -
names
Description copied from class:Context
Returns all the names available in this, or throws an UnsupportedOperationException if this operation is not supported. This default implementation does the latter. -
getIndex
Returns the index from a name.- Specified by:
getIndex
in interfaceContextIndex
- Throws:
NullPointerException
- is this name is not known to this context
-
size
public int size()Returns the max number of variables which may be set in this- Specified by:
size
in interfaceContextIndex
-
getDouble
public double getDouble(int index) Perform a fast lookup directly of the value as a double. This is faster than get(index).asDouble()- Specified by:
getDouble
in interfaceContextIndex
- Overrides:
getDouble
in classContext
- Parameters:
index
- the index of the variable whose value to return.- Returns:
- the value of the indexed variable.
-
toString
-
clone
Creates a clone of this context suitable for evaluating against the same ranking expression in a different thread (i.e, name name to index map, different value set.
-