Package org.eclipse.rdf4j.sail.inferencer.fc

## Class SchemaCachingRDFSInferencer

- java.lang.Object
- - org.eclipse.rdf4j.sail.helpers.SailWrapper
  - - org.eclipse.rdf4j.sail.helpers.NotifyingSailWrapper
    - - org.eclipse.rdf4j.sail.inferencer.fc.SchemaCachingRDFSInferencer

- All Implemented Interfaces:
    `FederatedServiceResolverClient`, `NotifyingSail`, `Sail`, `StackableSail`

      public class SchemaCachingRDFSInferencer
      extends NotifyingSailWrapper

  The SchemaCachingRDFSInferencer is an RDFS reasoner that caches all schema (TBox) statements and calculates an inference map to quickly determine inferred statements. The reasoner can also be instantiated with a predefined schema for improved performance.

  This reasoner is not a rule based reasoner and will be up to 80x faster than the `ForwardChainingRDFSInferencer`, as well as being more complete.

  The sail puts no limitations on isolation level for read transactions, however all write/delete/update transactions are serializable with exclusive locks. This limits write/delete/update transactions to one transaction at a time.

  Author:
    Håvard Mikkelsen Ottestad

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected boolean` | `useInferredToCreateSchema` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SchemaCachingRDFSInferencer()` | Instantiate a new SchemaCachingRDFSInferencer
    `SchemaCachingRDFSInferencer​(NotifyingSail data)` | Instantiate a SchemaCachingRDFSInferencer.
    `SchemaCachingRDFSInferencer​(NotifyingSail data, boolean useAllRdfsRules)` | Instantiate a SchemaCachingRDFSInferencer.
    `SchemaCachingRDFSInferencer​(NotifyingSail data, Repository predefinedSchema)` | Instantiate a SchemaCachingRDFSInferencer with a predefined schema.
    `SchemaCachingRDFSInferencer​(NotifyingSail data, Repository predefinedSchema, boolean useAllRdfsRules)` | Instantiate a SchemaCachingRDFSInferencer with a predefined schema.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static SchemaCachingRDFSInferencer` | `fastInstantiateFrom​(SchemaCachingRDFSInferencer sailToInstantiateFrom, NotifyingSail store)` | Instantiate a new SchemaCachingRDFSInferencer from an existing one.
    `static SchemaCachingRDFSInferencer` | `fastInstantiateFrom​(SchemaCachingRDFSInferencer sailToInstantiateFrom, NotifyingSail store, boolean useAllRdfsRules)` | Instantiate a new SchemaCachingRDFSInferencer from an existing one.
    `SchemaCachingRDFSInferencerConnection` | `getConnection()` | Opens a connection on the Sail which can be used to query and update data.
    `IsolationLevel` | `getDefaultIsolationLevel()` | Retrieves the default `IsolationLevel` level on which transactions in this Sail operate.
    `List<IsolationLevel>` | `getSupportedIsolationLevels()` | Retrieve the `IsolationLevel`s supported by this SAIL, ordered by increasing complexity.
    `ValueFactory` | `getValueFactory()` | Gets a ValueFactory object that can be used to create IRI-, blank node-, literal- and statement objects.
    `void` | `init()` | Initializes the Sail.
    `boolean` | `isAddInferredStatementsToDefaultContext()` | Inferred statements can either be added to the default context or to the context that the original inserted statement has.
    `void` | `setAddInferredStatementsToDefaultContext​(boolean addInferredStatementsToDefaultContext)` | Inferred statements can either be added to the default context or to the context that the original inserted statement has.

    - ### Methods inherited from class org.eclipse.rdf4j.sail.helpers.NotifyingSailWrapper

      `addSailChangedListener, getBaseSail, removeSailChangedListener, setBaseSail`

    - ### Methods inherited from class org.eclipse.rdf4j.sail.helpers.SailWrapper

      `getDataDir, isWritable, setDataDir, setFederatedServiceResolver, shutDown, verifyBaseSailSet`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.rdf4j.sail.Sail

      `getDataDir, isWritable, setDataDir, shutDown`

- - ### Field Detail

    - #### useInferredToCreateSchema

          protected volatile boolean useInferredToCreateSchema

  - ### Constructor Detail

    - #### SchemaCachingRDFSInferencer

          public SchemaCachingRDFSInferencer()

      Instantiate a new SchemaCachingRDFSInferencer

    - #### SchemaCachingRDFSInferencer

          public SchemaCachingRDFSInferencer​(NotifyingSail data)

      Instantiate a SchemaCachingRDFSInferencer.
      Parameters:
        `data` - Base sail for storing data.

    - #### SchemaCachingRDFSInferencer

          public SchemaCachingRDFSInferencer​(NotifyingSail data,
                                             Repository predefinedSchema)

      Instantiate a SchemaCachingRDFSInferencer with a predefined schema. The schema will be used for inference, all other schema statements added will be ignored and no schema statements can be removed. Using a predefined schema significantly improves performance.
      Parameters:
        `data` - Base sail for storing data.
        `predefinedSchema` - Repository containing the schema.

    - #### SchemaCachingRDFSInferencer

          public SchemaCachingRDFSInferencer​(NotifyingSail data,
                                             boolean useAllRdfsRules)

      Instantiate a SchemaCachingRDFSInferencer.
      Parameters:
        `data` - Base sail for storing data.
        `useAllRdfsRules` - Usel all RDFS rules. If set to false rule rdf4a and rdfs4b will be ignore

    - #### SchemaCachingRDFSInferencer

          public SchemaCachingRDFSInferencer​(NotifyingSail data,
                                             Repository predefinedSchema,
                                             boolean useAllRdfsRules)

      Instantiate a SchemaCachingRDFSInferencer with a predefined schema. The schema will be used for inference, all other schema statements added will be ignored and no schema statements can be removed. Using a predefined schema significantly improves performance.
      Parameters:
        `data` - Base sail for storing data.
        `predefinedSchema` - Repository containing the schema.
        `useAllRdfsRules` - Usel all RDFS rules. If set to false rule rdf4a and rdfs4b will be ignore

  - ### Method Detail

    - #### init

          public void init()
                    throws SailException

      Description copied from interface: `Sail`
      Initializes the Sail. Care should be taken that required initialization parameters have been set before this method is called. Please consult the specific Sail implementation for information about the relevant parameters.
      Specified by:
        `init` in interface `Sail`
      Overrides:
        `init` in class `SailWrapper`
      Throws:
        `SailException` - If the Sail could not be initialized.

    - #### getConnection

          public SchemaCachingRDFSInferencerConnection getConnection()
                                                              throws SailException

      Description copied from interface: `Sail`
      Opens a connection on the Sail which can be used to query and update data. Depending on how the implementation handles concurrent access, a call to this method might block when there is another open connection on this Sail.
      Specified by:
        `getConnection` in interface `NotifyingSail`
      Specified by:
        `getConnection` in interface `Sail`
      Overrides:
        `getConnection` in class `NotifyingSailWrapper`
      Throws:
        `SailException` - If no transaction could be started, for example because the Sail is not writable.

    - #### getValueFactory

          public ValueFactory getValueFactory()

      Description copied from interface: `Sail`
      Gets a ValueFactory object that can be used to create IRI-, blank node-, literal- and statement objects.
      Specified by:
        `getValueFactory` in interface `Sail`
      Overrides:
        `getValueFactory` in class `SailWrapper`
      Returns:
        a ValueFactory object for this Sail object.

    - #### fastInstantiateFrom

          public static SchemaCachingRDFSInferencer fastInstantiateFrom​(SchemaCachingRDFSInferencer sailToInstantiateFrom,
                                                                        NotifyingSail store)

      Instantiate a new SchemaCachingRDFSInferencer from an existing one. Fast instantiation extracts the schema lookup tables generated by the existing sail and uses them to populate the lookup tables of a new reasoner. Schema triples can not be queried in the SchemaCachingRDFSInferencer returned by this method.
      Parameters:
        `sailToInstantiateFrom` - The SchemaCachingRDFSInferencer to extract the lookup tables from.
        `store` - Base sail for storing data.
      Returns:
        inferencer

    - #### fastInstantiateFrom

          public static SchemaCachingRDFSInferencer fastInstantiateFrom​(SchemaCachingRDFSInferencer sailToInstantiateFrom,
                                                                        NotifyingSail store,
                                                                        boolean useAllRdfsRules)

      Instantiate a new SchemaCachingRDFSInferencer from an existing one. Fast instantiation extracts the schema lookup tables generated by the existing sail and uses them to populate the lookup tables of a new reasoner. Schema triples can not be queried in the SchemaCachingRDFSInferencer returned by this method.
      Parameters:
        `sailToInstantiateFrom` - The SchemaCachingRDFSInferencer to extract the lookup tables from.
        `store` - Base sail for storing data.
        `useAllRdfsRules` - Use all RDFS rules. If set to false rule rdf4a and rdfs4b will be ignore
      Returns:
        inferencer

    - #### getDefaultIsolationLevel

          public IsolationLevel getDefaultIsolationLevel()

      Description copied from interface: `Sail`
      Retrieves the default `IsolationLevel` level on which transactions in this Sail operate.
      Specified by:
        `getDefaultIsolationLevel` in interface `Sail`
      Overrides:
        `getDefaultIsolationLevel` in class `SailWrapper`
      Returns:
        the `IsolationLevel` that will be used with `SailConnection.begin()`, for SAIL connections returned by `Sail.getConnection()`.

    - #### getSupportedIsolationLevels

          public List<IsolationLevel> getSupportedIsolationLevels()

      Description copied from interface: `Sail`
      Retrieve the `IsolationLevel`s supported by this SAIL, ordered by increasing complexity.
      Specified by:
        `getSupportedIsolationLevels` in interface `Sail`
      Overrides:
        `getSupportedIsolationLevels` in class `SailWrapper`
      Returns:
        a non-empty List of supported Isolation Levels, in order of increasing complexity. Every SAIL supports at least one `IsolationLevel`.

    - #### isAddInferredStatementsToDefaultContext

          public boolean isAddInferredStatementsToDefaultContext()

      Inferred statements can either be added to the default context or to the context that the original inserted statement has.

    - #### setAddInferredStatementsToDefaultContext

          public void setAddInferredStatementsToDefaultContext​(boolean addInferredStatementsToDefaultContext)

      Inferred statements can either be added to the default context or to the context that the original inserted statement has. setAddInferredStatementsToDefaultContext(true) will add all inferred statements to the default context.

      Which context a tbox statement is added to is undefined.

      Before 3.0 default value for addInferredStatementsToDefaultContext was true. From 3.0 the default value is false.

      Parameters:
        `addInferredStatementsToDefaultContext` -