View Source SPARQL.ExtensionFunction behaviour (SPARQL.ex v0.3.9)

A behaviour for SPARQL extension functions.

Examples

An extension function can be defined like this:

defmodule ExampleFunction do
  use SPARQL.ExtensionFunction, name: "http://example.com/function"

  def call(distinct, arguments, data, execution) do
    # your implementation
  end
end

The name of the module is arbitrary and has no further meaning.

see

Summary

Callbacks

Calls the extension function.

The name of the extension function.

Callbacks

Link to this callback

call(distinct, arguments, data, execution)

View Source
@callback call(
  distinct :: boolean(),
  arguments :: [RDF.Term.t()],
  data :: RDF.Dataset.t() | RDF.Graph.t(),
  execution :: map()
) :: RDF.Term.t() | :error

Calls the extension function.

The distinct argument is a boolean flag which signifies if the DISTINCT modifier was used in the function call, which is syntactically allowed in custom aggregate function calls only.

The arguments argument is the list of already evaluated RDF terms with which the extension function was called in the SPARQL query.

The data argument contains the currently evaluated solution and some other internal information and shouldn't be relied upon, because it might be subject to changes and contain different elements depending on the context the function was called in. Since the arguments are already evaluated against the current solution it shouldn't be necessary anyway.

The execution argument is a map with some global execution context information. In particular:

@callback name() :: String.t()

The name of the extension function.

As specified in the SPARQL grammar the name of a function is an IRI.