Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {