@lde/sparql-qlever 0.17.0 → 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.
@@ -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 the triple count from QLever's metadata file. */
32
- private readTripleCount;
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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../src/importer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,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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5C,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 tripleCount = await this.readTripleCount(localFile);
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 the triple count from QLever's metadata file. */
133
- async readTripleCount(dataFile) {
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
- const raw = await readFile(metadataPath, 'utf-8');
137
- return this.parseTripleCount(raw);
143
+ return await readFile(metadataPath, 'utf-8');
138
144
  }
139
145
  catch {
140
- return undefined;
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.17.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"
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@lde/dataset": "^0.8.0",
28
28
  "@lde/distribution-downloader": "^0.7.0",
29
- "@lde/sparql-importer": "^0.7.0",
29
+ "@lde/sparql-importer": "^0.8.0",
30
30
  "@lde/sparql-server": "^0.5.0",
31
31
  "@lde/task-runner": "^0.3.0",
32
32
  "@lde/task-runner-docker": "^0.4.0",