Class FeatureData

java.lang.Object
com.yahoo.search.result.FeatureData
All Implemented Interfaces:
com.yahoo.data.access.Inspectable, JsonProducer

public class FeatureData extends Object implements 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

    Constructors
    Constructor
    Description
    FeatureData(com.yahoo.data.access.Inspector value)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    boolean
    equals(Object other)
     
    Returns the names of the features available in this
    getDouble(String featureName)
    Returns the value of a scalar feature, or null if it is not present.
    com.yahoo.tensor.Tensor
    getTensor(String featureName)
    Returns the value of a tensor feature, or null if it is not present.
    int
     
    com.yahoo.data.access.Inspector
    Returns the fields of this as an inspector, where tensors are represented as binary data which can be decoded using com.yahoo.tensor.serialization.TypedBinaryFormat.decode(Optional.empty(), GrowableByteBuffer.wrap(featureValue.asData()))
    Convenience method equivalent to writeJson(new StringBuilder()).toString()
    toJson(boolean tensorShortForm)
     
    toJson(boolean tensorShortForm, boolean tensorDirectValues)
     
     
    Append the JSON representation of this object's data to a StringBuilder.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FeatureData

      public FeatureData(com.yahoo.data.access.Inspector value)
  • Method Details

    • empty

      public static FeatureData 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 using com.yahoo.tensor.serialization.TypedBinaryFormat.decode(Optional.empty(), GrowableByteBuffer.wrap(featureValue.asData()))
      Specified by:
      inspect in interface com.yahoo.data.access.Inspectable
    • toJson

      public String toJson()
      Description copied from interface: JsonProducer
      Convenience method equivalent to writeJson(new StringBuilder()).toString()
      Specified by:
      toJson in interface JsonProducer
      Returns:
      a String containing JSON representation of this object's data
    • toJson

      public String toJson(boolean tensorShortForm)
    • toJson

      public String toJson(boolean tensorShortForm, boolean tensorDirectValues)
    • writeJson

      public StringBuilder writeJson(StringBuilder target)
      Description copied from interface: JsonProducer
      Append the JSON representation of this object's data to a StringBuilder.
      Specified by:
      writeJson in interface JsonProducer
      Parameters:
      target - the StringBuilder to append to
      Returns:
      the target passed in is also returned (to allow chaining)
    • getDouble

      public Double getDouble(String featureName)
      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

      public com.yahoo.tensor.Tensor getTensor(String featureName)
      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

      public Set<String> featureNames()
      Returns the names of the features available in this
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object