Class DoubleOnlyArrayContext
java.lang.Object
com.yahoo.searchlib.rankingexpression.evaluation.Context
com.yahoo.searchlib.rankingexpression.evaluation.AbstractArrayContext
com.yahoo.searchlib.rankingexpression.evaluation.DoubleOnlyArrayContext
- All Implemented Interfaces:
ContextIndex,com.yahoo.tensor.evaluation.EvaluationContext<Reference>,com.yahoo.tensor.evaluation.TypeContext<Reference>,Cloneable
A variant of an array context variant which supports faster binding of variables but slower lookup
from non-gbdt-optimized ranking expressions.
- Author:
- bratseth
-
Constructor Summary
ConstructorsConstructorDescriptionDoubleOnlyArrayContext(RankingExpression expression) Create a fast lookup context for an expression.DoubleOnlyArrayContext(RankingExpression expression, boolean ignoreUnknownValues) DoubleOnlyArrayContext(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.final Valueget(int index) Perform a faster lookup by indexPerform a slow lookup by namecom.yahoo.tensor.TensorTypefinal voidput(int index, double value) Same as put(index,DoubleValue.frozen(value))final voidPuts a value by index.final voidPuts a value by name.Methods inherited from class com.yahoo.searchlib.rankingexpression.evaluation.AbstractArrayContext
doubleValues, getDouble, getIndex, ignoreUnknownValues, names, nameToIndex, size, toString
-
Constructor Details
-
DoubleOnlyArrayContext
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. -
DoubleOnlyArrayContext
-
DoubleOnlyArrayContext
public DoubleOnlyArrayContext(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)missingValue- the value to return if not set.
-
-
Method Details
-
put
Puts a value by name. The value will be frozen if it isn't already.- Overrides:
putin classContext- Parameters:
name- the name of the variable to set.value- the value to set. Ownership of this value is transferred to this - if it is mutable (not frozen) it may be modified during execution- Throws:
IllegalArgumentException- if the name is not present in the ranking expression this was created with, and ignoredUnknownValues is false
-
put
public final void put(int index, double value) Same as put(index,DoubleValue.frozen(value)) -
put
Puts a value by index. -
getType
-
get
Perform a slow lookup by name -
get
Perform a faster lookup by index- Specified by:
getin interfaceContextIndex- Overrides:
getin classContext- Parameters:
index- the index of the variable whose value to return.- Returns:
- the value of the indexed variable.
-
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.- Overrides:
clonein classAbstractArrayContext
-