Package com.yahoo.document
Class DataType
- java.lang.Object
-
- com.yahoo.vespa.objects.Selectable
-
- com.yahoo.vespa.objects.Identifiable
-
- com.yahoo.document.DataType
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<DataType>
- Direct Known Subclasses:
AnnotationReferenceDataType
,CollectionDataType
,MapDataType
,PrimitiveDataType
,ReferenceDataType
,StructuredDataType
,TensorDataType
public abstract class DataType extends com.yahoo.vespa.objects.Identifiable implements Serializable, 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
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static PrimitiveDataType
BOOL
static NumericDataType
BYTE
static int
classId
static DocumentType
DOCUMENT
static NumericDataType
DOUBLE
static NumericDataType
FLOAT
static NumericDataType
FLOAT16
static NumericDataType
INT
static NumericDataType
LONG
static NumericDataType
NONE
static PrimitiveDataType
PREDICATE
static PrimitiveDataType
RAW
static PrimitiveDataType
STRING
static WeightedSetDataType
TAG
static int
tensorDataTypeCode
static PrimitiveDataType
URI
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description FieldPath
buildFieldPath(String fieldPathString)
Creates a field path from the given field path string.DataType
clone()
int
compareTo(DataType dataType)
protected FieldValue
createByReflection(Object arg)
Creates a field value by reflectionabstract FieldValue
createFieldValue()
Creates a new, empty FieldValue of this typeFieldValue
createFieldValue(Object arg)
Creates a new FieldValue of this type, with the given value.boolean
equals(Object other)
static ArrayDataType
getArray(DataType type)
Returns an array datatype, where the array elements are of the given typeint
getCode()
int
getId()
static MapDataType
getMap(DataType key, DataType value)
Returns a map datatypeString
getName()
PrimitiveDataType
getPrimitiveType()
Returns the primitive datatype associated with this datatype, i.e.static TensorDataType
getTensor(com.yahoo.tensor.TensorType type)
Returns the given tensor type as a DataTypeabstract Class
getValueClass()
static WeightedSetDataType
getWeightedSet(DataType type)
Returns a weighted set datatype, where the elements are of the given typestatic 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 removeIfZeroint
hashCode()
boolean
isAssignableFrom(DataType dataType)
boolean
isMultivalue()
Returns whether this is a multivalue type, i.e either a CollectionDataType or a MapDataTypeboolean
isRegistered()
abstract boolean
isValueCompatible(FieldValue value)
static int
lastPredefinedDataTypeId()
void
register(DocumentTypeManager manager)
Registers this type in the given document manager.protected void
register(DocumentTypeManager manager, List<DataType> seenTypes)
void
setId(int id)
Sets the ID of this data type.protected void
setName(String name)
Sets the name of this data type.String
toString()
void
visitMembers(com.yahoo.vespa.objects.ObjectVisitor visitor)
-
-
-
Field Detail
-
classId
public static int classId
-
NONE
public static final NumericDataType NONE
-
INT
public static final NumericDataType INT
-
FLOAT
public static final NumericDataType FLOAT
-
STRING
public static final PrimitiveDataType STRING
-
RAW
public static final PrimitiveDataType RAW
-
LONG
public static final NumericDataType LONG
-
DOUBLE
public static final NumericDataType DOUBLE
-
BOOL
public static final PrimitiveDataType BOOL
-
FLOAT16
public static final NumericDataType FLOAT16
-
DOCUMENT
public static final DocumentType DOCUMENT
-
URI
public static final PrimitiveDataType URI
-
BYTE
public static final NumericDataType BYTE
-
PREDICATE
public static final PrimitiveDataType PREDICATE
-
tensorDataTypeCode
public static final int tensorDataTypeCode
- See Also:
- Constant Field Values
-
TAG
public static final WeightedSetDataType TAG
-
-
Constructor Detail
-
DataType
protected DataType(String name, int dataTypeId)
Creates a datatype- Parameters:
name
- the name of the typedataTypeId
- the id of the type
-
-
Method Detail
-
lastPredefinedDataTypeId
public static int lastPredefinedDataTypeId()
-
clone
public DataType clone()
- Overrides:
clone
in classcom.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 final boolean isAssignableFrom(DataType dataType)
-
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 typevalue
- 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 ofcreateIfNonExistent
- whether the type has createIfNonExistentremoveIfZero
- 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 classcom.yahoo.vespa.objects.Identifiable
-
equals
public boolean equals(Object other)
- Overrides:
equals
in classcom.yahoo.vespa.objects.Identifiable
-
toString
public String toString()
- Overrides:
toString
in classcom.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
-
visitMembers
public void visitMembers(com.yahoo.vespa.objects.ObjectVisitor visitor)
- Overrides:
visitMembers
in classcom.yahoo.vespa.objects.Identifiable
-
compareTo
public int compareTo(DataType dataType)
- Specified by:
compareTo
in interfaceComparable<DataType>
-
isMultivalue
public boolean isMultivalue()
Returns whether this is a multivalue type, i.e either a CollectionDataType or a MapDataType
-
-