@comunica/mediator-join-coefficients-fixed 4.5.0 → 5.0.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.
- package/README.md +1 -1
- package/components/MediatorJoinCoefficientsFixed.jsonld +10 -10
- package/components/components.jsonld +1 -1
- package/components/context.jsonld +1 -1
- package/lib/MediatorJoinCoefficientsFixed.d.ts +0 -0
- package/lib/MediatorJoinCoefficientsFixed.js +8 -0
- package/lib/MediatorJoinCoefficientsFixed.js.map +1 -1
- package/lib/index.d.ts +0 -0
- package/lib/index.js +0 -0
- package/lib/index.js.map +0 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ After installing, this mediator can be instantiated as follows:
|
|
|
30
30
|
{
|
|
31
31
|
"@context": [
|
|
32
32
|
...
|
|
33
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-all/^
|
|
33
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-all/^5.0.0/components/context.jsonld"
|
|
34
34
|
],
|
|
35
35
|
"actors": [
|
|
36
36
|
...
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-join-coefficients-fixed/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-join/^
|
|
6
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediatortype-join-coefficients/^
|
|
7
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/types/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-join-coefficients-fixed/^5.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-join/^5.0.0/components/context.jsonld",
|
|
6
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediatortype-join-coefficients/^5.0.0/components/context.jsonld",
|
|
7
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/types/^5.0.0/components/context.jsonld"
|
|
8
8
|
],
|
|
9
9
|
"@id": "npmd:@comunica/mediator-join-coefficients-fixed",
|
|
10
10
|
"components": [
|
|
@@ -71,23 +71,23 @@
|
|
|
71
71
|
"genericTypeInstances": [
|
|
72
72
|
{
|
|
73
73
|
"@type": "ParameterRangeGenericTypeReference",
|
|
74
|
-
"parameterRangeGenericType": "npmd:@comunica/core/^
|
|
74
|
+
"parameterRangeGenericType": "npmd:@comunica/core/^5.0.0/components/Mediator.jsonld#Mediator__generic_A"
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
"@type": "ParameterRangeGenericTypeReference",
|
|
78
|
-
"parameterRangeGenericType": "npmd:@comunica/core/^
|
|
78
|
+
"parameterRangeGenericType": "npmd:@comunica/core/^5.0.0/components/Mediator.jsonld#Mediator__generic_I"
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
"@type": "ParameterRangeGenericTypeReference",
|
|
82
|
-
"parameterRangeGenericType": "npmd:@comunica/core/^
|
|
82
|
+
"parameterRangeGenericType": "npmd:@comunica/core/^5.0.0/components/Mediator.jsonld#Mediator__generic_T"
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
"@type": "ParameterRangeGenericTypeReference",
|
|
86
|
-
"parameterRangeGenericType": "npmd:@comunica/core/^
|
|
86
|
+
"parameterRangeGenericType": "npmd:@comunica/core/^5.0.0/components/Mediator.jsonld#Mediator__generic_O"
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
89
|
"@type": "ParameterRangeGenericTypeReference",
|
|
90
|
-
"parameterRangeGenericType": "npmd:@comunica/core/^
|
|
90
|
+
"parameterRangeGenericType": "npmd:@comunica/core/^5.0.0/components/Mediator.jsonld#Mediator__generic_TS"
|
|
91
91
|
}
|
|
92
92
|
]
|
|
93
93
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-join-coefficients-fixed/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-join-coefficients-fixed/^5.0.0/components/context.jsonld"
|
|
4
4
|
],
|
|
5
5
|
"@id": "npmd:@comunica/mediator-join-coefficients-fixed",
|
|
6
6
|
"@type": "Module",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
|
|
4
4
|
{
|
|
5
5
|
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
-
"cmjcf": "npmd:@comunica/mediator-join-coefficients-fixed/^
|
|
6
|
+
"cmjcf": "npmd:@comunica/mediator-join-coefficients-fixed/^5.0.0/",
|
|
7
7
|
"MediatorJoinCoefficientsFixed": {
|
|
8
8
|
"@id": "cmjcf:components/MediatorJoinCoefficientsFixed.jsonld#MediatorJoinCoefficientsFixed",
|
|
9
9
|
"@prefix": true,
|
|
File without changes
|
|
@@ -8,8 +8,16 @@ const core_1 = require("@comunica/core");
|
|
|
8
8
|
* to calculate an overall score and pick the actor with the lowest score.
|
|
9
9
|
*/
|
|
10
10
|
class MediatorJoinCoefficientsFixed extends core_1.Mediator {
|
|
11
|
+
cpuWeight;
|
|
12
|
+
memoryWeight;
|
|
13
|
+
timeWeight;
|
|
14
|
+
ioWeight;
|
|
11
15
|
constructor(args) {
|
|
12
16
|
super(args);
|
|
17
|
+
this.cpuWeight = args.cpuWeight;
|
|
18
|
+
this.memoryWeight = args.memoryWeight;
|
|
19
|
+
this.timeWeight = args.timeWeight;
|
|
20
|
+
this.ioWeight = args.ioWeight;
|
|
13
21
|
}
|
|
14
22
|
async mediateWith(action, testResults) {
|
|
15
23
|
// Obtain test results
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediatorJoinCoefficientsFixed.js","sourceRoot":"","sources":["MediatorJoinCoefficientsFixed.ts"],"names":[],"mappings":";;;AACA,+DAA+D;AAE/D,yCAAiF;AAIjF;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,eAMlD;
|
|
1
|
+
{"version":3,"file":"MediatorJoinCoefficientsFixed.js","sourceRoot":"","sources":["MediatorJoinCoefficientsFixed.ts"],"names":[],"mappings":";;;AACA,+DAA+D;AAE/D,yCAAiF;AAIjF;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,eAMlD;IACiB,SAAS,CAAS;IAClB,YAAY,CAAS;IACrB,UAAU,CAAS;IACnB,QAAQ,CAAS;IAEjC,YAAmB,IAAwC;QACzD,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IAES,KAAK,CAAC,WAAW,CACzB,MAAsB,EACtB,WAMD;QAEC,sBAAsB;QACtB,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAC/D,IAAI,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC1B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc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C,KAAK,CAAC,CAAC,CAAC;gBAC1G,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;oBAChD,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE;oBAC1E,KAAK;iBACN,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;gBAC3C,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC1D,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE;oBAC1E,MAAM,EAAE,KAAK;iBACd,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;aAC5C,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAA,2BAAoB,EAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAE,CAAC,QAAQ,CAAC,CAAC;IACtE,CAAC;CACF;AA3GD,sEA2GC","sourcesContent":["import type { ActorRdfJoin, IActionRdfJoin, IActorRdfJoinTestSideData } from '@comunica/bus-rdf-join';\nimport { KeysQueryOperation } from '@comunica/context-entries';\nimport type { IActorReply, IMediatorArgs, TestResult } from '@comunica/core';\nimport { passTestWithSideData, failTest, Actor, Mediator } from '@comunica/core';\nimport type { IMediatorTypeJoinCoefficients } from '@comunica/mediatortype-join-coefficients';\nimport type { IQueryOperationResult } from '@comunica/types';\n\n/**\n * A mediator that mediates over actors implementing the Join Coefficients mediator type and assigns fixed weights\n * to calculate an overall score and pick the actor with the lowest score.\n */\nexport class MediatorJoinCoefficientsFixed extends Mediator<\n ActorRdfJoin,\nIActionRdfJoin,\nIMediatorTypeJoinCoefficients,\nIQueryOperationResult,\nIActorRdfJoinTestSideData\n> {\n public readonly cpuWeight: number;\n public readonly memoryWeight: number;\n public readonly timeWeight: number;\n public readonly ioWeight: number;\n\n public constructor(args: IMediatorJoinCoefficientsFixedArgs) {\n super(args);\n this.cpuWeight = args.cpuWeight;\n this.memoryWeight = args.memoryWeight;\n this.timeWeight = args.timeWeight;\n this.ioWeight = args.ioWeight;\n }\n\n protected async mediateWith(\n action: IActionRdfJoin,\n testResults: IActorReply<\n ActorRdfJoin,\nIActionRdfJoin,\nIMediatorTypeJoinCoefficients,\nIQueryOperationResult,\nIActorRdfJoinTestSideData\n>[],\n ): Promise<TestResult<ActorRdfJoin, IActorRdfJoinTestSideData>> {\n // Obtain test results\n const errors: string[] = [];\n const promises = testResults.map(({ reply }) => reply);\n const results = (await Promise.all(promises)).map((testResult) => {\n if (testResult.isFailed()) {\n errors.push(testResult.getFailMessage());\n // eslint-disable-next-line array-callback-return\n return;\n }\n return { value: testResult.get(), sideData: testResult.getSideData() };\n });\n\n // Calculate costs\n let costs: (number | undefined)[] = results\n // eslint-disable-next-line array-callback-return\n .map((result) => {\n if (result) {\n return result.value.iterations * this.cpuWeight +\n result.value.persistedItems * this.memoryWeight +\n result.value.blockingItems * this.timeWeight +\n result.value.requestTime * this.ioWeight;\n }\n });\n const maxCost = Math.max(...costs.filter(cost => cost !== undefined));\n\n // If we have a limit indicator in the context,\n // increase cost of entries that have a number of iterations that is higher than the limit AND block items.\n // In these cases, join operators that produce results early on will be preferred.\n const limitIndicator: number | undefined = action.context.get(KeysQueryOperation.limitIndicator);\n if (limitIndicator) {\n costs = costs.map((cost, i) => {\n if (cost !== undefined && (<any> results[i]?.value).blockingItems > 0 &&\n\n (<any> results[i]?.value).iterations > limitIndicator) {\n return cost + maxCost;\n }\n return cost;\n });\n }\n\n // Determine index with lowest cost\n let minIndex = -1;\n let minValue = Number.POSITIVE_INFINITY;\n for (const [ i, cost ] of costs.entries()) {\n if (cost !== undefined && (minIndex === -1 || cost < minValue)) {\n minIndex = i;\n minValue = cost;\n }\n }\n\n // Reject if all actors rejected\n if (minIndex < 0) {\n return failTest(this.constructFailureMessage(action, errors));\n }\n\n // Return actor with lowest cost\n const bestActor = testResults[minIndex].actor;\n\n // Emit calculations in logger\n if (bestActor.includeInLogs) {\n Actor.getContextLogger(action.context)?.debug(`Determined physical join operator '${bestActor.logicalType}-${bestActor.physicalName}'`, {\n entries: action.entries.length,\n variables: await Promise.all(action.entries\n .map(async entry => (await entry.output.metadata()).variables.map(variable => variable.variable.value))),\n costs: Object.fromEntries(costs.map((coeff, i) => [\n `${testResults[i].actor.logicalType}-${testResults[i].actor.physicalName}`,\n coeff,\n ]).filter(entry => entry[1] !== undefined)),\n coefficients: Object.fromEntries(results.map((result, i) => [\n `${testResults[i].actor.logicalType}-${testResults[i].actor.physicalName}`,\n result?.value,\n ]).filter(entry => entry[1] !== undefined)),\n });\n }\n\n return passTestWithSideData(bestActor, results[minIndex]!.sideData);\n }\n}\n\nexport interface IMediatorJoinCoefficientsFixedArgs extends IMediatorArgs<\n ActorRdfJoin,\nIActionRdfJoin,\nIMediatorTypeJoinCoefficients,\nIQueryOperationResult,\nIActorRdfJoinTestSideData\n> {\n /**\n * Weight for the CPU cost\n */\n cpuWeight: number;\n /**\n * Weight for the memory cost\n */\n memoryWeight: number;\n /**\n * Weight for the execution time cost\n */\n timeWeight: number;\n /**\n * Weight for the I/O cost\n */\n ioWeight: number;\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
File without changes
|
package/lib/index.js
CHANGED
|
File without changes
|
package/lib/index.js.map
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/mediator-join-coefficients-fixed",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "A join-coefficients-fixed mediator",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"build:components": "componentsjs-generator"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@comunica/bus-rdf-join": "^
|
|
43
|
-
"@comunica/context-entries": "^
|
|
44
|
-
"@comunica/core": "^
|
|
45
|
-
"@comunica/mediatortype-join-coefficients": "^
|
|
46
|
-
"@comunica/types": "^
|
|
42
|
+
"@comunica/bus-rdf-join": "^5.0.0",
|
|
43
|
+
"@comunica/context-entries": "^5.0.0",
|
|
44
|
+
"@comunica/core": "^5.0.0",
|
|
45
|
+
"@comunica/mediatortype-join-coefficients": "^5.0.0",
|
|
46
|
+
"@comunica/types": "^5.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "0b1756fdb9bef014133432489627c1bd71779bd0"
|
|
49
49
|
}
|