@comunica/actor-query-operation-reduced-hash 2.7.1 → 2.8.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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActorQueryOperationReducedHash = void 0;
|
|
4
4
|
const bus_query_operation_1 = require("@comunica/bus-query-operation");
|
|
5
|
-
const
|
|
5
|
+
const lru_cache_1 = require("lru-cache");
|
|
6
6
|
/**
|
|
7
7
|
* A comunica Reduced Hash Query Operation Actor.
|
|
8
8
|
*/
|
|
@@ -30,7 +30,7 @@ class ActorQueryOperationReducedHash extends bus_query_operation_1.ActorQueryOpe
|
|
|
30
30
|
*/
|
|
31
31
|
async newHashFilter(context) {
|
|
32
32
|
const { hashFunction } = await this.mediatorHashBindings.mediate({ allowHashCollisions: true, context });
|
|
33
|
-
const hashes = new
|
|
33
|
+
const hashes = new lru_cache_1.LRUCache({ max: this.cacheSize });
|
|
34
34
|
return (bindings) => {
|
|
35
35
|
const hash = hashFunction(bindings);
|
|
36
36
|
if (hashes.has(hash)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorQueryOperationReducedHash.js","sourceRoot":"","sources":["ActorQueryOperationReducedHash.ts"],"names":[],"mappings":";;;AAEA,uEAAsG;AAKtG,
|
|
1
|
+
{"version":3,"file":"ActorQueryOperationReducedHash.js","sourceRoot":"","sources":["ActorQueryOperationReducedHash.ts"],"names":[],"mappings":";;;AAEA,uEAAsG;AAKtG,yCAAqC;AAErC;;GAEG;AACH,MAAa,8BAA+B,SAAQ,sDAAiD;IAInG,YAAmB,IAAyC;QAC1D,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,SAA0B,EAAE,OAAuB;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,SAA0B,EAAE,OAAuB;QAC3E,MAAM,MAAM,GAAkC,yCAAmB,CAAC,eAAe,CAC/E,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CACnF,CAAC;QACF,MAAM,cAAc,GAAmB,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QACvG,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,cAAc;YACd,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CAAC,OAAuB;QAChD,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACzG,MAAM,MAAM,GAAG,IAAI,oBAAQ,CAAkB,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QACtE,OAAO,CAAC,QAAkB,EAAE,EAAE;YAC5B,MAAM,IAAI,GAAW,YAAY,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBACpB,OAAO,KAAK,CAAC;aACd;YACD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;CACF;AA1CD,wEA0CC","sourcesContent":["import type { MediatorHashBindings } from '@comunica/bus-hash-bindings';\nimport type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';\nimport { ActorQueryOperation, ActorQueryOperationTypedMediated } from '@comunica/bus-query-operation';\nimport type { IActorTest } from '@comunica/core';\nimport type {\n Bindings, BindingsStream, IActionContext, IQueryOperationResult, IQueryOperationResultBindings,\n} from '@comunica/types';\nimport { LRUCache } from 'lru-cache';\nimport type { Algebra } from 'sparqlalgebrajs';\n/**\n * A comunica Reduced Hash Query Operation Actor.\n */\nexport class ActorQueryOperationReducedHash extends ActorQueryOperationTypedMediated<Algebra.Reduced> {\n public readonly mediatorHashBindings: MediatorHashBindings;\n public readonly cacheSize: number;\n\n public constructor(args: IActorQueryOperationReducedHashArgs) {\n super(args, 'reduced');\n }\n\n public async testOperation(operation: Algebra.Reduced, context: IActionContext): Promise<IActorTest> {\n return true;\n }\n\n public async runOperation(operation: Algebra.Reduced, context: IActionContext): Promise<IQueryOperationResult> {\n const output: IQueryOperationResultBindings = ActorQueryOperation.getSafeBindings(\n await this.mediatorQueryOperation.mediate({ operation: operation.input, context }),\n );\n const bindingsStream: BindingsStream = output.bindingsStream.filter(await this.newHashFilter(context));\n return {\n type: 'bindings',\n bindingsStream,\n metadata: output.metadata,\n };\n }\n\n /**\n * Create a new distinct filter function.\n * This will maintain an internal hash datastructure so that every bindings object only returns true once.\n * @param context The action context.\n * @return {(bindings: Bindings) => boolean} A distinct filter for bindings.\n */\n public async newHashFilter(context: IActionContext): Promise<(bindings: Bindings) => boolean> {\n const { hashFunction } = await this.mediatorHashBindings.mediate({ allowHashCollisions: true, context });\n const hashes = new LRUCache<string, boolean>({ max: this.cacheSize });\n return (bindings: Bindings) => {\n const hash: string = hashFunction(bindings);\n if (hashes.has(hash)) {\n return false;\n }\n hashes.set(hash, true);\n return true;\n };\n }\n}\n\nexport interface IActorQueryOperationReducedHashArgs extends IActorQueryOperationTypedMediatedArgs {\n mediatorHashBindings: MediatorHashBindings;\n /**\n * @range {integer}\n * @default {100}\n */\n cacheSize: number;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-query-operation-reduced-hash",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "A reduced-hash query-operation actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"lib/**/*.js.map"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@comunica/bus-hash-bindings": "^2.
|
|
36
|
-
"@comunica/bus-query-operation": "^2.
|
|
37
|
-
"@comunica/core": "^2.
|
|
38
|
-
"@comunica/types": "^2.
|
|
35
|
+
"@comunica/bus-hash-bindings": "^2.8.0",
|
|
36
|
+
"@comunica/bus-query-operation": "^2.8.0",
|
|
37
|
+
"@comunica/core": "^2.8.0",
|
|
38
|
+
"@comunica/types": "^2.8.0",
|
|
39
39
|
"@types/lru-cache": "^7.0.0",
|
|
40
|
-
"lru-cache": "^
|
|
41
|
-
"sparqlalgebrajs": "^4.0
|
|
40
|
+
"lru-cache": "^10.0.0",
|
|
41
|
+
"sparqlalgebrajs": "^4.2.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "npm run build:ts && npm run build:components",
|
|
45
45
|
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
46
46
|
"build:components": "componentsjs-generator"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2459c84cb0ddc959436d8742f1f7b2805ce09825"
|
|
49
49
|
}
|