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
ConstructorsModifierConstructorDescriptionprotectedAbstractArrayContext(RankingExpression expression) Create a fast lookup context for an expression.protectedAbstractArrayContext(RankingExpression expression, boolean ignoreUnknownValues) protectedAbstractArrayContext(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[]doublegetDouble(int index) Perform a fast lookup directly of the value as a double.final intReturns the index from a name.protected final booleannames()Returns all the names available in this, or throws an UnsupportedOperationException if this operation is not supported.intsize()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, putMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.yahoo.searchlib.rankingexpression.evaluation.ContextIndex
getMethods 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:ContextReturns 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:
getIndexin 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:
sizein 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:
getDoublein interfaceContextIndex- Overrides:
getDoublein 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.
-