Skip to content

Commit

Permalink
refactor engine destroy and add polling to context
Browse files Browse the repository at this point in the history
  • Loading branch information
maartyman committed Nov 12, 2024
1 parent 9ae2b4b commit d657227
Show file tree
Hide file tree
Showing 31 changed files with 988 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"import": [
"ccqs:config/bindings-aggregator-factory/actors.json",
"ccqs:config/bindings-aggregator-factory/mediators.json",
"ccqs:config/context-preprocess/actors.json",
"icqsi:config/context-preprocess/actors.json",
"ccqs:config/context-preprocess/mediators.json",
"ccqs:config/expression-evaluator-factory/actors.json",
"ccqs:config/expression-evaluator-factory/mediators.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/runner/^4.0.0/components/context.jsonld",

"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-context-preprocess-convert-shortcuts/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-context-preprocess-set-defaults/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-context-preprocess-source-to-destination/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-context-preprocess-query-source-identify/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-context-preprocess-query-source-skolemize/^4.0.0/components/context.jsonld"
],
"@id": "urn:comunica:default:Runner",
"@type": "Runner",
"actors": [
{
"@id": "urn:comunica:default:context-preprocess/actors#convert-shortcuts",
"@type": "ActorContextPreprocessConvertShortcuts",
"contextKeyShortcuts": {
"sources": "@comunica/actor-init-query:querySourcesUnidentified",
"destination": "@comunica/bus-rdf-update-quads:destination",
"initialBindings": "@comunica/actor-init-query:initialBindings",
"queryFormat": "@comunica/actor-init-query:queryFormat",
"baseIRI": "@comunica/actor-init-query:baseIRI",
"log": "@comunica/core:log",
"datetime": "@comunica/actor-http-memento:datetime",
"queryTimestamp": "@comunica/actor-init-query:queryTimestamp",
"queryTimestampHighResolution": "@comunica/actor-init-query:queryTimestampHighResolution",
"httpProxyHandler": "@comunica/actor-http-proxy:httpProxyHandler",
"lenient": "@comunica/actor-init-query:lenient",
"httpIncludeCredentials": "@comunica/bus-http:include-credentials",
"httpAuth": "@comunica/bus-http:auth",
"httpTimeout": "@comunica/bus-http:http-timeout",
"httpBodyTimeout": "@comunica/bus-http:http-body-timeout",
"httpRetryCount": "@comunica/bus-http:http-retry-count",
"httpRetryDelayFallback": "@comunica/bus-http:http-retry-delay-fallback",
"httpRetryDelayLimit": "@comunica/bus-http:http-retry-delay-limit",
"fetch": "@comunica/bus-http:fetch",
"recoverBrokenLinks": "@comunica/bus-http-wayback:recover-broken-links",
"readOnly": "@comunica/bus-query-operation:readOnly",
"extensionFunctions": "@comunica/actor-init-query:extensionFunctions",
"extensionFunctionCreator": "@comunica/actor-init-query:extensionFunctionCreator",
"functionArgumentsCache": "@comunica/actor-init-query:functionArgumentsCache",
"explain": "@comunica/actor-init-query:explain",
"unionDefaultGraph": "@comunica/bus-query-operation:unionDefaultGraph",
"traverse": "@comunica/bus-query-source-identify:traverse",
"invalidateCache": "@comunica/actor-init-query:invalidateCache",
"dataFactory": "@comunica/actor-init-query:dataFactory",
"distinctConstruct": "@comunica/actor-init-query:distinctConstruct",
"pollingFrequency": "@incremunica/resource-watch:pollingFrequency"
}
},
{
"@id": "urn:comunica:default:context-preprocess/actors#set-defaults",
"@type": "ActorContextPreprocessSetDefaults"
},
{
"@id": "urn:comunica:default:context-preprocess/actors#source-to-destination",
"@type": "ActorContextPreprocessSourceToDestination"
},
{
"@id": "urn:comunica:default:context-preprocess/actors#query-source-identify",
"@type": "ActorContextPreprocessQuerySourceIdentify",
"mediatorQuerySourceIdentify": { "@id": "urn:comunica:default:query-source-identify/mediators#main" },
"mediatorContextPreprocess": { "@id": "urn:comunica:default:context-preprocess/mediators#main" },
"beforeActors": { "@id": "urn:comunica:default:context-preprocess/actors#query-source-skolemize" }
},
{
"@id": "urn:comunica:default:context-preprocess/actors#query-source-skolemize",
"@type": "ActorContextPreprocessQuerySourceSkolemize"
}
]
}
35 changes: 28 additions & 7 deletions engines/query-sparql-incremental/test-browser/QuerySparql-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DevTools } from '@incremunica/dev-tools';
import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store';
import type { Quad } from '@incremunica/incremental-types';
import { DataFactory } from 'rdf-data-factory';
import { QueryEngine } from '../lib/QueryEngine';
import { QueryEngine } from '../lib';
import { usePolly } from '../test/util';

