org.eclipse.rdf4j.federated

## Class FedXConnection

- java.lang.Object
- - org.eclipse.rdf4j.sail.helpers.AbstractSailConnection
  - - org.eclipse.rdf4j.federated.FedXConnection

- All Implemented Interfaces:
    AutoCloseable, SailConnection

      public class FedXConnection
      extends AbstractSailConnection

  An implementation of RepositoryConnection that uses `FederationEvalStrategy` to evaluate provided queries. Prior to evaluation various optimizations are performed, see `FedXOptimizer` for further details.

  Since 4.0 FedX supports write operations using the supplied `WriteStrategy`, e.g. by writing to a designated federation member. Note: the `WriteStrategy` is initialized lazily upon first access to a write operation, see `getWriteStrategyInternal()`. Implementation notes: - not all methods are implemented as of now

  Author:
    Andreas Schwarte
  See Also:
    `FederationEvalStrategy`, `WriteStrategy`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `FedXConnection.SailBaseDefaultImpl` A default implementation for `AbstractSail`.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected FedX` | `federation`
    `protected FederationContext` | `federationContext`

    - ### Fields inherited from class org.eclipse.rdf4j.sail.helpers.AbstractSailConnection

      `connectionLock, updateLock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FedXConnection(FedX federation, FederationContext federationContext)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addStatementInternal(Resource subj, IRI pred, Value obj, Resource... contexts)`
    `protected void` | `clearInternal(Resource... contexts)`
    `protected void` | `clearNamespacesInternal()`
    `protected void` | `closeInternal()`
    `protected void` | `commitInternal()`
    `protected CloseableIteration<? extends BindingSet,QueryEvaluationException>` | `evaluateInternal(TupleExpr query, Dataset dataset, BindingSet bindings, boolean includeInferred)`
    `Explanation` | `explain(Explanation.Level level, TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred, int timeoutSeconds)` Explain how the TupleExpr will be (or has been) executed/evaluated by returning a TupleExpr (which may or may not be the provided TupleExpr) that has gone through zero or more of the stages prior to and also including execution as specified by the provided level.
    `protected CloseableIteration<? extends Resource,SailException>` | `getContextIDsInternal()`
    `protected String` | `getNamespaceInternal(String prefix)`
    `protected CloseableIteration<? extends Namespace,SailException>` | `getNamespacesInternal()`
    `protected CloseableIteration<? extends Statement,SailException>` | `getStatementsInternal(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts)`
    `protected WriteStrategy` | `getWriteStrategyInternal()` Return the initialized `writeStrategy`.
    `boolean` | `pendingRemovals()` Indicates if the Sail has any statement removal operations pending (not yet `flushed`) for the current transaction.
    `protected void` | `removeNamespaceInternal(String prefix)`
    `protected void` | `removeStatementsInternal(Resource subj, IRI pred, Value obj, Resource... contexts)`
    `protected void` | `rollbackInternal()`
    `protected void` | `setNamespaceInternal(String prefix, String name)`
    `void` | `setTransactionSettings(TransactionSetting... settings)` Pass any transaction-specific settings to the SailConnection.
    `protected long` | `sizeInternal(Resource... contexts)`
    `protected void` | `startTransactionInternal()`

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

      `addStatement, addStatement, autoStartTransaction, begin, begin, clear, clearNamespaces, close, commit, endUpdate, endUpdateInternal, evaluate, flush, getContextIDs, getExclusiveConnectionLock, getNamespace, getNamespaces, getSharedConnectionLock, getStatements, getTransactionIsolation, getTransactionLock, isActive, isActiveOperation, isOpen, iterationClosed, pendingAdds, prepare, prepareInternal, registerIteration, removeNamespace, removeStatement, removeStatements, rollback, setNamespace, size, startUpdate, transactionActive, verifyIsActive, verifyIsOpen`

    - ### 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.SailConnection

      `addStatement, addStatement, getStatements, hasStatement, prepareQuery, removeStatement, removeStatements`

- - ### Field Detail

    - #### federation

          protected final FedX federation

    - #### federationContext

          protected final FederationContext federationContext

  - ### Constructor Detail

    - #### FedXConnection

          public FedXConnection(FedX federation,
                                FederationContext federationContext)
                         throws SailException

      Throws:
        `SailException`

  - ### Method Detail

    - #### setTransactionSettings

          public void setTransactionSettings(TransactionSetting... settings)

      Description copied from interface: `SailConnection`
      Pass any transaction-specific settings to the SailConnection. This method needs to be called before the transaction is `started` .

      Sail implementations can override this method to receive the transaction settings (to inspect and/or pass them along to any wrapped sail objects). Remember to call `super.setTransactionSettings(settings)` if you override this method.

      Parameters:
        `settings` - the transaction settings on which the next transaction operates. It may or may not contain the isolation level.

    - #### evaluateInternal

          protected CloseableIteration<? extends BindingSet,QueryEvaluationException> evaluateInternal(TupleExpr query,
                                                                                                       Dataset dataset,
                                                                                                       BindingSet bindings,
                                                                                                       boolean includeInferred)
                                                                                                throws SailException

      Specified by:
        `evaluateInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### clearInternal

          protected void clearInternal(Resource... contexts)
                                throws SailException

      Specified by:
        `clearInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### clearNamespacesInternal

          protected void clearNamespacesInternal()
                                          throws SailException

      Specified by:
        `clearNamespacesInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### closeInternal

          protected void closeInternal()
                                throws SailException

      Specified by:
        `closeInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### commitInternal

          protected void commitInternal()
                                 throws SailException

      Specified by:
        `commitInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### getContextIDsInternal

          protected CloseableIteration<? extends Resource,SailException> getContextIDsInternal()
                                                                                        throws SailException

      Specified by:
        `getContextIDsInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### getNamespaceInternal

          protected String getNamespaceInternal(String prefix)
                                         throws SailException

      Specified by:
        `getNamespaceInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### getNamespacesInternal

          protected CloseableIteration<? extends Namespace,SailException> getNamespacesInternal()
                                                                                         throws SailException

      Specified by:
        `getNamespacesInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### getStatementsInternal

          protected CloseableIteration<? extends Statement,SailException> getStatementsInternal(Resource subj,
                                                                                                IRI pred,
                                                                                                Value obj,
                                                                                                boolean includeInferred,
                                                                                                Resource... contexts)
                                                                                         throws SailException

      Specified by:
        `getStatementsInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### addStatementInternal

          protected void addStatementInternal(Resource subj,
                                              IRI pred,
                                              Value obj,
                                              Resource... contexts)
                                       throws SailException

      Specified by:
        `addStatementInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### removeNamespaceInternal

          protected void removeNamespaceInternal(String prefix)
                                          throws SailException

      Specified by:
        `removeNamespaceInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### removeStatementsInternal

          protected void removeStatementsInternal(Resource subj,
                                                  IRI pred,
                                                  Value obj,
                                                  Resource... contexts)
                                           throws SailException

      Specified by:
        `removeStatementsInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### rollbackInternal

          protected void rollbackInternal()
                                   throws SailException

      Specified by:
        `rollbackInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### setNamespaceInternal

          protected void setNamespaceInternal(String prefix,
                                              String name)
                                       throws SailException

      Specified by:
        `setNamespaceInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### sizeInternal

          protected long sizeInternal(Resource... contexts)
                               throws SailException

      Specified by:
        `sizeInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### startTransactionInternal

          protected void startTransactionInternal()
                                           throws SailException

      Specified by:
        `startTransactionInternal` in class `AbstractSailConnection`
      Throws:
        `SailException`

    - #### getWriteStrategyInternal

          protected WriteStrategy getWriteStrategyInternal()
                                                    throws SailException

      Return the initialized `writeStrategy`. If this has not been done yet, `WriteStrategy#initialize()` is returned. This method guarantees lazy initialization upon the first write operation on this `FedXConnection` instance.
      Returns:
        the `WriteStrategy`
      Throws:
        `SailException`

    - #### pendingRemovals

          public boolean pendingRemovals()

      Description copied from interface: `SailConnection`
      Indicates if the Sail has any statement removal operations pending (not yet `flushed`) for the current transaction.
      Specified by:
        `pendingRemovals` in interface `SailConnection`
      Overrides:
        `pendingRemovals` in class `AbstractSailConnection`
      Returns:
        true if any statement removal operations have not yet been flushed, false otherwise.
      See Also:
        `SailConnection.flush()`

    - #### explain

          public Explanation explain(Explanation.Level level,
                                     TupleExpr tupleExpr,
                                     Dataset dataset,
                                     BindingSet bindings,
                                     boolean includeInferred,
                                     int timeoutSeconds)

      Description copied from interface: `SailConnection`

      Explain how the TupleExpr will be (or has been) executed/evaluated by returning a TupleExpr (which may or may not be the provided TupleExpr) that has gone through zero or more of the stages prior to and also including execution as specified by the provided level.

      This method is used by the Query interface.

      WARNING: This method is experimental and is subject to change or removal without warning. There is currently only partial support for this method in RDF4J and and UnsupportedOperationException where support is lacking.

      Parameters:
        `level` - the explanation level, eg. OPTIMIZED
        `tupleExpr` - The tuple expression to evaluate. Mutable.
        `dataset` - The dataset to use for evaluating the query, `null` to use the Sail's default dataset.
        `bindings` - A set of input parameters for the query evaluation. The keys reference variable names that should be bound to the value they map to.
        `includeInferred` - Indicates whether inferred triples are to be considered in the query result. If false, no inferred statements are returned; if true, inferred statements are returned if available
        `timeoutSeconds` - for explanations that require execution a timeout can be provided in seconds
      Returns:
        The resulting tuple expression after being run through the specified level

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.