Package com.arcadedb.database
Interface Database
-
- All Superinterfaces:
AutoCloseable
,BasicDatabase
- All Known Subinterfaces:
DatabaseInternal
- All Known Implementing Classes:
EmbeddedDatabase
public interface Database extends BasicDatabase
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Database.TRANSACTION_ISOLATION_LEVEL
-
Nested classes/interfaces inherited from interface com.arcadedb.database.BasicDatabase
BasicDatabase.TransactionScope
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description DatabaseAsyncExecutor
async()
ResultSet
command(String language, String query, ContextConfiguration configuration, Map<String,Object> args)
Executes a command by specifying the language and arguments in a map.ResultSet
command(String language, String query, Map<String,Object> args)
Executes a command by specifying the language and arguments in a map.ResultSet
execute(String language, String script, Map<String,Object> args)
Deprecated.<RET> RET
executeInReadLock(Callable<RET> callable)
Executes an operation in database read (shared) lock.<RET> RET
executeInWriteLock(Callable<RET> callable)
Executes an operation in database write (exclusive) lock.ContextConfiguration
getConfiguration()
String
getCurrentUserName()
Return the current username if the database supports security.String
getDatabasePath()
int
getEdgeListSize()
Returns the current default edge list initial size to hold and store edges.RecordEvents
getEvents()
Returns the record events listeners interface to manage listeners.ComponentFile.MODE
getMode()
QueryEngine
getQueryEngine(String language)
Returns the query engine by language name.Schema
getSchema()
Returns the database schema.Database.TRANSACTION_ISOLATION_LEVEL
getTransactionIsolationLevel()
returns the transaction isolation level between the available ones: READ_COMMITTED REPEATABLE_READ SERIALIZABLEboolean
isAsyncFlush()
Returns the asynchronous flush setting.boolean
isAutoTransaction()
Returns true if a transaction is started automatically for all non-idempotent operation in the database.boolean
isOpen()
boolean
isReadYourWrites()
If enabled, writes the writes to the database are immediately available in queries and lookup.Iterator<Record>
iterateBucket(String bucketName)
Iterates the records contained in a bucket.Iterator<Record>
iterateType(String typeName, boolean polymorphic)
Iterates the records contained in all the buckets defined by a type.IndexCursor
lookupByKey(String type, String[] keyNames, Object[] keyValues)
Looks up for records of a specific type by a set of keys and values.IndexCursor
lookupByKey(String type, String keyName, Object keyValue)
Looks up for records of a specific type by a key and value.Edge
newEdgeByKeys(Vertex sourceVertex, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, Object... properties)
Creates a new edge between two vertices specifying the source vertex instance and the key/value pairs to lookup for the destination vertices.Edge
newEdgeByKeys(String sourceVertexType, String[] sourceVertexKeyNames, Object[] sourceVertexKeyValues, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, Object... properties)
Creates a new edge between two vertices specifying the key/value pairs to lookup for both source and destination vertices.ResultSet
query(String language, String query, Map<String,Object> args)
Executes a query as an idempotent (read only) command by specifying the language and arguments in a map.void
rollbackAllNested()
Rolls back all the nested transactions if any.void
scanBucket(String bucketName, RecordCallback callback)
Scans the records contained in the specified bucket.void
scanBucket(String bucketName, RecordCallback callback, ErrorRecordCallback errorRecordCallback)
Scans the records contained in the specified bucket.void
scanType(String typeName, boolean polymorphic, DocumentCallback callback)
Scans the records contained in all the buckets defined by a type.void
scanType(String typeName, boolean polymorphic, DocumentCallback callback, ErrorRecordCallback errorRecordCallback)
Scans the records contained in all the buckets defined by a type.Database
setAsyncFlush(boolean value)
Changes the default asynchronous flush setting.void
setAutoTransaction(boolean autoTransaction)
Database
setEdgeListSize(int size)
Modifies the default edge list initial size to hold and store edges.Database
setReadYourWrites(boolean value)
Tells to the database writes must be immediately available for following reads and lookup.Database
setTransactionIsolationLevel(Database.TRANSACTION_ISOLATION_LEVEL level)
Sets the transaction isolation level between the available ones: READ_COMMITTED REPEATABLE_READ SERIALIZABLEDatabase
setUseWAL(boolean useWAL)
Changes the settings about using the WAL (Write Ahead Log - Transaction Journal) for transactions.Database
setWALFlush(WALFile.FLUSH_TYPE flush)
Sets the WAL (Write Ahead Log - Transaction Journal) flush strategy.-
Methods inherited from interface com.arcadedb.database.BasicDatabase
begin, begin, close, command, command, commit, countBucket, countType, deleteRecord, drop, execute, existsRecord, getName, getStats, isTransactionActive, lookupByRID, newDocument, newVertex, query, rollback, transaction, transaction, transaction, transaction
-
-
-
-
Method Detail
-
getConfiguration
ContextConfiguration getConfiguration()
-
getMode
ComponentFile.MODE getMode()
-
async
DatabaseAsyncExecutor async()
-
getDatabasePath
String getDatabasePath()
-
isOpen
boolean isOpen()
-
getCurrentUserName
String getCurrentUserName()
Return the current username if the database supports security. If used embedded, ArcadeDB does not provide a security model. If you want to use database security, use ArcadeDB server.
-
command
ResultSet command(String language, String query, Map<String,Object> args)
Executes a command by specifying the language and arguments in a map.- Parameters:
language
- The language to use between the supported ones ("sql", "gremlin", "cypher", "graphql", "mongo", etc.)query
- The command to be interpreted in the specified language as a stringargs
- Arguments to pass to the command as a map of name/values.- Returns:
- The
ResultSet
object containing the result of the operation if succeeded, otherwise a runtime exception is thrown
-
command
ResultSet command(String language, String query, ContextConfiguration configuration, Map<String,Object> args)
Executes a command by specifying the language and arguments in a map.- Parameters:
language
- The language to use between the supported ones ("sql", "gremlin", "cypher", "graphql", "mongo", etc.)query
- The command to be interpreted in the specified language as a stringconfiguration
- Configuration to use. When executed from a server, the server configuration is used. If null, an empty configuration will be usedargs
- Arguments to pass to the command as a map of name/values.- Returns:
- The
ResultSet
object containing the result of the operation if succeeded, otherwise a runtime exception is thrown
-
query
ResultSet query(String language, String query, Map<String,Object> args)
Executes a query as an idempotent (read only) command by specifying the language and arguments in a map.- Parameters:
language
- The language to use between the supported ones ("sql", "gremlin", "cypher", "graphql", "mongo", etc.)query
- The command to be interpreted in the specified language as a stringargs
- Arguments to pass to the command as a map of name/values.- Returns:
- The
ResultSet
object containing the result of the operation if succeeded, otherwise a runtime exception is thrown
-
execute
@Deprecated ResultSet execute(String language, String script, Map<String,Object> args)
Deprecated.
-
isAutoTransaction
boolean isAutoTransaction()
Returns true if a transaction is started automatically for all non-idempotent operation in the database.
-
setAutoTransaction
void setAutoTransaction(boolean autoTransaction)
-
rollbackAllNested
void rollbackAllNested()
Rolls back all the nested transactions if any.
-
scanType
void scanType(String typeName, boolean polymorphic, DocumentCallback callback)
Scans the records contained in all the buckets defined by a type. This operation scans in sequence each bucket looking for documents, vertices and edges. For each record found a call to #DocumentCallback.onRecord is invoked. If the callback returns false, the scan is terminated, otherwise it continues to the next record.- Parameters:
typeName
- The name of the typepolymorphic
- true if the records of all the subtypes must be included, otherwise only the records strictly contained in the #typeName will be scannedcallback
- Callback to handle the loaded record document. Returns false to interrupt the scan operation, otherwise true to continue till the end
-
scanType
void scanType(String typeName, boolean polymorphic, DocumentCallback callback, ErrorRecordCallback errorRecordCallback)
Scans the records contained in all the buckets defined by a type. This operation scans in sequence each bucket looking for documents, vertices and edges. For each record found a call to #DocumentCallback.onRecord is invoked. If the callback returns false, the scan is terminated, otherwise it continues to the next record.- Parameters:
typeName
- The name of the typepolymorphic
- true if the records of all the subtypes must be included, otherwise only the records strictly contained in the #typeName will be scannedcallback
- Callback to handle the loaded record document. Returns false to interrupt the scan operation, otherwise true to continue till the enderrorRecordCallback
- Callback used in case of error during the scan
-
scanBucket
void scanBucket(String bucketName, RecordCallback callback)
Scans the records contained in the specified bucket. This operation scans in sequence each bucket. For each record found a call to #RecordCallback.onRecord is invoked. If the callback returns false, the scan is terminated, otherwise it continues to the next record.- Parameters:
bucketName
- The name of the bucketcallback
- Callback to handle the loaded record document. Returns false to interrupt the scan operation, otherwise true to continue till the end
-
scanBucket
void scanBucket(String bucketName, RecordCallback callback, ErrorRecordCallback errorRecordCallback)
Scans the records contained in the specified bucket. This operation scans in sequence each bucket. For each record found a call to #RecordCallback.onRecord is invoked. If the callback returns false, the scan is terminated, otherwise it continues to the next record.- Parameters:
bucketName
- The name of the bucketcallback
- Callback to handle the loaded record document. Returns false to interrupt the scan operation, otherwise true to continue till the enderrorRecordCallback
- Callback used in case of error during the scan
-
lookupByKey
IndexCursor lookupByKey(String type, String keyName, Object keyValue)
Looks up for records of a specific type by a key and value. This operation requires an index to be created against the property used in the key.- Parameters:
type
- Type namekeyName
- Name of the property defined in the index to usekeyValue
- Value to look for in the index- Returns:
- A cursor containing the records found if any
- Throws:
IllegalArgumentException
- If an index is not defined on the `type.keyName` property
-
lookupByKey
IndexCursor lookupByKey(String type, String[] keyNames, Object[] keyValues)
Looks up for records of a specific type by a set of keys and values. This operation requires an index to be created against the properties used in the key.- Parameters:
type
- Type namekeyNames
- Names of the property defined in the index to usekeyValues
- Values to look for in the index- Returns:
- A cursor containing the records found if any
- Throws:
IllegalArgumentException
- If an index is not defined on the `type.keyNames` property
-
iterateType
Iterator<Record> iterateType(String typeName, boolean polymorphic)
Iterates the records contained in all the buckets defined by a type. This operation iterates in sequence each bucket.- Parameters:
typeName
- The name of the typepolymorphic
- true if the records of all the subtypes must be included, otherwise only the records strictly contained in the #typeName will be scanned- Returns:
- The number of records found
-
iterateBucket
Iterator<Record> iterateBucket(String bucketName)
Iterates the records contained in a bucket.- Parameters:
bucketName
- The name of the bucket- Returns:
- The number of records found
-
newEdgeByKeys
Edge newEdgeByKeys(String sourceVertexType, String[] sourceVertexKeyNames, Object[] sourceVertexKeyValues, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, Object... properties)
Creates a new edge between two vertices specifying the key/value pairs to lookup for both source and destination vertices. The direction of the edge is from source to destination. This API is useful for bulk import of edges.- Parameters:
sourceVertexType
- Source vertex type namesourceVertexKeyNames
- Source vertex keyssourceVertexKeyValues
- Source vertex valuesdestinationVertexType
- Destination vertex type namedestinationVertexKeyNames
- Destination vertex keysdestinationVertexKeyValues
- Source vertex valuescreateVertexIfNotExist
- True to create vertices if the lookup did not find the vertices. This is valid for both source and destination vertices. In case the vertices are implicitly created, only the properties specified in keys and values will be setedgeType
- Type of the edge to create. The type must be defined in the schema beforehandbidirectional
- True to create a bidirectional edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performancesproperties
- Initial properties to set to the new edge as a variable argument array with key/value pairs- Returns:
- The new edge. The edge is already persistent in the current transaction.
- See Also:
DatabaseAsyncExecutor.newEdgeByKeys(String, String, Object, String, String, Object, boolean, String, boolean, boolean, NewEdgeCallback, Object...)
,newEdgeByKeys(Vertex, String, String[], Object[], boolean, String, boolean, Object...)
-
newEdgeByKeys
Edge newEdgeByKeys(Vertex sourceVertex, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, Object... properties)
Creates a new edge between two vertices specifying the source vertex instance and the key/value pairs to lookup for the destination vertices. The direction of the edge is from source to destination. This API is useful for bulk import of edges.- Parameters:
sourceVertex
- Source vertex instancedestinationVertexType
- Destination vertex type namedestinationVertexKeyNames
- Destination vertex keysdestinationVertexKeyValues
- Source vertex valuescreateVertexIfNotExist
- True to create the destination vertex if the lookup did not find the destination vertex. In case the destination vertex is implicitly created, only the properties specified in keys and values will be setedgeType
- Type of the edge to create. The type must be defined in the schema beforehandbidirectional
- True to create a bidirectional edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performancesproperties
- Initial properties to set to the new edge as a variable argument array with key/value pairs- Returns:
- The new edge. The edge is already persistent in the current transaction.
- See Also:
DatabaseAsyncExecutor.newEdgeByKeys(String, String, Object, String, String, Object, boolean, String, boolean, boolean, NewEdgeCallback, Object...)
,newEdgeByKeys(String, String[], Object[], String, String[], Object[], boolean, String, boolean, Object...)
-
getQueryEngine
QueryEngine getQueryEngine(String language)
Returns the query engine by language name.- Parameters:
language
- Language name- Returns:
- Query engine implementation if available, otherwise null
-
getSchema
Schema getSchema()
Returns the database schema.
-
getEvents
RecordEvents getEvents()
Returns the record events listeners interface to manage listeners.
-
executeInReadLock
<RET> RET executeInReadLock(Callable<RET> callable)
Executes an operation in database read (shared) lock.
-
executeInWriteLock
<RET> RET executeInWriteLock(Callable<RET> callable)
Executes an operation in database write (exclusive) lock.
-
isReadYourWrites
boolean isReadYourWrites()
If enabled, writes the writes to the database are immediately available in queries and lookup.- Returns:
- true if "ready your write" setting is enabled, otherwise false.
-
setReadYourWrites
Database setReadYourWrites(boolean value)
Tells to the database writes must be immediately available for following reads and lookup. Disable this setting to speedup massive insertion workloads.- Parameters:
value
- set to true to enable the "ready your write" setting, otherwise false.- Returns:
- Current Database instance to execute setter methods in chain.
-
setTransactionIsolationLevel
Database setTransactionIsolationLevel(Database.TRANSACTION_ISOLATION_LEVEL level)
Sets the transaction isolation level between the available ones:- READ_COMMITTED
- REPEATABLE_READ
- SERIALIZABLE
- Parameters:
level
- The isolation level- Returns:
- Current Database instance to execute setter methods in chain.
-
getTransactionIsolationLevel
Database.TRANSACTION_ISOLATION_LEVEL getTransactionIsolationLevel()
returns the transaction isolation level between the available ones:- READ_COMMITTED
- REPEATABLE_READ
- SERIALIZABLE
- Returns:
- Current isolation level.
-
getEdgeListSize
int getEdgeListSize()
Returns the current default edge list initial size to hold and store edges.
-
setEdgeListSize
Database setEdgeListSize(int size)
Modifies the default edge list initial size to hold and store edges.- Parameters:
size
- new size of the list- Returns:
- Current Database instance to execute setter methods in chain.
-
setUseWAL
Database setUseWAL(boolean useWAL)
Changes the settings about using the WAL (Write Ahead Log - Transaction Journal) for transactions. By default, the WAL is enabled and preserve the database in case of crash. Disabling the WAL is not recommended unless initial importing of the database or bulk loading.- Parameters:
useWAL
- true to use the WAL, otherwise false- Returns:
- Current Database instance to execute setter methods in chain.
-
setWALFlush
Database setWALFlush(WALFile.FLUSH_TYPE flush)
Sets the WAL (Write Ahead Log - Transaction Journal) flush strategy.- Parameters:
flush
- The new value contained in the enum: `NO` (no flush), `YES_NOMETADATA` (flush only data, no metadata), `YES_FULL` (full flush)- Returns:
- Current Database instance to execute setter methods in chain.
- See Also:
DatabaseAsyncExecutor.setTransactionSync(WALFile.FLUSH_TYPE)
-
isAsyncFlush
boolean isAsyncFlush()
Returns the asynchronous flush setting. If enabled, modified pages in transactions are flushed to disk by using an asynchronous thread. This is the default behaviour. While the WAL (Write Ahead Log - Transaction Journal) is always written synchronously to avoid data loss in case of crash, the actual data pages write can be deferred because the updated information to save is contained also in the WAL and will be restored in case of crash.- Returns:
- true if asynchronous flush setting is enabled, otherwise false
- See Also:
setAsyncFlush(boolean)
-
setAsyncFlush
Database setAsyncFlush(boolean value)
Changes the default asynchronous flush setting. If enabled, modified pages in transactions are flushed to disk by using an asynchronous thread. This is the default behaviour. While the WAL (Write Ahead Log - Transaction Journal) is always written synchronously to avoid data loss in case of crash, the actual data pages write can be deferred because the updated information to save is contained also in the WAL and will be restored in case of crash.- Returns:
- Current Database instance to execute setter methods in chain.
- See Also:
isAsyncFlush()
-
-