I have a Fuseki endpoint running on some server. I would like to pass user defined functions using Jena's com.hp.hpl.jena.sparql.function
library. Unfortunately, I get the error:
URI <java:path.to.functions.halfString> has no registered function factory
I made sure to add the class (the jar containing the file) to the classpath and I can access this class from other applications that use this class on that server.
The example case that I am trying for now is some function that takes the subject of all the triples in the graph and returns the first half of each subject.
As a reference, I added the function below:
public class halfString extends FunctionBase1
{
public halfString() { super() ; }
public NodeValue exec(NodeValue nv1)
{
if (!nv1.isString())
{
return nv1;
}
String hey = nv1.toString();
int mid = hey.length() / 2;
String nay = hey.substring(0, mid);
return NodeValue.makeString(nay);
}
}
Here is the SPARQL query that I used:
PREFIX f: <path.to.functions.>
SELECT ?half ?s ?o ?g
WHERE {
?s ?p ?o
BIND (f:halfString(str(?s)) as ?half)
}
Running Fuseki (using the default configuration that was given with fuseki):
cd FUSEKI_HOME
./fuseki-server --mem /ds