Package com.arcadedb.schema
Class LocalSchema
- java.lang.Object
-
- com.arcadedb.schema.LocalSchema
-
- All Implemented Interfaces:
Schema
public class LocalSchema extends Object implements Schema
Local implementation of the database schema.- Author:
- Luca Garulli ([email protected])
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.arcadedb.schema.Schema
Schema.INDEX_TYPE
-
-
Field Summary
Fields Modifier and Type Field Description static int
BUILD_TX_BATCH_SIZE
static String
CACHED_COUNT_FILE_NAME
static String
DEFAULT_ENCODING
protected Map<String,IndexInternal>
indexMap
static String
SCHEMA_FILE_NAME
static String
SCHEMA_PREV_FILE_NAME
-
Constructor Summary
Constructors Constructor Description LocalSchema(DatabaseInternal database, String databasePath, SecurityManager security)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BucketIndexBuilder
buildBucketIndex(String typeName, String bucketName, String[] propertyNames)
TypeBuilder<LocalDocumentType>
buildDocumentType()
TypeBuilder<EdgeType>
buildEdgeType()
ManualIndexBuilder
buildManualIndex(String indexName, Type[] keyTypes)
TypeIndexBuilder
buildTypeIndex(String typeName, String[] propertyNames)
VectorIndexBuilder
buildVectorIndex()
TypeBuilder<VertexType>
buildVertexType()
void
close()
DocumentType
copyType(String typeName, String newTypeName, Class<? extends DocumentType> newTypeClass, int buckets, int pageSize, int transactionBatchSize)
void
create(ComponentFile.MODE mode)
LocalBucket
createBucket(String bucketName)
LocalBucket
createBucket(String bucketName, int pageSize)
protected Index
createBucketIndex(LocalDocumentType type, Type[] keyTypes, Bucket bucket, String typeName, Schema.INDEX_TYPE indexType, boolean unique, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback, String[] propertyNames, TypeIndex propIndex, int batchSize)
Index
createBucketIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String bucketName, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
Deprecated.DocumentType
createDocumentType(String typeName)
Creates a new document type with the default settings of buckets.DocumentType
createDocumentType(String typeName, int buckets)
DocumentType
createDocumentType(String typeName, int buckets, int pageSize)
DocumentType
createDocumentType(String typeName, List<Bucket> buckets)
DocumentType
createDocumentType(String typeName, List<Bucket> buckets, int pageSize)
EdgeType
createEdgeType(String typeName)
Creates a new edge type with the default settings of buckets.EdgeType
createEdgeType(String typeName, int buckets)
EdgeType
createEdgeType(String typeName, int buckets, int pageSize)
EdgeType
createEdgeType(String typeName, List<Bucket> buckets)
EdgeType
createEdgeType(String typeName, List<Bucket> buckets, int pageSize)
Index
createManualIndex(Schema.INDEX_TYPE indexType, boolean unique, String indexName, Type[] keyTypes, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy)
Deprecated.TypeIndex
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String... propertyNames)
TypeIndex
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize)
Deprecated.TypeIndex
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
Deprecated.TypeIndex
createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
Deprecated.VertexType
createVertexType(String typeName)
Creates a new vertex type with the default settings of buckets.VertexType
createVertexType(String typeName, int buckets)
VertexType
createVertexType(String typeName, int buckets, int pageSize)
VertexType
createVertexType(String typeName, List<Bucket> bucketInstances)
VertexType
createVertexType(String typeName, List<Bucket> bucketInstances, int pageSize)
void
dropBucket(String bucketName)
void
dropIndex(String indexName)
void
dropType(String typeName)
boolean
existsBucket(String bucketName)
boolean
existsIndex(String indexName)
boolean
existsType(String typeName)
LocalBucket
getBucketById(int id)
Bucket
getBucketByName(String name)
Collection<? extends Bucket>
getBuckets()
File
getConfigurationFile()
Database
getDatabase()
String
getDateFormat()
String
getDateTimeFormat()
Dictionary
getDictionary()
LocalSchema
getEmbedded()
String
getEncoding()
Component
getFileById(int id)
Component
getFileByIdIfExists(int id)
FunctionDefinition
getFunction(String libraryName, String functionName)
Returns a function defined in a library.Iterable<FunctionLibraryDefinition>
getFunctionLibraries()
Returns all the registered function libraries.FunctionLibraryDefinition
getFunctionLibrary(String name)
Returns the requested function library if defined or IllegalArgumentException if notIndex
getIndexByName(String indexName)
Index[]
getIndexes()
DocumentType
getInvolvedTypeByBucketId(int bucketId)
DocumentType
getOrCreateDocumentType(String typeName)
Returns a document type if already defined otherwise creates it in the schema.DocumentType
getOrCreateDocumentType(String typeName, int buckets)
DocumentType
getOrCreateDocumentType(String typeName, int buckets, int pageSize)
EdgeType
getOrCreateEdgeType(String typeName)
Returns an edge type if already defined otherwise creates it in the schema.EdgeType
getOrCreateEdgeType(String typeName, int buckets)
EdgeType
getOrCreateEdgeType(String typeName, int buckets, int pageSize)
TypeIndex
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String... propertyNames)
TypeIndex
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize)
Deprecated.TypeIndex
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
Deprecated.TypeIndex
getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
Deprecated.VertexType
getOrCreateVertexType(String typeName)
Returns a vertex type if already defined otherwise creates it in the schema.VertexType
getOrCreateVertexType(String typeName, int buckets)
VertexType
getOrCreateVertexType(String typeName, int buckets, int pageSize)
TimeZone
getTimeZone()
LocalDocumentType
getType(String typeName)
DocumentType
getTypeByBucketId(int bucketId)
DocumentType
getTypeByBucketName(String bucketName)
String
getTypeNameByBucketId(int bucketId)
Collection<DocumentType>
getTypes()
long
getVersion()
ZoneId
getZoneId()
boolean
hasFunctionLibrary(String name)
Returns true if the a function library is defined, otherwise false.void
initComponents()
boolean
isDirty()
protected boolean
isSchemaLoaded()
void
load(ComponentFile.MODE mode, boolean initialize)
protected void
readConfiguration()
protected <RET> RET
recordFileChanges(Callable<Object> callback)
void
registerFile(Component file)
Schema
registerFunctionLibrary(FunctionLibraryDefinition library)
Registers a function library.void
removeFile(int fileId)
void
saveConfiguration()
void
setDateFormat(String dateFormat)
void
setDateTimeFormat(String dateTimeFormat)
void
setEncoding(String encoding)
void
setTimeZone(TimeZone timeZone)
void
setZoneId(ZoneId zoneId)
JSONObject
toJSON()
Schema
unregisterFunctionLibrary(String name)
Unregister a function library previously defined.void
update(JSONObject newSchema)
protected void
updateSecurity()
-
-
-
Field Detail
-
DEFAULT_ENCODING
public static final String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
SCHEMA_FILE_NAME
public static final String SCHEMA_FILE_NAME
- See Also:
- Constant Field Values
-
SCHEMA_PREV_FILE_NAME
public static final String SCHEMA_PREV_FILE_NAME
- See Also:
- Constant Field Values
-
CACHED_COUNT_FILE_NAME
public static final String CACHED_COUNT_FILE_NAME
- See Also:
- Constant Field Values
-
BUILD_TX_BATCH_SIZE
public static final int BUILD_TX_BATCH_SIZE
- See Also:
- Constant Field Values
-
indexMap
protected final Map<String,IndexInternal> indexMap
-
-
Constructor Detail
-
LocalSchema
public LocalSchema(DatabaseInternal database, String databasePath, SecurityManager security)
-
-
Method Detail
-
getEmbedded
public LocalSchema getEmbedded()
- Specified by:
getEmbedded
in interfaceSchema
-
create
public void create(ComponentFile.MODE mode)
-
load
public void load(ComponentFile.MODE mode, boolean initialize) throws IOException
- Throws:
IOException
-
getTimeZone
public TimeZone getTimeZone()
- Specified by:
getTimeZone
in interfaceSchema
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
- Specified by:
setTimeZone
in interfaceSchema
-
getDateFormat
public String getDateFormat()
- Specified by:
getDateFormat
in interfaceSchema
-
setDateFormat
public void setDateFormat(String dateFormat)
- Specified by:
setDateFormat
in interfaceSchema
-
getDateTimeFormat
public String getDateTimeFormat()
- Specified by:
getDateTimeFormat
in interfaceSchema
-
setDateTimeFormat
public void setDateTimeFormat(String dateTimeFormat)
- Specified by:
setDateTimeFormat
in interfaceSchema
-
getFileById
public Component getFileById(int id)
- Specified by:
getFileById
in interfaceSchema
-
getFileByIdIfExists
public Component getFileByIdIfExists(int id)
- Specified by:
getFileByIdIfExists
in interfaceSchema
-
removeFile
public void removeFile(int fileId)
-
getBuckets
public Collection<? extends Bucket> getBuckets()
- Specified by:
getBuckets
in interfaceSchema
-
existsBucket
public boolean existsBucket(String bucketName)
- Specified by:
existsBucket
in interfaceSchema
-
getBucketByName
public Bucket getBucketByName(String name)
- Specified by:
getBucketByName
in interfaceSchema
-
getBucketById
public LocalBucket getBucketById(int id)
- Specified by:
getBucketById
in interfaceSchema
-
createBucket
public LocalBucket createBucket(String bucketName)
- Specified by:
createBucket
in interfaceSchema
-
createBucket
public LocalBucket createBucket(String bucketName, int pageSize)
-
getEncoding
public String getEncoding()
- Specified by:
getEncoding
in interfaceSchema
-
setEncoding
public void setEncoding(String encoding)
- Specified by:
setEncoding
in interfaceSchema
-
copyType
public DocumentType copyType(String typeName, String newTypeName, Class<? extends DocumentType> newTypeClass, int buckets, int pageSize, int transactionBatchSize)
-
existsIndex
public boolean existsIndex(String indexName)
- Specified by:
existsIndex
in interfaceSchema
-
getIndexes
public Index[] getIndexes()
- Specified by:
getIndexes
in interfaceSchema
-
getIndexByName
public Index getIndexByName(String indexName)
- Specified by:
getIndexByName
in interfaceSchema
-
buildTypeIndex
public TypeIndexBuilder buildTypeIndex(String typeName, String[] propertyNames)
- Specified by:
buildTypeIndex
in interfaceSchema
-
buildBucketIndex
public BucketIndexBuilder buildBucketIndex(String typeName, String bucketName, String[] propertyNames)
- Specified by:
buildBucketIndex
in interfaceSchema
-
buildManualIndex
public ManualIndexBuilder buildManualIndex(String indexName, Type[] keyTypes)
- Specified by:
buildManualIndex
in interfaceSchema
-
buildVectorIndex
public VectorIndexBuilder buildVectorIndex()
- Specified by:
buildVectorIndex
in interfaceSchema
-
createTypeIndex
public TypeIndex createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String... propertyNames)
- Specified by:
createTypeIndex
in interfaceSchema
-
createTypeIndex
@Deprecated public TypeIndex createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize)
Deprecated.- Specified by:
createTypeIndex
in interfaceSchema
-
createTypeIndex
@Deprecated public TypeIndex createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
Deprecated.- Specified by:
createTypeIndex
in interfaceSchema
-
createTypeIndex
@Deprecated public TypeIndex createTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
Deprecated.- Specified by:
createTypeIndex
in interfaceSchema
-
getOrCreateTypeIndex
public TypeIndex getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String... propertyNames)
- Specified by:
getOrCreateTypeIndex
in interfaceSchema
-
getOrCreateTypeIndex
@Deprecated public TypeIndex getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize)
Deprecated.- Specified by:
getOrCreateTypeIndex
in interfaceSchema
-
getOrCreateTypeIndex
@Deprecated public TypeIndex getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize, Index.BuildIndexCallback callback)
Deprecated.- Specified by:
getOrCreateTypeIndex
in interfaceSchema
-
getOrCreateTypeIndex
@Deprecated public TypeIndex getOrCreateTypeIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
Deprecated.- Specified by:
getOrCreateTypeIndex
in interfaceSchema
-
createBucketIndex
@Deprecated public Index createBucketIndex(Schema.INDEX_TYPE indexType, boolean unique, String typeName, String bucketName, String[] propertyNames, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback)
Deprecated.- Specified by:
createBucketIndex
in interfaceSchema
-
createManualIndex
@Deprecated public Index createManualIndex(Schema.INDEX_TYPE indexType, boolean unique, String indexName, Type[] keyTypes, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy)
Deprecated.- Specified by:
createManualIndex
in interfaceSchema
-
close
public void close()
-
getDictionary
public Dictionary getDictionary()
- Specified by:
getDictionary
in interfaceSchema
-
getDatabase
public Database getDatabase()
-
getTypes
public Collection<DocumentType> getTypes()
-
getType
public LocalDocumentType getType(String typeName)
-
getTypeNameByBucketId
public String getTypeNameByBucketId(int bucketId)
- Specified by:
getTypeNameByBucketId
in interfaceSchema
-
getTypeByBucketId
public DocumentType getTypeByBucketId(int bucketId)
- Specified by:
getTypeByBucketId
in interfaceSchema
-
getInvolvedTypeByBucketId
public DocumentType getInvolvedTypeByBucketId(int bucketId)
- Specified by:
getInvolvedTypeByBucketId
in interfaceSchema
-
getTypeByBucketName
public DocumentType getTypeByBucketName(String bucketName)
- Specified by:
getTypeByBucketName
in interfaceSchema
-
existsType
public boolean existsType(String typeName)
- Specified by:
existsType
in interfaceSchema
-
dropBucket
public void dropBucket(String bucketName)
- Specified by:
dropBucket
in interfaceSchema
-
createDocumentType
public DocumentType createDocumentType(String typeName)
Description copied from interface:Schema
Creates a new document type with the default settings of buckets. This is the same as using `buildDocumentType().withName(typeName).create()`.- Specified by:
createDocumentType
in interfaceSchema
-
createDocumentType
public DocumentType createDocumentType(String typeName, int buckets)
- Specified by:
createDocumentType
in interfaceSchema
-
createDocumentType
public DocumentType createDocumentType(String typeName, int buckets, int pageSize)
- Specified by:
createDocumentType
in interfaceSchema
-
createDocumentType
public DocumentType createDocumentType(String typeName, List<Bucket> buckets)
- Specified by:
createDocumentType
in interfaceSchema
-
createDocumentType
public DocumentType createDocumentType(String typeName, List<Bucket> buckets, int pageSize)
- Specified by:
createDocumentType
in interfaceSchema
-
getOrCreateDocumentType
public DocumentType getOrCreateDocumentType(String typeName)
Description copied from interface:Schema
Returns a document type if already defined otherwise creates it in the schema. This is equivalent to `buildDocumentType().withName(typeName).withIgnoreIfExists(true).create()`.- Specified by:
getOrCreateDocumentType
in interfaceSchema
-
getOrCreateDocumentType
public DocumentType getOrCreateDocumentType(String typeName, int buckets)
- Specified by:
getOrCreateDocumentType
in interfaceSchema
-
getOrCreateDocumentType
public DocumentType getOrCreateDocumentType(String typeName, int buckets, int pageSize)
- Specified by:
getOrCreateDocumentType
in interfaceSchema
-
buildDocumentType
public TypeBuilder<LocalDocumentType> buildDocumentType()
- Specified by:
buildDocumentType
in interfaceSchema
-
createVertexType
public VertexType createVertexType(String typeName)
Description copied from interface:Schema
Creates a new vertex type with the default settings of buckets. This is the same as using `buildVertexType().withName(typeName).create()`.- Specified by:
createVertexType
in interfaceSchema
-
createVertexType
public VertexType createVertexType(String typeName, int buckets)
- Specified by:
createVertexType
in interfaceSchema
-
createVertexType
public VertexType createVertexType(String typeName, List<Bucket> bucketInstances)
- Specified by:
createVertexType
in interfaceSchema
-
createVertexType
public VertexType createVertexType(String typeName, int buckets, int pageSize)
- Specified by:
createVertexType
in interfaceSchema
-
createVertexType
public VertexType createVertexType(String typeName, List<Bucket> bucketInstances, int pageSize)
- Specified by:
createVertexType
in interfaceSchema
-
getOrCreateVertexType
public VertexType getOrCreateVertexType(String typeName)
Description copied from interface:Schema
Returns a vertex type if already defined otherwise creates it in the schema. This is equivalent to `buildVertexType().withName(typeName).withIgnoreIfExists(true).create()`.- Specified by:
getOrCreateVertexType
in interfaceSchema
-
getOrCreateVertexType
public VertexType getOrCreateVertexType(String typeName, int buckets)
- Specified by:
getOrCreateVertexType
in interfaceSchema
-
getOrCreateVertexType
public VertexType getOrCreateVertexType(String typeName, int buckets, int pageSize)
- Specified by:
getOrCreateVertexType
in interfaceSchema
-
buildVertexType
public TypeBuilder<VertexType> buildVertexType()
- Specified by:
buildVertexType
in interfaceSchema
-
createEdgeType
public EdgeType createEdgeType(String typeName)
Description copied from interface:Schema
Creates a new edge type with the default settings of buckets. This is the same as using `buildEdgeType().withName(typeName).create()`.- Specified by:
createEdgeType
in interfaceSchema
-
createEdgeType
public EdgeType createEdgeType(String typeName, int buckets)
- Specified by:
createEdgeType
in interfaceSchema
-
createEdgeType
public EdgeType createEdgeType(String typeName, int buckets, int pageSize)
- Specified by:
createEdgeType
in interfaceSchema
-
createEdgeType
public EdgeType createEdgeType(String typeName, List<Bucket> buckets)
- Specified by:
createEdgeType
in interfaceSchema
-
createEdgeType
public EdgeType createEdgeType(String typeName, List<Bucket> buckets, int pageSize)
- Specified by:
createEdgeType
in interfaceSchema
-
getOrCreateEdgeType
public EdgeType getOrCreateEdgeType(String typeName)
Description copied from interface:Schema
Returns an edge type if already defined otherwise creates it in the schema. This is equivalent to `buildEdgeType().withName(typeName).withIgnoreIfExists(true).create()`.- Specified by:
getOrCreateEdgeType
in interfaceSchema
-
getOrCreateEdgeType
public EdgeType getOrCreateEdgeType(String typeName, int buckets)
- Specified by:
getOrCreateEdgeType
in interfaceSchema
-
getOrCreateEdgeType
public EdgeType getOrCreateEdgeType(String typeName, int buckets, int pageSize)
- Specified by:
getOrCreateEdgeType
in interfaceSchema
-
buildEdgeType
public TypeBuilder<EdgeType> buildEdgeType()
- Specified by:
buildEdgeType
in interfaceSchema
-
readConfiguration
protected void readConfiguration()
-
saveConfiguration
public void saveConfiguration()
-
toJSON
public JSONObject toJSON()
-
registerFile
public void registerFile(Component file)
-
initComponents
public void initComponents()
-
registerFunctionLibrary
public Schema registerFunctionLibrary(FunctionLibraryDefinition library)
Description copied from interface:Schema
Registers a function library.- Specified by:
registerFunctionLibrary
in interfaceSchema
- Parameters:
library
- Function library definition implementation- Returns:
- The current schema instance
-
unregisterFunctionLibrary
public Schema unregisterFunctionLibrary(String name)
Description copied from interface:Schema
Unregister a function library previously defined.- Specified by:
unregisterFunctionLibrary
in interfaceSchema
- Parameters:
name
- Name of the function to unregister- Returns:
- The current schema instance
-
getFunctionLibraries
public Iterable<FunctionLibraryDefinition> getFunctionLibraries()
Description copied from interface:Schema
Returns all the registered function libraries.- Specified by:
getFunctionLibraries
in interfaceSchema
-
hasFunctionLibrary
public boolean hasFunctionLibrary(String name)
Description copied from interface:Schema
Returns true if the a function library is defined, otherwise false.- Specified by:
hasFunctionLibrary
in interfaceSchema
- Parameters:
name
- Function library nme
-
getFunctionLibrary
public FunctionLibraryDefinition getFunctionLibrary(String name)
Description copied from interface:Schema
Returns the requested function library if defined or IllegalArgumentException if not- Specified by:
getFunctionLibrary
in interfaceSchema
- Parameters:
name
- Function library to search
-
getFunction
public FunctionDefinition getFunction(String libraryName, String functionName) throws IllegalArgumentException
Description copied from interface:Schema
Returns a function defined in a library.- Specified by:
getFunction
in interfaceSchema
- Parameters:
libraryName
- Name of the function libraryfunctionName
- Name of the function- Returns:
- The function definition if found
- Throws:
IllegalArgumentException
- if the library or the function is not defined
-
isDirty
public boolean isDirty()
-
getConfigurationFile
public File getConfigurationFile()
-
getVersion
public long getVersion()
-
update
public void update(JSONObject newSchema) throws IOException
- Throws:
IOException
-
createBucketIndex
protected Index createBucketIndex(LocalDocumentType type, Type[] keyTypes, Bucket bucket, String typeName, Schema.INDEX_TYPE indexType, boolean unique, int pageSize, LSMTreeIndexAbstract.NULL_STRATEGY nullStrategy, Index.BuildIndexCallback callback, String[] propertyNames, TypeIndex propIndex, int batchSize)
-
isSchemaLoaded
protected boolean isSchemaLoaded()
-
updateSecurity
protected void updateSecurity()
-
-