Interface Function

  • All Superinterfaces:
    Copyable<com.complexible.stardog.plan.filter.Expression>, com.complexible.stardog.plan.filter.Expression
    All Known Subinterfaces:
    Aggregate
    All Known Implementing Classes:
    AbstractFunction

    public interface Function
    extends com.complexible.stardog.plan.filter.Expression

    This is the extension point for 17.6 (Extensible Value Testing) of the SPARQL spec.

    For implementations of Function to be visible to the query parser and engine, they must be registered via the JDK ServiceLoader. Create a file called com.complexible.stardog.plan.filter.functions.Function in the META-INF/services directory. The contents of this file should be all of the *fully-qualified* class names for the custom Functions. Then if a jar containing the META-INF/services directory and the implementations for the Functions is included on the classpath, Stardog will pick up the implementations on startup.

    To use the example from the SPARQL spec, if the Function is used in a query aGeo:distance(?axLoc, ?ayLoc, ?bxLoc, ?byLoc) , its signature is as follows:
     {code
          xsd:double   aGeo:distance (numeric x1, numeric y1, numeric x2, numeric y2)
     }
     
    When evaluate is called, it will be provided four values via the ValueSolution, which are the current values for the parameters, x1, y1, x2, and y2.
    Since:
    0.1
    Version:
    3.0
    Author:
    Michael Grove
    See Also:
    FunctionRegistry, Extension Functions
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      Function copy()
      Create a deep copy of the object which does not share any references with the original.
      java.lang.String getName()
      Return the string that uniquely identifies this Expression, which should be a fully qualified URI.
      java.util.List<java.lang.String> getNames()
      Return all the strings that uniquely identifies this Function.
      default void initialize()
      Initialize this function.
      default boolean isDeterministic()
      Returns true if the function result is uniquely determined by its inputs or false if the function may return different results for the same inputs.
      • Methods inherited from interface com.complexible.stardog.plan.filter.Expression

        accept, couldRaiseError, evaluate, getArgs, replaceArg, setArgs
    • Method Detail

      • getName

        java.lang.String getName()
        Return the string that uniquely identifies this Expression, which should be a fully qualified URI. This URI is what is used to reference this Expression in a SPARQL query.
        Returns:
        the URI
      • getNames

        java.util.List<java.lang.String> getNames()
        Return all the strings that uniquely identifies this Function. A function may have different names in different namespaces.
        Returns:
        all aliases of this Function
        See Also:
        getName()
      • initialize

        default void initialize()
        Initialize this function. In the case of a pure function, this is a no-op. However, in some cases, a function needs to keep some global state during query execution for it to work correctly. initialize should prepare the function for execution by either clearing or otherwise preparing it's state for (re)execution.
      • copy

        Function copy()
        Create a deep copy of the object which does not share any references with the original.
        Specified by:
        copy in interface Copyable<com.complexible.stardog.plan.filter.Expression>
        Returns:
        a copy of the object
      • isDeterministic

        default boolean isDeterministic()
        Returns true if the function result is uniquely determined by its inputs or false if the function may return different results for the same inputs. If the function has no inputs then every invocation should always return the same value for it to be deterministic, e.g. PI(), whereas a function like UUID() is not deterministic.
        Returns:
        true if the function is deterministic