Package com.arcadedb.database
Interface Database
-
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
DatabaseInternal
- All Known Implementing Classes:
EmbeddedDatabase
public interface Database extends AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Database.TransactionScope
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DatabaseAsyncExecutor
async()
void
begin()
Begins a new transaction.boolean
checkTransactionIsActive(boolean createTx)
void
close()
ResultSet
command(String language, String query, Object... args)
ResultSet
command(String language, String query, Map<String,Object> args)
void
commit()
Commits the current transaction.long
countBucket(String bucketName)
long
countType(String typeName, boolean polymorphic)
void
deleteRecord(Record record)
void
drop()
ResultSet
execute(String language, String script, Object... args)
ResultSet
execute(String language, String script, Map<Object,Object> args)
<RET> RET
executeInReadLock(Callable<RET> callable)
<RET> RET
executeInWriteLock(Callable<RET> callable)
ContextConfiguration
getConfiguration()
String
getDatabasePath()
PaginatedFile.MODE
getMode()
String
getName()
Schema
getSchema()
Transaction
getTransaction()
boolean
isAutoTransaction()
boolean
isOpen()
boolean
isReadYourWrites()
boolean
isTransactionActive()
Iterator<Record>
iterateBucket(String bucketName)
Iterator<Record>
iterateType(String typeName, boolean polymorphic)
IndexCursor
lookupByKey(String type, String[] keyNames, Object[] keyValues)
IndexCursor
lookupByKey(String type, String keyName, Object keyValue)
Record
lookupByRID(RID rid, boolean loadContent)
MutableDocument
newDocument(String typeName)
Edge
newEdgeByKeys(Vertex sourceVertex, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, Object... properties)
Edge
newEdgeByKeys(String sourceVertexType, String[] sourceVertexKeyNames, Object[] sourceVertexKeyValues, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, Object... properties)
MutableVertex
newVertex(String typeName)
ResultSet
query(String language, String query, Object... args)
ResultSet
query(String language, String query, Map<String,Object> args)
void
rollback()
Rolls back the current transaction.void
rollbackAllNested()
Rolls back all the nested transactions if any.void
scanBucket(String bucketName, RecordCallback callback)
void
scanType(String typeName, boolean polymorphic, DocumentCallback callback)
void
setAutoTransaction(boolean autoTransaction)
void
setEdgeListSize(int size)
void
setReadYourWrites(boolean value)
void
transaction(Database.TransactionScope txBlock)
Executes a lambda in the transaction scope.boolean
transaction(Database.TransactionScope txBlock, boolean joinCurrentTx)
Executes a lambda in the transaction scope.boolean
transaction(Database.TransactionScope txBlock, boolean joinCurrentTx, int retries)
Executes a lambda in the transaction scope.boolean
transaction(Database.TransactionScope txBlock, boolean joinCurrentTx, int retries, OkCallback ok, ErrorCallback error)
Executes a lambda in the transaction scope.
-
-
-
Method Detail
-
getConfiguration
ContextConfiguration getConfiguration()
-
getName
String getName()
-
getMode
PaginatedFile.MODE getMode()
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
-
isOpen
boolean isOpen()
-
drop
void drop()
-
async
DatabaseAsyncExecutor async()
-
getDatabasePath
String getDatabasePath()
-
getTransaction
Transaction getTransaction()
-
isTransactionActive
boolean isTransactionActive()
-
checkTransactionIsActive
boolean checkTransactionIsActive(boolean createTx)
-
transaction
void transaction(Database.TransactionScope txBlock)
Executes a lambda in the transaction scope. If there is an active transaction, then the current transaction is parked and a new sub-transaction is begun.- Parameters:
txBlock
- Transaction lambda to execute
-
transaction
boolean transaction(Database.TransactionScope txBlock, boolean joinCurrentTx)
Executes a lambda in the transaction scope. If there is an active transaction, then the current transaction is parked and a new sub-transaction is begun if joinCurrentTx is true, otherwise the current active transaction is joined.- Parameters:
txBlock
- Transaction lambda to executejoinCurrentTx
- if active joins the current transaction, otherwise always create a new one- Returns:
- true if a new transaction has been created or false if an existent transaction has been joined
-
transaction
boolean transaction(Database.TransactionScope txBlock, boolean joinCurrentTx, int retries)
Executes a lambda in the transaction scope. If there is an active transaction, then the current transaction is parked and a new sub-transaction is begun if joinCurrentTx is true, otherwise the current active transaction is joined. The difference with the methodtransaction(TransactionScope)
is that in case the NeedRetryException exception is thrown, the transaction is re-executed for a number of retries.- Parameters:
txBlock
- Transaction lambda to executejoinCurrentTx
- if active joins the current transaction, otherwise always create a new oneretries
- number of retries in case the NeedRetryException exception is thrown- Returns:
- true if a new transaction has been created or false if an existent transaction has been joined
-
transaction
boolean transaction(Database.TransactionScope txBlock, boolean joinCurrentTx, int retries, OkCallback ok, ErrorCallback error)
Executes a lambda in the transaction scope. If there is an active transaction, then the current transaction is parked and a new sub-transaction is begun if joinCurrentTx is true, otherwise the current active transaction is joined. The difference with the methodtransaction(TransactionScope)
is that in case the NeedRetryException exception is thrown, the transaction is re-executed for a number of retries.- Parameters:
txBlock
- Transaction lambda to executejoinCurrentTx
- if active joins the current transaction, otherwise always create a new oneretries
- number of retries in case the NeedRetryException exception is thrownok
- callback invoked if the transaction completes the commiterror
- callback invoked if the transaction cannot complete the commit, after the rollback- Returns:
- true if a new transaction has been created or false if an existent transaction has been joined
-
isAutoTransaction
boolean isAutoTransaction()
-
setAutoTransaction
void setAutoTransaction(boolean autoTransaction)
-
begin
void begin()
Begins a new transaction. If a transaction is already begun, the current transaction is parked and a new sub-transaction is begun. The new sub-transaction does not access to the content of the previous transaction. Sub transactions are totally isolated.
-
commit
void commit()
Commits the current transaction. If it was a sub-transaction, then the previous in the stack becomes active again.
-
rollback
void rollback()
Rolls back the current transaction. If it was a sub-transaction, then the previous in the stack becomes active again.
-
rollbackAllNested
void rollbackAllNested()
Rolls back all the nested transactions if any.
-
scanType
void scanType(String typeName, boolean polymorphic, DocumentCallback callback)
-
scanBucket
void scanBucket(String bucketName, RecordCallback callback)
-
lookupByKey
IndexCursor lookupByKey(String type, String keyName, Object keyValue)
-
lookupByKey
IndexCursor lookupByKey(String type, String[] keyNames, Object[] keyValues)
-
deleteRecord
void deleteRecord(Record record)
-
countType
long countType(String typeName, boolean polymorphic)
-
countBucket
long countBucket(String bucketName)
-
newDocument
MutableDocument newDocument(String typeName)
-
newVertex
MutableVertex newVertex(String typeName)
-
newEdgeByKeys
Edge newEdgeByKeys(String sourceVertexType, String[] sourceVertexKeyNames, Object[] sourceVertexKeyValues, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, Object... properties)
-
newEdgeByKeys
Edge newEdgeByKeys(Vertex sourceVertex, String destinationVertexType, String[] destinationVertexKeyNames, Object[] destinationVertexKeyValues, boolean createVertexIfNotExist, String edgeType, boolean bidirectional, Object... properties)
-
getSchema
Schema getSchema()
-
executeInReadLock
<RET> RET executeInReadLock(Callable<RET> callable)
-
executeInWriteLock
<RET> RET executeInWriteLock(Callable<RET> callable)
-
isReadYourWrites
boolean isReadYourWrites()
-
setReadYourWrites
void setReadYourWrites(boolean value)
-
setEdgeListSize
void setEdgeListSize(int size)
-
-