Class DataType

java.lang.Object
com.yahoo.vespa.objects.Selectable
com.yahoo.vespa.objects.Identifiable
com.yahoo.document.DataType
All Implemented Interfaces:
Cloneable, Comparable<DataType>
Direct Known Subclasses:
AnnotationReferenceDataType, CollectionDataType, MapDataType, PrimitiveDataType, ReferenceDataType, StructuredDataType, TensorDataType

public abstract class DataType extends com.yahoo.vespa.objects.Identifiable implements Comparable<DataType>
Enumeration of the possible types of fields. Since arrays and weighted sets may be defined for any types, including themselves, this enumeration is open-ended.
Author:
bratseth
  • Field Details

  • Constructor Details

    • DataType

      protected DataType(String name, int dataTypeId)
      Creates a datatype
      Parameters:
      name - the name of the type
      dataTypeId - the id of the type
  • Method Details

    • lastPredefinedDataTypeId

      public static int lastPredefinedDataTypeId()
    • clone

      public DataType clone()
      Overrides:
      clone in class com.yahoo.vespa.objects.Identifiable
    • isRegistered

      public boolean isRegistered()
    • createFieldValue

      public abstract FieldValue createFieldValue()
      Creates a new, empty FieldValue of this type
    • createByReflection

      protected FieldValue createByReflection(Object arg)
      Creates a field value by reflection
      Parameters:
      arg - the value of the newly created field value
      Returns:
      a fully constructed value
    • createFieldValue

      public FieldValue createFieldValue(Object arg)
      Creates a new FieldValue of this type, with the given value.
      Parameters:
      arg - the value of the new FieldValue
      Returns:
      a new FieldValue of this type, with the given value
    • getValueClass

      public abstract Class getValueClass()
    • isValueCompatible

      public abstract boolean isValueCompatible(FieldValue value)
    • isAssignableFrom

      public boolean isAssignableFrom(DataType dataType)
    • isAssignableTo

      public boolean isAssignableTo(DataType dataType)
      The reverse of isAssignableFrom
    • getArray

      public static ArrayDataType getArray(DataType type)
      Returns an array datatype, where the array elements are of the given type
      Parameters:
      type - the type to create an array of
      Returns:
      the array data type
    • getMap

      public static MapDataType getMap(DataType key, DataType value)
      Returns a map datatype
      Parameters:
      key - the key type
      value - the value type
      Returns:
      the map data type
    • getWeightedSet

      public static WeightedSetDataType getWeightedSet(DataType type)
      Returns a weighted set datatype, where the elements are of the given type
      Parameters:
      type - the type to create a weighted set of
      Returns:
      the weighted set data type
    • getWeightedSet

      public static WeightedSetDataType getWeightedSet(DataType type, boolean createIfNonExistent, boolean removeIfZero)
      Returns a weighted set datatype, where the elements are of the given type, and which supports the properties createIfNonExistent and removeIfZero
      Parameters:
      type - the type to create a weighted set of
      createIfNonExistent - whether the type has createIfNonExistent
      removeIfZero - whether the type has removeIfZero
      Returns:
      the weighted set data type
    • getTensor

      public static TensorDataType getTensor(com.yahoo.tensor.TensorType type)
      Returns the given tensor type as a DataType
    • getName

      public String getName()
    • setName

      protected void setName(String name)
      Sets the name of this data type. WARNING! Do not use!
      Parameters:
      name - the name of this data type.
    • getId

      public int getId()
    • setId

      public void setId(int id)
      Sets the ID of this data type. WARNING! Do not use!
      Parameters:
      id - the ID of this data type.
    • register

      public final void register(DocumentTypeManager manager)
      Registers this type in the given document manager.
      Parameters:
      manager - the DocumentTypeManager to register in.
    • register

      protected void register(DocumentTypeManager manager, List<DataType> seenTypes)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class com.yahoo.vespa.objects.Identifiable
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class com.yahoo.vespa.objects.Identifiable
    • toString

      public String toString()
      Overrides:
      toString in class com.yahoo.vespa.objects.Identifiable
    • getCode

      public int getCode()
    • buildFieldPath

      public FieldPath buildFieldPath(String fieldPathString)
      Creates a field path from the given field path string.
      Parameters:
      fieldPathString - a string containing the field path
      Returns:
      Returns a valid field path, parsed from the string
    • getPrimitiveType

      public PrimitiveDataType getPrimitiveType()
      Returns the primitive datatype associated with this datatype, i.e. the type itself if this is a PrimitiveDataType, the nested type if this is a CollectionDataType or null for all other cases
      Returns:
      primitive data type, or null
    • getNestedType

      public DataType getNestedType()
      Returns the nested type of this if it is a collection type, null otherwise.
    • visitMembers

      public void visitMembers(com.yahoo.vespa.objects.ObjectVisitor visitor)
      Overrides:
      visitMembers in class com.yahoo.vespa.objects.Identifiable
    • compareTo

      public int compareTo(DataType dataType)
      Specified by:
      compareTo in interface Comparable<DataType>
    • isMultivalue

      public boolean isMultivalue()
      Returns whether this is a multivalue type, i.e either a CollectionDataType or a MapDataType