@comunica/actor-rdf-join-selectivity-variable-counting 4.5.0 → 5.0.2
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/ActorRdfJoinSelectivityVariableCounting.jsonld +15 -15
- package/components/components.jsonld +1 -1
- package/components/context.jsonld +1 -1
- package/lib/ActorRdfJoinSelectivityVariableCounting.d.ts +1 -1
- package/lib/ActorRdfJoinSelectivityVariableCounting.js +14 -13
- package/lib/ActorRdfJoinSelectivityVariableCounting.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 +6 -6
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
29
29
|
{
|
|
30
30
|
"@context": [
|
|
31
31
|
...
|
|
32
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-selectivity-variable-counting/^
|
|
32
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-selectivity-variable-counting/^5.0.0/components/context.jsonld"
|
|
33
33
|
],
|
|
34
34
|
"actors": [
|
|
35
35
|
...
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-selectivity-variable-counting/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-join-selectivity/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-selectivity-variable-counting/^5.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-join-selectivity/^5.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld"
|
|
6
6
|
],
|
|
7
7
|
"@id": "npmd:@comunica/actor-rdf-join-selectivity-variable-counting",
|
|
8
8
|
"components": [
|
|
@@ -35,37 +35,37 @@
|
|
|
35
35
|
"genericTypeInstances": [
|
|
36
36
|
{
|
|
37
37
|
"@type": "ParameterRangeGenericTypeReference",
|
|
38
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
38
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"@type": "ParameterRangeGenericTypeReference",
|
|
42
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
42
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"@type": "ParameterRangeGenericTypeReference",
|
|
46
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
46
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"@type": "ParameterRangeGenericTypeReference",
|
|
50
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
50
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
51
51
|
}
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"@type": "ParameterRangeGenericTypeReference",
|
|
56
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
56
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"@type": "ParameterRangeGenericTypeReference",
|
|
60
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
60
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
"@type": "ParameterRangeGenericTypeReference",
|
|
64
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
64
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"@type": "ParameterRangeGenericTypeReference",
|
|
68
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
68
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
69
69
|
}
|
|
70
70
|
]
|
|
71
71
|
},
|
|
@@ -102,19 +102,19 @@
|
|
|
102
102
|
"genericTypeInstances": [
|
|
103
103
|
{
|
|
104
104
|
"@type": "ParameterRangeGenericTypeReference",
|
|
105
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
105
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
"@type": "ParameterRangeGenericTypeReference",
|
|
109
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
109
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
"@type": "ParameterRangeGenericTypeReference",
|
|
113
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
113
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
"@type": "ParameterRangeGenericTypeReference",
|
|
117
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
117
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
118
118
|
}
|
|
119
119
|
]
|
|
120
120
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-selectivity-variable-counting/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-join-selectivity-variable-counting/^5.0.0/components/context.jsonld"
|
|
4
4
|
],
|
|
5
5
|
"@id": "npmd:@comunica/actor-rdf-join-selectivity-variable-counting",
|
|
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
|
-
"carjsvc": "npmd:@comunica/actor-rdf-join-selectivity-variable-counting/^
|
|
6
|
+
"carjsvc": "npmd:@comunica/actor-rdf-join-selectivity-variable-counting/^5.0.0/",
|
|
7
7
|
"ActorRdfJoinSelectivityVariableCounting": {
|
|
8
8
|
"@id": "carjsvc:components/ActorRdfJoinSelectivityVariableCounting.jsonld#ActorRdfJoinSelectivityVariableCounting",
|
|
9
9
|
"@prefix": true,
|
|
@@ -2,7 +2,7 @@ import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '
|
|
|
2
2
|
import { ActorRdfJoinSelectivity } from '@comunica/bus-rdf-join-selectivity';
|
|
3
3
|
import type { IActorArgs, TestResult } from '@comunica/core';
|
|
4
4
|
import type { IMediatorTypeAccuracy } from '@comunica/mediatortype-accuracy';
|
|
5
|
-
import { Algebra } from '
|
|
5
|
+
import { Algebra } from '@comunica/utils-algebra';
|
|
6
6
|
/**
|
|
7
7
|
* A comunica Variable Counting RDF Join Selectivity Actor.
|
|
8
8
|
* Based on the "variable counting predicates" heuristic from
|
|
@@ -3,13 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.JoinTypes = exports.ActorRdfJoinSelectivityVariableCounting = void 0;
|
|
4
4
|
const bus_rdf_join_selectivity_1 = require("@comunica/bus-rdf-join-selectivity");
|
|
5
5
|
const core_1 = require("@comunica/core");
|
|
6
|
-
const
|
|
6
|
+
const utils_algebra_1 = require("@comunica/utils-algebra");
|
|
7
7
|
/**
|
|
8
8
|
* A comunica Variable Counting RDF Join Selectivity Actor.
|
|
9
9
|
* Based on the "variable counting predicates" heuristic from
|
|
10
10
|
* "SPARQL basic graph pattern optimization using selectivity estimation."
|
|
11
11
|
*/
|
|
12
12
|
class ActorRdfJoinSelectivityVariableCounting extends bus_rdf_join_selectivity_1.ActorRdfJoinSelectivity {
|
|
13
|
+
// Calculated as sum of unbound join type costs times 2 (best-case)
|
|
14
|
+
static MAX_PAIRWISE_COST = 41 * 2;
|
|
13
15
|
constructor(args) {
|
|
14
16
|
super(args);
|
|
15
17
|
}
|
|
@@ -21,7 +23,8 @@ class ActorRdfJoinSelectivityVariableCounting extends bus_rdf_join_selectivity_1
|
|
|
21
23
|
if (pattern.subject.termType === 'Variable') {
|
|
22
24
|
cost += 4;
|
|
23
25
|
}
|
|
24
|
-
if (pattern.predicate.termType === 'Variable' ||
|
|
26
|
+
if (('termType' in pattern.predicate && pattern.predicate.termType === 'Variable') ||
|
|
27
|
+
pattern.type === utils_algebra_1.Algebra.Types.PATH) {
|
|
25
28
|
cost += 1;
|
|
26
29
|
}
|
|
27
30
|
if (pattern.object.termType === 'Variable') {
|
|
@@ -262,15 +265,15 @@ class ActorRdfJoinSelectivityVariableCounting extends bus_rdf_join_selectivity_1
|
|
|
262
265
|
// Determine all operations that select values (patterns and paths)
|
|
263
266
|
const patterns = [];
|
|
264
267
|
for (const operation of operations) {
|
|
265
|
-
|
|
266
|
-
[
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
[
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
268
|
+
utils_algebra_1.algebraUtils.visitOperation(operation, {
|
|
269
|
+
[utils_algebra_1.Algebra.Types.PATTERN]: { preVisitor: (pattern) => {
|
|
270
|
+
patterns.push(pattern);
|
|
271
|
+
return { continue: false };
|
|
272
|
+
} },
|
|
273
|
+
[utils_algebra_1.Algebra.Types.PATH]: { preVisitor: (path) => {
|
|
274
|
+
patterns.push(path);
|
|
275
|
+
return { continue: false };
|
|
276
|
+
} },
|
|
274
277
|
});
|
|
275
278
|
}
|
|
276
279
|
// Determine pairwise costs
|
|
@@ -303,8 +306,6 @@ class ActorRdfJoinSelectivityVariableCounting extends bus_rdf_join_selectivity_1
|
|
|
303
306
|
}
|
|
304
307
|
}
|
|
305
308
|
exports.ActorRdfJoinSelectivityVariableCounting = ActorRdfJoinSelectivityVariableCounting;
|
|
306
|
-
// Calculated as sum of unbound join type costs times 2 (best-case)
|
|
307
|
-
ActorRdfJoinSelectivityVariableCounting.MAX_PAIRWISE_COST = 41 * 2;
|
|
308
309
|
var JoinTypes;
|
|
309
310
|
(function (JoinTypes) {
|
|
310
311
|
JoinTypes[JoinTypes["boundSS"] = 0] = "boundSS";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorRdfJoinSelectivityVariableCounting.js","sourceRoot":"","sources":["ActorRdfJoinSelectivityVariableCounting.ts"],"names":[],"mappings":";;;AACA,iFAA6E;AAE7E,yCAA0C;AAE1C,qDAAgD;AAEhD;;;;GAIG;AACH,MAAa,uCAAwC,SAAQ,kDAAuB;IAIlF,YACE,IAAkG;QAElG,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAkC;QAClD,OAAO,IAAA,eAAQ,EAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;IACrC,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,OAAuC;QAClE,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,CAAC;QACZ,CAAC;QACD,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU,IAAI,OAAO,CAAC,IAAI,KAAK,yBAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YACrF,IAAI,IAAI,CAAC,CAAC;QACZ,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;YAC3C,IAAI,IAAI,CAAC,CAAC;QACZ,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;YAC1C,IAAI,IAAI,CAAC,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,GAAG,CAAC,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,YAAY,CACxB,UAA0C,EAC1C,UAA0C;QAE1C,MAAM,SAAS,GAAgB,EAAE,CAAC;QAEl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uC,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9G,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAAiC;QAChD,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QAC5B,CAAC;QACD,OAAO;YACL,WAAW,EAAE,uCAAuC;iBACjD,qBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SACvE,CAAC;IACJ,CAAC;;AA1TH,0FA2TC;AA1TC,mEAAmE;AACrD,yDAAiB,GAAG,EAAE,GAAG,CAAC,CAAC;AA2T3C,IAAY,SAkCX;AAlCD,WAAY,SAAS;IACnB,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IAEP,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;AACX,CAAC,EAlCW,SAAS,yBAAT,SAAS,QAkCpB","sourcesContent":["import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity';\nimport { ActorRdfJoinSelectivity } from '@comunica/bus-rdf-join-selectivity';\nimport type { IActorArgs, TestResult } from '@comunica/core';\nimport { passTest } from '@comunica/core';\nimport type { IMediatorTypeAccuracy } from '@comunica/mediatortype-accuracy';\nimport { Algebra, Util } from 'sparqlalgebrajs';\n\n/**\n * A comunica Variable Counting RDF Join Selectivity Actor.\n * Based on the \"variable counting predicates\" heuristic from\n * \"SPARQL basic graph pattern optimization using selectivity estimation.\"\n */\nexport class ActorRdfJoinSelectivityVariableCounting extends ActorRdfJoinSelectivity {\n // Calculated as sum of unbound join type costs times 2 (best-case)\n public static MAX_PAIRWISE_COST = 41 * 2;\n\n public constructor(\n args: IActorArgs<IActionRdfJoinSelectivity, IMediatorTypeAccuracy, IActorRdfJoinSelectivityOutput>,\n ) {\n super(args);\n }\n\n public async test(_action: IActionRdfJoinSelectivity): Promise<TestResult<IMediatorTypeAccuracy>> {\n return passTest({ accuracy: 0.5 });\n }\n\n public static getPatternCost(pattern: Algebra.Pattern | Algebra.Path): number {\n let cost = 1;\n if (pattern.subject.termType === 'Variable') {\n cost += 4;\n }\n if (pattern.predicate.termType === 'Variable' || pattern.type === Algebra.types.PATH) {\n cost += 1;\n }\n if (pattern.object.termType === 'Variable') {\n cost += 2;\n }\n if (pattern.graph.termType === 'Variable') {\n cost += 1;\n }\n return cost / 9;\n }\n\n public static getJoinTypes(\n operation1: Algebra.Pattern | Algebra.Path,\n operation2: Algebra.Pattern | Algebra.Path,\n ): JoinTypes[] {\n const joinTypes: JoinTypes[] = [];\n\n // Check operation1.subject\n if (operation1.subject.termType === 'Variable') {\n if (operation1.subject.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.unboundSS);\n }\n if (operation2.type === 'pattern' && operation1.subject.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.unboundSP);\n }\n if (operation1.subject.equals(operation2.object)) {\n joinTypes.push(JoinTypes.unboundSO);\n }\n if (operation1.subject.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.unboundSG);\n }\n } else {\n if (operation1.subject.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.boundSS);\n }\n if (operation2.type === 'pattern' && operation1.subject.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.boundSP);\n }\n if (operation1.subject.equals(operation2.object)) {\n joinTypes.push(JoinTypes.boundSO);\n }\n if (operation1.subject.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.boundSG);\n }\n }\n\n // Check operation1.predicate\n if (operation1.type === 'pattern') {\n if (operation1.predicate.termType === 'Variable') {\n if (operation1.predicate.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.unboundPS);\n }\n if (operation2.type === 'pattern' && operation1.predicate.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.unboundPP);\n }\n if (operation1.predicate.equals(operation2.object)) {\n joinTypes.push(JoinTypes.unboundPO);\n }\n if (operation1.predicate.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.unboundPG);\n }\n } else {\n if (operation1.predicate.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.boundPS);\n }\n if (operation2.type === 'pattern' && operation1.predicate.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.boundPP);\n }\n if (operation1.predicate.equals(operation2.object)) {\n joinTypes.push(JoinTypes.boundPO);\n }\n if (operation1.predicate.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.boundPG);\n }\n }\n }\n\n // Check operation1.object\n if (operation1.object.termType === 'Variable') {\n if (operation1.object.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.unboundOS);\n }\n if (operation2.type === 'pattern' && operation1.object.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.unboundOP);\n }\n if (operation1.object.equals(operation2.object)) {\n joinTypes.push(JoinTypes.unboundOO);\n }\n if (operation1.object.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.unboundOG);\n }\n } else {\n if (operation1.object.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.boundOS);\n }\n if (operation2.type === 'pattern' && operation1.object.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.boundOP);\n }\n if (operation1.object.equals(operation2.object)) {\n joinTypes.push(JoinTypes.boundOO);\n }\n if (operation1.object.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.boundOG);\n }\n }\n\n // Check operation1.graph\n if (operation1.graph.termType === 'Variable') {\n if (operation1.graph.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.unboundGS);\n }\n if (operation2.type === 'pattern' && operation1.graph.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.unboundGP);\n }\n if (operation1.graph.equals(operation2.object)) {\n joinTypes.push(JoinTypes.unboundGO);\n }\n if (operation1.graph.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.unboundGG);\n }\n } else {\n if (operation1.graph.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.boundGS);\n }\n if (operation2.type === 'pattern' && operation1.graph.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.boundGP);\n }\n if (operation1.graph.equals(operation2.object)) {\n joinTypes.push(JoinTypes.boundGO);\n }\n if (operation1.graph.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.boundGG);\n }\n }\n\n return joinTypes;\n }\n\n public static getOperationsPairwiseJoinCost(\n operation1: Algebra.Pattern | Algebra.Path,\n operation2: Algebra.Pattern | Algebra.Path,\n ): number {\n let cost = ActorRdfJoinSelectivityVariableCounting.MAX_PAIRWISE_COST;\n\n for (const joinType of ActorRdfJoinSelectivityVariableCounting.getJoinTypes(operation1, operation2)) {\n switch (joinType) {\n case JoinTypes.boundSS:\n cost -= 2 * 2;\n break;\n case JoinTypes.boundSP:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundSO:\n cost -= 1 * 2;\n break;\n case JoinTypes.boundSG:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundPS:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundPP:\n // Special case: patterns with equal (bound) predicates have the highest cost\n return 1;\n case JoinTypes.boundPO:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundPG:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundOS:\n cost -= 1 * 2;\n break;\n case JoinTypes.boundOP:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundOO:\n cost -= 1 * 2;\n break;\n case JoinTypes.boundOG:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundGS:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundGP:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundGO:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundGG:\n cost -= 3 * 2;\n break;\n case JoinTypes.unboundSS:\n cost -= 2;\n break;\n case JoinTypes.unboundSP:\n cost -= 3;\n break;\n case JoinTypes.unboundSO:\n cost -= 1;\n break;\n case JoinTypes.unboundSG:\n cost -= 3;\n break;\n case JoinTypes.unboundPS:\n cost -= 3;\n break;\n case JoinTypes.unboundPP:\n cost -= 3;\n break;\n case JoinTypes.unboundPO:\n cost -= 3;\n break;\n case JoinTypes.unboundPG:\n cost -= 3;\n break;\n case JoinTypes.unboundOS:\n cost -= 1;\n break;\n case JoinTypes.unboundOP:\n cost -= 3;\n break;\n case JoinTypes.unboundOO:\n cost -= 1;\n break;\n case JoinTypes.unboundOG:\n cost -= 3;\n break;\n case JoinTypes.unboundGS:\n cost -= 3;\n break;\n case JoinTypes.unboundGP:\n cost -= 3;\n break;\n case JoinTypes.unboundGO:\n cost -= 3;\n break;\n case JoinTypes.unboundGG:\n cost -= 3;\n break;\n }\n }\n\n return cost / ActorRdfJoinSelectivityVariableCounting.MAX_PAIRWISE_COST;\n }\n\n public static getOperationsJoinCost(operations: Algebra.Operation[]): number {\n // Determine all operations that select values (patterns and paths)\n const patterns: (Algebra.Pattern | Algebra.Path)[] = [];\n for (const operation of operations) {\n Util.recurseOperation(operation, {\n [Algebra.types.PATTERN](pattern: Algebra.Pattern): boolean {\n patterns.push(pattern);\n return false;\n },\n [Algebra.types.PATH](path: Algebra.Path): boolean {\n patterns.push(path);\n return false;\n },\n });\n }\n\n // Determine pairwise costs\n let totalCost = 0;\n let costEntries = 0;\n for (const pattern1 of patterns) {\n for (const pattern2 of patterns) {\n if (pattern1 !== pattern2) {\n totalCost += ActorRdfJoinSelectivityVariableCounting.getOperationsPairwiseJoinCost(pattern1, pattern2);\n costEntries++;\n }\n }\n }\n\n // If there are no overlapping patterns, the cost is 1\n if (costEntries === 0) {\n return 1;\n }\n\n // Combine all pairwise costs, and multiply with costs of each pattern separately\n return totalCost / costEntries * patterns\n .reduce((factor, pattern) => factor * ActorRdfJoinSelectivityVariableCounting.getPatternCost(pattern), 1);\n }\n\n public async run(action: IActionRdfJoinSelectivity): Promise<IActorRdfJoinSelectivityOutput> {\n if (action.entries.length <= 1) {\n return { selectivity: 1 };\n }\n return {\n selectivity: ActorRdfJoinSelectivityVariableCounting\n .getOperationsJoinCost(action.entries.map(entry => entry.operation)),\n };\n }\n}\n\nexport enum JoinTypes {\n boundSS,\n boundSP,\n boundSO,\n boundSG,\n boundPS,\n boundPP,\n boundPO,\n boundPG,\n boundOS,\n boundOP,\n boundOO,\n boundOG,\n boundGS,\n boundGP,\n boundGO,\n boundGG,\n\n unboundSS,\n unboundSP,\n unboundSO,\n unboundSG,\n unboundPS,\n unboundPP,\n unboundPO,\n unboundPG,\n unboundOS,\n unboundOP,\n unboundOO,\n unboundOG,\n unboundGS,\n unboundGP,\n unboundGO,\n unboundGG,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ActorRdfJoinSelectivityVariableCounting.js","sourceRoot":"","sources":["ActorRdfJoinSelectivityVariableCounting.ts"],"names":[],"mappings":";;;AACA,iFAA6E;AAE7E,yCAA0C;AAE1C,2DAAgE;AAEhE;;;;GAIG;AACH,MAAa,uCAAwC,SAAQ,kDAAuB;IAClF,mEAAmE;IAC5D,MAAM,CAAC,iBAAiB,GAAG,EAAE,GAAG,CAAC,CAAC;IAEzC,YACE,IAAkG;QAElG,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC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OAAO;YACL,WAAW,EAAE,uCAAuC;iBACjD,qBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SACvE,CAAC;IACJ,CAAC;;AA3TH,0FA4TC;AAED,IAAY,SAkCX;AAlCD,WAAY,SAAS;IACnB,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,+CAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IACP,gDAAO,CAAA;IAEP,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;IACT,oDAAS,CAAA;AACX,CAAC,EAlCW,SAAS,yBAAT,SAAS,QAkCpB","sourcesContent":["import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity';\nimport { ActorRdfJoinSelectivity } from '@comunica/bus-rdf-join-selectivity';\nimport type { IActorArgs, TestResult } from '@comunica/core';\nimport { passTest } from '@comunica/core';\nimport type { IMediatorTypeAccuracy } from '@comunica/mediatortype-accuracy';\nimport { Algebra, algebraUtils } from '@comunica/utils-algebra';\n\n/**\n * A comunica Variable Counting RDF Join Selectivity Actor.\n * Based on the \"variable counting predicates\" heuristic from\n * \"SPARQL basic graph pattern optimization using selectivity estimation.\"\n */\nexport class ActorRdfJoinSelectivityVariableCounting extends ActorRdfJoinSelectivity {\n // Calculated as sum of unbound join type costs times 2 (best-case)\n public static MAX_PAIRWISE_COST = 41 * 2;\n\n public constructor(\n args: IActorArgs<IActionRdfJoinSelectivity, IMediatorTypeAccuracy, IActorRdfJoinSelectivityOutput>,\n ) {\n super(args);\n }\n\n public async test(_action: IActionRdfJoinSelectivity): Promise<TestResult<IMediatorTypeAccuracy>> {\n return passTest({ accuracy: 0.5 });\n }\n\n public static getPatternCost(pattern: Algebra.Pattern | Algebra.Path): number {\n let cost = 1;\n if (pattern.subject.termType === 'Variable') {\n cost += 4;\n }\n if (('termType' in pattern.predicate && pattern.predicate.termType === 'Variable') ||\n pattern.type === Algebra.Types.PATH) {\n cost += 1;\n }\n if (pattern.object.termType === 'Variable') {\n cost += 2;\n }\n if (pattern.graph.termType === 'Variable') {\n cost += 1;\n }\n return cost / 9;\n }\n\n public static getJoinTypes(\n operation1: Algebra.Pattern | Algebra.Path,\n operation2: Algebra.Pattern | Algebra.Path,\n ): JoinTypes[] {\n const joinTypes: JoinTypes[] = [];\n\n // Check operation1.subject\n if (operation1.subject.termType === 'Variable') {\n if (operation1.subject.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.unboundSS);\n }\n if (operation2.type === 'pattern' && operation1.subject.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.unboundSP);\n }\n if (operation1.subject.equals(operation2.object)) {\n joinTypes.push(JoinTypes.unboundSO);\n }\n if (operation1.subject.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.unboundSG);\n }\n } else {\n if (operation1.subject.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.boundSS);\n }\n if (operation2.type === 'pattern' && operation1.subject.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.boundSP);\n }\n if (operation1.subject.equals(operation2.object)) {\n joinTypes.push(JoinTypes.boundSO);\n }\n if (operation1.subject.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.boundSG);\n }\n }\n\n // Check operation1.predicate\n if (operation1.type === 'pattern') {\n if (operation1.predicate.termType === 'Variable') {\n if (operation1.predicate.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.unboundPS);\n }\n if (operation2.type === 'pattern' && operation1.predicate.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.unboundPP);\n }\n if (operation1.predicate.equals(operation2.object)) {\n joinTypes.push(JoinTypes.unboundPO);\n }\n if (operation1.predicate.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.unboundPG);\n }\n } else {\n if (operation1.predicate.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.boundPS);\n }\n if (operation2.type === 'pattern' && operation1.predicate.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.boundPP);\n }\n if (operation1.predicate.equals(operation2.object)) {\n joinTypes.push(JoinTypes.boundPO);\n }\n if (operation1.predicate.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.boundPG);\n }\n }\n }\n\n // Check operation1.object\n if (operation1.object.termType === 'Variable') {\n if (operation1.object.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.unboundOS);\n }\n if (operation2.type === 'pattern' && operation1.object.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.unboundOP);\n }\n if (operation1.object.equals(operation2.object)) {\n joinTypes.push(JoinTypes.unboundOO);\n }\n if (operation1.object.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.unboundOG);\n }\n } else {\n if (operation1.object.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.boundOS);\n }\n if (operation2.type === 'pattern' && operation1.object.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.boundOP);\n }\n if (operation1.object.equals(operation2.object)) {\n joinTypes.push(JoinTypes.boundOO);\n }\n if (operation1.object.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.boundOG);\n }\n }\n\n // Check operation1.graph\n if (operation1.graph.termType === 'Variable') {\n if (operation1.graph.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.unboundGS);\n }\n if (operation2.type === 'pattern' && operation1.graph.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.unboundGP);\n }\n if (operation1.graph.equals(operation2.object)) {\n joinTypes.push(JoinTypes.unboundGO);\n }\n if (operation1.graph.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.unboundGG);\n }\n } else {\n if (operation1.graph.equals(operation2.subject)) {\n joinTypes.push(JoinTypes.boundGS);\n }\n if (operation2.type === 'pattern' && operation1.graph.equals(operation2.predicate)) {\n joinTypes.push(JoinTypes.boundGP);\n }\n if (operation1.graph.equals(operation2.object)) {\n joinTypes.push(JoinTypes.boundGO);\n }\n if (operation1.graph.equals(operation2.graph)) {\n joinTypes.push(JoinTypes.boundGG);\n }\n }\n\n return joinTypes;\n }\n\n public static getOperationsPairwiseJoinCost(\n operation1: Algebra.Pattern | Algebra.Path,\n operation2: Algebra.Pattern | Algebra.Path,\n ): number {\n let cost = ActorRdfJoinSelectivityVariableCounting.MAX_PAIRWISE_COST;\n\n for (const joinType of ActorRdfJoinSelectivityVariableCounting.getJoinTypes(operation1, operation2)) {\n switch (joinType) {\n case JoinTypes.boundSS:\n cost -= 2 * 2;\n break;\n case JoinTypes.boundSP:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundSO:\n cost -= 1 * 2;\n break;\n case JoinTypes.boundSG:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundPS:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundPP:\n // Special case: patterns with equal (bound) predicates have the highest cost\n return 1;\n case JoinTypes.boundPO:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundPG:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundOS:\n cost -= 1 * 2;\n break;\n case JoinTypes.boundOP:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundOO:\n cost -= 1 * 2;\n break;\n case JoinTypes.boundOG:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundGS:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundGP:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundGO:\n cost -= 3 * 2;\n break;\n case JoinTypes.boundGG:\n cost -= 3 * 2;\n break;\n case JoinTypes.unboundSS:\n cost -= 2;\n break;\n case JoinTypes.unboundSP:\n cost -= 3;\n break;\n case JoinTypes.unboundSO:\n cost -= 1;\n break;\n case JoinTypes.unboundSG:\n cost -= 3;\n break;\n case JoinTypes.unboundPS:\n cost -= 3;\n break;\n case JoinTypes.unboundPP:\n cost -= 3;\n break;\n case JoinTypes.unboundPO:\n cost -= 3;\n break;\n case JoinTypes.unboundPG:\n cost -= 3;\n break;\n case JoinTypes.unboundOS:\n cost -= 1;\n break;\n case JoinTypes.unboundOP:\n cost -= 3;\n break;\n case JoinTypes.unboundOO:\n cost -= 1;\n break;\n case JoinTypes.unboundOG:\n cost -= 3;\n break;\n case JoinTypes.unboundGS:\n cost -= 3;\n break;\n case JoinTypes.unboundGP:\n cost -= 3;\n break;\n case JoinTypes.unboundGO:\n cost -= 3;\n break;\n case JoinTypes.unboundGG:\n cost -= 3;\n break;\n }\n }\n\n return cost / ActorRdfJoinSelectivityVariableCounting.MAX_PAIRWISE_COST;\n }\n\n public static getOperationsJoinCost(operations: Algebra.Operation[]): number {\n // Determine all operations that select values (patterns and paths)\n const patterns: (Algebra.Pattern | Algebra.Path)[] = [];\n for (const operation of operations) {\n algebraUtils.visitOperation(operation, {\n [Algebra.Types.PATTERN]: { preVisitor: (pattern) => {\n patterns.push(pattern);\n return { continue: false };\n } },\n [Algebra.Types.PATH]: { preVisitor: (path) => {\n patterns.push(path);\n return { continue: false };\n } },\n });\n }\n\n // Determine pairwise costs\n let totalCost = 0;\n let costEntries = 0;\n for (const pattern1 of patterns) {\n for (const pattern2 of patterns) {\n if (pattern1 !== pattern2) {\n totalCost += ActorRdfJoinSelectivityVariableCounting.getOperationsPairwiseJoinCost(pattern1, pattern2);\n costEntries++;\n }\n }\n }\n\n // If there are no overlapping patterns, the cost is 1\n if (costEntries === 0) {\n return 1;\n }\n\n // Combine all pairwise costs, and multiply with costs of each pattern separately\n return totalCost / costEntries * patterns\n .reduce((factor, pattern) => factor * ActorRdfJoinSelectivityVariableCounting.getPatternCost(pattern), 1);\n }\n\n public async run(action: IActionRdfJoinSelectivity): Promise<IActorRdfJoinSelectivityOutput> {\n if (action.entries.length <= 1) {\n return { selectivity: 1 };\n }\n return {\n selectivity: ActorRdfJoinSelectivityVariableCounting\n .getOperationsJoinCost(action.entries.map(entry => entry.operation)),\n };\n }\n}\n\nexport enum JoinTypes {\n boundSS,\n boundSP,\n boundSO,\n boundSG,\n boundPS,\n boundPP,\n boundPO,\n boundPG,\n boundOS,\n boundOP,\n boundOO,\n boundOG,\n boundGS,\n boundGP,\n boundGO,\n boundGG,\n\n unboundSS,\n unboundSP,\n unboundSO,\n unboundSG,\n unboundPS,\n unboundPP,\n unboundPO,\n unboundPG,\n unboundOS,\n unboundOP,\n unboundOO,\n unboundOG,\n unboundGS,\n unboundGP,\n unboundGO,\n unboundGG,\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/actor-rdf-join-selectivity-variable-counting",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "A variable-counting rdf-join-selectivity actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"build:components": "componentsjs-generator"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@comunica/bus-rdf-join-selectivity": "^
|
|
45
|
-
"@comunica/core": "^
|
|
46
|
-
"@comunica/mediatortype-accuracy": "^
|
|
47
|
-
"
|
|
44
|
+
"@comunica/bus-rdf-join-selectivity": "^5.0.2",
|
|
45
|
+
"@comunica/core": "^5.0.2",
|
|
46
|
+
"@comunica/mediatortype-accuracy": "^5.0.2",
|
|
47
|
+
"@comunica/utils-algebra": "^5.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "3b29f914010fd2fc56682a0ceff962ef6ff24f32"
|
|
50
50
|
}
|