@comunica/mediator-join-coefficients-fixed 2.0.7-alpha.10.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,23 +20,30 @@ class MediatorJoinCoefficientsFixed extends core_1.Mediator {
|
|
|
20
20
|
errors.push(error);
|
|
21
21
|
}));
|
|
22
22
|
const coefficients = await Promise.all(promises);
|
|
23
|
-
// Check if we had a limit indicator in the context
|
|
24
|
-
const limitIndicator = action.context.get(context_entries_1.KeysQueryOperation.limitIndicator);
|
|
25
23
|
// Calculate costs
|
|
26
|
-
|
|
24
|
+
let costs = coefficients
|
|
27
25
|
// eslint-disable-next-line array-callback-return
|
|
28
|
-
.map(coeff => {
|
|
29
|
-
if (coeff
|
|
30
|
-
// If we have a limit indicator,
|
|
31
|
-
// disallow entries that have a number of iterations that is higher than the limit AND persist items.
|
|
32
|
-
// In these cases, join operators that produce results early on will be preferred.
|
|
33
|
-
(!limitIndicator || coeff.iterations < limitIndicator || coeff.persistedItems === 0)) {
|
|
26
|
+
.map((coeff, i) => {
|
|
27
|
+
if (coeff) {
|
|
34
28
|
return coeff.iterations * this.cpuWeight +
|
|
35
29
|
coeff.persistedItems * this.memoryWeight +
|
|
36
30
|
coeff.blockingItems * this.timeWeight +
|
|
37
31
|
coeff.requestTime * this.ioWeight;
|
|
38
32
|
}
|
|
39
33
|
});
|
|
34
|
+
const maxCost = Math.max(...costs.filter(cost => cost !== undefined));
|
|
35
|
+
// If we have a limit indicator in the context,
|
|
36
|
+
// increase cost of entries that have a number of iterations that is higher than the limit AND persist items.
|
|
37
|
+
// In these cases, join operators that produce results early on will be preferred.
|
|
38
|
+
const limitIndicator = action.context.get(context_entries_1.KeysQueryOperation.limitIndicator);
|
|
39
|
+
if (limitIndicator) {
|
|
40
|
+
costs = costs.map((cost, i) => {
|
|
41
|
+
if (cost !== undefined && coefficients[i].persistedItems > 0 && coefficients[i].iterations > limitIndicator) {
|
|
42
|
+
return cost + maxCost;
|
|
43
|
+
}
|
|
44
|
+
return cost;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
40
47
|
// Determine index with lowest cost
|
|
41
48
|
let minIndex = -1;
|
|
42
49
|
let minValue = Number.POSITIVE_INFINITY;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/mediator-join-coefficients-fixed",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A join-coefficients-fixed mediator",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"lib/**/*.js"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@comunica/bindings-factory": "2.
|
|
33
|
-
"@comunica/bus-rdf-join": "2.
|
|
34
|
-
"@comunica/context-entries": "2.
|
|
35
|
-
"@comunica/core": "2.
|
|
36
|
-
"@comunica/mediatortype-join-coefficients": "2.
|
|
37
|
-
"@comunica/types": "2.
|
|
32
|
+
"@comunica/bindings-factory": "^2.2.0",
|
|
33
|
+
"@comunica/bus-rdf-join": "^2.2.0",
|
|
34
|
+
"@comunica/context-entries": "^2.2.0",
|
|
35
|
+
"@comunica/core": "^2.2.0",
|
|
36
|
+
"@comunica/mediatortype-join-coefficients": "^2.2.0",
|
|
37
|
+
"@comunica/types": "^2.2.0",
|
|
38
38
|
"asynciterator": "^3.3.0",
|
|
39
39
|
"rdf-string": "^1.5.0",
|
|
40
40
|
"rdf-terms": "^1.6.2",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
46
46
|
"build:components": "componentsjs-generator"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "00d4108e46250fb94b586bfb8caf5e8b1c704160"
|
|
49
49
|
}
|