Class ODatabaseDocumentEmbedded

All Implemented Interfaces:
ODatabaseDocument, OQueryLifecycleListener, ODatabase<ORecord>, ODatabaseDocumentInternal, ODatabaseInternal<ORecord>, ODatabaseSession, OBackupable, Closeable, AutoCloseable
Direct Known Subclasses:
ODatabaseDocumentDistributed, ODatabaseDocumentEmbeddedPooled

public class ODatabaseDocumentEmbedded extends ODatabaseDocumentAbstract implements OQueryLifecycleListener
Created by tglman on 27/06/16.
  • Constructor Details

    • ODatabaseDocumentEmbedded

      public ODatabaseDocumentEmbedded(OStorage storage)
  • Method Details

    • open

      public <DB extends ODatabase> DB open(String iUserName, String iUserPassword)
      Description copied from interface: ODatabase
      Opens a database using the user and password received as arguments.
      Specified by:
      open in interface ODatabase<ORecord>
      Parameters:
      iUserName - Username to login
      iUserPassword - Password associated to the user
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • init

      public void init(OrientDBConfig config, OSharedContext sharedContext)
    • internalOpen

      public void internalOpen(OAuthenticationInfo authenticationInfo)
    • internalOpen

      public void internalOpen(String iUserName, String iUserPassword)
    • internalOpen

      public void internalOpen(String iUserName, String iUserPassword, boolean checkPassword)
    • open

      @Deprecated public <DB extends ODatabase> DB open(OToken iToken)
      Deprecated.
      Opens a database using an authentication token received as an argument.
      Specified by:
      open in interface ODatabaseInternal<ORecord>
      Parameters:
      iToken - Authentication token
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • create

      public <DB extends ODatabase> DB create()
      Description copied from interface: ODatabase
      Creates a new database.
      Specified by:
      create in interface ODatabase<ORecord>
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • internalCreate

      public void internalCreate(OrientDBConfig config, OSharedContext ctx)
    • callOnCreateListeners

      public void callOnCreateListeners()
    • createMetadata

      protected void createMetadata(OSharedContext shared)
    • loadMetadata

      protected void loadMetadata()
      Specified by:
      loadMetadata in class ODatabaseDocumentAbstract
    • set

      public <DB extends ODatabase> DB set(ODatabase.ATTRIBUTES iAttribute, Object iValue)
      Description copied from interface: ODatabase
      Sets a database attribute value
      Specified by:
      set in interface ODatabase<ORecord>
      Parameters:
      iAttribute - Attributes between #ATTRIBUTES enum
      iValue - Value to set
      Returns:
      underlying
    • setCustom

      public <DB extends ODatabase> DB setCustom(String name, Object iValue)
      Specified by:
      setCustom in interface ODatabaseDocumentInternal
    • create

      public <DB extends ODatabase> DB create(String incrementalBackupPath)
      Creates new database from database backup. Only incremental backups are supported.
      Specified by:
      create in interface ODatabase<ORecord>
      Type Parameters:
      DB - Concrete database instance type.
      Parameters:
      incrementalBackupPath - Path to incremental backup
      Returns:
      he Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • create

      public <DB extends ODatabase> DB create(Map<OGlobalConfiguration,Object> iInitialSettings)
      Description copied from interface: ODatabase
      Creates a new database passing initial settings.
      Specified by:
      create in interface ODatabase<ORecord>
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • drop

      public void drop()
      Drops a database.
      Specified by:
      drop in interface ODatabase<ORecord>
    • copy

      Returns a copy of current database if it's open. The returned instance can be used by another thread without affecting current instance. The database copy is not set in thread local.
      Specified by:
      copy in interface ODatabaseDocumentInternal
    • exists

      public boolean exists()
      Description copied from interface: ODatabase
      Checks if the database exists.
      Specified by:
      exists in interface ODatabase<ORecord>
      Returns:
      True if already exists, otherwise false.
    • isClosed

      public boolean isClosed()
      Description copied from interface: ODatabase
      Checks if the database is closed.
      Specified by:
      isClosed in interface ODatabase<ORecord>
      Returns:
      true if is closed, otherwise false.
    • rebuildIndexes

      public void rebuildIndexes()
    • installHooksEmbedded

      protected void installHooksEmbedded()
    • getStorage

      public OStorage getStorage()
      Description copied from interface: ODatabaseInternal
      Returns the underlying storage implementation.
      Specified by:
      getStorage in interface ODatabaseInternal<ORecord>
      Returns:
      The underlying storage implementation
      See Also:
    • getStorageInfo

      public OStorageInfo getStorageInfo()
      Specified by:
      getStorageInfo in interface ODatabaseInternal<ORecord>
    • replaceStorage

      public void replaceStorage(OStorage iNewStorage)
      Description copied from interface: ODatabaseInternal
      Internal only: replace the storage with a new one.
      Specified by:
      replaceStorage in interface ODatabaseInternal<ORecord>
      Parameters:
      iNewStorage - The new storage to use. Usually it's a wrapped instance of the current cluster.
    • query

      public OResultSet query(String query, Object[] args)
      Description copied from interface: ODatabase
      Executes an SQL query. The result set has to be closed after usage

      Sample usage:

      OResultSet rs = db.query("SELECT FROM V where name = ?", "John"); while(rs.hasNext()){ OResult item = rs.next(); ... } rs.close();

      Specified by:
      query in interface ODatabase<ORecord>
      Parameters:
      query - the query string
      args - query parameters (positional)
      Returns:
      the query result set
    • query

      public OResultSet query(String query, Map args)
      Description copied from interface: ODatabase
      Executes an SQL query (idempotent). The result set has to be closed after usage

      Sample usage:

      Map<String, Object&gt params = new HashMapMap<&gt(); params.put("name", "John"); OResultSet rs = db.query("SELECT FROM V where name = :name", params); while(rs.hasNext()){ OResult item = rs.next(); ... } rs.close();

      Specified by:
      query in interface ODatabase<ORecord>
      Parameters:
      query - the query string
      args - query parameters (named)
      Returns:
    • command

      public OResultSet command(String query, Object[] args)
      Description copied from interface: ODatabase
      Executes a generic (idempotent or non idempotent) command. The result set has to be closed after usage

      Sample usage:

      OResultSet rs = db.command("INSERT INTO Person SET name = ?", "John"); ... rs.close();

      Specified by:
      command in interface ODatabase<ORecord>
      args - query arguments
      Returns:
    • command

      public OResultSet command(String query, Map args)
      Description copied from interface: ODatabase
      Executes a generic (idempotent or non idempotent) command. The result set has to be closed after usage

      Sample usage:

      Map<String, Object&gt params = new HashMapMap<&gt(); params.put("name", "John"); OResultSet rs = db.query("INSERT INTO Person SET name = :name", params); ... rs.close();

      Specified by:
      command in interface ODatabase<ORecord>
      Returns:
    • execute

      public OResultSet execute(String language, String script, Object... args)
      Description copied from interface: ODatabase
      Execute a script in a specified query language. The result set has to be closed after usage

      Sample usage:

      String script = "INSERT INTO Person SET name = 'foo', surname = ?;"+ "INSERT INTO Person SET name = 'bar', surname = ?;"+ "INSERT INTO Person SET name = 'baz', surname = ?;";

      OResultSet rs = db.execute("sql", script, "Surname1", "Surname2", "Surname3"); ... rs.close();

      Specified by:
      execute in interface ODatabase<ORecord>
      Returns:
    • execute

      public OResultSet execute(String language, String script, Map<String,?> args)
      Description copied from interface: ODatabase
      Execute a script of a specified query language The result set has to be closed after usage

      Sample usage:

      Map<String, Object&gt params = new HashMapMap<&gt(); params.put("surname1", "Jones"); params.put("surname2", "May"); params.put("surname3", "Ali");

      String script = "INSERT INTO Person SET name = 'foo', surname = :surname1;"+ "INSERT INTO Person SET name = 'bar', surname = :surname2;"+ "INSERT INTO Person SET name = 'baz', surname = :surname3;";

      OResultSet rs = db.execute("sql", script, params); ... rs.close();

      Specified by:
      execute in interface ODatabase<ORecord>
      Returns:
    • query

    • queryStartUsingViewCluster

      public void queryStartUsingViewCluster(int clusterId)
      Specified by:
      queryStartUsingViewCluster in interface ODatabaseDocumentInternal
    • queryStartUsingViewIndex

      public void queryStartUsingViewIndex(String index)
      Specified by:
      queryStartUsingViewIndex in interface ODatabaseDocumentInternal
    • queryStarted

      public void queryStarted(String id, OResultSet resultSet)
      Specified by:
      queryStarted in interface OQueryLifecycleListener
    • getConfig

      public OrientDBConfig getConfig()
    • live

      public OLiveQueryMonitor live(String query, OLiveQueryResultListener listener, Object... args)
      Description copied from interface: ODatabase
      Subscribe a query as a live query for future create/update event with the referred conditions
      Specified by:
      live in interface ODatabase<ORecord>
      Parameters:
      query - live query
      listener - the listener that receive the query results
      args - the live query args
    • live

      public OLiveQueryMonitor live(String query, OLiveQueryResultListener listener, Map<String,?> args)
      Description copied from interface: ODatabase
      Subscribe a query as a live query for future create/update event with the referred conditions
      Specified by:
      live in interface ODatabase<ORecord>
      Parameters:
      query - live query
      listener - the listener that receive the query results
      args - the live query args
    • recycle

      public void recycle(ORecord record)
      Specified by:
      recycle in interface ODatabaseDocumentInternal
    • addBlobCluster

      public int addBlobCluster(String iClusterName, Object... iParameters)
      Description copied from interface: ODatabaseDocument
      Add a cluster for blob records.
      Specified by:
      addBlobCluster in interface ODatabase<ORecord>
      Specified by:
      addBlobCluster in interface ODatabaseDocument
      Parameters:
      iClusterName - Cluster name
      iParameters - Additional parameters to pass to the factories
      Returns:
      Cluster id
    • executeDeleteRecord

      public void executeDeleteRecord(OIdentifiable identifiable, int iVersion, boolean iRequired, ODatabase.OPERATION_MODE iMode, boolean prohibitTombstones)
      This method is internal, it can be subject to signature change or be removed, do not use. @Internal
      Specified by:
      executeDeleteRecord in interface ODatabaseDocumentInternal
    • beforeCreateOperations

      public OIdentifiable beforeCreateOperations(OIdentifiable id, String iClusterName)
      Specified by:
      beforeCreateOperations in interface ODatabaseDocumentInternal
      Returns:
      null if nothing changed the instance if has been modified or replaced
    • beforeUpdateOperations

      public OIdentifiable beforeUpdateOperations(OIdentifiable id, String iClusterName)
      Specified by:
      beforeUpdateOperations in interface ODatabaseDocumentInternal
      Returns:
      null if nothing changed the instance if has been modified or replaced
    • delete

      public ODatabaseDocumentAbstract delete(ORecord record)
      Deletes a document. Behavior depends by the current running transaction if any. If no transaction is running then the record is deleted immediately. If an Optimistic transaction is running then the record will be deleted at commit time. The current transaction will continue to see the record as deleted, while others not. If a Pessimistic transaction is running, then an exclusive lock is acquired against the record. Current transaction will continue to see the record as deleted, while others cannot access to it since it's locked.

      If MVCC is enabled and the version of the document is different by the version stored in the database, then a OConcurrentModificationException exception is thrown.

      Specified by:
      delete in interface ODatabase<ORecord>
      Parameters:
      record - record to delete
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • beforeDeleteOperations

      public void beforeDeleteOperations(OIdentifiable id, String iClusterName)
      Specified by:
      beforeDeleteOperations in interface ODatabaseDocumentInternal
    • afterCreateOperations

      public void afterCreateOperations(OIdentifiable id)
      Specified by:
      afterCreateOperations in interface ODatabaseDocumentInternal
    • afterUpdateOperations

      public void afterUpdateOperations(OIdentifiable id)
      Specified by:
      afterUpdateOperations in interface ODatabaseDocumentInternal
    • afterDeleteOperations

      public void afterDeleteOperations(OIdentifiable id)
      Specified by:
      afterDeleteOperations in interface ODatabaseDocumentInternal
    • afterReadOperations

      public void afterReadOperations(OIdentifiable identifiable)
      Specified by:
      afterReadOperations in interface ODatabaseDocumentInternal
    • beforeReadOperations

      public boolean beforeReadOperations(OIdentifiable identifiable)
      Specified by:
      beforeReadOperations in interface ODatabaseDocumentInternal
      Returns:
      true if the record should be skipped
    • afterCommitOperations

      protected void afterCommitOperations()
      Overrides:
      afterCommitOperations in class ODatabaseDocumentAbstract
    • afterRollbackOperations

      protected void afterRollbackOperations()
      Overrides:
      afterRollbackOperations in class ODatabaseDocumentAbstract
    • saveAll

      public ORecord saveAll(ORecord iRecord, String iClusterName, ODatabase.OPERATION_MODE iMode, boolean iForceCreate, ORecordCallback<? extends Number> iRecordCreatedCallback, ORecordCallback<Integer> iRecordUpdatedCallback)
      Specified by:
      saveAll in interface ODatabaseDocumentInternal
    • getClusterName

      public String getClusterName(ORecord record)
      Specified by:
      getClusterName in interface ODatabaseDocumentInternal
    • getViewFromCluster

      public OView getViewFromCluster(int cluster)
      Specified by:
      getViewFromCluster in interface ODatabaseDocumentInternal
      Overrides:
      getViewFromCluster in class ODatabaseDocumentAbstract
    • executeReadRecord

      public <RET extends ORecord> RET executeReadRecord(ORecordId rid, ORecord iRecord, int recordVersion, String fetchPlan, boolean ignoreCache, boolean iUpdateCache, boolean loadTombstones, OStorage.LOCKING_STRATEGY lockingStrategy, RecordReader recordReader)
      This method is internal, it can be subject to signature change or be removed, do not use. @Internal
      Specified by:
      executeReadRecord in interface ODatabaseDocumentInternal
      Specified by:
      executeReadRecord in class ODatabaseDocumentAbstract
    • internalLockRecord

      public void internalLockRecord(OIdentifiable iRecord, OStorage.LOCKING_STRATEGY lockingStrategy)
      Specified by:
      internalLockRecord in interface ODatabaseDocumentInternal
    • internalLockRecord

      public void internalLockRecord(OIdentifiable iRecord, OStorage.LOCKING_STRATEGY lockingStrategy, long timeout)
    • internalUnlockRecord

      public void internalUnlockRecord(OIdentifiable iRecord)
      Specified by:
      internalUnlockRecord in interface ODatabaseDocumentInternal
    • lock

      public <RET extends ORecord> RET lock(ORID recordId) throws OLockException
      Description copied from interface: ODatabase
      Pessimistic lock a record.

      In case of lock inside the transaction the lock will be release by the commit operation, In case of lock outside a transaction unlock need to be call manually.

      Specified by:
      lock in interface ODatabase<ORecord>
      Parameters:
      recordId - the id of the record that need to be locked
      Returns:
      the record updated to the last state after the lock.
      Throws:
      OLockException - In case of deadlock detected
    • lock

      public <RET extends ORecord> RET lock(ORID recordId, long timeout, TimeUnit timeoutUnit) throws OLockException
      Description copied from interface: ODatabase
      Pessimistic lock a record.
      Specified by:
      lock in interface ODatabase<ORecord>
      Parameters:
      recordId - the id of the record that need to be locked
      timeout - for the record locking
      timeoutUnit - relative for the timeout
      Returns:
      the record updated to the last state after the lock.
      Throws:
      OLockException - In case of deadlock detected
    • unlock

      public void unlock(ORID recordId) throws OLockException
      Description copied from interface: ODatabase
      Pessimistic unlock
      Specified by:
      unlock in interface ODatabase<ORecord>
      Parameters:
      recordId - the id of the record to unlock
      Throws:
      OLockException - if the record is not locked.
    • sendSequenceAction

      public <T> T sendSequenceAction(OSequenceAction action) throws ExecutionException, InterruptedException
      Specified by:
      sendSequenceAction in interface ODatabaseDocumentInternal
      Throws:
      ExecutionException
      InterruptedException
    • checkSecurity

      public <DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric resourceGeneric, String resourceSpecific, int iOperation)
      Checks if the operation on a resource is allowed for the current user.
      Specified by:
      checkSecurity in interface ODatabaseDocument
      Parameters:
      resourceGeneric - Generic Resource where to execute the operation
      iOperation - Operation to execute against the resource
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • checkSecurity

      public <DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric iResourceGeneric, int iOperation, Object... iResourcesSpecific)
      Checks if the operation against multiple resources is allowed for the current user. The check is made in two steps:
      1. Access to all the resource as *
      2. Access to the specific target resources
      Specified by:
      checkSecurity in interface ODatabaseDocument
      Parameters:
      iResourceGeneric - Resource where to execute the operation, i.e.: database.clusters
      iOperation - Operation to execute against the resource
      iResourcesSpecific - Target resources as an array of Objects, i.e.: ["employee", 2] to specify cluster name and id.
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • checkSecurity

      public <DB extends ODatabaseDocument> DB checkSecurity(ORule.ResourceGeneric iResourceGeneric, int iOperation, Object iResourceSpecific)
      Checks if the operation on a resource is allowed for the current user. The check is made in two steps:
      1. Access to all the resource as *
      2. Access to the specific target resource
      Specified by:
      checkSecurity in interface ODatabaseDocument
      Parameters:
      iResourceGeneric - Resource where to execute the operation, i.e.: database.clusters
      iOperation - Operation to execute against the resource
      iResourceSpecific - Target resource, i.e.: "employee" to specify the cluster name.
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • checkSecurity

      @Deprecated public <DB extends ODatabaseDocument> DB checkSecurity(String iResource, int iOperation)
      Deprecated.
      Description copied from interface: ODatabaseDocument
      Checks if the operation on a resource is allowed for the current user.
      Specified by:
      checkSecurity in interface ODatabaseDocument
      Parameters:
      iResource - Resource where to execute the operation
      iOperation - Operation to execute against the resource
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • checkSecurity

      @Deprecated public <DB extends ODatabaseDocument> DB checkSecurity(String iResourceGeneric, int iOperation, Object iResourceSpecific)
      Deprecated.
      Description copied from interface: ODatabaseDocument
      Checks if the operation on a resource is allowed for the current user. The check is made in two steps:
      1. Access to all the resource as *
      2. Access to the specific target resource
      Specified by:
      checkSecurity in interface ODatabaseDocument
      Parameters:
      iResourceGeneric - Resource where to execute the operation, i.e.: database.clusters
      iOperation - Operation to execute against the resource
      iResourceSpecific - Target resource, i.e.: "employee" to specify the cluster name.
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • checkSecurity

      @Deprecated public <DB extends ODatabaseDocument> DB checkSecurity(String iResourceGeneric, int iOperation, Object... iResourcesSpecific)
      Deprecated.
      Description copied from interface: ODatabaseDocument
      Checks if the operation against multiple resources is allowed for the current user. The check is made in two steps:
      1. Access to all the resource as *
      2. Access to the specific target resources
      Specified by:
      checkSecurity in interface ODatabaseDocument
      Parameters:
      iResourceGeneric - Resource where to execute the operation, i.e.: database.clusters
      iOperation - Operation to execute against the resource
      iResourcesSpecific - Target resources as an array of Objects, i.e.: ["employee", 2] to specify cluster name and id.
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • addCluster

      public int addCluster(String iClusterName, Object... iParameters)
      Description copied from interface: ODatabase
      Adds a new cluster.
      Specified by:
      addCluster in interface ODatabase<ORecord>
      Parameters:
      iClusterName - Cluster name
      iParameters - Additional parameters to pass to the factories
      Returns:
      Cluster id
    • addCluster

      public int addCluster(String iClusterName, int iRequestedId)
      Description copied from interface: ODatabase
      Adds a new cluster.
      Specified by:
      addCluster in interface ODatabase<ORecord>
      Parameters:
      iClusterName - Cluster name
      iRequestedId - requested id of the cluster
      Returns:
      Cluster id
    • getConflictStrategy

      public ORecordConflictStrategy getConflictStrategy()
      Description copied from interface: ODatabase
      Returns the current record conflict strategy.
      Specified by:
      getConflictStrategy in interface ODatabase<ORecord>
    • setConflictStrategy

      public ODatabaseDocumentEmbedded setConflictStrategy(String iStrategyName)
      Description copied from interface: ODatabase
      Overrides record conflict strategy selecting the strategy by name.
      Specified by:
      setConflictStrategy in interface ODatabase<ORecord>
      Parameters:
      iStrategyName - ORecordConflictStrategy strategy name
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • setConflictStrategy

      public ODatabaseDocumentEmbedded setConflictStrategy(ORecordConflictStrategy iResolver)
      Description copied from interface: ODatabase
      Overrides record conflict strategy.
      Specified by:
      setConflictStrategy in interface ODatabase<ORecord>
      Parameters:
      iResolver - ORecordConflictStrategy implementation
      Returns:
      The Database instance itself giving a "fluent interface". Useful to call multiple methods in chain.
    • getClusterRecordSizeByName

      public long getClusterRecordSizeByName(String clusterName)
      Description copied from interface: ODatabase
      Returns the total size of records contained in the cluster defined by its name.
      Specified by:
      getClusterRecordSizeByName in interface ODatabase<ORecord>
      Parameters:
      clusterName - Cluster name
      Returns:
      Total size of records contained.
    • getClusterRecordSizeById

      public long getClusterRecordSizeById(int clusterId)
      Description copied from interface: ODatabase
      Returns the total size of records contained in the cluster defined by its id.
      Specified by:
      getClusterRecordSizeById in interface ODatabase<ORecord>
      Parameters:
      clusterId - Cluster id
      Returns:
      The name of searched cluster.
    • countClusterElements

      public long countClusterElements(int iClusterId, boolean countTombstones)
      Specified by:
      countClusterElements in interface ODatabase<ORecord>
    • countClusterElements

      public long countClusterElements(int[] iClusterIds, boolean countTombstones)
      Specified by:
      countClusterElements in interface ODatabase<ORecord>
    • countClusterElements

      public long countClusterElements(String iClusterName)
      Counts all the entities in the specified cluster name.
      Specified by:
      countClusterElements in interface ODatabase<ORecord>
      Parameters:
      iClusterName - Cluster name
      Returns:
      Total number of entities contained in the specified cluster
    • dropCluster

      public boolean dropCluster(String iClusterName)
      Description copied from interface: ODatabase
      Drops a cluster by its name. Physical clusters will be completely deleted
      Specified by:
      dropCluster in interface ODatabase<ORecord>
      Parameters:
      iClusterName - the name of the cluster
      Returns:
      true if has been removed, otherwise false
    • dropClusterInternal

      protected boolean dropClusterInternal(String iClusterName)
    • dropCluster

      public boolean dropCluster(int clusterId)
      Description copied from interface: ODatabase
      Drops a cluster by its id. Physical clusters will be completely deleted.
      Specified by:
      dropCluster in interface ODatabase<ORecord>
      Parameters:
      clusterId - id of cluster to delete
      Returns:
      true if has been removed, otherwise false
    • dropClusterInternal

      public boolean dropClusterInternal(int clusterId)
      Specified by:
      dropClusterInternal in interface ODatabaseDocumentInternal
    • getSize

      public long getSize()
      Description copied from interface: ODatabase
      Returns the total size of the records in the database.
      Specified by:
      getSize in interface ODatabase<ORecord>
    • getStats

      public ODatabaseStats getStats()
      Specified by:
      getStats in interface ODatabaseInternal<ORecord>
    • addRidbagPrefetchStats

      public void addRidbagPrefetchStats(long execTimeMs)
      Specified by:
      addRidbagPrefetchStats in interface ODatabaseInternal<ORecord>
    • resetRecordLoadStats

      public void resetRecordLoadStats()
      Specified by:
      resetRecordLoadStats in interface ODatabaseInternal<ORecord>
    • incrementalBackup

      public String incrementalBackup(String path) throws UnsupportedOperationException
      Description copied from interface: ODatabase
      Performs incremental backup of database content to the selected folder. This is thread safe operation and can be done in normal operational mode.

      If it will be first backup of data full content of database will be copied into folder otherwise only changes after last backup in the same folder will be copied.

      Specified by:
      incrementalBackup in interface ODatabase<ORecord>
      Parameters:
      path - Path to backup folder.
      Returns:
      File name of the backup
      Throws:
      UnsupportedOperationException
    • getRecordMetadata

      public ORecordMetadata getRecordMetadata(ORID rid)
      Specified by:
      getRecordMetadata in interface ODatabase<ORecord>
    • freeze

      public void freeze(boolean throwException)
      Flush all indexes and cached storage content to the disk.

      After this call users can perform only select queries. All write-related commands will queued till ODatabaseDocument.release() command will be called or exception will be thrown on attempt to modify DB data. Concrete behaviour depends on throwException parameter.

      IMPORTANT: This command is not reentrant.

      Specified by:
      freeze in interface ODatabase<ORecord>
      Specified by:
      freeze in interface ODatabaseDocument
      Parameters:
      throwException - If true OModificationOperationProhibitedException exception will be thrown in case of write command will be performed.
    • freeze

      public void freeze()
      Flush all indexes and cached storage content to the disk.

      After this call users can perform only select queries. All write-related commands will queued till ODatabaseDocument.release() command will be called.

      Given command waits till all on going modifications in indexes or DB will be finished.

      IMPORTANT: This command is not reentrant.

      Specified by:
      freeze in interface ODatabase<ORecord>
      Specified by:
      freeze in interface ODatabaseDocument
      See Also:
    • release

      public void release()
      Allows to execute write-related commands on DB. Called after ODatabaseDocument.freeze() command.
      Specified by:
      release in interface ODatabase<ORecord>
      Specified by:
      release in interface ODatabaseDocument
      See Also:
    • backup

      public List<String> backup(OutputStream out, Map<String,Object> options, Callable<Object> callable, OCommandOutputListener iListener, int compressionLevel, int bufferSize) throws IOException
      Description copied from interface: OBackupable
      Executes a backup of the database. During the backup the database will be frozen in read-only mode.
      Specified by:
      backup in interface OBackupable
      Parameters:
      out - OutputStream used to write the backup content. Use a FileOutputStream to make the backup persistent on disk
      options - Backup options as Map<String, Object> object
      callable - Callback to execute when the database is locked
      iListener - Listener called for backup messages
      compressionLevel - ZIP Compression level between 1 (the minimum) and 9 (maximum). The bigger is the compression, the smaller will be the final backup content, but will consume more CPU and time to execute
      bufferSize - Buffer size in bytes, the bigger is the buffer, the more efficient will be the compression
      Throws:
      IOException
      See Also:
    • restore

      public void restore(InputStream in, Map<String,Object> options, Callable<Object> callable, OCommandOutputListener iListener) throws IOException
      Description copied from interface: OBackupable
      Executes a restore of a database backup. During the restore the database will be frozen in read-only mode.
      Specified by:
      restore in interface OBackupable
      Parameters:
      in - InputStream used to read the backup content. Use a FileInputStream to read a backup on a disk
      options - Backup options as Map<String, Object> object
      callable - Callback to execute when the database is locked
      iListener - Listener called for backup messages
      Throws:
      IOException
      See Also:
    • getSbTreeCollectionManager

      public OSBTreeCollectionManager getSbTreeCollectionManager()
      Internal. Gets an instance of sb-tree collection manager for current database.
      Specified by:
      getSbTreeCollectionManager in interface ODatabaseDocumentInternal
    • reload

      public void reload()
      Description copied from interface: ODatabase
      Reloads the database information like the cluster list.
      Specified by:
      reload in interface ODatabase<ORecord>
    • internalCommit

      public void internalCommit(OTransactionInternal transaction)
      Description copied from interface: ODatabaseDocumentInternal
      Executed the commit on the storage hiding away storage concepts from the transaction
      Specified by:
      internalCommit in interface ODatabaseDocumentInternal
    • internalClose

      public void internalClose(boolean recycle)
      Specified by:
      internalClose in interface ODatabaseDocumentInternal
    • getClusterDataRange

      public long[] getClusterDataRange(int currentClusterId)
      Specified by:
      getClusterDataRange in interface ODatabaseDocumentInternal
    • setDefaultClusterId

      public void setDefaultClusterId(int addCluster)
      Specified by:
      setDefaultClusterId in interface ODatabaseDocumentInternal
    • getLastClusterPosition

      public long getLastClusterPosition(int clusterId)
      Specified by:
      getLastClusterPosition in interface ODatabaseDocumentInternal
    • getClusterRecordConflictStrategy

      public String getClusterRecordConflictStrategy(int clusterId)
      Specified by:
      getClusterRecordConflictStrategy in interface ODatabaseDocumentInternal
    • getClustersIds

      public int[] getClustersIds(Set<String> filterClusters)
      Specified by:
      getClustersIds in interface ODatabaseDocumentInternal
    • startEsclusiveMetadataChange

      public void startEsclusiveMetadataChange()
      Specified by:
      startEsclusiveMetadataChange in interface ODatabaseDocumentInternal
    • endEsclusiveMetadataChange

      public void endEsclusiveMetadataChange()
      Specified by:
      endEsclusiveMetadataChange in interface ODatabaseDocumentInternal
    • truncateClass

      public long truncateClass(String name, boolean polimorfic)
      Specified by:
      truncateClass in interface ODatabaseDocumentInternal
    • truncateClass

      public void truncateClass(String name)
      Specified by:
      truncateClass in interface ODatabaseDocumentInternal
    • truncateClusterInternal

      public long truncateClusterInternal(String clusterName)
      Specified by:
      truncateClusterInternal in interface ODatabaseDocumentInternal
    • truncateCluster

      public void truncateCluster(String clusterName)
      Description copied from interface: ODatabase
      Removes all data in the cluster with given name. As result indexes for this class will be rebuilt.
      Specified by:
      truncateCluster in interface ODatabase<ORecord>
      Parameters:
      clusterName - Name of cluster to be truncated.
    • commitPreallocate

      public void commitPreallocate()
      Specified by:
      commitPreallocate in interface ODatabaseDocumentInternal
    • internalCommitPreallocate

      public void internalCommitPreallocate(OTransactionOptimistic oTransactionOptimistic)
      Specified by:
      internalCommitPreallocate in interface ODatabaseDocumentInternal