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
To use the example from the SPARQL spec, if the Function is used in a queryServiceLoader
. Create a file calledcom.complexible.stardog.plan.filter.functions.Function
in theMETA-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 theMETA-INF/services
directory and the implementations for the Functions is included on the classpath, Stardog will pick up the implementations on startup.aGeo:distance(?axLoc, ?ayLoc, ?bxLoc, ?byLoc)
, its signature is as follows:{code xsd:double aGeo:distance (numeric x1, numeric y1, numeric x2, numeric y2) }
Whenevaluate
is called, it will be provided fourvalues
via theValueSolution
, which are the current values for the parameters,x1
,y1
,x2
, andy2
.- 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 thisExpression
, which should be a fully qualified URI.java.util.List<java.lang.String>
getNames()
Return all the strings that uniquely identifies thisFunction
.default void
initialize()
Initialize this function.default boolean
isDeterministic()
Returnstrue
if the function result is uniquely determined by its inputs orfalse
if the function may return different results for the same inputs.
-
-
-
Method Detail
-
getName
java.lang.String getName()
Return the string that uniquely identifies thisExpression
, which should be a fully qualified URI. This URI is what is used to reference thisExpression
in a SPARQL query.- Returns:
- the URI
-
getNames
java.util.List<java.lang.String> getNames()
Return all the strings that uniquely identifies thisFunction
. 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.
-
isDeterministic
default boolean isDeterministic()
Returnstrue
if the function result is uniquely determined by its inputs orfalse
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 likeUUID()
is not deterministic.- Returns:
true
if the function is deterministic
-
-