Class FeatureData

  • All Implemented Interfaces:
    com.yahoo.data.access.Inspectable, JsonProducer

    public class FeatureData
    extends java.lang.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.
    • Constructor Summary

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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static FeatureData empty()  
      boolean equals​(java.lang.Object other)  
      java.util.Set<java.lang.String> featureNames()
      Returns the names of the features available in this
      java.lang.Double getDouble​(java.lang.String featureName)
      Returns the value of a scalar feature, or null if it is not present.
      com.yahoo.tensor.Tensor getTensor​(java.lang.String featureName)
      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 using com.yahoo.tensor.serialization.TypedBinaryFormat.decode(Optional.empty(), GrowableByteBuffer.wrap(featureValue.asData()))
      java.lang.String toJson()
      Convenience method equivalent to: writeJson(new StringBuilder()).toString()
      java.lang.String toString()  
      java.lang.StringBuilder writeJson​(java.lang.StringBuilder target)
      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 Detail

      • FeatureData

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

      • 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 java.lang.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.
      • writeJson

        public java.lang.StringBuilder writeJson​(java.lang.StringBuilder target)
        Description copied from interface: JsonProducer
        Append the JSON representation of this object's data to a StringBuilder. Note that when passing compact=false the generated string will be human-readable and containing embedded newlines; also the exact indentation etc may change, so use compact=true for a canonical format.
        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 java.lang.Double getDouble​(java.lang.String featureName)
        Returns the value of a scalar feature, or null if it is not present.
        Throws:
        java.lang.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​(java.lang.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 java.util.Set<java.lang.String> featureNames()
        Returns the names of the features available in this
      • toString

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

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

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object