Skip to content

Commit

Permalink
fix broken aggregate evaluators
Browse files Browse the repository at this point in the history
  • Loading branch information
jitsedesmet committed Nov 1, 2023
1 parent a1734f8 commit 3f4da2b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ActorBindingsAggregatorFactoryAverage extends ActorBindingsAggregat
Promise<IActorBindingsAggregatorFactoryOutput> {
return {
aggregator: new AverageAggregator(
await factory.createEvaluator(expr, context),
await factory.createEvaluator(expr.expression, context),
expr.distinct,
<ITermFunction> await factory.createFunction({
functionName: RegularOperator.ADDITION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ActorBindingsAggregatorFactoryCount extends ActorBindingsAggregator
public async run(action: IActionBindingsAggregatorFactory): Promise<IActorBindingsAggregatorFactoryOutput> {
return {
aggregator: new CountAggregator(
await action.factory.createEvaluator(action.expr, action.context),
await action.factory.createEvaluator(action.expr.expression, action.context),
action.expr.distinct,
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BF, DF, int, makeAggregate } from '@comunica/jest';
import type { IActionContext, IBindingsAggregator, IExpressionEvaluatorFactory } from '@comunica/types';
import type * as RDF from '@rdfjs/types';
import { ArrayIterator } from 'asynciterator';
import { CountAggregator } from '../lib/CountAggregator';
import { CountAggregator } from '../lib';

async function runAggregator(aggregator: IBindingsAggregator, input: RDF.Bindings[]): Promise<RDF.Term | undefined> {
for (const bindings of input) {
Expand Down Expand Up @@ -42,11 +42,12 @@ describe('CountAggregator', () => {
describe('non distinctive count', () => {
let aggregator: IBindingsAggregator;

beforeEach(() => {
beforeEach(async() => {
aggregator = new CountAggregator(
makeAggregate('count', false),
expressionEvaluatorFactory,
context,
await expressionEvaluatorFactory.createEvaluator(
makeAggregate('count', false), new ActionContext({}),
),
false,
);
});

Expand All @@ -69,11 +70,12 @@ describe('CountAggregator', () => {
describe('distinctive count', () => {
let aggregator: IBindingsAggregator;

beforeEach(() => {
beforeEach(async() => {
aggregator = new CountAggregator(
makeAggregate('count', true),
expressionEvaluatorFactory,
context,
await expressionEvaluatorFactory.createEvaluator(
makeAggregate('count', true), new ActionContext({}),
),
true,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ActorBindingsAggregatorFactoryGroupConcat extends ActorBindingsAggr
public async run(action: IActionBindingsAggregatorFactory): Promise<IActorBindingsAggregatorFactoryOutput> {
return {
aggregator: new GroupConcatAggregator(
await action.factory.createEvaluator(action.expr, action.context),
await action.factory.createEvaluator(action.expr.expression, action.context),
action.expr.distinct,
action.expr.separator,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ActorBindingsAggregatorFactoryMax extends ActorBindingsAggregatorFa
public async run(action: IActionBindingsAggregatorFactory): Promise<IActorBindingsAggregatorFactoryOutput> {
return {
aggregator: new MaxAggregator(
await action.factory.createEvaluator(action.expr, action.context),
await action.factory.createEvaluator(action.expr.expression, action.context),
action.expr.distinct,
await action.factory.createOrderByEvaluator(action.context),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ActorBindingsAggregatorFactoryMin extends ActorBindingsAggregatorFa
public async run(action: IActionBindingsAggregatorFactory): Promise<IActorBindingsAggregatorFactoryOutput> {
return {
aggregator: new MinAggregator(
await action.factory.createEvaluator(action.expr, action.context),
await action.factory.createEvaluator(action.expr.expression, action.context),
action.expr.distinct,
await action.factory.createOrderByEvaluator(action.context),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ActorBindingsAggregatorFactorySample extends ActorBindingsAggregato
public async run(action: IActionBindingsAggregatorFactory): Promise<IActorBindingsAggregatorFactoryOutput> {
return {
aggregator: new SampleAggregator(
await action.factory.createEvaluator(action.expr, action.context),
await action.factory.createEvaluator(action.expr.expression, action.context),
action.expr.distinct,
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ActorBindingsAggregatorFactorySum extends ActorBindingsAggregatorFa
Promise<IActorBindingsAggregatorFactoryOutput> {
return {
aggregator: new SumAggregator(
await factory.createEvaluator(expr, context),
await factory.createEvaluator(expr.expression, context),
expr.distinct,
<ITermFunction> await factory.createFunction({
functionName: RegularOperator.ADDITION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ActorBindingsAggregatorFactoryWildcardCount extends ActorBindingsAg
public async run(action: IActionBindingsAggregatorFactory): Promise<IActorBindingsAggregatorFactoryOutput> {
return {
aggregator: new WildcardCountAggregator(
await action.factory.createEvaluator(action.expr, action.context),
await action.factory.createEvaluator(action.expr.expression, action.context),
action.expr.distinct,
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ import * as RdfString from 'rdf-string';
* NOTE: The wildcard count aggregator significantly differs from the others and overloads parts of this class.
*/
export abstract class AggregateEvaluator {
private readonly throwError: boolean;
private errorOccurred = false;

protected readonly variableValues: Set<string>;

protected constructor(protected readonly evaluator: IExpressionEvaluator,
protected readonly distinct: boolean,
throwError?: boolean) {
this.throwError = throwError || false;
private readonly throwError: boolean = false) {
this.errorOccurred = false;

this.variableValues = new Set();
Expand Down

0 comments on commit 3f4da2b

Please sign in to comment.