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:
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 Summary
Modifier and TypeFieldDescriptionstatic final PrimitiveDataType
static final NumericDataType
static final int
static final DocumentType
static final NumericDataType
static final NumericDataType
static final NumericDataType
static final NumericDataType
static final NumericDataType
static final NumericDataType
static final PrimitiveDataType
static final PrimitiveDataType
static final PrimitiveDataType
static final WeightedSetDataType
static final int
static final PrimitiveDataType
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuildFieldPath
(String fieldPathString) Creates a field path from the given field path string.clone()
int
protected FieldValue
createByReflection
(Object arg) Creates a field value by reflectionabstract FieldValue
Creates a new, empty FieldValue of this typecreateFieldValue
(Object arg) Creates a new FieldValue of this type, with the given value.boolean
static ArrayDataType
Returns an array datatype, where the array elements are of the given typeint
getCode()
int
getId()
static MapDataType
Returns a map datatypegetName()
Returns the nested type of this if it is a collection type, null otherwise.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 casesstatic TensorDataType
getTensor
(com.yahoo.tensor.TensorType type) Returns the given tensor type as a DataTypeabstract Class
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
isAssignableTo
(DataType dataType) The reverse of isAssignableFromboolean
Returns whether this is a multivalue type, i.e either a CollectionDataType or a MapDataTypeboolean
abstract boolean
isValueCompatible
(FieldValue value) static int
final 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
Sets the name of this data type.toString()
void
visitMembers
(com.yahoo.vespa.objects.ObjectVisitor visitor) Methods inherited from class com.yahoo.vespa.objects.Identifiable
create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getRawUtf8Bytes, getUtf8, onDeserialize, onGetClassId, onSerialize, putUtf8, registerClass, registerClass, serialize, serializeOptional, serializeWithId
Methods inherited from class com.yahoo.vespa.objects.Selectable
select, select, selectMembers
-
Field Details
-
classId
public static final int classId -
NONE
-
INT
-
FLOAT
-
STRING
-
RAW
-
LONG
-
DOUBLE
-
BOOL
-
FLOAT16
-
DOCUMENT
-
URI
-
BYTE
-
PREDICATE
-
tensorDataTypeCode
public static final int tensorDataTypeCode- See Also:
-
TAG
-
-
Constructor Details
-
DataType
Creates a datatype- Parameters:
name
- the name of the typedataTypeId
- the id of the type
-
-
Method Details
-
lastPredefinedDataTypeId
public static int lastPredefinedDataTypeId() -
clone
- Overrides:
clone
in classcom.yahoo.vespa.objects.Identifiable
-
isRegistered
public boolean isRegistered() -
createFieldValue
Creates a new, empty FieldValue of this type -
createByReflection
Creates a field value by reflection- Parameters:
arg
- the value of the newly created field value- Returns:
- a fully constructed value
-
createFieldValue
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
-
isValueCompatible
-
isAssignableFrom
-
isAssignableTo
The reverse of isAssignableFrom -
getArray
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
Returns a map datatype- Parameters:
key
- the key typevalue
- the value type- Returns:
- the map data type
-
getWeightedSet
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
Returns the given tensor type as a DataType -
getName
-
setName
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
Registers this type in the given document manager.- Parameters:
manager
- the DocumentTypeManager to register in.
-
register
-
hashCode
public int hashCode()- Overrides:
hashCode
in classcom.yahoo.vespa.objects.Identifiable
-
equals
- Overrides:
equals
in classcom.yahoo.vespa.objects.Identifiable
-
toString
- Overrides:
toString
in classcom.yahoo.vespa.objects.Identifiable
-
getCode
public int getCode() -
buildFieldPath
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
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
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 classcom.yahoo.vespa.objects.Identifiable
-
compareTo
- 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
-