diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStoreRevision.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStoreRevision.java index 55703efd865..05928026933 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStoreRevision.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStoreRevision.java @@ -70,24 +70,28 @@ class Lazy extends Base implements Serializable { private static final long serialVersionUID = -2434063125560285009L; private final ValueStoreRevision revision; + private final long revisionId; + private final ValueStore valueStore; public Lazy(ValueStoreRevision revision) { this.revision = revision; + this.revisionId = revision.getRevisionId(); + this.valueStore = revision.getValueStore(); } @Override public long getRevisionId() { - return revision.getRevisionId(); + return revisionId; } @Override public ValueStore getValueStore() { - return revision.getValueStore(); + return valueStore; } @Override public boolean resolveValue(long id, LmdbValue value) { - if (revision.resolveValue(id, value)) { + if (valueStore.resolveValue(id, value)) { // set unwrapped version of revision value.setInternalID(id, revision); return true; diff --git a/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/QueryBenchmark.java b/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/QueryBenchmark.java index 4636e691b1a..1f9f3311d40 100644 --- a/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/QueryBenchmark.java +++ b/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/QueryBenchmark.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Eclipse RDF4J contributors. + * Copyright (c) 2022 Eclipse RDF4J contributors. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Distribution License v1.0 @@ -15,17 +15,15 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.assertj.core.util.Files; -import org.eclipse.rdf4j.common.iteration.Iterations; import org.eclipse.rdf4j.common.transaction.IsolationLevels; -import org.eclipse.rdf4j.model.Resource; -import org.eclipse.rdf4j.model.Statement; -import org.eclipse.rdf4j.model.vocabulary.RDF; +import org.eclipse.rdf4j.query.BindingSet; +import org.eclipse.rdf4j.query.TupleQueryResult; import org.eclipse.rdf4j.repository.sail.SailRepository; import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection; import org.eclipse.rdf4j.rio.RDFFormat; @@ -48,13 +46,13 @@ import org.openjdk.jmh.runner.options.OptionsBuilder; /** - * Benchmarks query performance with real data. + * @author Håvard Ottestad */ @State(Scope.Benchmark) -@Warmup(iterations = 2) +@Warmup(iterations = 5) @BenchmarkMode({ Mode.AverageTime }) -@Fork(value = 1, jvmArgs = { "-Xms2G", "-Xmx2G", "-Xmn1G", "-XX:+UseSerialGC" }) -//@Fork(value = 1, jvmArgs = {"-Xms8G", "-Xmx8G", "-Xmn4G", "-XX:+UseSerialGC", "-XX:+UnlockCommercialFeatures", "-XX:StartFlightRecording=delay=60s,duration=120s,filename=recording.jfr,settings=profile", "-XX:FlightRecorderOptions=samplethreads=true,stackdepth=1024", "-XX:+UnlockDiagnosticVMOptions", "-XX:+DebugNonSafepoints"}) +@Fork(value = 1, jvmArgs = { "-Xms1G", "-Xmx1G" }) +//@Fork(value = 1, jvmArgs = {"-Xms1G", "-Xmx1G", "-XX:StartFlightRecording=delay=60s,duration=120s,filename=recording.jfr,settings=profile", "-XX:FlightRecorderOptions=samplethreads=true,stackdepth=1024", "-XX:+UnlockDiagnosticVMOptions", "-XX:+DebugNonSafepoints"}) @Measurement(iterations = 5) @OutputTimeUnit(TimeUnit.MILLISECONDS) public class QueryBenchmark { @@ -62,32 +60,59 @@ public class QueryBenchmark { private SailRepository repository; private static final String query1; - private static final String query2; - private static final String query3; private static final String query4; - private static final String query5; private static final String query7_pathexpression1; + private static final String query8_pathexpression2; + + private static final String common_themes; + private static final String different_datasets_with_similar_distributions; + private static final String long_chain; + private static final String lots_of_optional; + private static final String minus; + private static final String nested_optionals; + private static final String particularly_large_join_surface; + private static final String query_distinct_predicates; + private static final String simple_filter_not; + private static final String wild_card_chain_with_common_ends; static { try { + common_themes = IOUtils.toString(getResourceAsStream("benchmarkFiles/common-themes.qr"), + StandardCharsets.UTF_8); + different_datasets_with_similar_distributions = IOUtils.toString( + getResourceAsStream("benchmarkFiles/different-datasets-with-similar-distributions.qr"), + StandardCharsets.UTF_8); + long_chain = IOUtils.toString(getResourceAsStream("benchmarkFiles/long-chain.qr"), StandardCharsets.UTF_8); + lots_of_optional = IOUtils.toString(getResourceAsStream("benchmarkFiles/lots-of-optional.qr"), + StandardCharsets.UTF_8); + minus = IOUtils.toString(getResourceAsStream("benchmarkFiles/minus.qr"), StandardCharsets.UTF_8); + nested_optionals = IOUtils.toString(getResourceAsStream("benchmarkFiles/nested-optionals.qr"), + StandardCharsets.UTF_8); + particularly_large_join_surface = IOUtils.toString( + getResourceAsStream("benchmarkFiles/particularly-large-join-surface.qr"), StandardCharsets.UTF_8); query1 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query1.qr"), StandardCharsets.UTF_8); - query2 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query2.qr"), StandardCharsets.UTF_8); - query3 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query3.qr"), StandardCharsets.UTF_8); query4 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query4.qr"), StandardCharsets.UTF_8); - query5 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query5.qr"), StandardCharsets.UTF_8); query7_pathexpression1 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query7-pathexpression1.qr"), StandardCharsets.UTF_8); + query8_pathexpression2 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query8-pathexpression2.qr"), + StandardCharsets.UTF_8); + query_distinct_predicates = IOUtils.toString( + getResourceAsStream("benchmarkFiles/query-distinct-predicates.qr"), StandardCharsets.UTF_8); + simple_filter_not = IOUtils.toString(getResourceAsStream("benchmarkFiles/simple-filter-not.qr"), + StandardCharsets.UTF_8); + wild_card_chain_with_common_ends = IOUtils.toString( + getResourceAsStream("benchmarkFiles/wild-card-chain-with-common-ends.qr"), StandardCharsets.UTF_8); + } catch (IOException e) { throw new RuntimeException(e); } } - List statementList; private File file; public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() - .include("QueryBenchmark") // adapt to control which benchmark tests to run + .include("QueryBenchmark") // adapt to run other benchmark tests .forks(1) .build(); @@ -96,28 +121,17 @@ public static void main(String[] args) throws RunnerException { @Setup(Level.Trial) public void beforeClass() throws IOException { - file = Files.newTemporaryFolder(); repository = new SailRepository(new LmdbStore(file, ConfigUtil.createConfig())); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(IsolationLevels.NONE); - connection.add(getResourceAsStream("benchmarkFiles/datagovbe-valid.ttl"), "", RDFFormat.TURTLE); + try (InputStream resourceAsStream = getResourceAsStream("benchmarkFiles/datagovbe-valid.ttl")) { + connection.add(resourceAsStream, RDFFormat.TURTLE); + } connection.commit(); } - - try (SailRepositoryConnection connection = repository.getConnection()) { - - statementList = Iterations.asList(connection.getStatements(null, RDF.TYPE, null, false)); - } - - System.gc(); - - } - - private static InputStream getResourceAsStream(String name) { - return QueryBenchmark.class.getClassLoader().getResourceAsStream(name); } @TearDown(Level.Trial) @@ -126,125 +140,148 @@ public void afterClass() throws IOException { FileUtils.deleteDirectory(file); } + private static long count(TupleQueryResult evaluate) { + try (Stream stream = evaluate.stream()) { + return stream.count(); + } + } + @Benchmark public long groupByQuery() { - try (SailRepositoryConnection connection = repository.getConnection()) { - return connection + return count(connection .prepareTupleQuery(query1) - .evaluate() - .stream() - .count(); + .evaluate()); } } @Benchmark public long complexQuery() { - try (SailRepositoryConnection connection = repository.getConnection()) { - return connection + return count(connection .prepareTupleQuery(query4) .evaluate() - .stream() - .count(); + ); } } @Benchmark - public long distinctPredicatesQuery() { + public long pathExpressionQuery1() { try (SailRepositoryConnection connection = repository.getConnection()) { - return connection - .prepareTupleQuery(query5) - .evaluate() - .stream() - .count(); + return count(connection + .prepareTupleQuery(query7_pathexpression1) + .evaluate()); + } } @Benchmark - public long pathExpressionQuery1() { - + public long pathExpressionQuery2() { try (SailRepositoryConnection connection = repository.getConnection()) { - return connection - .prepareTupleQuery(query7_pathexpression1) - .evaluate() - .stream() - .count(); - + return count(connection + .prepareTupleQuery(query8_pathexpression2) + .evaluate()); } } - @Benchmark - public boolean removeByQuery() { +// @Benchmark +// public long common_themes() { +// try (SailRepositoryConnection connection = repository.getConnection()) { +// return connection +// .prepareTupleQuery(common_themes) +// .evaluate() +// .stream() +// .count(); +// } +// } + @Benchmark + public long different_datasets_with_similar_distributions() { try (SailRepositoryConnection connection = repository.getConnection()) { - connection.begin(IsolationLevels.NONE); - connection.remove((Resource) null, RDF.TYPE, null); - connection.commit(); - connection.begin(IsolationLevels.NONE); - connection.add(statementList); - connection.commit(); + return count(connection + .prepareTupleQuery(different_datasets_with_similar_distributions) + .evaluate()); } - return hasStatement(); - } @Benchmark - public boolean removeByQueryReadCommitted() { - + public long long_chain() { try (SailRepositoryConnection connection = repository.getConnection()) { - connection.begin(IsolationLevels.READ_COMMITTED); - connection.remove((Resource) null, RDF.TYPE, null); - connection.commit(); - connection.begin(IsolationLevels.READ_COMMITTED); - connection.add(statementList); - connection.commit(); + return count(connection + .prepareTupleQuery(long_chain) + .evaluate()); } - return hasStatement(); - } @Benchmark - public boolean simpleUpdateQueryIsolationReadCommitted() { - + public long lots_of_optional() { try (SailRepositoryConnection connection = repository.getConnection()) { - connection.begin(IsolationLevels.READ_COMMITTED); - connection.prepareUpdate(query2).execute(); - connection.commit(); + return count(connection + .prepareTupleQuery(lots_of_optional) + .evaluate()); } + } + @Benchmark + public long minus() { try (SailRepositoryConnection connection = repository.getConnection()) { - connection.begin(IsolationLevels.READ_COMMITTED); - connection.prepareUpdate(query3).execute(); - connection.commit(); + return count(connection + .prepareTupleQuery(minus) + .evaluate()); } - return hasStatement(); - } @Benchmark - public boolean simpleUpdateQueryIsolationNone() { - + public long nested_optionals() { try (SailRepositoryConnection connection = repository.getConnection()) { - connection.begin(IsolationLevels.NONE); - connection.prepareUpdate(query2).execute(); - connection.commit(); + return count(connection + .prepareTupleQuery(nested_optionals) + .evaluate()); } + } +// @Benchmark +// public long particularly_large_join_surface() { +// try (SailRepositoryConnection connection = repository.getConnection()) { +// return connection +// .prepareTupleQuery(particularly_large_join_surface) +// .evaluate() +// .stream() +// .count(); +// } +// } + + @Benchmark + public long query_distinct_predicates() { try (SailRepositoryConnection connection = repository.getConnection()) { - connection.begin(IsolationLevels.NONE); - connection.prepareUpdate(query3).execute(); - connection.commit(); + return count(connection + .prepareTupleQuery(query_distinct_predicates) + .evaluate()); } - return hasStatement(); - } - private boolean hasStatement() { + @Benchmark + public long simple_filter_not() { try (SailRepositoryConnection connection = repository.getConnection()) { - return connection.hasStatement(RDF.TYPE, RDF.TYPE, RDF.TYPE, true); + return count(connection + .prepareTupleQuery(simple_filter_not) + .evaluate()); } } +// @Benchmark +// public long wild_card_chain_with_common_ends() { +// try (SailRepositoryConnection connection = repository.getConnection()) { +// return connection +// .prepareTupleQuery(wild_card_chain_with_common_ends) +// .evaluate() +// .stream() +// .count(); +// } +// } + + private static InputStream getResourceAsStream(String filename) { + return QueryBenchmark.class.getClassLoader().getResourceAsStream(filename); + } } diff --git a/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/QueryWriteBenchmark.java b/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/QueryWriteBenchmark.java new file mode 100644 index 00000000000..83ccd8311b4 --- /dev/null +++ b/core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/QueryWriteBenchmark.java @@ -0,0 +1,267 @@ +/******************************************************************************* + * Copyright (c) 2022 Eclipse RDF4J contributors. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Distribution License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + *******************************************************************************/ + +package org.eclipse.rdf4j.sail.lmdb.benchmark; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.assertj.core.util.Files; +import org.eclipse.rdf4j.common.iteration.Iterations; +import org.eclipse.rdf4j.common.transaction.IsolationLevels; +import org.eclipse.rdf4j.model.Model; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.model.vocabulary.RDF; +import org.eclipse.rdf4j.repository.sail.SailRepository; +import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection; +import org.eclipse.rdf4j.rio.RDFFormat; +import org.eclipse.rdf4j.rio.Rio; +import org.eclipse.rdf4j.sail.lmdb.LmdbStore; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.RunnerException; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +/** + * @author Håvard Ottestad + */ +@State(Scope.Benchmark) +@Warmup(iterations = 3) +@BenchmarkMode({ Mode.AverageTime }) +@Fork(value = 1, jvmArgs = { "-Xms1G", "-Xmx1G" }) +//@Fork(value = 1, jvmArgs = {"-Xms1G", "-Xmx1G", "-XX:StartFlightRecording=delay=60s,duration=120s,filename=recording.jfr,settings=profile", "-XX:FlightRecorderOptions=samplethreads=true,stackdepth=1024", "-XX:+UnlockDiagnosticVMOptions", "-XX:+DebugNonSafepoints"}) +@Measurement(iterations = 3) +@OutputTimeUnit(TimeUnit.MILLISECONDS) +public class QueryWriteBenchmark { + + private SailRepository repository; + + private static final String query2; + private static final String query3; + + private static final Model data; + List statementList; + + static { + try { + query2 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query2.qr"), StandardCharsets.UTF_8); + query3 = IOUtils.toString(getResourceAsStream("benchmarkFiles/query3.qr"), StandardCharsets.UTF_8); + + try (InputStream inputStream = getResourceAsStream("benchmarkFiles/datagovbe-valid.ttl")) { + data = Rio.parse(inputStream, RDFFormat.TURTLE); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private File file; + + public static void main(String[] args) throws RunnerException { + Options opt = new OptionsBuilder() + .include("QueryWriteBenchmark") // adapt to run other benchmark tests + .forks(1) + .build(); + + new Runner(opt).run(); + } + + @Setup(Level.Invocation) + public void beforeClass() { + file = Files.newTemporaryFolder(); + + repository = new SailRepository(new LmdbStore(file, ConfigUtil.createConfig())); + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.NONE); + connection.add(data); + connection.commit(); + } + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.NONE); + statementList = Iterations.asList(connection.getStatements(null, RDF.TYPE, null, false)); + connection.commit(); + } + + System.gc(); + + } + + @TearDown(Level.Invocation) + public void afterClass() throws IOException { + repository.shutDown(); + FileUtils.deleteDirectory(file); + + } + + @Benchmark + public boolean simpleUpdateQueryIsolationReadCommitted() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.READ_COMMITTED); + connection.prepareUpdate(query2).execute(); + connection.commit(); + } + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.READ_COMMITTED); + connection.prepareUpdate(query3).execute(); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean simpleUpdateQueryIsolationNone() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.NONE); + connection.prepareUpdate(query2).execute(); + connection.commit(); + } + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.NONE); + connection.prepareUpdate(query3).execute(); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean removeByQuery() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.NONE); + connection.remove((Resource) null, RDF.TYPE, null); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean removeByQueryReadCommitted() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.READ_COMMITTED); + connection.remove((Resource) null, RDF.TYPE, null); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean clear() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.NONE); + connection.clear(); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean clearReadCommitted() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.READ_COMMITTED); + connection.clear(); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean clearContext() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.NONE); + connection.clear(new Resource[] { null }); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean clearContextReadCommitted() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.READ_COMMITTED); + connection.clear(new Resource[] { null }); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean clearByQuery() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.NONE); + connection.remove((Resource) null, null, null); + connection.commit(); + } + return hasStatement(); + + } + + @Benchmark + public boolean clearByQueryReadCommitted() { + + try (SailRepositoryConnection connection = repository.getConnection()) { + connection.begin(IsolationLevels.READ_COMMITTED); + connection.remove((Resource) null, null, null); + connection.commit(); + } + return hasStatement(); + + } + + private boolean hasStatement() { + try (SailRepositoryConnection connection = repository.getConnection()) { + return connection.hasStatement(RDF.TYPE, RDF.TYPE, RDF.TYPE, true); + } + } + + private static InputStream getResourceAsStream(String filename) { + return QueryWriteBenchmark.class.getClassLoader().getResourceAsStream(filename); + } + +} diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/common-themes.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/common-themes.qr new file mode 100644 index 00000000000..026b6bc1e8e --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/common-themes.qr @@ -0,0 +1,22 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT * where { + ?a a dcat:Dataset. + ?b a dcat:Dataset. + + ?a dcat:theme ?theme. + ?b dcat:theme ?theme. + filter(?a != ?b) +} + + diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/different-datasets-with-similar-distributions.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/different-datasets-with-similar-distributions.qr new file mode 100644 index 00000000000..53ddd913bcf --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/different-datasets-with-similar-distributions.qr @@ -0,0 +1,32 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT * where { + ?a dcat:dataset ?dataset. + ?dataset dcat:distribution ?dist. +?dataset dcat:contactPoint ?contact. + + ?contact ?unit. + ?dist dct:format ?format. + ?dist dct:license ?license. + ?dist dct:rights ?rights. + + ?dataset2 dcat:distribution ?dist2. + + ?dist2 dct:format ?format. + ?dist2 dct:license ?license. + ?dist2 dct:rights ?rights. + + filter(?dataset != ?dataset2) + filter(NOT EXISTS {?unit a foaf:Organization}) + +} diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/long-chain.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/long-chain.qr new file mode 100644 index 00000000000..59e4deed7bd --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/long-chain.qr @@ -0,0 +1,19 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT * where { + ?a ?b ?c. + ?c ?d ?e. + ?e ?f ?g. + ?g ?h ?i. + ?i ?j ?k. +} diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/lots-of-optional.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/lots-of-optional.qr new file mode 100644 index 00000000000..387247c7f3d --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/lots-of-optional.qr @@ -0,0 +1,31 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT * where { + + ?a a dcat:Dataset. + + ?a dcat:distribution ?dist. + +OPTIONAL { ?dist dct:format ?format. } +OPTIONAL { ?dist dct:license ?license } +OPTIONAL { ?dist dct:rights ?rights } +OPTIONAL { ?dist dcat:mediaType ?mediaType } +OPTIONAL { ?dist dcat:accessURL ?accessURL } +OPTIONAL { ?dist dcat:downloadURL ?downloadURL } +OPTIONAL { ?dist foaf:page ?page } + + FILTER NOT EXISTS { + ?dist dcat:mediaType "text/csv". + } + +} diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/minus.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/minus.qr new file mode 100644 index 00000000000..617503e9eb3 --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/minus.qr @@ -0,0 +1,21 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT * where { + ?a dcat:dataset ?dataset. + + MINUS{ + ?dataset dcat:distribution ?dist. + ?dataset dcat:contactPoint ?contact. + ?contact ?unit. + } +} diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/nested-optionals.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/nested-optionals.qr new file mode 100644 index 00000000000..a162bfed3ac --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/nested-optionals.qr @@ -0,0 +1,26 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT distinct ?h where { +?a dcat:dataset ?c. + OPTIONAL { + ?c dcat:distribution ?e. + OPTIONAL { + ?e ?f ?g. + OPTIONAL { + ?g a ?h. + } + } + } + FILTER(bound(?h)) +} + diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/particularly-large-join-surface.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/particularly-large-join-surface.qr new file mode 100644 index 00000000000..c33e6ebf989 --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/particularly-large-join-surface.qr @@ -0,0 +1,17 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT distinct ?type where { + ?a (<:> | !<:>) / (<:> | !<:>) / (<:> | !<:>) / a ?type. + ?a (<:> | !<:>) / (<:> | !<:>) / a ?type. + +} diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/query-distinct-predicates.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/query-distinct-predicates.qr new file mode 100644 index 00000000000..81ca9ea8582 --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/query-distinct-predicates.qr @@ -0,0 +1,17 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT distinct ?p where { + ?s ?p ?o. +} + + diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/query5.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/query5.qr index b1941383256..d3db73b9386 100644 --- a/core/sail/lmdb/src/test/resources/benchmarkFiles/query5.qr +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/query5.qr @@ -10,9 +10,7 @@ PREFIX skos: PREFIX foaf: PREFIX dct: -SELECT DISTINCT ?pred WHERE { - ?subj ?pred ?obj. - - +select * where { + ?a ?b ?c } diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/query6.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/query6.qr new file mode 100644 index 00000000000..205554d9bbc --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/query6.qr @@ -0,0 +1,60 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + + + +select * where { + ?a ?b ?c. + ?c ?d ?e. + ?e ?f ?g. + ?g ?h ?k. + ?k ?l ?m. + ?m ?n ?o. + ?o ?p ?q. + ?q ?r ?s. + ?s ?t ?u. + ?u ?v. + ?v ?w ?x. + ?x ?y ?z. + + ?z ?jfefeo ?2a. + + ?2a ?2b ?2c. + ?2c ?2d ?2e. + ?2e ?2f ?2g. + ?2g ?2h ?2k. + ?2k ?2l ?2m. + ?2m ?2n ?2o. + ?2o ?2p ?2q. + ?2q ?2r ?2s. + ?2s ?2t ?2u. + ?2u ?2v. + ?2v ?2w ?2x. + ?2x ?2y ?2z. + + ?2z ?gjreijoir ?3a. + + ?3a ?3b ?3c. + ?3c ?3d ?3e. + ?3e ?3f ?3g. + ?3g ?3h ?3k. + ?3k ?3l ?3m. + ?3m ?3n ?3o. + ?3o ?3p ?3q. + ?3q ?3r ?3s. + ?3s ?3t ?3u. + ?3u ?3v. + ?3v ?3w ?3x. + ?3x ?3y ?3z. + +} + diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/query8-pathexpression2.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/query8-pathexpression2.qr new file mode 100644 index 00000000000..7f450c9447f --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/query8-pathexpression2.qr @@ -0,0 +1,13 @@ +prefix dcat: +prefix dct: +prefix foaf: +prefix rdf: +prefix rdfs: +prefix skos: +prefix vcard: +prefix xsd: + +SELECT * +WHERE { + ?dataset ^dcat:dataset/dcat:themeTaxonomy . + } \ No newline at end of file diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/query9.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/query9.qr new file mode 100644 index 00000000000..50b468ec555 --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/query9.qr @@ -0,0 +1,18 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + + + +select ?c where { + ?a ?b ?c +} order by ?c + diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/simple-filter-not.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/simple-filter-not.qr new file mode 100644 index 00000000000..7cff52c7e74 --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/simple-filter-not.qr @@ -0,0 +1,20 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT * where { + + ?a a dcat:Dataset. + + FILTER(NOT EXISTS {?a dcat:theme ?b.}) +} + + diff --git a/core/sail/lmdb/src/test/resources/benchmarkFiles/wild-card-chain-with-common-ends.qr b/core/sail/lmdb/src/test/resources/benchmarkFiles/wild-card-chain-with-common-ends.qr new file mode 100644 index 00000000000..20992142c23 --- /dev/null +++ b/core/sail/lmdb/src/test/resources/benchmarkFiles/wild-card-chain-with-common-ends.qr @@ -0,0 +1,19 @@ +PREFIX ex: +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX sh: +PREFIX xsd: +PREFIX dcat: +PREFIX dc: +PREFIX skos: +PREFIX foaf: +PREFIX dct: + +SELECT distinct ?type where { + ?a (<:> | !<:>) / (<:> | !<:>) / (<:> | !<:>) / a ?type. + ?b (<:> | !<:>) / (<:> | !<:>) / (<:> | !<:>) / a ?type. + + FILTER(?type in (foaf:Organization ,dct:IMT ,dct:LicenseDocument ,dct:RightsStatement , foaf:Document, foaf:Agent) && ?b != ?a) + +}