@comunica/statistic-link-discovery 3.2.4-alpha.47.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/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
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.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Comunica Statistic Link Discovery
2
+
3
+ [![npm version](https://badge.fury.io/js/%40comunica%2Fstatistic-link-discovery.svg)](https://www.npmjs.com/package/@comunica/statistic-link-discovery)
4
+
5
+ A statistics tracker package for tracking discovered links during query execution in Comunica. This class must be added to the context with the key defined in the class.
6
+
7
+ This module is part of the [Comunica framework](https://github.com/comunica/comunica),
8
+
9
+ [Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ $ yarn add @comunica/statistic-link-discovery
15
+ ```
16
+
17
+ ## Using the tracker
18
+
19
+ ```javascript
20
+ const QueryEngine = require('@comunica/query-sparql').QueryEngine;
21
+ const myEngine = new QueryEngine();
22
+ const statisticTracker = new StatisticLinkDiscovery();
23
+
24
+ // Print any data emitted by the tracker
25
+ statisticTracker.on((data) => console.log(data));
26
+
27
+ // Add the tracker to the context
28
+ let context = {sources: ['https://fragments.dbpedia.org/2015/en']};
29
+ context[statisticTracker.key.name] = statisticTracker;
30
+
31
+ // Execute the query
32
+ const bindingsStream = await myEngine.queryBindings(`
33
+ SELECT ?s ?p ?o WHERE {
34
+ ?s ?p ?o
35
+ } LIMIT 10`, context);
36
+ bindingsStream.on('data', (binding) => {
37
+ console.log(binding.toString());
38
+ });
39
+ ```
@@ -0,0 +1,10 @@
1
+ import type { ActionContextKey } from '@comunica/core';
2
+ import { StatisticBase } from '@comunica/statistic-base';
3
+ import type { IDiscoverEventData, ILink, IStatisticBase } from '@comunica/types';
4
+ export declare class StatisticLinkDiscovery extends StatisticBase<IDiscoverEventData> {
5
+ key: ActionContextKey<IStatisticBase<IDiscoverEventData>>;
6
+ count: number;
7
+ metadata: Record<string, Record<any, any>[]>;
8
+ constructor();
9
+ updateStatistic(link: ILink, parent: ILink): boolean;
10
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StatisticLinkDiscovery = void 0;
4
+ const context_entries_1 = require("@comunica/context-entries");
5
+ const statistic_base_1 = require("@comunica/statistic-base");
6
+ class StatisticLinkDiscovery extends statistic_base_1.StatisticBase {
7
+ constructor() {
8
+ super();
9
+ this.count = 0;
10
+ this.metadata = {};
11
+ this.key = context_entries_1.KeysStatistics.discoveredLinks;
12
+ }
13
+ updateStatistic(link, parent) {
14
+ const discoveredLinkMetadata = {
15
+ ...link.metadata,
16
+ discoveredTimestamp: performance.now(),
17
+ discoverOrder: this.count,
18
+ };
19
+ // Retain previous metadata if this link has already been discovered, and add any metadata in the passed link
20
+ this.metadata[link.url] = this.metadata[link.url] ?
21
+ [...this.metadata[link.url], discoveredLinkMetadata] :
22
+ [discoveredLinkMetadata];
23
+ this.emit({
24
+ edge: [parent.url, link.url],
25
+ metadataChild: this.metadata[link.url],
26
+ metadataParent: this.metadata[parent.url],
27
+ });
28
+ this.count++;
29
+ return true;
30
+ }
31
+ }
32
+ exports.StatisticLinkDiscovery = StatisticLinkDiscovery;
33
+ //# sourceMappingURL=StatisticLinkDiscovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatisticLinkDiscovery.js","sourceRoot":"","sources":["StatisticLinkDiscovery.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAE3D,6DAAyD;AAGzD,MAAa,sBAAuB,SAAQ,8BAAiC;IAY3E;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,gCAAc,CAAC,eAAe,CAAC;IAC5C,CAAC;IAEM,eAAe,CAAC,IAAW,EAAE,MAAa;QAC/C,MAAM,sBAAsB,GAAG;YAC7B,GAAG,IAAI,CAAC,QAAQ;YAChB,mBAAmB,EAAE,WAAW,CAAC,GAAG,EAAE;YACtC,aAAa,EAAE,IAAI,CAAC,KAAK;SAC1B,CAAC;QACF,6GAA6G;QAC7G,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/C,CAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,sBAAsB,CAAE,CAAC,CAAC;YACxD,CAAE,sBAAsB,CAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,CAAE,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAE;YAC9B,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;YACtC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC;SAC1C,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArCD,wDAqCC","sourcesContent":["import { KeysStatistics } from '@comunica/context-entries';\nimport type { ActionContextKey } from '@comunica/core';\nimport { StatisticBase } from '@comunica/statistic-base';\nimport type { IDiscoverEventData, ILink, IStatisticBase } from '@comunica/types';\n\nexport class StatisticLinkDiscovery extends StatisticBase<IDiscoverEventData> {\n // Key this statistic tracker should be saved under in context\n public key: ActionContextKey<IStatisticBase<IDiscoverEventData>>;\n\n // Number of discover events tracked\n public count: number;\n\n // Metadata is saved as follows: First key indicates what url this metadata belongs to, while value is\n // a list of all metadata objects recorded. This list can contain multiple Records as links can be discovered from\n // multiple data sources.\n public metadata: Record<string, Record<any, any>[]>;\n\n public constructor() {\n super();\n this.count = 0;\n this.metadata = {};\n this.key = KeysStatistics.discoveredLinks;\n }\n\n public updateStatistic(link: ILink, parent: ILink): boolean {\n const discoveredLinkMetadata = {\n ...link.metadata,\n discoveredTimestamp: performance.now(),\n discoverOrder: this.count,\n };\n // Retain previous metadata if this link has already been discovered, and add any metadata in the passed link\n this.metadata[link.url] = this.metadata[link.url] ?\n [ ...this.metadata[link.url], discoveredLinkMetadata ] :\n [ discoveredLinkMetadata ];\n this.emit({\n edge: [ parent.url, link.url ],\n metadataChild: this.metadata[link.url],\n metadataParent: this.metadata[parent.url],\n });\n this.count++;\n return true;\n }\n}\n"]}
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './StatisticLinkDiscovery';
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./StatisticLinkDiscovery"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC","sourcesContent":["export * from './StatisticLinkDiscovery';\n"]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@comunica/statistic-link-discovery",
3
+ "version": "3.2.4-alpha.47.0",
4
+ "description": "Comunica package that defines the statistic tracking link discovery events",
5
+ "license": "MIT",
6
+ "funding": {
7
+ "type": "opencollective",
8
+ "url": "https://opencollective.com/comunica-association"
9
+ },
10
+ "homepage": "https://comunica.dev/",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/comunica/comunica.git",
14
+ "directory": "packages/statistic-link-discovery"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/comunica/comunica/issues"
18
+ },
19
+ "keywords": [
20
+ "comunica",
21
+ "statistic",
22
+ "link discovery"
23
+ ],
24
+ "sideEffects": false,
25
+ "main": "lib/index.js",
26
+ "typings": "lib/index",
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "files": [
31
+ "bin/**/*.d.ts",
32
+ "bin/**/*.js",
33
+ "bin/**/*.js.map",
34
+ "lib/**/*.d.ts",
35
+ "lib/**/*.js",
36
+ "lib/**/*.js.map"
37
+ ],
38
+ "scripts": {
39
+ "build": "node \"../../node_modules/typescript/bin/tsc\""
40
+ },
41
+ "dependencies": {
42
+ "@comunica/context-entries": "3.2.4-alpha.47.0",
43
+ "@comunica/core": "3.2.4-alpha.47.0",
44
+ "@comunica/statistic-base": "3.2.4-alpha.47.0",
45
+ "@comunica/types": "3.2.4-alpha.47.0"
46
+ },
47
+ "gitHead": "85bd4c5cf07dfc293ebbc3a1416b70e2db8bfc48"
48
+ }