Package com.yahoo.search.result
Class FeatureData
java.lang.Object
com.yahoo.search.result.FeatureData
- All Implemented Interfaces:
com.yahoo.data.access.Inspectable,com.yahoo.data.JsonProducer
public class FeatureData
extends Object
implements com.yahoo.data.access.Inspectable, com.yahoo.data.JsonProducer
A wrapper for structured data representing feature values: A map of floats and tensors.
This class is immutable but not thread safe.
- Author:
- bratseth
-
Constructor Summary
ConstructorsConstructorDescriptionFeatureData(com.yahoo.data.access.Inspector encodedValues) FeatureData(Map<String, com.yahoo.tensor.Tensor> values) Creates a feature data from a map of values. -
Method Summary
Modifier and TypeMethodDescriptionstatic FeatureDataempty()booleanReturns the names of the features available in thisReturns the value of a scalar feature, or null if it is not present.com.yahoo.tensor.TensorReturns the value of a tensor feature, or null if it is not present.inthashCode()com.yahoo.data.access.Inspectorinspect()Returns the fields of this as an inspector, where tensors are represented as binary data which can be decoded usingcom.yahoo.tensor.serialization.TypedBinaryFormat.decode(Optional.empty(), GrowableByteBuffer.wrap(featureValue.asData()))booleanisEmpty()voidSets a new or modified value in this.voidSets a new or modified value in this.toJson()toJson(boolean tensorShortForm) toJson(boolean tensorShortForm, boolean tensorDirectValues) toJson(com.yahoo.tensor.serialization.JsonFormat.EncodeOptions tensorOptions) toString()writeJson(StringBuilder target)
-
Constructor Details
-
FeatureData
public FeatureData(com.yahoo.data.access.Inspector encodedValues) -
FeatureData
Creates a feature data from a map of values.
-
-
Method Details
-
empty
-
inspect
public com.yahoo.data.access.Inspector inspect()Returns the fields of this as an inspector, where tensors are represented as binary data which can be decoded usingcom.yahoo.tensor.serialization.TypedBinaryFormat.decode(Optional.empty(), GrowableByteBuffer.wrap(featureValue.asData()))- Specified by:
inspectin interfacecom.yahoo.data.access.Inspectable
-
toJson
- Specified by:
toJsonin interfacecom.yahoo.data.JsonProducer
-
toJson
-
toJson
-
toJson
-
writeJson
- Specified by:
writeJsonin interfacecom.yahoo.data.JsonProducer
-
getDouble
Returns the value of a scalar feature, or null if it is not present.- Throws:
IllegalArgumentException- if the value exists but isn't a scalar (that is, if it is a tensor with nonzero rank)
-
getTensor
Returns the value of a tensor feature, or null if it is not present. This will return any feature value: Scalars are returned as a rank 0 tensor. -
set
Sets a new or modified value in this. -
set
Sets a new or modified value in this. -
isEmpty
public boolean isEmpty() -
featureNames
Returns the names of the features available in this -
toString
-
hashCode
public int hashCode() -
equals
-