A bindings aggregator factory actor
that constructs a bindings aggregator for any extension aggregate
passed by the extensionAggregatorCreator or extensionAggregators
context keys.
An extension aggregate creates the aggregator of a single group. Like for extension functions, the arguments of the aggregate call are evaluated beforehand, and the aggregator receives the evaluated arguments of each solution in the group:
const result = await engine.queryBindings(`
PREFIX ex: <http://example.org/>
SELECT (ex:median(?o) AS ?median) WHERE { ?s ?p ?o } GROUP BY ?s`, {
sources: [ 'https://www.rubensworks.net/' ],
extensionAggregators: {
'http://example.org/median': () => {
const values: number[] = [];
return {
put([ term ]) {
values.push(Number.parseFloat(term.value));
},
result() {
// Calculate and return the median of values as an RDF term
},
};
},
},
});
Like for the built-in aggregates:
DISTINCT, each distinct list of arguments is only put once.This module is part of the Comunica framework, and should only be used by developers that want to build their own query engine.
Click here if you just want to query with Comunica.
$ yarn add @comunica/actor-bindings-aggregator-factory-extensions
After installing, this package can be added to your engine's configuration as follows:
{
"@context": [
...
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-bindings-aggregator-factory-extensions/^5.0.0/components/context.jsonld"
],
"actors": [
...
{
"@id": "urn:comunica:default:bindings-aggregator-factory/actors#extensions",
"@type": "ActorBindingsAggregatorFactoryExtensions",
"mediatorExpressionEvaluatorFactory": { "@id": "urn:comunica:default:expression-evaluator-factory/mediators#main" }
}
]
}
mediatorExpressionEvaluatorFactory: A mediator over the Expression Evaluator Factory bus.