mi::neuraylib::IDatabase Class Reference
[Database Access]
Description
This interface is used to interact with the distributed database.
Public Enumerations
- enum Garbage_collection_priority{ PRIORITY_LOW = 0, PRIORITY_MEDIUM = 1, PRIORITY_HIGH = 2, PRIORITY_FORCE_32_BIT = 0xffffffffU}
- Priorities for synchronous garbage collection runs.
Public Member Functions
- virtual IScope* create_or_get_named_scope( const char* name, IScope* parent = 0, Uint8 privacy_level = 0) =0
- Creates or retrieves a new named scope at the given privacy level with the given parent scope ID. More...
- virtual IScope* create_scope( IScope* parent, Uint8 privacy_level = 0, bool temp = false) =0
- Creates a new optionally temporary scope at the given privacy level with the given parent scope ID. More...
- virtual void garbage_collection( Garbage_collection_priority priority = PRIORITY_MEDIUM) =0
- Triggers a synchronous garbage collection run. More...
- virtual IScope* get_global_scope() const =0
- Returns the global scope which is the root of a tree of scopes. More...
- virtual IScope* get_named_scope( const char* name) const =0
- Looks up and returns a scope with a given name. More...
- virtual IScope* get_scope( const char* id) const =0
- Looks up and returns a scope with a given ID. More...
- virtual void lock( Uint32 lock_id) =0
- Acquires a DB lock. More...
- virtual Sint32 remove_scope( const char* id) const =0
- Removes a scope with the specified ID. More...
- virtual Sint32 unlock( Uint32 lock_id) =0
- Releases a previously obtained DB lock. More...
Enums
- enum mi::neuraylib::IDatabase::Garbage_collection_priority
-
Priorities for synchronous garbage collection runs.
Enumerator:
- PRIORITY_LOW = 0
- Low priority for synchronous garbage collection runs. Use this priority if the performance of other concurrent DB operations is more important than a fast synchronous garbage collection.
- PRIORITY_MEDIUM = 1
- Medium priority for synchronous garbage collection runs. This priority attempts to maintain a balance between the synchronous garbage collection and other concurrent DB operations.
- PRIORITY_HIGH = 2
- High priority for synchronous garbage collection runs. Other concurrent DB operations will experience a large performance drop. Therefore, this priority should not be used in multi-user settings.
- PRIORITY_FORCE_32_BIT = 0xffffffffU
Member Functions
- virtual IScope* mi::neuraylib::IDatabase::create_or_get_named_scope( const char* name, IScope* parent = 0, Uint8 privacy_level = 0) [pure virtual]
-
Creates or retrieves a new named scope at the given privacy level with the given parent scope ID.
Parameters
- name
- A name which can be used to lookup the scope. If a scope with the same name exists already then it will be returned if the parent and privacy level are identical. Otherwise creating the scope will fail.
- parent
- The parent scope for this scope. If the value is NULL the created scope will be a child of the global scope.
- privacy_level
- The privacy level of the scope. This must be higher than the privacy level of the parent scope. The privacy level of the global scope is 0 (and the global scope is the only scope with privacy level 0). The default value of 0 indicates the privacy level of the parent scope plus 1.
Returns
The created scope or NULL if something went wrong.
- virtual IScope* mi::neuraylib::IDatabase::create_scope( IScope* parent, Uint8 privacy_level = 0, bool temp = false) [pure virtual]
-
Creates a new optionally temporary scope at the given privacy level with the given parent scope ID.
Note:A scope continues to exist if the pointer returned by this method is released. Use remove_scope() to remove a scope.
Parameters
- parent
- The parent scope for this scope. If the value is NULL the created scope will be a child of the global scope.
- privacy_level
- The privacy level of the scope. This must be higher than the privacy level of the parent scope. The privacy level of the global scope is 0 (and the global scope is the only scope with privacy level 0). The default value of 0 indicates the privacy level of the parent scope plus 1.
- temp
- A bool indicating if the scope is temporary. If the scope is temporary, then when the host that created the scope is removed from the cluster the scope and all data contained in the scope will be removed. If the scope is not temporary, the default, then when the creating host is removed from the cluster the scope and all contained data will remain in the database.
Returns
The created scope or NULL if something went wrong.
- virtual void mi::neuraylib::IDatabase::garbage_collection( Garbage_collection_priority priority = PRIORITY_MEDIUM) [pure virtual]
-
Triggers a synchronous garbage collection run. The method sweeps through the entire database and removes all database elements which have been marked for removal and are no longer referenced. Note that it is not possible to remove database elements if there are open transactions in which such an element is still referenced.
To mark an element for removal use mi::neuraylib::ITransaction::remove().
Parameters
- priority
- The intended priority of the synchronous garbage collection run.
- virtual IScope* mi::neuraylib::IDatabase::get_global_scope() const [pure virtual]
-
Returns the global scope which is the root of a tree of scopes.
Returns
The global scope which is guaranteed to exist after startup of the system.
- virtual IScope* mi::neuraylib::IDatabase::get_named_scope( const char* name) const [pure virtual]
-
Looks up and returns a scope with a given name.
Parameters
- name
- The name of the scope
Returns
The found scope or NULL if no such scope exists.
- virtual IScope* mi::neuraylib::IDatabase::get_scope( const char* id) const [pure virtual]
-
Looks up and returns a scope with a given ID.
Parameters
- id
- The ID of the scope as returned by mi::neuraylib::IScope::get_id().
Returns
The found scope or NULL if no such scope exists.
- virtual void mi::neuraylib::IDatabase::lock( Uint32 lock_id) [pure virtual]
-
Acquires a DB lock. The method blocks until the requested lock has been obtained. Recursively locking the same lock from within the same thread on the same host is supported.
If the host holding a lock leaves the cluster, the lock is automatically released.
Note:-
The locking mechanism is kind of a co-operative locking mechanism: The lock does not prevent other threads from accessing or editing the DB. It only prevents other threads from obtaining the same lock.
-
DB locks are not restricted to threads on a single host, they apply to all threads on all hosts in the cluster.
-
DB locks are an expensive operation and should only be used when absolutely necessary.
Parameters
- lock_id
- The lock to acquire.
-
- virtual Sint32 mi::neuraylib::IDatabase::remove_scope( const char* id) const [pure virtual]
-
Removes a scope with the specified ID. Note that scopes are reference counted. The actual removal will not happen before all elements referencing the scope have been released, e.g., child scopes, transactions, database elements, including handles to the scope itself. Even when all these conditions are met, scope removal might actually happen at a later point in time, depending on the timing of past and current transactions, even in unrelated scopes.
It is not possible to remove the global scope.
Parameters
- id
- The ID of the scope as returned by mi::neuraylib::IScope::get_id().
Returns
0, in case of success, -1 in case of failure.
- virtual Sint32 mi::neuraylib::IDatabase::unlock( Uint32 lock_id) [pure virtual]
-
Releases a previously obtained DB lock. If the lock has been locked several times from within the same thread on the same host, it simply decrements the lock count. If the lock count reaches zero, the lock is released.
Parameters
- lock_id
- The lock to release.
Returns
0, in case of success, -1 in case of failure, i.e., the lock is not held by this thread on this host