How to use the sparqlee.AggregateEvaluator function in sparqlee

To help you get started, we’ve selected a few sparqlee examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github comunica / comunica / packages / actor-query-operation-group / lib / GroupsState.ts View on Github external
public consumeBindings(bindings: Bindings) {
    // Select the bindings on which we group
    const grouper = bindings
      .filter((_, variable) => this.groupVariables.has(variable))
      .toMap();
    const groupHash = this.hashBindings(grouper);

    // First member of group -> create new group
    if (!this.groups.has(groupHash)) {
      // Initialize state for all aggregators for new group
      const aggregators: { [key: string]: AggregateEvaluator } = {};
      for (const i in this.pattern.aggregates) {
        const aggregate = this.pattern.aggregates[i];
        const key = termToString(aggregate.variable);
        aggregators[key] = new AggregateEvaluator(aggregate, this.sparqleeConfig);
        aggregators[key].put(bindings);
      }

      const group: IGroup = { aggregators, bindings: grouper };
      this.groups.set(groupHash, group);

      if (this.distinctHashes) {
        const bindingsHash = this.hashBindings(bindings);
        this.distinctHashes.set(groupHash, new Set([bindingsHash]));
      }

    } else {
      // Group already exists
      // Update all the aggregators with the input binding
      const group = this.groups.get(groupHash);
      for (const i in this.pattern.aggregates) {

sparqlee

A simple SPARQL expression evaluator library

MIT
Latest version published 1 year ago

Package Health Score

48 / 100
Full package analysis