Package com.complexible.stardog.plan.eval.service

# Interface Service

public interface Service

Interface representing a Service that is capable of providing results due to the evaluation of a SPARQL query.

Since:
  3.0
Author:
  Michael Grove

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default boolean`
  `answersSparqlQueries()`
  Are queries against this service SPARQL queries? If so, we can perform reasoning, etc.
  `boolean`
  `canEvaluate(IRI iri)`
  Return whether or not the Service can answer
  `default boolean`
  `customTermReplacement()`
  If this returns true, the service is expected to override `replaceQueryTerms(PlanNodeVarReplacer, ServicePlanNode)` to implement custom logic of replacing query terms.
  `default BooleanSupplier`
  `getAvailability(IRI serviceIri)`
  Return a `BooleanSupplier` that indicates whether the service is available (not closed) and therefore still valid for use in the cache The purpose of using a `BooleanSupplier` rather than just calling an availability method is to account for the possibility that a `Service` may delegate to different virtual graphs over time.
  `default boolean`
  `isAccessibleFrom(String database, IRI serviceIri)`
  `default com.complexible.stardog.plan.PlanNode`
  `replaceQueryTerms(com.complexible.stardog.plan.util.PlanNodeVarReplacer replacer, com.complexible.stardog.plan.ServicePlanNode serviceNode)`
  Replaces query terms in the given `ServicePlanNode`.
  `default boolean`
  `respectsNamedGraphSecurity()`
  Is the service restricted to graphs accessible according to the named graph security constraints?
  `default boolean`
  `supportsConstantReplacement()`
  Does this service create queries which support constant replacement? If so, caching with constant canonicalization is performed.
  `default com.complexible.stardog.plan.PlanNode`
  `translate(com.complexible.stardog.plan.eval.ExecutionContext theExecutionContext, IRI iri, com.complexible.stardog.plan.PlanNode body, com.complexible.stardog.plan.QueryTerm context, IntFunction<String> varNames, Function<String,Integer> varAllocator, boolean silent)`
  `com.complexible.stardog.plan.PlanNode`
  `translate(com.complexible.stardog.plan.eval.ExecutionContext theExecutionContext, IRI iri, com.complexible.stardog.plan.PlanNode body, IntFunction<String> varNames, Function<String,Integer> varAllocator, boolean silent)`
  Translate a query fragment to a call to this service
  `default com.complexible.stardog.plan.PlanNode`
  `translate(com.complexible.stardog.plan.optimizer.OptimizationContext theOptimizationContext, IRI iri, com.complexible.stardog.plan.PlanNode body, com.complexible.stardog.plan.QueryTerm context, IntFunction<String> varNames, Function<String,Integer> varAllocator, boolean silent)`
  `default com.complexible.stardog.plan.PlanNode`
  `translate(com.complexible.stardog.plan.optimizer.OptimizationContext theOptimizationContext, IRI iri, com.complexible.stardog.plan.PlanNode body, IntFunction<String> varNames, Function<String,Integer> varAllocator, boolean silent)`
  Translate a query fragment to a call to this service.

- ## Method Details

  - ### canEvaluate

    boolean canEvaluate(IRI iri)
    Return whether or not the Service can answer
    Parameters:
      `iri` - the IRI of the service
    Returns:
      true if this service can evaluate the query, false otherwise

  - ### translate

    com.complexible.stardog.plan.PlanNode translate(com.complexible.stardog.plan.eval.ExecutionContext theExecutionContext, IRI iri, com.complexible.stardog.plan.PlanNode body, IntFunction<String> varNames, Function<String,Integer> varAllocator, boolean silent)
    Translate a query fragment to a call to this service

  - ### translate

    default com.complexible.stardog.plan.PlanNode translate(com.complexible.stardog.plan.eval.ExecutionContext theExecutionContext, IRI iri, com.complexible.stardog.plan.PlanNode body, com.complexible.stardog.plan.QueryTerm context, IntFunction<String> varNames, Function<String,Integer> varAllocator, boolean silent)

  - ### translate

    default com.complexible.stardog.plan.PlanNode translate(com.complexible.stardog.plan.optimizer.OptimizationContext theOptimizationContext, IRI iri, com.complexible.stardog.plan.PlanNode body, IntFunction<String> varNames, Function<String,Integer> varAllocator, boolean silent)
    Translate a query fragment to a call to this service. We may also pass the Optimization context here. This allows for applying optimizations after translation (see e.g., VirtualGraphService)

  - ### translate

    default com.complexible.stardog.plan.PlanNode translate(com.complexible.stardog.plan.optimizer.OptimizationContext theOptimizationContext, IRI iri, com.complexible.stardog.plan.PlanNode body, com.complexible.stardog.plan.QueryTerm context, IntFunction<String> varNames, Function<String,Integer> varAllocator, boolean silent)

  - ### respectsNamedGraphSecurity

    default boolean respectsNamedGraphSecurity()
    Is the service restricted to graphs accessible according to the named graph security constraints?

  - ### supportsConstantReplacement

    default boolean supportsConstantReplacement()
    Does this service create queries which support constant replacement? If so, caching with constant canonicalization is performed. If not, the service body will be added to the cache without canonicalization.

  - ### customTermReplacement

    default boolean customTermReplacement()
    If this returns true, the service is expected to override `replaceQueryTerms(PlanNodeVarReplacer, ServicePlanNode)` to implement custom logic of replacing query terms.

  - ### replaceQueryTerms

    default com.complexible.stardog.plan.PlanNode replaceQueryTerms(com.complexible.stardog.plan.util.PlanNodeVarReplacer replacer, com.complexible.stardog.plan.ServicePlanNode serviceNode)
    Replaces query terms in the given `ServicePlanNode`. Most services would simply delegate to the `PlanNodeVarReplacer` but some may require custom logic for inlining constants etc.

  - ### answersSparqlQueries

    default boolean answersSparqlQueries()
    Are queries against this service SPARQL queries? If so, we can perform reasoning, etc.

  - ### getAvailability

    default BooleanSupplier getAvailability(IRI serviceIri)
    Return a `BooleanSupplier` that indicates whether the service is available (not closed) and therefore still valid for use in the cache The purpose of using a `BooleanSupplier` rather than just calling an availability method is to account for the possibility that a `Service` may delegate to different virtual graphs over time. The `BooleanSupplier` will return the availability of the virtual graph that handled this serviceIri at the time this method is called, not when `BooleanSupplier.getAsBoolean()` is called. Important for plan cache invalidation.

  - ### isAccessibleFrom

    default boolean isAccessibleFrom(String database, IRI serviceIri)