Package com.arcadedb.schema
Class DocumentType
- java.lang.Object
-
- com.arcadedb.schema.DocumentType
-
- Direct Known Subclasses:
EdgeType
,VertexType
public class DocumentType extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Integer,List<IndexInternal>>
bucketIndexesByBucket
protected List<Bucket>
buckets
protected BucketSelectionStrategy
bucketSelectionStrategy
protected Map<String,Object>
custom
protected RecordEventsRegistry
events
protected Map<List<String>,TypeIndex>
indexesByProperties
protected String
name
protected Map<String,Property>
properties
protected Set<String>
propertiesWithDefaultDefined
protected EmbeddedSchema
schema
protected List<DocumentType>
subTypes
protected List<DocumentType>
superTypes
-
Constructor Summary
Constructors Constructor Description DocumentType(EmbeddedSchema schema, String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DocumentType
addBucket(Bucket bucket)
protected void
addBucketInternal(Bucket bucket)
protected void
addIndexInternal(IndexInternal index, int bucketId, String[] propertyNames)
DocumentType
addSuperType(DocumentType superType)
protected DocumentType
addSuperType(DocumentType superType, boolean createIndexes)
DocumentType
addSuperType(String superName)
Property
createProperty(String propertyName, Type propertyType)
Creates a new property with type `propertyType`.Property
createProperty(String propertyName, Class<?> propertyType)
Creates a new property with type `propertyType`.Property
createProperty(String propertyName, String propertyType)
Creates a new property with type `propertyType`.Index
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String... propertyNames)
Index
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize)
Index
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
Index
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
void
dropProperty(String propertyName)
Drops a property from the type.boolean
equals(Object o)
boolean
existsPolymorphicProperty(String propertyName)
boolean
existsProperty(String propertyName)
List<TypeIndex>
getAllIndexes(boolean polymorphic)
Bucket
getBucketIdByRecord(Document record, boolean async)
int
getBucketIndexByKeys(Object[] keys, boolean async)
List<Bucket>
getBuckets(boolean polymorphic)
BucketSelectionStrategy
getBucketSelectionStrategy()
Set<String>
getCustomKeys()
Object
getCustomValue(String key)
RecordEvents
getEvents()
int
getFirstBucketId()
List<TypeIndex>
getIndexesByProperties(String property1, String... propertiesN)
String
getName()
Property
getOrCreateProperty(String propertyName, Type propertyType)
Returns a property by its name.Property
getOrCreateProperty(String propertyName, Class<?> propertyType)
Returns a property by its name.Property
getOrCreateProperty(String propertyName, String propertyType)
Returns a property by its name.Index
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String... propertyNames)
Index
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize)
Index
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
Index
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
List<Index>
getPolymorphicBucketIndexByBucketId(int bucketId)
TypeIndex
getPolymorphicIndexByProperties(String... properties)
TypeIndex
getPolymorphicIndexByProperties(List<String> properties)
protected Map<String,Property>
getPolymorphicProperties()
Set<String>
getPolymorphicPropertiesWithDefaultDefined()
Property
getPolymorphicProperty(String propertyName)
Property
getPolymorphicPropertyIfExists(String propertyName)
Set<String>
getPolymorphicPropertyNames()
Returns all the properties defined in the type and subtypes.Property
getProperty(String propertyName)
Property
getPropertyIfExists(String propertyName)
Set<String>
getPropertyNames()
Returns all the properties defined in the type, not considering the ones inherited from subtypes.Schema
getSchema()
List<DocumentType>
getSubTypes()
Returns the list of subtypes, in any, or an empty list in case the type has not subtypes defined.List<DocumentType>
getSuperTypes()
Returns the list of super types if any, otherwise an empty collection.byte
getType()
boolean
hasBucket(String bucketName)
int
hashCode()
boolean
instanceOf(String type)
Returns true if the current type is the same or a subtype of `type` parameter.boolean
isSubTypeOf(String type)
boolean
isSuperTypeOf(String type)
boolean
isTheSameAs(Object o)
protected <RET> RET
recordFileChanges(Callable<Object> callback)
DocumentType
removeBucket(Bucket bucket)
void
removeBucketIndexInternal(Index index)
protected void
removeBucketInternal(Bucket bucket)
void
removeSuperType(DocumentType superType)
Removes a super type from the current type.void
removeSuperType(String superTypeName)
Removes a super type (by its name) from the current type.void
removeTypeIndexInternal(TypeIndex index)
void
setBucketSelectionStrategy(BucketSelectionStrategy selectionStrategy)
Object
setCustomValue(String key, Object value)
void
setSuperTypes(List<DocumentType> newSuperTypes)
Set the type super types.org.json.JSONObject
toJSON()
String
toString()
-
-
-
Field Detail
-
schema
protected final EmbeddedSchema schema
-
name
protected final String name
-
superTypes
protected final List<DocumentType> superTypes
-
subTypes
protected final List<DocumentType> subTypes
-
bucketSelectionStrategy
protected BucketSelectionStrategy bucketSelectionStrategy
-
bucketIndexesByBucket
protected Map<Integer,List<IndexInternal>> bucketIndexesByBucket
-
events
protected final RecordEventsRegistry events
-
-
Constructor Detail
-
DocumentType
public DocumentType(EmbeddedSchema schema, String name)
-
-
Method Detail
-
getName
public String getName()
-
getType
public byte getType()
-
getEvents
public RecordEvents getEvents()
-
getPolymorphicPropertiesWithDefaultDefined
public Set<String> getPolymorphicPropertiesWithDefaultDefined()
-
addSuperType
public DocumentType addSuperType(String superName)
-
addSuperType
public DocumentType addSuperType(DocumentType superType)
-
addSuperType
protected DocumentType addSuperType(DocumentType superType, boolean createIndexes)
-
removeSuperType
public void removeSuperType(String superTypeName)
Removes a super type (by its name) from the current type.
-
removeSuperType
public void removeSuperType(DocumentType superType)
Removes a super type from the current type.
-
instanceOf
public boolean instanceOf(String type)
Returns true if the current type is the same or a subtype of `type` parameter.- Parameters:
type
- the type name to check- See Also:
addSuperType(DocumentType)
,addSuperType(String)
,addSuperType(DocumentType, boolean)
-
getSuperTypes
public List<DocumentType> getSuperTypes()
Returns the list of super types if any, otherwise an empty collection.
-
setSuperTypes
public void setSuperTypes(List<DocumentType> newSuperTypes)
Set the type super types. Any previous configuration about supertypes will be replaced with this new list.- Parameters:
newSuperTypes
- List of super types to assign- See Also:
addSuperType(DocumentType)
,addSuperType(String)
,addSuperType(DocumentType, boolean)
-
getSubTypes
public List<DocumentType> getSubTypes()
Returns the list of subtypes, in any, or an empty list in case the type has not subtypes defined.
-
getPropertyNames
public Set<String> getPropertyNames()
Returns all the properties defined in the type, not considering the ones inherited from subtypes.- Returns:
- Set containing all the names
- See Also:
getPolymorphicPropertyNames()
-
getPolymorphicPropertyNames
public Set<String> getPolymorphicPropertyNames()
Returns all the properties defined in the type and subtypes.- Returns:
- Set containing all the names
- See Also:
getPropertyNames()
-
createProperty
public Property createProperty(String propertyName, String propertyType)
Creates a new property with type `propertyType`.- Parameters:
propertyName
- Property name to removepropertyType
- Property type by type name @String
-
createProperty
public Property createProperty(String propertyName, Class<?> propertyType)
Creates a new property with type `propertyType`.- Parameters:
propertyName
- Property name to removepropertyType
- Property type as Java @Class
-
createProperty
public Property createProperty(String propertyName, Type propertyType)
Creates a new property with type `propertyType`.- Parameters:
propertyName
- Property name to removepropertyType
- Property type as @Type
-
getOrCreateProperty
public Property getOrCreateProperty(String propertyName, String propertyType)
Returns a property by its name. If the property does not exist, it is created with type `propertyType`.- Parameters:
propertyName
- Property name to removepropertyType
- Property type, by type name @String
, to use in case the property does not exist and will be created
-
getOrCreateProperty
public Property getOrCreateProperty(String propertyName, Class<?> propertyType)
Returns a property by its name. If the property does not exist, it is created with type `propertyType`.- Parameters:
propertyName
- Property name to removepropertyType
- Property type, as Java @Class
, to use in case the property does not exist and will be created
-
getOrCreateProperty
public Property getOrCreateProperty(String propertyName, Type propertyType)
Returns a property by its name. If the property does not exist, it is created with type `propertyType`.- Parameters:
propertyName
- Property name to removepropertyType
- Property type, as @Type
, to use in case the property does not exist and will be created
-
dropProperty
public void dropProperty(String propertyName)
Drops a property from the type. If there is any index on the property a @SchemaException
is thrown.- Parameters:
propertyName
- Property name to remove
-
createTypeIndex
public Index createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String... propertyNames)
-
createTypeIndex
public Index createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize)
-
createTypeIndex
public Index createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
-
createTypeIndex
public Index createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
-
getOrCreateTypeIndex
public Index getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String... propertyNames)
-
getOrCreateTypeIndex
public Index getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize)
-
getOrCreateTypeIndex
public Index getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
-
getOrCreateTypeIndex
public Index getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
-
addBucket
public DocumentType addBucket(Bucket bucket)
-
removeBucket
public DocumentType removeBucket(Bucket bucket)
-
getBucketIndexByKeys
public int getBucketIndexByKeys(Object[] keys, boolean async)
-
getBucketSelectionStrategy
public BucketSelectionStrategy getBucketSelectionStrategy()
-
setBucketSelectionStrategy
public void setBucketSelectionStrategy(BucketSelectionStrategy selectionStrategy)
-
existsProperty
public boolean existsProperty(String propertyName)
-
existsPolymorphicProperty
public boolean existsPolymorphicProperty(String propertyName)
-
getPolymorphicBucketIndexByBucketId
public List<Index> getPolymorphicBucketIndexByBucketId(int bucketId)
-
getIndexesByProperties
public List<TypeIndex> getIndexesByProperties(String property1, String... propertiesN)
-
getPolymorphicIndexByProperties
public TypeIndex getPolymorphicIndexByProperties(String... properties)
-
getPolymorphicIndexByProperties
public TypeIndex getPolymorphicIndexByProperties(List<String> properties)
-
getSchema
public Schema getSchema()
-
isTheSameAs
public boolean isTheSameAs(Object o)
-
addIndexInternal
protected void addIndexInternal(IndexInternal index, int bucketId, String[] propertyNames)
-
removeTypeIndexInternal
public void removeTypeIndexInternal(TypeIndex index)
-
removeBucketIndexInternal
public void removeBucketIndexInternal(Index index)
-
addBucketInternal
protected void addBucketInternal(Bucket bucket)
-
removeBucketInternal
protected void removeBucketInternal(Bucket bucket)
-
hasBucket
public boolean hasBucket(String bucketName)
-
getFirstBucketId
public int getFirstBucketId()
-
isSubTypeOf
public boolean isSubTypeOf(String type)
-
isSuperTypeOf
public boolean isSuperTypeOf(String type)
-
toJSON
public org.json.JSONObject toJSON()
-
-