@comunica/actor-rdf-join-selectivity-variable-counting 2.4.0 → 2.5.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorRdfJoinSelectivityVariableCounting.js","sourceRoot":"","sources":["ActorRdfJoinSelectivityVariableCounting.ts"],"names":[],"mappings":";;;AACA,iFAA6E;AAG7E,qDAAgD;AAEhD;;;;GAIG;AACH,MAAa,uCAAwC,SAAQ,kDAAuB;IAIlF,YACE,IAAkG;QAElG,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAAiC;QACjD,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,OAAuC;QAClE,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,KAAK,UAAU,EAAE;YAC3C,IAAI,IAAI,CAAC,CAAC;SACX;QACD,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU,IAAI,OAAO,CAAC,IAAI,KAAK,yBAAO,CAAC,KAAK,CAAC,IAAI,EAAE;YACpF,IAAI,IAAI,CAAC,CAAC;SACX;QACD,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,UAAU,EAAE;YAC1C,IAAI,IAAI,CAAC,CAAC;SACX;QACD,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,UAAU,EAAE;YACzC,IAAI,IAAI,CAAC,CAAC;SACX;QACD,OAAO,IAAI,GAAG,CAAC,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,YAAY,CACxB,UAA0C,EAC1C,UAA0C;QAE1C,MAAM,SAAS,GAAgB,EAAE,CAAC;QAElC,2BAA2B;QAC3B,IAAI,UAAU,CAAC,OAAO,CAAC,QAAQ,KAAK,UAAU,EAAE;Y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O,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,GAAT,iBAAS,KAAT,iBAAS,QAkCpB","sourcesContent":["import type { IActionRdfJoinSelectivity, IActorRdfJoinSelectivityOutput } from '@comunica/bus-rdf-join-selectivity';\nimport { ActorRdfJoinSelectivity } from '@comunica/bus-rdf-join-selectivity';\nimport type { IActorArgs } 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<IMediatorTypeAccuracy> {\n return { 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 // 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"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4EAA0D","sourcesContent":["export * from './ActorRdfJoinSelectivityVariableCounting';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/actor-rdf-join-selectivity-variable-counting",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "A variable-counting rdf-join-selectivity actor",
5
5
  "lsd:module": true,
6
6
  "main": "lib/index.js",
@@ -28,12 +28,13 @@
28
28
  "files": [
29
29
  "components",
30
30
  "lib/**/*.d.ts",
31
- "lib/**/*.js"
31
+ "lib/**/*.js",
32
+ "lib/**/*.js.map"
32
33
  ],
33
34
  "dependencies": {
34
- "@comunica/bus-rdf-join-selectivity": "^2.4.0",
35
- "@comunica/core": "^2.4.0",
36
- "@comunica/mediatortype-accuracy": "^2.4.0",
35
+ "@comunica/bus-rdf-join-selectivity": "^2.5.0",
36
+ "@comunica/core": "^2.5.0",
37
+ "@comunica/mediatortype-accuracy": "^2.5.0",
37
38
  "sparqlalgebrajs": "^4.0.0"
38
39
  },
39
40
  "scripts": {
@@ -41,5 +42,5 @@
41
42
  "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
42
43
  "build:components": "componentsjs-generator"
43
44
  },
44
- "gitHead": "cb5a1560c9ab9ebaf3335888a1411a7e1654de1e"
45
+ "gitHead": "349d57f5d1e539200e980bdff96973c2e0b66caa"
45
46
  }
package/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
4
- Comunica Association and Ghent University – imec, Belgium
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in
14
- all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- THE SOFTWARE.