From b9f8d616ba84b0dc2209d1b87cfa09cbf25d78de Mon Sep 17 00:00:00 2001 From: David de Boer Date: Tue, 28 May 2024 14:13:17 +0200 Subject: [PATCH] fix: Number of statements for multiple generators (#63) When multiple generators are configured, the number of statements reporting was that of only one of those generators, picked randomly based on which generator ends first. Fix that by reporting the total number of statements for all generators combined. --- src/lib/Stage.class.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib/Stage.class.ts b/src/lib/Stage.class.ts index f08ec29..d91712c 100644 --- a/src/lib/Stage.class.ts +++ b/src/lib/Stage.class.ts @@ -87,19 +87,18 @@ class Stage extends EventEmitter { end: false, format: 'N-Triples', }); - let quadCount = 0; const generatorProcessedCounts = new Map(); let quadsGenerated = 0; - const checkEnd = (iterationsIncoming: number, statements: number): void => { + const checkEnd = (iterationsIncoming: number): void => { if ( ![...generatorProcessedCounts].some( ([, processed]) => processed < iterationsIncoming ) && this.iteratorEnded ) { - this.emit('end', iterationsIncoming, statements); + this.emit('end', iterationsIncoming, quadsGenerated); } }; @@ -109,13 +108,12 @@ class Stage extends EventEmitter { generator.on('data', quad => { quadsGenerated++; writer.addQuad(quad); - quadCount++; - this.emit('generatorResult', quadCount); + this.emit('generatorResult', quadsGenerated); }); generator.on('end', (iterationsIncoming, statements, processed) => { generatorProcessedCounts.set(index, processed); - checkEnd(iterationsIncoming, statements); + checkEnd(iterationsIncoming); }); generator.on('error', e => {