Package com.yahoo.search.result
Class FeatureData
java.lang.Object
com.yahoo.search.result.FeatureData
- All Implemented Interfaces:
com.yahoo.data.access.Inspectable
,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
-
Method Summary
Modifier and TypeMethodDescriptionstatic FeatureData
empty()
boolean
Returns the names of the features available in thisReturns the value of a scalar feature, or null if it is not present.com.yahoo.tensor.Tensor
Returns the value of a tensor feature, or null if it is not present.int
hashCode()
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()))
toJson()
Convenience method equivalent to writeJson(new StringBuilder()).toString()toJson
(boolean tensorShortForm) toJson
(boolean tensorShortForm, boolean tensorDirectValues) toString()
writeJson
(StringBuilder target) Append the JSON representation of this object's data to a StringBuilder.
-
Constructor Details
-
FeatureData
public FeatureData(com.yahoo.data.access.Inspector value)
-
-
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:
inspect
in interfacecom.yahoo.data.access.Inspectable
-
toJson
Description copied from interface:JsonProducer
Convenience method equivalent to writeJson(new StringBuilder()).toString()- Specified by:
toJson
in interfaceJsonProducer
- Returns:
- a String containing JSON representation of this object's data
-
toJson
-
toJson
-
writeJson
Description copied from interface:JsonProducer
Append the JSON representation of this object's data to a StringBuilder.- Specified by:
writeJson
in interfaceJsonProducer
- Parameters:
target
- the StringBuilder to append to- Returns:
- the target passed in is also returned (to allow chaining)
-
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. -
featureNames
Returns the names of the features available in this -
toString
-
hashCode
public int hashCode() -
equals
-