@lde/sparql-qlever 0.16.3 → 0.18.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/dist/createQlever.d.ts +12 -2
- package/dist/createQlever.d.ts.map +1 -1
- package/dist/createQlever.js +6 -3
- package/dist/importer.d.ts +5 -2
- package/dist/importer.d.ts.map +1 -1
- package/dist/importer.js +14 -8
- package/package.json +25 -9
package/dist/createQlever.d.ts
CHANGED
|
@@ -36,12 +36,22 @@ export type QleverOptions = {
|
|
|
36
36
|
containerName: string;
|
|
37
37
|
} | {
|
|
38
38
|
mode: 'native';
|
|
39
|
+
} | {
|
|
40
|
+
/**
|
|
41
|
+
* Run QLever in another container of the same pod, such as a sidecar
|
|
42
|
+
* with its own memory limit, through the task agent of
|
|
43
|
+
* `@lde/task-runner-http`. Both containers mount `dataDir` at the same
|
|
44
|
+
* path.
|
|
45
|
+
*/
|
|
46
|
+
mode: 'remote';
|
|
47
|
+
/** Absolute, and the same path in both containers. */
|
|
48
|
+
dataDir: string;
|
|
39
49
|
});
|
|
40
50
|
/**
|
|
41
51
|
* Create a paired QLever {@link Importer} and {@link Server} that share a
|
|
42
52
|
* single {@link TaskRunner}. In pipeline setups the importer and server must
|
|
43
|
-
* use the same runner (and therefore the same Docker container or
|
|
44
|
-
* directory) so that the server can serve the index the importer built.
|
|
53
|
+
* use the same runner (and therefore the same Docker container, sidecar or
|
|
54
|
+
* working directory) so that the server can serve the index the importer built.
|
|
45
55
|
*/
|
|
46
56
|
export declare function createQlever(options: QleverOptions): {
|
|
47
57
|
importer: Importer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQlever.d.ts","sourceRoot":"","sources":["../src/createQlever.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createQlever.d.ts","sourceRoot":"","sources":["../src/createQlever.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EAEX,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG;IAC1B,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,6FAA6F;IAC7F,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mDAAmD;IACnD,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,sDAAsD;IACtD,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC,GAAG,CACA;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAC;CACvB,GACD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IACE;;;;;OAKG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;CACjB,CACJ,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa;;;EAsClD"}
|
package/dist/createQlever.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DockerTaskRunner } from '@lde/task-runner-docker';
|
|
2
|
+
import { HttpTaskRunner } from '@lde/task-runner-http';
|
|
2
3
|
import { NativeTaskRunner } from '@lde/task-runner-native';
|
|
3
4
|
import { LastModifiedDownloader, } from '@lde/distribution-downloader';
|
|
4
5
|
import { Importer } from './importer.js';
|
|
@@ -6,8 +7,8 @@ import { Server } from './server.js';
|
|
|
6
7
|
/**
|
|
7
8
|
* Create a paired QLever {@link Importer} and {@link Server} that share a
|
|
8
9
|
* single {@link TaskRunner}. In pipeline setups the importer and server must
|
|
9
|
-
* use the same runner (and therefore the same Docker container or
|
|
10
|
-
* directory) so that the server can serve the index the importer built.
|
|
10
|
+
* use the same runner (and therefore the same Docker container, sidecar or
|
|
11
|
+
* working directory) so that the server can serve the index the importer built.
|
|
11
12
|
*/
|
|
12
13
|
export function createQlever(options) {
|
|
13
14
|
const port = options.port ?? 7001;
|
|
@@ -24,7 +25,9 @@ export function createQlever(options) {
|
|
|
24
25
|
network: options.network,
|
|
25
26
|
port: hostname ? undefined : port,
|
|
26
27
|
})
|
|
27
|
-
:
|
|
28
|
+
: options.mode === 'remote'
|
|
29
|
+
? new HttpTaskRunner({ cwd: options.dataDir })
|
|
30
|
+
: new NativeTaskRunner({ cwd: options.dataDir });
|
|
28
31
|
return {
|
|
29
32
|
importer: new Importer({
|
|
30
33
|
taskRunner,
|
package/dist/importer.d.ts
CHANGED
|
@@ -23,13 +23,16 @@ export declare class Importer implements ImporterInterface {
|
|
|
23
23
|
import(distributions: Distribution[]): Promise<NotSupported | ImportSuccessful | ImportFailed>;
|
|
24
24
|
private doImport;
|
|
25
25
|
private parseTripleCount;
|
|
26
|
+
/** The QLever that built the index, from the `git-hash` in its metadata:
|
|
27
|
+
* QLever has no releases, so the commit is its version. */
|
|
28
|
+
private parseEngine;
|
|
26
29
|
private cacheInfoPath;
|
|
27
30
|
/**
|
|
28
31
|
* Check whether the cached index is still up to date.
|
|
29
32
|
*/
|
|
30
33
|
private isIndexUpToDate;
|
|
31
|
-
/** Read
|
|
32
|
-
private
|
|
34
|
+
/** Read QLever's metadata file, or an empty string when there is none. */
|
|
35
|
+
private readMetadata;
|
|
33
36
|
private writeCacheInfo;
|
|
34
37
|
private index;
|
|
35
38
|
}
|
package/dist/importer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../src/importer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../src/importer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,IAAI,iBAAiB,EAC7B,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAyB,YAAY,EAAE,MAAM,cAAc,CAAC;AAOnE,MAAM,WAAW,kBAAkB;IACjC,oBAAoB;IACpB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,yBAAyB;IACzB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,uEAAuE;IACvE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,yJAAyJ;IACzJ,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAED,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAWD,qBAAa,QAAS,YAAW,iBAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;gBAE9B,OAAO,EAAE,qBAAqB;IAa7B,MAAM,CACjB,aAAa,EAAE,YAAY,EAAE,GAC5B,OAAO,CAAC,YAAY,GAAG,gBAAgB,GAAG,YAAY,CAAC;YAqC5C,QAAQ;IA0EtB,OAAO,CAAC,gBAAgB;IAQxB;gEAC4D;IAC5D,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,aAAa;IAIrB;;OAEG;YACW,eAAe;IA0B7B,0EAA0E;YAC5D,YAAY;YAYZ,cAAc;YAKd,KAAK;CA8CpB"}
|
package/dist/importer.js
CHANGED
|
@@ -52,11 +52,12 @@ export class Importer {
|
|
|
52
52
|
async doImport(distribution) {
|
|
53
53
|
const { path: localFile, headers } = await this.options.downloader.download(distribution);
|
|
54
54
|
if (await this.isIndexUpToDate(localFile)) {
|
|
55
|
-
const
|
|
55
|
+
const metadata = await this.readMetadata(localFile);
|
|
56
|
+
const tripleCount = this.parseTripleCount(metadata);
|
|
56
57
|
if (tripleCount === 0) {
|
|
57
58
|
return new ImportFailed(distribution, 'Index is cached but contains 0 triples');
|
|
58
59
|
}
|
|
59
|
-
return new ImportSuccessful(distribution, undefined, tripleCount);
|
|
60
|
+
return new ImportSuccessful(distribution, undefined, tripleCount, [], this.parseEngine(metadata));
|
|
60
61
|
}
|
|
61
62
|
let indexFile = localFile;
|
|
62
63
|
let format;
|
|
@@ -91,7 +92,7 @@ export class Importer {
|
|
|
91
92
|
return new ImportFailed(distribution, 'Indexed 0 triples from distribution');
|
|
92
93
|
}
|
|
93
94
|
await this.writeCacheInfo(localFile);
|
|
94
|
-
return new ImportSuccessful(distribution, undefined, tripleCount, warnings);
|
|
95
|
+
return new ImportSuccessful(distribution, undefined, tripleCount, warnings, this.parseEngine(logs));
|
|
95
96
|
}
|
|
96
97
|
parseTripleCount(logs) {
|
|
97
98
|
// Extract num-triples.normal from the metadata JSON that the index
|
|
@@ -100,6 +101,12 @@ export class Importer {
|
|
|
100
101
|
const match = logs.match(/"num-triples":\{[^}]*"normal":(\d+)/);
|
|
101
102
|
return match ? Number(match[1]) : undefined;
|
|
102
103
|
}
|
|
104
|
+
/** The QLever that built the index, from the `git-hash` in its metadata:
|
|
105
|
+
* QLever has no releases, so the commit is its version. */
|
|
106
|
+
parseEngine(metadata) {
|
|
107
|
+
const match = metadata.match(/"git-hash"\s*:\s*"([0-9a-f]+)"/);
|
|
108
|
+
return match ? { name: 'QLever', version: match[1] } : undefined;
|
|
109
|
+
}
|
|
103
110
|
cacheInfoPath(dataFile) {
|
|
104
111
|
return join(dirname(dataFile), `${this.options.indexName}.cache-info.json`);
|
|
105
112
|
}
|
|
@@ -129,15 +136,14 @@ export class Importer {
|
|
|
129
136
|
}
|
|
130
137
|
return true;
|
|
131
138
|
}
|
|
132
|
-
/** Read
|
|
133
|
-
async
|
|
139
|
+
/** Read QLever's metadata file, or an empty string when there is none. */
|
|
140
|
+
async readMetadata(dataFile) {
|
|
134
141
|
try {
|
|
135
142
|
const metadataPath = join(dirname(dataFile), `${this.options.indexName}.meta-data.json`);
|
|
136
|
-
|
|
137
|
-
return this.parseTripleCount(raw);
|
|
143
|
+
return await readFile(metadataPath, 'utf-8');
|
|
138
144
|
}
|
|
139
145
|
catch {
|
|
140
|
-
return
|
|
146
|
+
return '';
|
|
141
147
|
}
|
|
142
148
|
}
|
|
143
149
|
async writeCacheInfo(dataFile) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/sparql-qlever",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
6
6
|
"directory": "packages/sparql-qlever"
|
|
@@ -24,14 +24,15 @@
|
|
|
24
24
|
"!**/*.tsbuildinfo"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lde/dataset": "^0.
|
|
28
|
-
"@lde/distribution-downloader": "^0.
|
|
29
|
-
"@lde/sparql-importer": "^0.
|
|
30
|
-
"@lde/sparql-server": "^0.
|
|
31
|
-
"@lde/task-runner": "^0.
|
|
32
|
-
"@lde/task-runner-docker": "^0.
|
|
33
|
-
"@lde/task-runner-
|
|
34
|
-
"@lde/
|
|
27
|
+
"@lde/dataset": "^0.8.0",
|
|
28
|
+
"@lde/distribution-downloader": "^0.7.0",
|
|
29
|
+
"@lde/sparql-importer": "^0.8.0",
|
|
30
|
+
"@lde/sparql-server": "^0.5.0",
|
|
31
|
+
"@lde/task-runner": "^0.3.0",
|
|
32
|
+
"@lde/task-runner-docker": "^0.4.0",
|
|
33
|
+
"@lde/task-runner-http": "^0.1.0",
|
|
34
|
+
"@lde/task-runner-native": "^0.3.0",
|
|
35
|
+
"@lde/wait-for-sparql": "^0.3.0",
|
|
35
36
|
"rdf-parse": "^5.0.0",
|
|
36
37
|
"rdf-serialize": "^5.1.0",
|
|
37
38
|
"tslib": "^2.3.0",
|
|
@@ -40,5 +41,20 @@
|
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@rdfjs/types": "^2.0.0",
|
|
42
43
|
"@types/yauzl": "^3.4.0"
|
|
44
|
+
},
|
|
45
|
+
"nx": {
|
|
46
|
+
"targets": {
|
|
47
|
+
"test": {
|
|
48
|
+
"dependsOn": [
|
|
49
|
+
"^build",
|
|
50
|
+
{
|
|
51
|
+
"projects": [
|
|
52
|
+
"@lde/task-runner-http"
|
|
53
|
+
],
|
|
54
|
+
"target": "docker:build"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
43
59
|
}
|
|
44
60
|
}
|