Interface Database

    • Method Detail

      • 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 string
        args - 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 string
        configuration - Configuration to use. When executed from a server, the server configuration is used. If null, an empty configuration will be used
        args - 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 string
        args - 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
      • 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 type
        polymorphic - true if the records of all the subtypes must be included, otherwise only the records strictly contained in the #typeName will be scanned
        callback - 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 type
        polymorphic - true if the records of all the subtypes must be included, otherwise only the records strictly contained in the #typeName will be scanned
        callback - Callback to handle the loaded record document. Returns false to interrupt the scan operation, otherwise true to continue till the end
        errorRecordCallback - 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 bucket
        callback - 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 bucket
        callback - Callback to handle the loaded record document. Returns false to interrupt the scan operation, otherwise true to continue till the end
        errorRecordCallback - 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 name
        keyName - Name of the property defined in the index to use
        keyValue - 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 name
        keyNames - Names of the property defined in the index to use
        keyValues - 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 type
        polymorphic - 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 name
        sourceVertexKeyNames - Source vertex keys
        sourceVertexKeyValues - Source vertex values
        destinationVertexType - Destination vertex type name
        destinationVertexKeyNames - Destination vertex keys
        destinationVertexKeyValues - Source vertex values
        createVertexIfNotExist - 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 set
        edgeType - Type of the edge to create. The type must be defined in the schema beforehand
        bidirectional - True to create a bidirectional edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performances
        properties - 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 instance
        destinationVertexType - Destination vertex type name
        destinationVertexKeyNames - Destination vertex keys
        destinationVertexKeyValues - Source vertex values
        createVertexIfNotExist - 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 set
        edgeType - Type of the edge to create. The type must be defined in the schema beforehand
        bidirectional - True to create a bidirectional edge. Using bidirectional edges is always the recommended setting, unless advanced fine-tuning on performances
        properties - 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.
      • 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()