Package com.arcadedb.schema
Class LocalDocumentType
- java.lang.Object
-
- com.arcadedb.schema.LocalDocumentType
-
- All Implemented Interfaces:
DocumentType
- Direct Known Subclasses:
LocalEdgeType
,LocalVertexType
public class LocalDocumentType extends Object implements DocumentType
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Integer>
bucketIds
protected Map<Integer,List<IndexInternal>>
bucketIndexesByBucket
protected List<Bucket>
buckets
protected BucketSelectionStrategy
bucketSelectionStrategy
protected List<Integer>
cachedPolymorphicBucketIds
protected List<Bucket>
cachedPolymorphicBuckets
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 LocalSchema
schema
protected List<LocalDocumentType>
subTypes
protected List<LocalDocumentType>
superTypes
-
Constructor Summary
Constructors Constructor Description LocalDocumentType(LocalSchema 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, TypeIndex propIndex)
DocumentType
addSuperType(DocumentType superType)
DocumentType
addSuperType(String superName)
LocalProperty
createProperty(String propertyName, Type propertyType)
Creates a new property with type `propertyType`.LocalProperty
createProperty(String propertyName, Type propertyType, String ofType)
Creates a new property with type `propertyType`.Property
createProperty(String propName, JSONObject prop)
Property
createProperty(String propertyName, Class<?> propertyType)
Creates a new property with type `propertyType`.LocalProperty
createProperty(String propertyName, String propertyType)
Creates a new property with type `propertyType`.TypeIndex
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String... propertyNames)
TypeIndex
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize)
TypeIndex
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
TypeIndex
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
Property
dropProperty(String propertyName)
Drops a property from the type.boolean
equals(Object o)
boolean
existsPolymorphicProperty(String propertyName)
boolean
existsProperty(String propertyName)
Collection<TypeIndex>
getAllIndexes(boolean polymorphic)
Bucket
getBucketIdByRecord(Document record, boolean async)
List<Integer>
getBucketIds(boolean polymorphic)
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)
List<TypeIndex>
getIndexesByProperties(Collection<String> properties)
List<Bucket>
getInvolvedBuckets()
String
getName()
Property
getOrCreateProperty(String propertyName, Type propertyType)
Returns a property by its name.Property
getOrCreateProperty(String propertyName, Type propertyType, String ofType)
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.Property
getOrCreateProperty(String propertyName, String propertyType, String ofType)
Returns a property by its name.TypeIndex
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String... propertyNames)
TypeIndex
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize)
TypeIndex
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
TypeIndex
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
List<IndexInternal>
getPolymorphicBucketIndexByBucketId(int bucketId, List<String> filterByProperties)
TypeIndex
getPolymorphicIndexByProperties(String... properties)
TypeIndex
getPolymorphicIndexByProperties(List<String> properties)
Collection<? extends Property>
getPolymorphicProperties()
Returns all the properties defined in the type and subtypes.Set<String>
getPolymorphicPropertiesWithDefaultDefined()
Set<String>
getPolymorphicPropertyNames()
Returns all the properties defined in the type and subtypes.Collection<? extends Property>
getProperties()
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.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)
MutableDocument
newRecord()
protected <RET> RET
recordFileChanges(Callable<Object> callback)
DocumentType
removeBucket(Bucket bucket)
void
removeBucketIndexInternal(Index index)
protected void
removeBucketInternal(Bucket bucket)
DocumentType
removeSuperType(DocumentType superType)
Removes a super type from the current type.DocumentType
removeSuperType(String superTypeName)
Removes a super type (by its name) from the current type.void
removeTypeIndexInternal(TypeIndex index)
DocumentType
setBucketSelectionStrategy(BucketSelectionStrategy selectionStrategy)
DocumentType
setBucketSelectionStrategy(String selectionStrategyName, Object... args)
Object
setCustomValue(String key, Object value)
DocumentType
setSuperTypes(List<DocumentType> newSuperTypes)
Set the type super types.JSONObject
toJSON()
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.arcadedb.schema.DocumentType
getPolymorphicProperty, getPolymorphicPropertyIfExists, getProperty, getType
-
-
-
-
Field Detail
-
schema
protected final LocalSchema schema
-
name
protected final String name
-
superTypes
protected final List<LocalDocumentType> superTypes
-
subTypes
protected final List<LocalDocumentType> subTypes
-
bucketSelectionStrategy
protected BucketSelectionStrategy bucketSelectionStrategy
-
bucketIndexesByBucket
protected final Map<Integer,List<IndexInternal>> bucketIndexesByBucket
-
events
protected final RecordEventsRegistry events
-
-
Constructor Detail
-
LocalDocumentType
public LocalDocumentType(LocalSchema schema, String name)
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getName
in interfaceDocumentType
-
newRecord
public MutableDocument newRecord()
- Specified by:
newRecord
in interfaceDocumentType
-
getEvents
public RecordEvents getEvents()
- Specified by:
getEvents
in interfaceDocumentType
-
getPolymorphicPropertiesWithDefaultDefined
public Set<String> getPolymorphicPropertiesWithDefaultDefined()
- Specified by:
getPolymorphicPropertiesWithDefaultDefined
in interfaceDocumentType
-
addSuperType
public DocumentType addSuperType(String superName)
- Specified by:
addSuperType
in interfaceDocumentType
-
addSuperType
public DocumentType addSuperType(DocumentType superType)
- Specified by:
addSuperType
in interfaceDocumentType
-
removeSuperType
public DocumentType removeSuperType(String superTypeName)
Removes a super type (by its name) from the current type.- Specified by:
removeSuperType
in interfaceDocumentType
- See Also:
removeSuperType(DocumentType)
,addSuperType(DocumentType)
,addSuperType(String)
,addSuperType(DocumentType, boolean)
-
removeSuperType
public DocumentType removeSuperType(DocumentType superType)
Removes a super type from the current type.- Specified by:
removeSuperType
in interfaceDocumentType
- See Also:
removeSuperType(String)
,addSuperType(DocumentType)
,addSuperType(String)
,addSuperType(DocumentType, boolean)
-
instanceOf
public boolean instanceOf(String type)
Returns true if the current type is the same or a subtype of `type` parameter.- Specified by:
instanceOf
in interfaceDocumentType
- 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.- Specified by:
getSuperTypes
in interfaceDocumentType
- See Also:
addSuperType(DocumentType)
,addSuperType(String)
,addSuperType(DocumentType, boolean)
-
setSuperTypes
public DocumentType setSuperTypes(List<DocumentType> newSuperTypes)
Set the type super types. Any previous configuration about supertypes will be replaced with this new list.- Specified by:
setSuperTypes
in interfaceDocumentType
- 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.- Specified by:
getSubTypes
in interfaceDocumentType
- See Also:
addSuperType(DocumentType)
,addSuperType(String)
,addSuperType(DocumentType, boolean)
-
getPropertyNames
public Set<String> getPropertyNames()
Returns all the properties defined in the type, not considering the ones inherited from subtypes.- Specified by:
getPropertyNames
in interfaceDocumentType
- Returns:
- Set containing all the names
- See Also:
getPolymorphicPropertyNames()
-
getProperties
public Collection<? extends Property> getProperties()
- Specified by:
getProperties
in interfaceDocumentType
-
getPolymorphicProperties
public Collection<? extends Property> getPolymorphicProperties()
Returns all the properties defined in the type and subtypes.- Specified by:
getPolymorphicProperties
in interfaceDocumentType
-
getPolymorphicPropertyNames
public Set<String> getPolymorphicPropertyNames()
Returns all the properties defined in the type and subtypes.- Specified by:
getPolymorphicPropertyNames
in interfaceDocumentType
- Returns:
- Set containing all the names
- See Also:
getPropertyNames()
-
createProperty
public LocalProperty createProperty(String propertyName, String propertyType)
Creates a new property with type `propertyType`.- Specified by:
createProperty
in interfaceDocumentType
- 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`.- Specified by:
createProperty
in interfaceDocumentType
- Parameters:
propertyName
- Property name to removepropertyType
- Property type as Java @Class
-
createProperty
public Property createProperty(String propName, JSONObject prop)
- Specified by:
createProperty
in interfaceDocumentType
-
createProperty
public LocalProperty createProperty(String propertyName, Type propertyType)
Creates a new property with type `propertyType`.- Specified by:
createProperty
in interfaceDocumentType
- Parameters:
propertyName
- Property name to removepropertyType
- Property type as @Type
-
createProperty
public LocalProperty createProperty(String propertyName, Type propertyType, String ofType)
Creates a new property with type `propertyType`.- Specified by:
createProperty
in interfaceDocumentType
- Parameters:
propertyName
- Property name to removepropertyType
- Property type as @Type
ofType
- Linked type. For List the type contained in the list. For RID the schema type name.
-
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`.- Specified by:
getOrCreateProperty
in interfaceDocumentType
- 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, String propertyType, String ofType)
Returns a property by its name. If the property does not exist, it is created with type `propertyType`.- Specified by:
getOrCreateProperty
in interfaceDocumentType
- Parameters:
propertyName
- Property name to removepropertyType
- Property type, by type name @String
, to use in case the property does not exist and will be createdofType
- Linked type. For List the type contained in the list. For RID the schema type name.
-
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`.- Specified by:
getOrCreateProperty
in interfaceDocumentType
- 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`.- Specified by:
getOrCreateProperty
in interfaceDocumentType
- Parameters:
propertyName
- Property name to removepropertyType
- Property type, as @Type
, to use in case the property does not exist and will be created
-
getOrCreateProperty
public Property getOrCreateProperty(String propertyName, Type propertyType, String ofType)
Returns a property by its name. If the property does not exist, it is created with type `propertyType`.- Specified by:
getOrCreateProperty
in interfaceDocumentType
- Parameters:
propertyName
- Property name to removepropertyType
- Property type, as @Type
, to use in case the property does not exist and will be createdofType
- Linked type. For List the type contained in the list. For RID the schema type name.
-
dropProperty
public Property dropProperty(String propertyName)
Drops a property from the type. If there is any index on the property a @SchemaException
is thrown.- Specified by:
dropProperty
in interfaceDocumentType
- Parameters:
propertyName
- Property name to remove- Returns:
- the property dropped if found
-
createTypeIndex
public TypeIndex createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String... propertyNames)
- Specified by:
createTypeIndex
in interfaceDocumentType
-
createTypeIndex
public TypeIndex createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize)
- Specified by:
createTypeIndex
in interfaceDocumentType
-
createTypeIndex
public TypeIndex createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
- Specified by:
createTypeIndex
in interfaceDocumentType
-
createTypeIndex
public TypeIndex createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
- Specified by:
createTypeIndex
in interfaceDocumentType
-
getOrCreateTypeIndex
public TypeIndex getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String... propertyNames)
- Specified by:
getOrCreateTypeIndex
in interfaceDocumentType
-
getOrCreateTypeIndex
public TypeIndex getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize)
- Specified by:
getOrCreateTypeIndex
in interfaceDocumentType
-
getOrCreateTypeIndex
public TypeIndex getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
- Specified by:
getOrCreateTypeIndex
in interfaceDocumentType
-
getOrCreateTypeIndex
public TypeIndex getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
- Specified by:
getOrCreateTypeIndex
in interfaceDocumentType
-
getInvolvedBuckets
public List<Bucket> getInvolvedBuckets()
- Specified by:
getInvolvedBuckets
in interfaceDocumentType
-
getBuckets
public List<Bucket> getBuckets(boolean polymorphic)
- Specified by:
getBuckets
in interfaceDocumentType
-
getBucketIds
public List<Integer> getBucketIds(boolean polymorphic)
- Specified by:
getBucketIds
in interfaceDocumentType
-
addBucket
public DocumentType addBucket(Bucket bucket)
- Specified by:
addBucket
in interfaceDocumentType
-
removeBucket
public DocumentType removeBucket(Bucket bucket)
- Specified by:
removeBucket
in interfaceDocumentType
-
getBucketIdByRecord
public Bucket getBucketIdByRecord(Document record, boolean async)
- Specified by:
getBucketIdByRecord
in interfaceDocumentType
-
getBucketIndexByKeys
public int getBucketIndexByKeys(Object[] keys, boolean async)
- Specified by:
getBucketIndexByKeys
in interfaceDocumentType
-
getBucketSelectionStrategy
public BucketSelectionStrategy getBucketSelectionStrategy()
- Specified by:
getBucketSelectionStrategy
in interfaceDocumentType
-
setBucketSelectionStrategy
public DocumentType setBucketSelectionStrategy(BucketSelectionStrategy selectionStrategy)
- Specified by:
setBucketSelectionStrategy
in interfaceDocumentType
-
setBucketSelectionStrategy
public DocumentType setBucketSelectionStrategy(String selectionStrategyName, Object... args)
- Specified by:
setBucketSelectionStrategy
in interfaceDocumentType
-
existsProperty
public boolean existsProperty(String propertyName)
- Specified by:
existsProperty
in interfaceDocumentType
-
existsPolymorphicProperty
public boolean existsPolymorphicProperty(String propertyName)
- Specified by:
existsPolymorphicProperty
in interfaceDocumentType
-
getPropertyIfExists
public Property getPropertyIfExists(String propertyName)
- Specified by:
getPropertyIfExists
in interfaceDocumentType
-
getAllIndexes
public Collection<TypeIndex> getAllIndexes(boolean polymorphic)
- Specified by:
getAllIndexes
in interfaceDocumentType
-
getPolymorphicBucketIndexByBucketId
public List<IndexInternal> getPolymorphicBucketIndexByBucketId(int bucketId, List<String> filterByProperties)
- Specified by:
getPolymorphicBucketIndexByBucketId
in interfaceDocumentType
-
getIndexesByProperties
public List<TypeIndex> getIndexesByProperties(String property1, String... propertiesN)
- Specified by:
getIndexesByProperties
in interfaceDocumentType
-
getIndexesByProperties
public List<TypeIndex> getIndexesByProperties(Collection<String> properties)
- Specified by:
getIndexesByProperties
in interfaceDocumentType
-
getPolymorphicIndexByProperties
public TypeIndex getPolymorphicIndexByProperties(String... properties)
- Specified by:
getPolymorphicIndexByProperties
in interfaceDocumentType
-
getPolymorphicIndexByProperties
public TypeIndex getPolymorphicIndexByProperties(List<String> properties)
- Specified by:
getPolymorphicIndexByProperties
in interfaceDocumentType
-
getSchema
public Schema getSchema()
- Specified by:
getSchema
in interfaceDocumentType
-
isTheSameAs
public boolean isTheSameAs(Object o)
- Specified by:
isTheSameAs
in interfaceDocumentType
-
addIndexInternal
protected void addIndexInternal(IndexInternal index, int bucketId, String[] propertyNames, TypeIndex propIndex)
-
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)
- Specified by:
hasBucket
in interfaceDocumentType
-
getFirstBucketId
public int getFirstBucketId()
- Specified by:
getFirstBucketId
in interfaceDocumentType
-
isSubTypeOf
public boolean isSubTypeOf(String type)
- Specified by:
isSubTypeOf
in interfaceDocumentType
-
isSuperTypeOf
public boolean isSuperTypeOf(String type)
- Specified by:
isSuperTypeOf
in interfaceDocumentType
-
getCustomKeys
public Set<String> getCustomKeys()
- Specified by:
getCustomKeys
in interfaceDocumentType
-
getCustomValue
public Object getCustomValue(String key)
- Specified by:
getCustomValue
in interfaceDocumentType
-
setCustomValue
public Object setCustomValue(String key, Object value)
- Specified by:
setCustomValue
in interfaceDocumentType
-
toJSON
public JSONObject toJSON()
- Specified by:
toJSON
in interfaceDocumentType
-
-