@lde/pipeline 0.6.17 → 0.6.19
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/batch.d.ts +6 -0
- package/dist/batch.d.ts.map +1 -0
- package/dist/batch.js +17 -0
- package/dist/distribution/index.d.ts +1 -0
- package/dist/distribution/index.d.ts.map +1 -1
- package/dist/distribution/index.js +1 -0
- package/dist/distribution/resolveDistributions.d.ts +11 -0
- package/dist/distribution/resolveDistributions.d.ts.map +1 -0
- package/dist/distribution/resolveDistributions.js +17 -0
- package/dist/distribution/resolver.d.ts +7 -2
- package/dist/distribution/resolver.d.ts.map +1 -1
- package/dist/distribution/resolver.js +15 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/stage.d.ts +4 -1
- package/dist/stage.d.ts.map +1 -1
- package/dist/stage.js +24 -13
- package/package.json +1 -1
package/dist/batch.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAuB,KAAK,CAAC,CAAC,EAC5B,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,IAAI,EAAE,MAAM,GACX,aAAa,CAAC,CAAC,EAAE,CAAC,CAYpB"}
|
package/dist/batch.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Groups items from an async iterable into arrays of at most `size` items.
|
|
3
|
+
* Yields partial final batches.
|
|
4
|
+
*/
|
|
5
|
+
export async function* batch(iterable, size) {
|
|
6
|
+
let buffer = [];
|
|
7
|
+
for await (const item of iterable) {
|
|
8
|
+
buffer.push(item);
|
|
9
|
+
if (buffer.length === size) {
|
|
10
|
+
yield buffer;
|
|
11
|
+
buffer = [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (buffer.length > 0) {
|
|
15
|
+
yield buffer;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { probe, NetworkError, SparqlProbeResult, DataDumpProbeResult, type ProbeResultType, } from './probe.js';
|
|
2
2
|
export { probeResultsToQuads } from './report.js';
|
|
3
3
|
export { ResolvedDistribution, NoDistributionAvailable, SparqlDistributionResolver, type DistributionResolver, type SparqlDistributionResolverOptions, } from './resolver.js';
|
|
4
|
+
export { resolveDistributions, type DistributionStageResult, } from './resolveDistributions.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/distribution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,iCAAiC,GACvC,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/distribution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,iCAAiC,GACvC,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,oBAAoB,EACpB,KAAK,uBAAuB,GAC7B,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { probe, NetworkError, SparqlProbeResult, DataDumpProbeResult, } from './probe.js';
|
|
2
2
|
export { probeResultsToQuads } from './report.js';
|
|
3
3
|
export { ResolvedDistribution, NoDistributionAvailable, SparqlDistributionResolver, } from './resolver.js';
|
|
4
|
+
export { resolveDistributions, } from './resolveDistributions.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Distribution, type Dataset } from '@lde/dataset';
|
|
2
|
+
import type { Quad } from 'n3';
|
|
3
|
+
import type { ProbeResultType } from './probe.js';
|
|
4
|
+
import { type DistributionResolver } from './resolver.js';
|
|
5
|
+
export interface DistributionStageResult {
|
|
6
|
+
distribution: Distribution | null;
|
|
7
|
+
probeResults: ProbeResultType[];
|
|
8
|
+
quads: AsyncIterable<Quad>;
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveDistributions(dataset: Dataset, resolver: DistributionResolver): Promise<DistributionStageResult>;
|
|
11
|
+
//# sourceMappingURL=resolveDistributions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDistributions.d.ts","sourceRoot":"","sources":["../../src/distribution/resolveDistributions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAoBlC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { probeResultsToQuads } from './report.js';
|
|
2
|
+
import { NoDistributionAvailable, } from './resolver.js';
|
|
3
|
+
export async function resolveDistributions(dataset, resolver) {
|
|
4
|
+
const result = await resolver.resolve(dataset);
|
|
5
|
+
if (result instanceof NoDistributionAvailable) {
|
|
6
|
+
return {
|
|
7
|
+
distribution: null,
|
|
8
|
+
probeResults: result.probeResults,
|
|
9
|
+
quads: probeResultsToQuads(result.probeResults, dataset.iri.toString(), result.importFailed),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
distribution: result.distribution,
|
|
14
|
+
probeResults: result.probeResults,
|
|
15
|
+
quads: probeResultsToQuads(result.probeResults, dataset.iri.toString()),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { Dataset, Distribution } from '@lde/dataset';
|
|
2
2
|
import type { Importer } from '@lde/sparql-importer';
|
|
3
|
+
import { ImportFailed } from '@lde/sparql-importer';
|
|
4
|
+
import { type ProbeResultType } from './probe.js';
|
|
3
5
|
export declare class ResolvedDistribution {
|
|
4
6
|
readonly distribution: Distribution;
|
|
5
|
-
|
|
7
|
+
readonly probeResults: ProbeResultType[];
|
|
8
|
+
constructor(distribution: Distribution, probeResults: ProbeResultType[]);
|
|
6
9
|
}
|
|
7
10
|
export declare class NoDistributionAvailable {
|
|
8
11
|
readonly dataset: Dataset;
|
|
9
12
|
readonly message: string;
|
|
10
|
-
|
|
13
|
+
readonly probeResults: ProbeResultType[];
|
|
14
|
+
readonly importFailed?: ImportFailed | undefined;
|
|
15
|
+
constructor(dataset: Dataset, message: string, probeResults: ProbeResultType[], importFailed?: ImportFailed | undefined);
|
|
11
16
|
}
|
|
12
17
|
export interface DistributionResolver {
|
|
13
18
|
resolve(dataset: Dataset): Promise<ResolvedDistribution | NoDistributionAvailable>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/distribution/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/distribution/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAoB,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE5E,qBAAa,oBAAoB;IAE7B,QAAQ,CAAC,YAAY,EAAE,YAAY;IACnC,QAAQ,CAAC,YAAY,EAAE,eAAe,EAAE;gBAD/B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,eAAe,EAAE;CAE3C;AAED,qBAAa,uBAAuB;IAEhC,QAAQ,CAAC,OAAO,EAAE,OAAO;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,YAAY,EAAE,eAAe,EAAE;IACxC,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY;gBAH3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,CAAC,EAAE,YAAY,YAAA;CAEvC;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CACL,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,oBAAoB,GAAG,uBAAuB,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,qBAAa,0BAA2B,YAAW,oBAAoB;IACrE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,CAAC,EAAE,iCAAiC;IAKjD,OAAO,CACX,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,oBAAoB,GAAG,uBAAuB,CAAC;CA+C3D"}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { Distribution } from '@lde/dataset';
|
|
2
|
-
import { ImportSuccessful } from '@lde/sparql-importer';
|
|
2
|
+
import { ImportFailed, ImportSuccessful } from '@lde/sparql-importer';
|
|
3
3
|
import { probe, SparqlProbeResult } from './probe.js';
|
|
4
4
|
export class ResolvedDistribution {
|
|
5
5
|
distribution;
|
|
6
|
-
|
|
6
|
+
probeResults;
|
|
7
|
+
constructor(distribution, probeResults) {
|
|
7
8
|
this.distribution = distribution;
|
|
9
|
+
this.probeResults = probeResults;
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
12
|
export class NoDistributionAvailable {
|
|
11
13
|
dataset;
|
|
12
14
|
message;
|
|
13
|
-
|
|
15
|
+
probeResults;
|
|
16
|
+
importFailed;
|
|
17
|
+
constructor(dataset, message, probeResults, importFailed) {
|
|
14
18
|
this.dataset = dataset;
|
|
15
19
|
this.message = message;
|
|
20
|
+
this.probeResults = probeResults;
|
|
21
|
+
this.importFailed = importFailed;
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
/**
|
|
@@ -41,7 +47,7 @@ export class SparqlDistributionResolver {
|
|
|
41
47
|
if (distribution.isSparql() &&
|
|
42
48
|
result instanceof SparqlProbeResult &&
|
|
43
49
|
result.isSuccess()) {
|
|
44
|
-
return new ResolvedDistribution(distribution);
|
|
50
|
+
return new ResolvedDistribution(distribution, results);
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
// No SPARQL endpoint; try importer if available.
|
|
@@ -49,9 +55,12 @@ export class SparqlDistributionResolver {
|
|
|
49
55
|
const importResult = await this.importer.import(dataset);
|
|
50
56
|
if (importResult instanceof ImportSuccessful) {
|
|
51
57
|
const distribution = Distribution.sparql(importResult.distribution.accessUrl, importResult.identifier);
|
|
52
|
-
return new ResolvedDistribution(distribution);
|
|
58
|
+
return new ResolvedDistribution(distribution, results);
|
|
59
|
+
}
|
|
60
|
+
if (importResult instanceof ImportFailed) {
|
|
61
|
+
return new NoDistributionAvailable(dataset, 'No SPARQL endpoint or importable data dump available', results, importResult);
|
|
53
62
|
}
|
|
54
63
|
}
|
|
55
|
-
return new NoDistributionAvailable(dataset, 'No SPARQL endpoint or importable data dump available');
|
|
64
|
+
return new NoDistributionAvailable(dataset, 'No SPARQL endpoint or importable data dump available', results);
|
|
56
65
|
}
|
|
57
66
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/stage.d.ts
CHANGED
|
@@ -6,14 +6,17 @@ export interface StageOptions {
|
|
|
6
6
|
name: string;
|
|
7
7
|
executors: Executor | Executor[];
|
|
8
8
|
selector?: StageSelector;
|
|
9
|
+
/** Maximum number of bindings per executor call. @default 10 */
|
|
10
|
+
batchSize?: number;
|
|
9
11
|
}
|
|
10
12
|
export declare class Stage {
|
|
11
13
|
readonly name: string;
|
|
12
14
|
private readonly executors;
|
|
13
15
|
private readonly selector?;
|
|
16
|
+
private readonly batchSize;
|
|
14
17
|
constructor(options: StageOptions);
|
|
15
18
|
run(dataset: Dataset, distribution: Distribution): Promise<AsyncIterable<Quad> | NotSupported>;
|
|
16
|
-
private
|
|
19
|
+
private executeAll;
|
|
17
20
|
}
|
|
18
21
|
/** Stage-level selector that yields variable bindings for use in executor queries. Pagination is an implementation detail. */
|
|
19
22
|
export interface StageSelector extends AsyncIterable<VariableBindings> {
|
package/dist/stage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage.d.ts","sourceRoot":"","sources":["../src/stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"stage.d.ts","sourceRoot":"","sources":["../src/stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,KAAK;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAgB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,OAAO,EAAE,YAAY;IAS3B,GAAG,CACP,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;YAwBhC,UAAU;CAkBzB;AAUD,8HAA8H;AAE9H,MAAM,WAAW,aAAc,SAAQ,aAAa,CAAC,gBAAgB,CAAC;CAAG"}
|
package/dist/stage.js
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import { NotSupported } from './sparql/executor.js';
|
|
2
|
+
import { batch } from './batch.js';
|
|
2
3
|
export class Stage {
|
|
3
4
|
name;
|
|
4
5
|
executors;
|
|
5
6
|
selector;
|
|
7
|
+
batchSize;
|
|
6
8
|
constructor(options) {
|
|
7
9
|
this.name = options.name;
|
|
8
10
|
this.executors = Array.isArray(options.executors)
|
|
9
11
|
? options.executors
|
|
10
12
|
: [options.executors];
|
|
11
13
|
this.selector = options.selector;
|
|
14
|
+
this.batchSize = options.batchSize ?? 10;
|
|
12
15
|
}
|
|
13
16
|
async run(dataset, distribution) {
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
if (!this.selector) {
|
|
18
|
+
return this.executeAll(dataset, distribution);
|
|
19
|
+
}
|
|
16
20
|
const streams = [];
|
|
17
|
-
for (const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
for await (const bindings of batch(this.selector, this.batchSize)) {
|
|
22
|
+
for (const executor of this.executors) {
|
|
23
|
+
const result = await executor.execute(dataset, distribution, {
|
|
24
|
+
bindings,
|
|
25
|
+
});
|
|
26
|
+
if (!(result instanceof NotSupported)) {
|
|
27
|
+
streams.push(result);
|
|
28
|
+
}
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
31
|
if (streams.length === 0) {
|
|
@@ -25,15 +33,18 @@ export class Stage {
|
|
|
25
33
|
}
|
|
26
34
|
return mergeStreams(streams);
|
|
27
35
|
}
|
|
28
|
-
async
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
async executeAll(dataset, distribution) {
|
|
37
|
+
const streams = [];
|
|
38
|
+
for (const executor of this.executors) {
|
|
39
|
+
const result = await executor.execute(dataset, distribution);
|
|
40
|
+
if (!(result instanceof NotSupported)) {
|
|
41
|
+
streams.push(result);
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
bindings.push(row);
|
|
44
|
+
if (streams.length === 0) {
|
|
45
|
+
return new NotSupported('All executors returned NotSupported');
|
|
35
46
|
}
|
|
36
|
-
return
|
|
47
|
+
return mergeStreams(streams);
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
50
|
async function* mergeStreams(streams) {
|