@undefineds.co/xpod 0.3.17 → 0.3.22
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/config/bun.json +57 -11
- package/config/cloud.json +14 -12
- package/config/local.json +16 -14
- package/config/xpod.json +47 -9
- package/dist/api/matrix/PodMatrixStore.d.ts +4 -7
- package/dist/api/matrix/PodMatrixStore.js +116 -148
- package/dist/api/matrix/PodMatrixStore.js.map +1 -1
- package/dist/api/matrix/types.d.ts +2 -0
- package/dist/api/matrix/types.js.map +1 -1
- package/dist/components/components.jsonld +3 -0
- package/dist/components/context.jsonld +71 -32
- package/dist/http/SubgraphSparqlHttpHandler.d.ts +1 -0
- package/dist/http/SubgraphSparqlHttpHandler.js +27 -4
- package/dist/http/SubgraphSparqlHttpHandler.js.map +1 -1
- package/dist/http/SubgraphSparqlHttpHandler.jsonld +4 -0
- package/dist/http/vector/VectorHttpHandler.d.ts +5 -1
- package/dist/http/vector/VectorHttpHandler.js +5 -5
- package/dist/http/vector/VectorHttpHandler.js.map +1 -1
- package/dist/http/vector/VectorHttpHandler.jsonld +40 -28
- package/dist/index.d.ts +5 -3
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/runtime/Proxy.d.ts +3 -0
- package/dist/runtime/Proxy.js +31 -7
- package/dist/runtime/Proxy.js.map +1 -1
- package/dist/storage/SparqlUpdateResourceStore.js +94 -33
- package/dist/storage/SparqlUpdateResourceStore.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.d.ts +22 -5
- package/dist/storage/accessors/MixDataAccessor.js +376 -61
- package/dist/storage/accessors/MixDataAccessor.js.map +1 -1
- package/dist/storage/accessors/MixDataAccessor.jsonld +73 -5
- package/dist/storage/accessors/QuadstoreSparqlDataAccessor.js +32 -10
- package/dist/storage/accessors/QuadstoreSparqlDataAccessor.js.map +1 -1
- package/dist/storage/accessors/QuintStoreSparqlDataAccessor.js +28 -6
- package/dist/storage/accessors/QuintStoreSparqlDataAccessor.js.map +1 -1
- package/dist/storage/accessors/SolidRdfDataAccessor.d.ts +45 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.js +277 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.js.map +1 -0
- package/dist/storage/accessors/SolidRdfDataAccessor.jsonld +161 -0
- package/dist/storage/rdf/Rdf3xIndex.d.ts +122 -0
- package/dist/storage/rdf/Rdf3xIndex.js +2695 -0
- package/dist/storage/rdf/Rdf3xIndex.js.map +1 -0
- package/dist/storage/rdf/Rdf3xIndex.jsonld +528 -0
- package/dist/storage/rdf/Rdf3xSchema.d.ts +20 -0
- package/dist/storage/rdf/Rdf3xSchema.js +65 -0
- package/dist/storage/rdf/Rdf3xSchema.js.map +1 -0
- package/dist/storage/rdf/RdfLocalQueryEngine.d.ts +10 -4
- package/dist/storage/rdf/RdfLocalQueryEngine.js +607 -127
- package/dist/storage/rdf/RdfLocalQueryEngine.js.map +1 -1
- package/dist/storage/rdf/RdfQuadIndex.d.ts +12 -1
- package/dist/storage/rdf/RdfQuadIndex.js +152 -22
- package/dist/storage/rdf/RdfQuadIndex.js.map +1 -1
- package/dist/storage/rdf/RdfQuadIndex.jsonld +36 -4
- package/dist/storage/rdf/RdfSparqlAdapter.d.ts +20 -2
- package/dist/storage/rdf/RdfSparqlAdapter.js +364 -40
- package/dist/storage/rdf/RdfSparqlAdapter.js.map +1 -1
- package/dist/storage/rdf/RdfSparqlAdapter.jsonld +60 -0
- package/dist/storage/rdf/RdfTermDictionary.d.ts +8 -0
- package/dist/storage/rdf/RdfTermDictionary.js +141 -70
- package/dist/storage/rdf/RdfTermDictionary.js.map +1 -1
- package/dist/storage/rdf/RdfTermDictionary.jsonld +24 -0
- package/dist/storage/rdf/RdfTextIndex.js +10 -3
- package/dist/storage/rdf/RdfTextIndex.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.d.ts +15 -6
- package/dist/storage/rdf/SolidRdfEngine.js +218 -25
- package/dist/storage/rdf/SolidRdfEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfEngine.jsonld +70 -7
- package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +11 -7
- package/dist/storage/rdf/SolidRdfSparqlEngine.js +60 -47
- package/dist/storage/rdf/SolidRdfSparqlEngine.js.map +1 -1
- package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +9 -5
- package/dist/storage/rdf/index.d.ts +2 -2
- package/dist/storage/rdf/index.js +3 -3
- package/dist/storage/rdf/index.js.map +1 -1
- package/dist/storage/rdf/models-benchmark.d.ts +12 -1
- package/dist/storage/rdf/models-benchmark.js +549 -32
- package/dist/storage/rdf/models-benchmark.js.map +1 -1
- package/dist/storage/rdf/types.d.ts +81 -7
- package/dist/storage/rdf/types.js.map +1 -1
- package/dist/storage/sparql/CompatibilitySparqlEngine.d.ts +36 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.js +96 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.js.map +1 -0
- package/dist/storage/sparql/CompatibilitySparqlEngine.jsonld +123 -0
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.d.ts +35 -0
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js +112 -0
- package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js.map +1 -0
- package/dist/storage/sparql/SubgraphQueryEngine.d.ts +1 -36
- package/dist/storage/sparql/SubgraphQueryEngine.js +2 -115
- package/dist/storage/sparql/SubgraphQueryEngine.js.map +1 -1
- package/dist/storage/sparql/SubgraphQueryEngine.jsonld +1 -124
- package/dist/terminal/AclPermissionService.d.ts +2 -1
- package/dist/terminal/AclPermissionService.js +26 -3
- package/dist/terminal/AclPermissionService.js.map +1 -1
- package/dist/terminal/TerminalSessionManager.js +25 -3
- package/dist/terminal/TerminalSessionManager.js.map +1 -1
- package/package.json +1 -1
- package/dist/storage/rdf/Rdf3xTripleIndex.d.ts +0 -55
- package/dist/storage/rdf/Rdf3xTripleIndex.js +0 -1235
- package/dist/storage/rdf/Rdf3xTripleIndex.js.map +0 -1
|
@@ -15,9 +15,16 @@ export declare class RdfQuadIndex {
|
|
|
15
15
|
put(quad: Quad, options?: RdfIndexPutOptions): void;
|
|
16
16
|
replaceSource(quads: Quad[], source: RdfSourceInput): void;
|
|
17
17
|
deleteSource(source: string): number;
|
|
18
|
+
private deleteSourceInternal;
|
|
18
19
|
multiPut(quads: Quad[], options?: RdfIndexPutOptions): void;
|
|
19
20
|
private insertQuads;
|
|
20
21
|
delete(pattern: QuintPattern): number;
|
|
22
|
+
applyDelta(deletes: QuintPattern[], inserts: Quad[], options?: RdfIndexPutOptions): {
|
|
23
|
+
deletedRows: number;
|
|
24
|
+
insertedRows: number;
|
|
25
|
+
};
|
|
26
|
+
private deleteInternal;
|
|
27
|
+
dataVersion(): number;
|
|
21
28
|
scan(pattern: QuintPattern, options?: RdfQuadScanOptions): RdfQuadIndexScanResult;
|
|
22
29
|
scanWithTupleConstraints(pattern: QuintPattern, tupleSource: RdfQuadTupleConstraintSource, options?: RdfQuadScanOptions): RdfQuadIndexScanResult;
|
|
23
30
|
joinPatterns(patterns: RdfQuadJoinPattern[], options?: RdfQuadJoinOptions): RdfQuadJoinScanResult;
|
|
@@ -30,7 +37,6 @@ export declare class RdfQuadIndex {
|
|
|
30
37
|
private scanInternal;
|
|
31
38
|
private compileJoinPatterns;
|
|
32
39
|
private buildJoinOrderClause;
|
|
33
|
-
private joinRowKeyExpression;
|
|
34
40
|
private buildJoinAggregateColumn;
|
|
35
41
|
private buildGroupCountHavingClause;
|
|
36
42
|
private buildGroupAggregateHavingClause;
|
|
@@ -57,6 +63,11 @@ export declare class RdfQuadIndex {
|
|
|
57
63
|
private estimateSpaceObjectsFromSchema;
|
|
58
64
|
private estimatePageSize;
|
|
59
65
|
private initializeSchema;
|
|
66
|
+
private prepareSchemaVersion;
|
|
67
|
+
private ensureMetadataTable;
|
|
68
|
+
private dropIndexSchema;
|
|
69
|
+
private bumpDataVersion;
|
|
70
|
+
private setMetadataValue;
|
|
60
71
|
private upsertSource;
|
|
61
72
|
private buildWhereClause;
|
|
62
73
|
private matchToCondition;
|
|
@@ -7,10 +7,12 @@ const n3_1 = require("n3");
|
|
|
7
7
|
const SqliteRuntime_1 = require("../SqliteRuntime");
|
|
8
8
|
const types_1 = require("../quint/types");
|
|
9
9
|
const RdfTermDictionary_1 = require("./RdfTermDictionary");
|
|
10
|
+
const Rdf3xSchema_1 = require("./Rdf3xSchema");
|
|
10
11
|
const RdfTermSemantics_1 = require("./RdfTermSemantics");
|
|
11
12
|
const XSD_INTEGER = 'http://www.w3.org/2001/XMLSchema#integer';
|
|
12
13
|
const XSD_DECIMAL = 'http://www.w3.org/2001/XMLSchema#decimal';
|
|
13
14
|
const XSD_STRING = 'http://www.w3.org/2001/XMLSchema#string';
|
|
15
|
+
const RDF_QUAD_INDEX_SCHEMA_VERSION = 1;
|
|
14
16
|
const TERM_COLUMN = {
|
|
15
17
|
graph: 'graph_id',
|
|
16
18
|
subject: 'subject_id',
|
|
@@ -38,6 +40,7 @@ class RdfQuadIndex {
|
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
this.db = this.sqliteRuntime.openDatabase(this.options.path);
|
|
43
|
+
this.prepareSchemaVersion();
|
|
41
44
|
this.dictionary = new RdfTermDictionary_1.RdfTermDictionary(this.db);
|
|
42
45
|
this.dictionary.initialize();
|
|
43
46
|
this.initializeSchema();
|
|
@@ -51,6 +54,7 @@ class RdfQuadIndex {
|
|
|
51
54
|
const db = this.requireDb();
|
|
52
55
|
db.exec('DELETE FROM rdf_quads; DELETE FROM rdf_sources; DELETE FROM rdf_terms;');
|
|
53
56
|
this.cardinalityCache.clear();
|
|
57
|
+
this.bumpDataVersion();
|
|
54
58
|
}
|
|
55
59
|
put(quad, options) {
|
|
56
60
|
this.multiPut([quad], options);
|
|
@@ -58,7 +62,7 @@ class RdfQuadIndex {
|
|
|
58
62
|
replaceSource(quads, source) {
|
|
59
63
|
const db = this.requireDb();
|
|
60
64
|
db.transaction(() => {
|
|
61
|
-
this.
|
|
65
|
+
this.deleteSourceInternal(source.source);
|
|
62
66
|
if (quads.length > 0) {
|
|
63
67
|
this.insertQuads(quads, { source });
|
|
64
68
|
}
|
|
@@ -67,8 +71,17 @@ class RdfQuadIndex {
|
|
|
67
71
|
}
|
|
68
72
|
})();
|
|
69
73
|
this.cardinalityCache.clear();
|
|
74
|
+
this.bumpDataVersion();
|
|
70
75
|
}
|
|
71
76
|
deleteSource(source) {
|
|
77
|
+
const result = this.deleteSourceInternal(source);
|
|
78
|
+
if (result > 0) {
|
|
79
|
+
this.cardinalityCache.clear();
|
|
80
|
+
this.bumpDataVersion();
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
deleteSourceInternal(source) {
|
|
72
85
|
const db = this.requireDb();
|
|
73
86
|
const row = db
|
|
74
87
|
.prepare('SELECT id FROM rdf_sources WHERE source = ?')
|
|
@@ -78,9 +91,6 @@ class RdfQuadIndex {
|
|
|
78
91
|
}
|
|
79
92
|
const result = db.prepare('DELETE FROM rdf_quads WHERE source_file_id = ?').run(row.id);
|
|
80
93
|
db.prepare('DELETE FROM rdf_sources WHERE id = ?').run(row.id);
|
|
81
|
-
if (result.changes > 0) {
|
|
82
|
-
this.cardinalityCache.clear();
|
|
83
|
-
}
|
|
84
94
|
return result.changes;
|
|
85
95
|
}
|
|
86
96
|
multiPut(quads, options) {
|
|
@@ -92,6 +102,7 @@ class RdfQuadIndex {
|
|
|
92
102
|
this.insertQuads(quads, options);
|
|
93
103
|
})();
|
|
94
104
|
this.cardinalityCache.clear();
|
|
105
|
+
this.bumpDataVersion();
|
|
95
106
|
}
|
|
96
107
|
insertQuads(quads, options) {
|
|
97
108
|
const db = this.requireDb();
|
|
@@ -117,21 +128,53 @@ class RdfQuadIndex {
|
|
|
117
128
|
}
|
|
118
129
|
}
|
|
119
130
|
delete(pattern) {
|
|
131
|
+
const changes = this.deleteInternal(pattern);
|
|
132
|
+
if (changes > 0) {
|
|
133
|
+
this.cardinalityCache.clear();
|
|
134
|
+
this.bumpDataVersion();
|
|
135
|
+
}
|
|
136
|
+
return changes;
|
|
137
|
+
}
|
|
138
|
+
applyDelta(deletes, inserts, options) {
|
|
139
|
+
if (deletes.length === 0 && inserts.length === 0) {
|
|
140
|
+
return { deletedRows: 0, insertedRows: 0 };
|
|
141
|
+
}
|
|
142
|
+
const db = this.requireDb();
|
|
143
|
+
let deletedRows = 0;
|
|
144
|
+
db.transaction(() => {
|
|
145
|
+
for (const pattern of deletes) {
|
|
146
|
+
deletedRows += this.deleteInternal(pattern);
|
|
147
|
+
}
|
|
148
|
+
if (inserts.length > 0) {
|
|
149
|
+
this.insertQuads(inserts, options);
|
|
150
|
+
}
|
|
151
|
+
})();
|
|
152
|
+
if (deletedRows > 0 || inserts.length > 0) {
|
|
153
|
+
this.cardinalityCache.clear();
|
|
154
|
+
this.bumpDataVersion();
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
deletedRows,
|
|
158
|
+
insertedRows: inserts.length,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
deleteInternal(pattern) {
|
|
120
162
|
const db = this.requireDb();
|
|
121
163
|
const { joins, whereClause, params } = this.buildWhereClause(pattern, false);
|
|
122
164
|
if (!whereClause) {
|
|
123
165
|
const result = db.prepare('DELETE FROM rdf_quads').run();
|
|
124
|
-
this.cardinalityCache.clear();
|
|
125
166
|
return result.changes;
|
|
126
167
|
}
|
|
127
168
|
const sql = joins
|
|
128
169
|
? `DELETE FROM rdf_quads WHERE rowid IN (SELECT rdf_quads.rowid FROM rdf_quads${joins}${whereClause})`
|
|
129
170
|
: `DELETE FROM rdf_quads${whereClause}`;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
171
|
+
return db.prepare(sql).run(...params).changes;
|
|
172
|
+
}
|
|
173
|
+
dataVersion() {
|
|
174
|
+
const row = this.requireDb()
|
|
175
|
+
.prepare("SELECT value FROM rdf_index_metadata WHERE key = 'data_version'")
|
|
176
|
+
.get();
|
|
177
|
+
return Number(row?.value ?? 0) || 0;
|
|
135
178
|
}
|
|
136
179
|
scan(pattern, options) {
|
|
137
180
|
return this.scanInternal(pattern, options);
|
|
@@ -191,7 +234,7 @@ class RdfQuadIndex {
|
|
|
191
234
|
const projection = options.aggregates.map((aggregate, index) => {
|
|
192
235
|
const alias = `a${index}`;
|
|
193
236
|
aggregateAliases.set(aggregate.as, alias);
|
|
194
|
-
return this.buildJoinAggregateColumn(aggregate, alias, compiled.variableColumns, aggregateTypes, numericJoins, numericJoinSql, 'RDF BGP'
|
|
237
|
+
return this.buildJoinAggregateColumn(aggregate, alias, compiled.variableColumns, aggregateTypes, numericJoins, numericJoinSql, 'RDF BGP');
|
|
195
238
|
}).join(', ');
|
|
196
239
|
const aggregateJoins = numericJoinSql.join('');
|
|
197
240
|
const sql = `SELECT ${projection} FROM ${compiled.from}${compiled.joins}${aggregateJoins}${compiled.whereClause}`;
|
|
@@ -246,7 +289,7 @@ class RdfQuadIndex {
|
|
|
246
289
|
const alias = `a${index}`;
|
|
247
290
|
aggregateAliases.set(aggregate.as, alias);
|
|
248
291
|
aggregateSqlAliases.set(aggregate.as, alias);
|
|
249
|
-
return this.buildJoinAggregateColumn(aggregate, alias, compiled.variableColumns, aggregateTypes, numericJoins, numericJoinSql, 'RDF BGP group aggregate'
|
|
292
|
+
return this.buildJoinAggregateColumn(aggregate, alias, compiled.variableColumns, aggregateTypes, numericJoins, numericJoinSql, 'RDF BGP group aggregate');
|
|
250
293
|
});
|
|
251
294
|
const projection = [
|
|
252
295
|
...options.groupBy.map((variableName) => {
|
|
@@ -260,15 +303,12 @@ class RdfQuadIndex {
|
|
|
260
303
|
...aggregateColumns,
|
|
261
304
|
].join(', ');
|
|
262
305
|
const groupBy = groupColumns.join(', ');
|
|
263
|
-
const rowKeyExpression = this.joinRowKeyExpression(patterns);
|
|
264
306
|
const aggregateJoins = numericJoinSql.join('');
|
|
265
307
|
const havingClause = this.buildGroupAggregateHavingClause(options.having, aggregateSqlAliases);
|
|
266
308
|
const orderScope = this.buildGroupAggregateOrderScope(options, compiled.variableColumns, aggregateSqlAliases);
|
|
267
309
|
const fromSql = `${compiled.from}${compiled.joins}${aggregateJoins}${compiled.whereClause}`;
|
|
268
310
|
const sourceFromSql = `${compiled.from}${compiled.joins}${aggregateJoins}${orderScope.joins}${compiled.whereClause}`;
|
|
269
|
-
const sourceSql =
|
|
270
|
-
? `SELECT ${projection.replace(/__row_key/g, rowKeyExpression)} FROM ${sourceFromSql} GROUP BY ${groupBy}${havingClause.sql}`
|
|
271
|
-
: `SELECT ${projection} FROM ${sourceFromSql} GROUP BY ${groupBy}${havingClause.sql}`;
|
|
311
|
+
const sourceSql = `SELECT ${projection} FROM ${sourceFromSql} GROUP BY ${groupBy}${havingClause.sql}`;
|
|
272
312
|
const orderClause = orderScope.orderBy;
|
|
273
313
|
let sql = `${sourceSql}${orderClause}`;
|
|
274
314
|
const params = [...compiled.params, ...havingClause.params];
|
|
@@ -476,13 +516,10 @@ class RdfQuadIndex {
|
|
|
476
516
|
orderBy: ` ORDER BY ${joins.map((entry) => entry.order).join(', ')}`,
|
|
477
517
|
};
|
|
478
518
|
}
|
|
479
|
-
|
|
480
|
-
return patterns.map((_, index) => `q${index}.rowid`).join(` || ':' || `);
|
|
481
|
-
}
|
|
482
|
-
buildJoinAggregateColumn(aggregate, alias, variableColumns, aggregateTypes, numericJoins, numericJoinSql, errorPrefix, rowKeyExpression) {
|
|
519
|
+
buildJoinAggregateColumn(aggregate, alias, variableColumns, aggregateTypes, numericJoins, numericJoinSql, errorPrefix) {
|
|
483
520
|
if (aggregate.type === 'count' && !aggregate.variable) {
|
|
484
521
|
aggregateTypes.set(aggregate.as, 'integer');
|
|
485
|
-
return `${aggregate.distinct ? `COUNT(DISTINCT ${
|
|
522
|
+
return `${aggregate.distinct ? `COUNT(DISTINCT ${joinSolutionMappingKeyExpression(variableColumns, aggregate.distinctVariables, errorPrefix)})` : 'COUNT(*)'} AS ${alias}`;
|
|
486
523
|
}
|
|
487
524
|
if (!aggregate.variable) {
|
|
488
525
|
throw new Error(`${errorPrefix} ${aggregate.type} aggregate requires a bound variable`);
|
|
@@ -977,8 +1014,83 @@ class RdfQuadIndex {
|
|
|
977
1014
|
CREATE INDEX IF NOT EXISTS rdf_quads_gspo ON rdf_quads(graph_id, subject_id, predicate_id, object_id);
|
|
978
1015
|
CREATE INDEX IF NOT EXISTS rdf_quads_gpos ON rdf_quads(graph_id, predicate_id, object_id, subject_id);
|
|
979
1016
|
CREATE INDEX IF NOT EXISTS rdf_quads_source ON rdf_quads(source_file_id);
|
|
1017
|
+
|
|
1018
|
+
CREATE TABLE IF NOT EXISTS rdf_index_metadata (
|
|
1019
|
+
key TEXT PRIMARY KEY,
|
|
1020
|
+
value TEXT NOT NULL
|
|
1021
|
+
);
|
|
1022
|
+
`);
|
|
1023
|
+
this.requireDb().prepare(`
|
|
1024
|
+
INSERT OR IGNORE INTO rdf_index_metadata (key, value)
|
|
1025
|
+
SELECT 'data_version', '1'
|
|
1026
|
+
WHERE EXISTS (SELECT 1 FROM rdf_quads LIMIT 1)
|
|
1027
|
+
`).run();
|
|
1028
|
+
}
|
|
1029
|
+
prepareSchemaVersion() {
|
|
1030
|
+
this.ensureMetadataTable();
|
|
1031
|
+
const db = this.requireDb();
|
|
1032
|
+
const row = db
|
|
1033
|
+
.prepare("SELECT value FROM rdf_index_metadata WHERE key = 'schema_version'")
|
|
1034
|
+
.get();
|
|
1035
|
+
if (row && row.value !== String(RDF_QUAD_INDEX_SCHEMA_VERSION)) {
|
|
1036
|
+
this.dropIndexSchema();
|
|
1037
|
+
this.ensureMetadataTable();
|
|
1038
|
+
}
|
|
1039
|
+
this.setMetadataValue('schema_version', String(RDF_QUAD_INDEX_SCHEMA_VERSION));
|
|
1040
|
+
}
|
|
1041
|
+
ensureMetadataTable() {
|
|
1042
|
+
this.requireDb().exec(`
|
|
1043
|
+
CREATE TABLE IF NOT EXISTS rdf_index_metadata (
|
|
1044
|
+
key TEXT PRIMARY KEY,
|
|
1045
|
+
value TEXT NOT NULL
|
|
1046
|
+
);
|
|
980
1047
|
`);
|
|
981
1048
|
}
|
|
1049
|
+
dropIndexSchema() {
|
|
1050
|
+
const db = this.requireDb();
|
|
1051
|
+
const foreignKeys = db.prepare('PRAGMA foreign_keys').get()?.foreign_keys ?? 0;
|
|
1052
|
+
db.exec('PRAGMA foreign_keys = OFF;');
|
|
1053
|
+
try {
|
|
1054
|
+
db.exec(`
|
|
1055
|
+
DROP INDEX IF EXISTS rdf_quads_spog;
|
|
1056
|
+
DROP INDEX IF EXISTS rdf_quads_sopg;
|
|
1057
|
+
DROP INDEX IF EXISTS rdf_quads_psog;
|
|
1058
|
+
DROP INDEX IF EXISTS rdf_quads_posg;
|
|
1059
|
+
DROP INDEX IF EXISTS rdf_quads_ospg;
|
|
1060
|
+
DROP INDEX IF EXISTS rdf_quads_opsg;
|
|
1061
|
+
DROP INDEX IF EXISTS rdf_quads_gspo;
|
|
1062
|
+
DROP INDEX IF EXISTS rdf_quads_gpos;
|
|
1063
|
+
DROP INDEX IF EXISTS rdf_quads_source;
|
|
1064
|
+
DROP TABLE IF EXISTS rdf_quads;
|
|
1065
|
+
DROP TABLE IF EXISTS rdf_sources;
|
|
1066
|
+
DROP TABLE IF EXISTS rdf_terms;
|
|
1067
|
+
DROP TABLE IF EXISTS rdf_index_metadata;
|
|
1068
|
+
`);
|
|
1069
|
+
(0, Rdf3xSchema_1.dropRdf3xDerivedSchemaObjects)(db);
|
|
1070
|
+
}
|
|
1071
|
+
finally {
|
|
1072
|
+
if (foreignKeys) {
|
|
1073
|
+
db.exec('PRAGMA foreign_keys = ON;');
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
this.cardinalityCache.clear();
|
|
1077
|
+
}
|
|
1078
|
+
bumpDataVersion() {
|
|
1079
|
+
this.requireDb().prepare(`
|
|
1080
|
+
INSERT INTO rdf_index_metadata (key, value)
|
|
1081
|
+
VALUES ('data_version', '1')
|
|
1082
|
+
ON CONFLICT (key)
|
|
1083
|
+
DO UPDATE SET value = CAST(value AS INTEGER) + 1
|
|
1084
|
+
`).run();
|
|
1085
|
+
}
|
|
1086
|
+
setMetadataValue(key, value) {
|
|
1087
|
+
this.requireDb().prepare(`
|
|
1088
|
+
INSERT INTO rdf_index_metadata (key, value)
|
|
1089
|
+
VALUES (?, ?)
|
|
1090
|
+
ON CONFLICT (key)
|
|
1091
|
+
DO UPDATE SET value = excluded.value
|
|
1092
|
+
`).run(key, value);
|
|
1093
|
+
}
|
|
982
1094
|
upsertSource(source) {
|
|
983
1095
|
const db = this.requireDb();
|
|
984
1096
|
db.prepare(`
|
|
@@ -1443,9 +1555,11 @@ class RdfQuadIndex {
|
|
|
1443
1555
|
return {
|
|
1444
1556
|
join: ` JOIN rdf_terms ${alias} ON ${alias}.id = ${this.scopedQuadColumn(column, scope)}`,
|
|
1445
1557
|
sql: `${alias}.kind IN (${kind.map(() => '?').join(', ')})
|
|
1558
|
+
AND ${alias}.value_head >= ?
|
|
1559
|
+
AND ${alias}.value_head < ?
|
|
1446
1560
|
AND ${alias}.value >= ?
|
|
1447
1561
|
AND ${alias}.value < ?`,
|
|
1448
|
-
params: [...kind, prefix, `${prefix}\uffff`],
|
|
1562
|
+
params: [...kind, (0, RdfTermDictionary_1.rdfTermValueHead)(prefix), `${(0, RdfTermDictionary_1.rdfTermValueHead)(prefix)}\uffff`, prefix, `${prefix}\uffff`],
|
|
1449
1563
|
};
|
|
1450
1564
|
}
|
|
1451
1565
|
textSearchConditionJoin(kind, column, operator, value, scope) {
|
|
@@ -1837,4 +1951,20 @@ function uniqueNumbers(values) {
|
|
|
1837
1951
|
function uniquePatternKeys(values) {
|
|
1838
1952
|
return TERM_KEYS.filter((key) => values.includes(key));
|
|
1839
1953
|
}
|
|
1954
|
+
function uniqueVariableNames(values) {
|
|
1955
|
+
return [...new Set(values)];
|
|
1956
|
+
}
|
|
1957
|
+
function joinSolutionMappingKeyExpression(variableColumns, variables, errorPrefix) {
|
|
1958
|
+
const variableNames = uniqueVariableNames(variables ?? [...variableColumns.keys()]);
|
|
1959
|
+
if (variableNames.length === 0) {
|
|
1960
|
+
return '1';
|
|
1961
|
+
}
|
|
1962
|
+
return variableNames.map((variableName) => {
|
|
1963
|
+
const column = variableColumns.get(variableName);
|
|
1964
|
+
if (!column) {
|
|
1965
|
+
throw new Error(`${errorPrefix} COUNT(DISTINCT *) cannot read unbound variable: ${variableName}`);
|
|
1966
|
+
}
|
|
1967
|
+
return column;
|
|
1968
|
+
}).join(` || ':' || `);
|
|
1969
|
+
}
|
|
1840
1970
|
//# sourceMappingURL=RdfQuadIndex.js.map
|