DB support module documentation

clusterUIDOfResource :: Resource -> <ReadGraph> ClusterUID

Returns the UID of the cluster that stores the given resource.

collectClusters :: <Proc> ()

Releases as many cached clusters from memory as possible. The clusters are loaded again from the database when they are next needed.

countQueries :: <ReadGraph> Integer

Returns the number of queries currently held in the query cache.

directStatements :: Resource -> Boolean -> <ReadGraph> [Statement]

Returns the statements stored directly on the given resource, bypassing inference and the query cache. When the second argument is True only persistent statements are returned, otherwise virtual statements are included as well.

domainSetImmutability :: Resource -> Boolean -> <WriteGraph> ()

Sets the immutable flag of every cluster that holds part of the domain of the given resource, for example of a whole model or ontology. Determining the domain traverses everything the resource owns, so this is not a cheap operation. Requires a write transaction.

dumpHeap :: String -> <Proc> ()

Writes a heap dump of the running JVM to the given file path, in the HPROF format that memory analysers read. Only live objects are dumped. Every failure is swallowed, so an unwritable path produces neither a dump nor a complaint.

emptyTrashBinWithMonitor :: ProgressMonitor -> <Proc> ()

Permanently deletes everything in the trash bin of the current project, reporting progress to the given monitor.

garbageResources :: <ReadGraph> [Resource]

Returns the resources that are no longer reachable from the root library, that is, the ones the database still holds but nothing refers to.

This walks every resource of every cluster in the database, collects all of their direct statements and then iterates a reachability fixpoint over them. It is a whole-database diagnostic and is correspondingly slow.

isClusterLoaded :: ClusterUID -> <ReadGraph> Boolean

Tells whether the given cluster is currently loaded in memory. Does not load it.

listClusters :: <ReadGraph> [ClusterUID]

Returns the UIDs of all clusters that the database server knows about.

mergeSources :: Resource -> TransferableGraphSource -> TransferableGraphSource -> <WriteGraph> ()

Modifies the resource given as the first argument so that its content matches the graph read from the second argument, using the third argument as the current state of the target. Requires a write transaction.

modelTransferableGraphSource :: TransferableGraphConfiguration2 -> <ReadGraph> TransferableGraphSource

Opens a transferable graph source over the content described by the given configuration.

printStack :: () -> <Proc> ()

Prints the current Java stack trace to the SCL console, or to the log if there is no console. For finding out where a piece of SCL code is being run from.

resourcesByCluster :: ClusterUID -> <ReadGraph> [Resource]

Returns the resources that exist in the given cluster. Every resource index the cluster can hold is probed, so the cost is proportional to the capacity of the cluster rather than to the number of resources in it, and the cluster is loaded if it was not loaded already.

restrictQueries :: Integer -> Integer -> Integer -> <ReadGraph> ()

restrictQueries amount step maxTimeInMs

Collects some DB queries. Tries to reach at maximum 'amount' queries. Uses at maximum 'maxTimeInMs' milliseconds in 'step' millisecond stints.

setImmutable :: Resource -> Boolean -> <ReadGraph> ()

Sets the immutable flag of the cluster that the given resource belongs to. The flag applies to the whole cluster, not to the single resource. Writing to an immutable cluster fails unless it is done inside withServiceMode True.

tgConfigurer :: Boolean -> Boolean -> <ReadGraph> TGConfigurer

Creates a transferable graph configuration builder. The first argument leaves virtual resources out of the export, the second enables validation of the external references found while the export is produced.

tgConfigurerCreate :: TGConfigurer -> TransferableGraphConfiguration2

Builds the transferable graph configuration from the roots and exclusions accumulated in the builder.

tgConfigurerExclusions :: TGConfigurer -> [Resource] -> <Proc> TGConfigurer

Marks the given resources as excluded, so that the export refers to them from the outside instead of including them.

tgConfigurerRoots :: TGConfigurer -> [Resource] -> <ReadGraph> TGConfigurer

Adds the given resources as export roots. Each root is exported together with everything it owns, and its own name literal is excluded.

withServiceMode :: Boolean -> Boolean -> (() -> <b> a) -> <b> a
withServiceMode allowImmutableWrites createAsImmutable fn

runs function fn so that:

  • when allowImmutableWrites is True, fn is allowed to write to immutable clusters
  • when createAsImmutable is True, any new database clusters created by fn will be immutable