async function partialArrayifyStream(stream: EventEmitter, num: number): Promise<any[]> {
Expand Down Expand Up @@ -57,6 +57,7 @@ describe('System test: QuerySparql (without polly)', () => {
?s ?p ?o.
}`, {
sources: [ streamingStore ],
pollingFrequency: 1000,
});

expect(await partialArrayifyStream(bindingStream, 2)).toBeIsomorphicBindingsArray([
Expand Down Expand Up @@ -104,6 +105,7 @@ describe('System test: QuerySparql (without polly)', () => {
?o1 ?p2 ?o2.
}`, {
sources: [ streamingStore ],
pollingFrequency: 1000,
});

expect(await partialArrayifyStream(bindingStream, 1)).toBeIsomorphicBindingsArray([
Expand Down Expand Up @@ -163,7 +165,10 @@ describe('System test: QuerySparql (with polly)', () => {
it('with results', async() => {
bindingStream = await engine.queryBindings(`SELECT * WHERE {
?s ?p ?o.
}`, { sources: [ 'https://www.rubensworks.net/' ]});
}`, {
sources: [ 'https://www.rubensworks.net/' ],
pollingFrequency: 1000,
});

expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);
});
Expand All @@ -172,7 +177,10 @@ describe('System test: QuerySparql (with polly)', () => {
const query = `SELECT * WHERE {
?s ?p ?o.
}`;
const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]};
const context: QueryStringContext = {
sources: [ 'https://www.rubensworks.net/' ],
pollingFrequency: 1000,
};

bindingStream = await engine.queryBindings(query, context);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);
Expand All @@ -197,7 +205,10 @@ describe('System test: QuerySparql (with polly)', () => {
const query = `SELECT * WHERE {
?s ?p ?o.
}`;
const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]};
const context: QueryStringContext = {
sources: [ 'https://www.rubensworks.net/' ],
pollingFrequency: 1000,
};

bindingStream = await engine.queryBindings(query, context);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);
Expand All @@ -212,7 +223,10 @@ describe('System test: QuerySparql (with polly)', () => {
it('Raw Source', async() => {
bindingStream = await engine.queryBindings(`SELECT * WHERE {
?s ?p ?s.
}`, { sources: [ 'https://www.rubensworks.net/' ]});
}`, {
sources: [ 'https://www.rubensworks.net/' ],
pollingFrequency: 1000,
});

expect(await partialArrayifyStream(bindingStream, 1)).toHaveLength(1);
});
Expand All @@ -223,7 +237,10 @@ describe('System test: QuerySparql (with polly)', () => {
bindingStream = await engine.queryBindings(`SELECT ?name WHERE {
<https://www.rubensworks.net/#me> <http://xmlns.com/foaf/0.1/knows> ?v0.
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
}`, { sources: [ 'https://www.rubensworks.net/' ]});
}`, {
sources: [ 'https://www.rubensworks.net/' ],
pollingFrequency: 1000,
});

expect(await partialArrayifyStream(bindingStream, 20)).toHaveLength(20);
});
Expand All @@ -232,7 +249,10 @@ describe('System test: QuerySparql (with polly)', () => {
bindingStream = await engine.queryBindings(`SELECT ?name WHERE {
<https://www.rubensworks.net/#me> <http://xmlns.com/foaf/0.1/knows> ?v0.
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
}`, { sources: [ 'https://www.rubensworks.net/' ]});
}`, {
sources: [ 'https://www.rubensworks.net/' ],
pollingFrequency: 1000,
});

expect(await partialArrayifyStream(bindingStream, 20)).toHaveLength(20);
});
Expand All @@ -246,6 +266,7 @@ describe('System test: QuerySparql (with polly)', () => {
'https://raw.githubusercontent.com/w3c/data-shapes/gh-pages/shacl-compact-syntax/' +
'tests/valid/basic-shape-iri.shaclc',
],
pollingFrequency: 1000,
});

expect(await partialArrayifyStream(bindingStream, 1)).toHaveLength(1);
Expand Down
Loading

0 comments on commit d657227

Please sign in to comment.