@jbr-experiment/largerdfbench 0.0.0-stage → 6.7.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.
@@ -0,0 +1,368 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.LineageComputer = exports.compareOrder = exports.rdfTermToJson = exports.jsonTermToRdf = exports.evaluate = void 0;
27
+ const Path = __importStar(require("node:path"));
28
+ const algebra_sparql_1_1_1 = require("@traqula/algebra-sparql-1-1");
29
+ const fs = __importStar(require("fs-extra"));
30
+ const n3_1 = require("n3");
31
+ const rdf_string_ttl_1 = require("rdf-string-ttl");
32
+ const QueryPatterns_1 = require("./QueryPatterns");
33
+ /**
34
+ * Evaluate a query to an array of bindings, failing after the timeout.
35
+ * @param engine A query engine.
36
+ * @param query A query string.
37
+ * @param context A query context.
38
+ * @param timeoutSeconds A timeout in seconds.
39
+ */
40
+ async function evaluate(engine, query, context, timeoutSeconds) {
41
+ const stream = await engine.queryBindings(query, context);
42
+ return await new Promise((resolve, reject) => {
43
+ const solutions = [];
44
+ const timer = setTimeout(() => {
45
+ stream.destroy();
46
+ reject(new Error(`Query timed out after ${timeoutSeconds} seconds`));
47
+ }, timeoutSeconds * 1000);
48
+ stream.on('data', (bindings) => solutions.push(bindings));
49
+ stream.on('error', (error) => {
50
+ clearTimeout(timer);
51
+ reject(error);
52
+ });
53
+ stream.on('end', () => {
54
+ clearTimeout(timer);
55
+ resolve(solutions);
56
+ });
57
+ });
58
+ }
59
+ exports.evaluate = evaluate;
60
+ /**
61
+ * Convert a term in the SPARQL 1.1 Query Results JSON Format to an RDF term.
62
+ * @param term A term in the SPARQL 1.1 Query Results JSON Format.
63
+ */
64
+ function jsonTermToRdf(term) {
65
+ var _a;
66
+ switch (term.type) {
67
+ case 'uri':
68
+ return n3_1.DataFactory.namedNode(term.value);
69
+ case 'bnode':
70
+ return n3_1.DataFactory.blankNode(term.value);
71
+ case 'literal':
72
+ case 'typed-literal':
73
+ return n3_1.DataFactory.literal(term.value, (_a = term['xml:lang']) !== null && _a !== void 0 ? _a : (term.datatype ? n3_1.DataFactory.namedNode(term.datatype) : undefined));
74
+ default:
75
+ throw new Error(`Unsupported result term type ${term.type}`);
76
+ }
77
+ }
78
+ exports.jsonTermToRdf = jsonTermToRdf;
79
+ /**
80
+ * Convert an RDF term to a term in the SPARQL 1.1 Query Results JSON Format.
81
+ * @param term An RDF term.
82
+ */
83
+ function rdfTermToJson(term) {
84
+ switch (term.termType) {
85
+ case 'NamedNode':
86
+ return { type: 'uri', value: term.value };
87
+ case 'BlankNode':
88
+ return { type: 'bnode', value: term.value };
89
+ case 'Literal':
90
+ if (term.language) {
91
+ return { type: 'literal', value: term.value, 'xml:lang': term.language };
92
+ }
93
+ return term.datatype.value === 'http://www.w3.org/2001/XMLSchema#string' ?
94
+ { type: 'literal', value: term.value } :
95
+ { type: 'literal', value: term.value, datatype: term.datatype.value };
96
+ default:
97
+ throw new Error(`Unsupported binding term type ${term.termType}`);
98
+ }
99
+ }
100
+ exports.rdfTermToJson = rdfTermToJson;
101
+ const TERM_TYPE_ORDER = { BlankNode: 1, NamedNode: 2, Literal: 3 };
102
+ /**
103
+ * Compare two solutions on the conditions of an ORDER BY, which may only contain variables.
104
+ * @param a A solution.
105
+ * @param b A solution.
106
+ * @param order The ORDER BY conditions of a parsed query.
107
+ */
108
+ function compareOrder(a, b, order) {
109
+ for (const { expression, descending } of order) {
110
+ if (expression.type !== 'term' || expression.subType !== 'variable') {
111
+ throw new Error('Only variables are supported in ORDER BY of queries without published results');
112
+ }
113
+ const x = a.get(expression.value);
114
+ const y = b.get(expression.value);
115
+ let result;
116
+ if (!x || !y) {
117
+ result = (x ? 1 : 0) - (y ? 1 : 0);
118
+ }
119
+ else if (x.termType === y.termType) {
120
+ const nx = Number(x.value);
121
+ const ny = Number(y.value);
122
+ if (x.termType === 'Literal' && !Number.isNaN(nx) && !Number.isNaN(ny)) {
123
+ result = nx - ny;
124
+ }
125
+ else {
126
+ result = (0, QueryPatterns_1.compareStrings)(x.value, y.value);
127
+ }
128
+ }
129
+ else {
130
+ result = TERM_TYPE_ORDER[x.termType] - TERM_TYPE_ORDER[y.termType];
131
+ }
132
+ if (result !== 0) {
133
+ return descending ? -result : result;
134
+ }
135
+ }
136
+ return 0;
137
+ }
138
+ exports.compareOrder = compareOrder;
139
+ /**
140
+ * Computes the answer lineage of queries over the full datasets: every triple, per dataset, that contributes to a
141
+ * solution.
142
+ * Queries with published expected results get those results bound via VALUES, so that the values of unprojected
143
+ * variables are recovered as well.
144
+ * Queries without published results (the LIMIT queries) are evaluated first, and their result is stored as their
145
+ * expected result.
146
+ */
147
+ class LineageComputer {
148
+ constructor(options) {
149
+ this.options = options;
150
+ }
151
+ /**
152
+ * Compute the lineage of all queries, writing it as N-Triples per query and dataset, and statistics.
153
+ */
154
+ async computeAll() {
155
+ await fs.ensureDir(this.options.lineageDirectory);
156
+ await fs.ensureDir(this.options.resultsDirectory);
157
+ const stats = {};
158
+ for (const id of Object.keys(this.options.queries)) {
159
+ stats[id] = await this.compute(id);
160
+ this.options.log(` ${id}: ${stats[id].solutions} solutions, lineage ${JSON.stringify(stats[id].triples)}`);
161
+ await fs.writeFile(Path.join(this.options.lineageDirectory, 'stats.json'), `${JSON.stringify(stats, null, 2)}\n`, 'utf8');
162
+ }
163
+ return stats;
164
+ }
165
+ /**
166
+ * The query used to evaluate the given query, which may be an equivalent formulation of it.
167
+ * @param id A query id.
168
+ */
169
+ getEvaluationQuery(id) {
170
+ var _a;
171
+ return (_a = this.options.evaluationQueries[id]) !== null && _a !== void 0 ? _a : this.options.queries[id];
172
+ }
173
+ /**
174
+ * Compute the lineage of a single query.
175
+ * @param id A query id.
176
+ */
177
+ async compute(id) {
178
+ var _a;
179
+ const start = Date.now();
180
+ const expected = (_a = this.options.publishedResults[id]) !== null && _a !== void 0 ? _a : await this.computeExpectedResults(id);
181
+ const rows = LineageComputer.uniqueRows(expected);
182
+ const text = this.getEvaluationQuery(id);
183
+ const solutions = await this.evaluate(LineageComputer.lineageQuery(text, rows));
184
+ // Expected rows whose terms differ from the data (e.g., altered literals) match no solution,
185
+ // so those are retried with their literals unbound, which recovers the actual solutions.
186
+ const rowKey = (row) => JSON.stringify(Object.keys(row).sort()
187
+ .map(variable => [variable, (0, rdf_string_ttl_1.termToString)(row[variable])]));
188
+ const project = (solution, variables) => Object
189
+ .fromEntries(variables.filter(variable => solution.has(variable))
190
+ .map(variable => [variable, solution.get(variable)]));
191
+ const matched = new Set(solutions.map(solution => rowKey(project(solution, expected.head.vars))));
192
+ const unmatched = rows.filter(row => !matched.has(rowKey(row)));
193
+ const relaxed = unmatched
194
+ .map(row => Object.fromEntries(Object.entries(row).filter(([, term]) => term.termType !== 'Literal')))
195
+ .filter(row => Object.keys(row).length > 0);
196
+ let stillUnmatched = unmatched.length - relaxed.length;
197
+ if (relaxed.length > 0) {
198
+ const retried = await this.evaluate(LineageComputer.lineageQuery(text, relaxed));
199
+ solutions.push(...retried);
200
+ const recovered = new Set(retried.flatMap(solution => relaxed
201
+ .filter(row => rowKey(project(solution, Object.keys(row))) === rowKey(row))
202
+ .map(rowKey)));
203
+ stillUnmatched += relaxed.filter(row => !recovered.has(rowKey(row))).length;
204
+ }
205
+ if (unmatched.length > 0) {
206
+ this.options.log(` ${id}: ${unmatched.length} expected rows match no solution, ${relaxed.length} retried with their literals unbound, ${stillUnmatched} still without solution`);
207
+ }
208
+ // Find the datasets that contain each triple of each solution.
209
+ const datasets = Object.keys(this.options.documents);
210
+ const triples = Object.fromEntries(datasets.map(ds => [ds, new Set()]));
211
+ const patterns = (0, QueryPatterns_1.collectPatterns)((0, QueryPatterns_1.parseQuery)(text).algebra);
212
+ for (const solution of solutions) {
213
+ for (const pattern of patterns) {
214
+ const terms = [pattern.subject, pattern.predicate, pattern.object]
215
+ .map(term => term.termType === 'Variable' ? solution.get(term.value) : term);
216
+ if (terms.includes(undefined)) {
217
+ continue;
218
+ }
219
+ for (const ds of datasets) {
220
+ if ((await this.options.documents[ds].countTriples(...terms)).totalCount > 0) {
221
+ triples[ds].add((0, QueryPatterns_1.tripleToLine)(terms[0], terms[1], terms[2]));
222
+ }
223
+ }
224
+ }
225
+ }
226
+ for (const ds of datasets) {
227
+ await fs.writeFile(Path.join(this.options.lineageDirectory, `${id}.${ds}.nt`), [...triples[ds]].join(''), 'utf8');
228
+ }
229
+ return {
230
+ expectedRows: rows.length,
231
+ unmatchedRows: unmatched.map(row => Object.fromEntries(Object.entries(row)
232
+ .map(([variable, term]) => [variable, (0, rdf_string_ttl_1.termToString)(term)]))),
233
+ stillUnmatchedRows: stillUnmatched,
234
+ solutions: solutions.length,
235
+ triples: Object.fromEntries(datasets.filter(ds => triples[ds].size > 0).map(ds => [ds, triples[ds].size])),
236
+ seconds: Math.round((Date.now() - start) / 1000),
237
+ };
238
+ }
239
+ /**
240
+ * Compute the expected results of a query without published results, which has a LIMIT,
241
+ * so that any subset of the solutions of the right size is a correct result.
242
+ * To remain deterministic, all solutions are computed, sorted on the ORDER BY and their values,
243
+ * and the first ones are taken. The result is written to the results directory.
244
+ * @param id A query id.
245
+ */
246
+ async computeExpectedResults(id) {
247
+ var _a, _b, _c;
248
+ this.options.log(` ${id}: no published results, evaluating the query over the full data`);
249
+ const text = this.getEvaluationQuery(id);
250
+ const { ast } = (0, QueryPatterns_1.parseQuery)(text);
251
+ const { limit, offset = 0 } = (_a = ast.solutionModifiers.limitOffset) !== null && _a !== void 0 ? _a : {};
252
+ const order = (_c = (_b = ast.solutionModifiers.order) === null || _b === void 0 ? void 0 : _b.orderDefs) !== null && _c !== void 0 ? _c : [];
253
+ const end = limit === undefined ? undefined : offset + limit;
254
+ delete ast.solutionModifiers.limitOffset;
255
+ const candidates = this.options.limitCandidates[id];
256
+ const solutions = candidates ?
257
+ await this.evaluateOnCandidates(id, text, candidates, end !== null && end !== void 0 ? end : Number.POSITIVE_INFINITY) :
258
+ await this.evaluate((0, QueryPatterns_1.generateQuery)(ast));
259
+ const variables = (0, QueryPatterns_1.projectedVariables)((0, QueryPatterns_1.parseQuery)(this.options.queries[id]).ast, solutions);
260
+ const solutionKey = (solution) => JSON.stringify(variables
261
+ .map(variable => solution.has(variable) ? (0, rdf_string_ttl_1.termToString)(solution.get(variable)) : ''));
262
+ let keyed = solutions.map(solution => ({ solution, key: solutionKey(solution) }));
263
+ if (ast.distinct) {
264
+ keyed = [...new Map(keyed.map(entry => [entry.key, entry])).values()];
265
+ }
266
+ keyed.sort((a, b) => compareOrder(a.solution, b.solution, order) || (0, QueryPatterns_1.compareStrings)(a.key, b.key));
267
+ const selected = keyed.slice(offset, end);
268
+ const results = {
269
+ head: { vars: variables },
270
+ results: {
271
+ bindings: selected.map(({ solution }) => Object.fromEntries(variables
272
+ .filter(variable => solution.has(variable))
273
+ .map(variable => [variable, rdfTermToJson(solution.get(variable))]))),
274
+ },
275
+ };
276
+ await fs.writeFile(Path.join(this.options.resultsDirectory, `${id}.srj`), JSON.stringify(results), 'utf8');
277
+ return results;
278
+ }
279
+ /**
280
+ * Evaluate a LIMIT query on batches of candidate values for one variable, in a fixed order,
281
+ * until enough distinct projected rows are found.
282
+ * All these rows are actual solutions, and the outcome is deterministic.
283
+ * @param id A query id.
284
+ * @param text The query to evaluate.
285
+ * @param candidates The candidates configuration.
286
+ * @param needed The number of distinct rows that are needed.
287
+ */
288
+ async evaluateOnCandidates(id, text, candidates, needed) {
289
+ const subjects = new Map();
290
+ for (const document of Object.values(this.options.documents)) {
291
+ const { triples } = await document.searchTriples(undefined, n3_1.DataFactory.namedNode(candidates.predicate), undefined, { limit: Number.MAX_SAFE_INTEGER });
292
+ for (const { subject } of triples) {
293
+ subjects.set((0, rdf_string_ttl_1.termToString)(subject), subject);
294
+ }
295
+ }
296
+ const ordered = [...subjects.keys()].sort().map(key => subjects.get(key));
297
+ const projection = (0, QueryPatterns_1.parseQuery)(this.options.queries[id]).ast;
298
+ const solutions = [];
299
+ const distinct = new Set();
300
+ let used = 0;
301
+ for (let i = 0; i < ordered.length && distinct.size < needed; i += candidates.batchSize) {
302
+ used = Math.min(ordered.length, i + candidates.batchSize);
303
+ const { ast } = (0, QueryPatterns_1.parseQuery)(text);
304
+ delete ast.solutionModifiers.limitOffset;
305
+ ast.where.patterns.unshift((0, QueryPatterns_1.valuesPattern)(ordered.slice(i, i + candidates.batchSize)
306
+ .map(term => ({ [candidates.variable]: term }))));
307
+ for (const solution of await this.evaluate((0, QueryPatterns_1.generateQuery)(ast))) {
308
+ solutions.push(solution);
309
+ distinct.add(JSON.stringify((0, QueryPatterns_1.projectedVariables)(projection, [solution])
310
+ .map(variable => solution.has(variable) ? (0, rdf_string_ttl_1.termToString)(solution.get(variable)) : '')));
311
+ }
312
+ }
313
+ this.options.log(` ${id}: ${distinct.size} distinct rows from the first ${used} of ${ordered.length} candidates for ?${candidates.variable}`);
314
+ return solutions;
315
+ }
316
+ /**
317
+ * Evaluate a query over the full data.
318
+ * @param query A query string.
319
+ */
320
+ evaluate(query) {
321
+ return evaluate(this.options.engine, query, this.options.engineContext, this.options.timeoutSeconds);
322
+ }
323
+ /**
324
+ * The rows of results as maps from variable names to terms, without duplicates.
325
+ * @param results Results in the SPARQL 1.1 Query Results JSON Format.
326
+ */
327
+ static uniqueRows(results) {
328
+ const unique = new Map();
329
+ for (const row of results.results.bindings) {
330
+ unique.set(JSON.stringify(Object.entries(row).sort(([a], [b]) => a.localeCompare(b))), row);
331
+ }
332
+ return [...unique.values()].map(row => Object.fromEntries(Object.entries(row)
333
+ .map(([variable, term]) => [variable, jsonTermToRdf(term)])));
334
+ }
335
+ /**
336
+ * The query with all variables projected and without solution modifiers, joined with the rows via VALUES.
337
+ * The full rows are joined last, so that their values never end up in solutions of an OPTIONAL that does not
338
+ * match them.
339
+ * The rows projected on the variables outside OPTIONAL and UNION are also joined first, which does not change the
340
+ * solutions, but lets the engine start from them.
341
+ * @param text A query string.
342
+ * @param rows Rows of variable bindings.
343
+ */
344
+ static lineageQuery(text, rows) {
345
+ const { ast } = (0, QueryPatterns_1.parseQuery)(text);
346
+ ast.variables = [QueryPatterns_1.AST_FACTORY.wildcard(QueryPatterns_1.AST_FACTORY.gen())];
347
+ delete ast.distinct;
348
+ delete ast.reduced;
349
+ delete ast.solutionModifiers.limitOffset;
350
+ delete ast.solutionModifiers.order;
351
+ const mandatory = (0, QueryPatterns_1.mandatoryVariables)((0, algebra_sparql_1_1_1.toAlgebra)(ast));
352
+ const first = [...new Map(rows
353
+ .map(row => Object.fromEntries(Object.entries(row).filter(([variable]) => mandatory.has(variable))))
354
+ .filter(row => Object.keys(row).length > 0)
355
+ .map(row => [JSON.stringify(Object.entries(row)
356
+ .map(([variable, term]) => [variable, (0, rdf_string_ttl_1.termToString)(term)])
357
+ .sort(([a], [b]) => (0, QueryPatterns_1.compareStrings)(a, b))), row]))
358
+ .values()];
359
+ ast.where.patterns = [
360
+ ...first.length > 0 ? [(0, QueryPatterns_1.valuesPattern)(first)] : [],
361
+ ...ast.where.patterns,
362
+ (0, QueryPatterns_1.valuesPattern)(rows),
363
+ ];
364
+ return (0, QueryPatterns_1.generateQuery)(ast);
365
+ }
366
+ }
367
+ exports.LineageComputer = LineageComputer;
368
+ //# sourceMappingURL=LineageComputer.js.map
@@ -0,0 +1,115 @@
1
+ import type * as RDF from '@rdfjs/types';
2
+ import type { Algebra } from '@traqula/algebra-transformations-1-1';
3
+ import type { QuerySelect, TermIri, TermLiteral } from '@traqula/rules-sparql-1-1';
4
+ import { AstFactory } from '@traqula/rules-sparql-1-1';
5
+ export declare const AST_FACTORY: AstFactory;
6
+ /**
7
+ * The N-Triples line of a triple, including the trailing newline, which is used as its identity.
8
+ * @param subject The subject.
9
+ * @param predicate The predicate.
10
+ * @param object The object.
11
+ */
12
+ export declare function tripleToLine(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term): string;
13
+ /**
14
+ * A 32-bit FNV-1a hash over UTF-16 code units, which is stable across platforms.
15
+ * @param value A string.
16
+ */
17
+ export declare function fnv1a(value: string): number;
18
+ /**
19
+ * Deterministically decide if something identified by the given key parts is kept at the given rate.
20
+ * @param seed A seed.
21
+ * @param rate A rate between 0 and 1.
22
+ * @param keyParts Strings that identify what is sampled.
23
+ */
24
+ export declare function keep(seed: string, rate: number, ...keyParts: string[]): boolean;
25
+ /**
26
+ * Compare two strings by their UTF-16 code units, which is independent of the locale.
27
+ * @param a A string.
28
+ * @param b A string.
29
+ */
30
+ export declare function compareStrings(a: string, b: string): number;
31
+ /**
32
+ * A parsed SELECT query.
33
+ */
34
+ export interface IParsedQuery {
35
+ /**
36
+ * The syntax tree, which is used to rewrite the query.
37
+ */
38
+ ast: QuerySelect;
39
+ /**
40
+ * The algebra, in which prefixed names are resolved to IRIs.
41
+ */
42
+ algebra: Algebra.Operation;
43
+ }
44
+ /**
45
+ * Parse a SPARQL SELECT query.
46
+ * @param query A SPARQL query string.
47
+ */
48
+ export declare function parseQuery(query: string): IParsedQuery;
49
+ /**
50
+ * Serialize a syntax tree to a SPARQL query string.
51
+ * @param ast A syntax tree of a SELECT query.
52
+ */
53
+ export declare function generateQuery(ast: QuerySelect): string;
54
+ /**
55
+ * Convert a term to a term in a syntax tree, for use in VALUES.
56
+ * @param term An IRI or literal.
57
+ */
58
+ export declare function termToAst(term: RDF.Term): TermIri | TermLiteral;
59
+ /**
60
+ * A VALUES pattern over the variables of the given rows, in which missing variables are UNDEF.
61
+ * @param rows Rows of variable bindings.
62
+ */
63
+ export declare function valuesPattern(rows: Record<string, RDF.Term>[]): QuerySelect['where']['patterns'][number];
64
+ /**
65
+ * All triple patterns of an operation, in query order, including those in OPTIONAL, UNION, and subqueries.
66
+ * @param operation An algebra operation.
67
+ * @param acc The array to add the triple patterns to.
68
+ */
69
+ export declare function collectPatterns(operation: Algebra.Operation, acc?: Algebra.Pattern[]): Algebra.Pattern[];
70
+ /**
71
+ * Variables that are bound in every solution of an operation:
72
+ * those of its triple patterns outside OPTIONAL, MINUS, and UNION, that are projected by the subqueries they are in.
73
+ * @param operation An algebra operation.
74
+ */
75
+ export declare function mandatoryVariables(operation: Algebra.Operation): Set<string>;
76
+ /**
77
+ * Check if a query projects all its variables.
78
+ * @param ast The syntax tree of a SELECT query.
79
+ */
80
+ export declare function isSelectAll(ast: QuerySelect): boolean;
81
+ /**
82
+ * The names of the projected variables of a query, which are taken from the solutions for SELECT *.
83
+ * @param ast The syntax tree of a SELECT query.
84
+ * @param solutions The solutions of the query.
85
+ */
86
+ export declare function projectedVariables(ast: QuerySelect, solutions: RDF.Bindings[]): string[];
87
+ /**
88
+ * A triple pattern of a query, with the keys of its constant terms.
89
+ */
90
+ export interface IMatcherPattern {
91
+ index: number;
92
+ key: string;
93
+ subject?: string;
94
+ predicate?: string;
95
+ object?: string;
96
+ terms: (RDF.Term | undefined)[];
97
+ }
98
+ /**
99
+ * Matches triples against the triple patterns of queries.
100
+ * Fully open patterns (?s ?p ?o) are excluded, as they match every triple.
101
+ */
102
+ export declare class PatternMatcher {
103
+ readonly patterns: IMatcherPattern[];
104
+ private readonly byPredicate;
105
+ private readonly variablePredicate;
106
+ constructor(queries: string[]);
107
+ /**
108
+ * The indexes of the patterns that a triple matches.
109
+ * The key of the object is only computed when needed, as this is called for every triple of the full data.
110
+ * @param subject The key of the subject.
111
+ * @param predicate The key of the predicate.
112
+ * @param object The object.
113
+ */
114
+ match(subject: string, predicate: string, object: RDF.Term): number[];
115
+ }