Class Value
java.lang.Object
com.yahoo.searchlib.rankingexpression.evaluation.Value
- Direct Known Subclasses:
DoubleCompatibleValue,StringValue,TensorValue
The result of a ranking expression evaluation.
Concrete subclasses of this provides implementations of these methods or throws
UnsupportedOperationException if the operation is not supported.
- Author:
- bratseth
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Valueabstract Valueabstract ValueapproxEqual(Value value) abstract booleanReturns this value as a boolean.abstract doubleasDouble()Returns this value as a double, or throws UnsupportedOperationException if it cannot be represented as a doubleReturns this value as a double value, or throws UnsupportedOperationException if it cannot be represented as a doubleabstract ValueReturns this is mutable, or a mutable copy otherwiseabstract com.yahoo.tensor.TensorasTensor()Returns this as a tensor valueabstract Valueprotected com.yahoo.tensor.TensordoubleAsTensor(double value) A utility method for wrapping a double in a rank 0 tensorabstract Valueabstract booleanfreeze()Irreversibly makes this immutable.abstract ValuePerform the given binary function on this value and the given valueabstract booleanReturns true if this value can return itself as a double, i.e asDoubleValue will return a value and not throwabstract inthashCode()Returns a hash which only depends on the content of this value.final booleanisFrozen()Returns true if this is immutable, false otherwisebooleanisNaN()Returns true if this has a double value which is NaNabstract Valueabstract ValuelargerOrEqual(Value value) abstract Valueabstract Valueabstract Valuenegate()abstract Valuenot()abstract Valuestatic Valueof(double scalar) static Valueof(com.yahoo.tensor.Tensor tensor) abstract Valuestatic ValueParses the given string to a value and returns it.abstract Valueabstract Valueabstract ValuesmallerOrEqual(Value value) abstract Valueabstract StringtoString()abstract com.yahoo.tensor.TensorTypetype()Returns the type of this value
-
Constructor Details
-
Value
public Value()
-
-
Method Details
-
type
public abstract com.yahoo.tensor.TensorType type()Returns the type of this value -
asDouble
public abstract double asDouble()Returns this value as a double, or throws UnsupportedOperationException if it cannot be represented as a double -
asDoubleValue
Returns this value as a double value, or throws UnsupportedOperationException if it cannot be represented as a double -
isNaN
public boolean isNaN()Returns true if this has a double value which is NaN -
asTensor
public abstract com.yahoo.tensor.Tensor asTensor()Returns this as a tensor value -
doubleAsTensor
protected com.yahoo.tensor.Tensor doubleAsTensor(double value) A utility method for wrapping a double in a rank 0 tensor -
hasDouble
public abstract boolean hasDouble()Returns true if this value can return itself as a double, i.e asDoubleValue will return a value and not throw -
asBoolean
public abstract boolean asBoolean()Returns this value as a boolean. -
negate
-
not
-
or
-
and
-
largerOrEqual
-
larger
-
smallerOrEqual
-
smaller
-
approxEqual
-
notEqual
-
equal
-
add
-
subtract
-
multiply
-
divide
-
modulo
-
power
-
function
Perform the given binary function on this value and the given value -
freeze
Irreversibly makes this immutable. Overriders must always call super.freeze() and return this- Returns:
- this for convenience
-
isFrozen
public final boolean isFrozen()Returns true if this is immutable, false otherwise -
asMutable
Returns this is mutable, or a mutable copy otherwise -
toString
-
equals
-
hashCode
public abstract int hashCode()Returns a hash which only depends on the content of this value. -
parse
Parses the given string to a value and returns it. Different subtypes of Value will be returned depending on the string.- Returns:
- a mutable Value
- Throws:
IllegalArgumentException- if the given string is not parseable as a value
-
of
-
of
-