-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#164 isolated param from create method by introducing a setter. Added…
… abstract base impl. Added tests. This removed the need for overrides of getEvaluationStrategy in NativeStoreConnection and MemoryStoreConnection. Signed-off-by: Jeen Broekstra <[email protected]>
- Loading branch information
1 parent
53d31a4
commit 10f1278
Showing
11 changed files
with
228 additions
and
62 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
.../src/test/java/org/eclipse/rdf4j/repository/sail/memory/MemoryEvaluationStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) 2016 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. | ||
*/ | ||
package org.eclipse.rdf4j.repository.sail.memory; | ||
|
||
import org.eclipse.rdf4j.repository.EvaluationStrategyTest; | ||
import org.eclipse.rdf4j.sail.base.config.BaseSailConfig; | ||
import org.eclipse.rdf4j.sail.memory.config.MemoryStoreConfig; | ||
|
||
|
||
/** | ||
* @author jeen | ||
* | ||
*/ | ||
public class MemoryEvaluationStrategyTest extends EvaluationStrategyTest { | ||
|
||
@Override | ||
protected BaseSailConfig getBaseSailConfig() { | ||
return new MemoryStoreConfig(false); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...c/test/java/org/eclipse/rdf4j/repository/sail/nativerdf/NativeEvaluationStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) 2016 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. | ||
*/ | ||
package org.eclipse.rdf4j.repository.sail.nativerdf; | ||
|
||
import org.eclipse.rdf4j.repository.EvaluationStrategyTest; | ||
import org.eclipse.rdf4j.sail.base.config.BaseSailConfig; | ||
import org.eclipse.rdf4j.sail.nativerdf.config.NativeStoreConfig; | ||
|
||
|
||
/** | ||
* @author jeen | ||
* | ||
*/ | ||
public class NativeEvaluationStrategyTest extends EvaluationStrategyTest { | ||
|
||
@Override | ||
protected BaseSailConfig getBaseSailConfig() { | ||
return new NativeStoreConfig(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...va/org/eclipse/rdf4j/query/algebra/evaluation/impl/AbstractEvaluationStrategyFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2016 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. | ||
*/ | ||
package org.eclipse.rdf4j.query.algebra.evaluation.impl; | ||
|
||
import org.eclipse.rdf4j.query.algebra.evaluation.EvaluationStrategyFactory; | ||
|
||
/** | ||
* Abstract base class for {@link ExtendedEvaluationStrategy}. | ||
* | ||
* @author Jeen Broekstra | ||
*/ | ||
public abstract class AbstractEvaluationStrategyFactory implements EvaluationStrategyFactory { | ||
|
||
private long querySolutionCacheThreshold; | ||
|
||
@Override | ||
public void setQuerySolutionCacheThreshold(long threshold) { | ||
this.querySolutionCacheThreshold = threshold; | ||
} | ||
|
||
@Override | ||
public long getQuerySolutionCacheThreshold() { | ||
return querySolutionCacheThreshold; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
testsuites/store/src/main/java/org/eclipse/rdf4j/repository/EvaluationStrategyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/** | ||
* Copyright (c) 2016 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. | ||
*/ | ||
package org.eclipse.rdf4j.repository; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.eclipse.rdf4j.model.IRI; | ||
import org.eclipse.rdf4j.model.Literal; | ||
import org.eclipse.rdf4j.model.ValueFactory; | ||
import org.eclipse.rdf4j.model.vocabulary.RDFS; | ||
import org.eclipse.rdf4j.model.vocabulary.XMLSchema; | ||
import org.eclipse.rdf4j.query.BindingSet; | ||
import org.eclipse.rdf4j.query.QueryResults; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.impl.ExtendedEvaluationStrategy; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.impl.ExtendedEvaluationStrategyFactory; | ||
import org.eclipse.rdf4j.query.algebra.evaluation.impl.StrictEvaluationStrategyFactory; | ||
import org.eclipse.rdf4j.repository.config.RepositoryConfig; | ||
import org.eclipse.rdf4j.repository.config.RepositoryImplConfig; | ||
import org.eclipse.rdf4j.repository.manager.RepositoryManager; | ||
import org.eclipse.rdf4j.repository.manager.RepositoryProvider; | ||
import org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig; | ||
import org.eclipse.rdf4j.sail.base.config.BaseSailConfig; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test cases for behavior of {@link StrictEvaluationStrategy} and {@link ExtendedEvaluationStrategy} on base | ||
* Sail implementations. | ||
* | ||
* @author Jeen Broekstra | ||
*/ | ||
public abstract class EvaluationStrategyTest { | ||
|
||
private Repository strictRepo; | ||
|
||
private Repository extendedRepo; | ||
|
||
private RepositoryManager manager; | ||
|
||
/** | ||
* @throws java.lang.Exception | ||
*/ | ||
@Before | ||
public void setUp() | ||
throws Exception | ||
{ | ||
manager = RepositoryProvider.getRepositoryManager(FileUtils.getTempDirectory()); | ||
|
||
BaseSailConfig strictStoreConfig = getBaseSailConfig(); | ||
strictStoreConfig.setEvaluationStrategyFactoryClassName( | ||
StrictEvaluationStrategyFactory.class.getName()); | ||
|
||
strictRepo = createRepo(strictStoreConfig, "test-strict"); | ||
|
||
BaseSailConfig extendedStoreConfig = getBaseSailConfig(); | ||
extendedStoreConfig.setEvaluationStrategyFactoryClassName( | ||
ExtendedEvaluationStrategyFactory.class.getName()); | ||
|
||
extendedRepo = createRepo(extendedStoreConfig, "test-extended"); | ||
} | ||
|
||
private Repository createRepo(BaseSailConfig config, String id) { | ||
RepositoryImplConfig ric = new SailRepositoryConfig(config); | ||
manager.addRepositoryConfig(new RepositoryConfig(id, ric)); | ||
|
||
return manager.getRepository(id); | ||
} | ||
|
||
@Test | ||
public void testDatetimeSubtypesStrict() { | ||
ValueFactory vf = strictRepo.getValueFactory(); | ||
|
||
try (RepositoryConnection conn = strictRepo.getConnection()) { | ||
Literal l1 = vf.createLiteral("2009", XMLSchema.GYEAR); | ||
Literal l2 = vf.createLiteral("2009-01", XMLSchema.GYEARMONTH); | ||
IRI s1 = vf.createIRI("urn:s1"); | ||
IRI s2 = vf.createIRI("urn:s2"); | ||
conn.add(s1, RDFS.LABEL, l1); | ||
conn.add(s2, RDFS.LABEL, l2); | ||
|
||
String query = "SELECT * WHERE { ?s rdfs:label ?l . FILTER(?l >= \"2008\"^^xsd:gYear) }"; | ||
|
||
List<BindingSet> result = QueryResults.asList(conn.prepareTupleQuery(query).evaluate()); | ||
assertEquals(1, result.size()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDatetimeSubtypesExtended() { | ||
ValueFactory vf = extendedRepo.getValueFactory(); | ||
|
||
try (RepositoryConnection conn = extendedRepo.getConnection()) { | ||
Literal l1 = vf.createLiteral("2009", XMLSchema.GYEAR); | ||
Literal l2 = vf.createLiteral("2009-01", XMLSchema.GYEARMONTH); | ||
IRI s1 = vf.createIRI("urn:s1"); | ||
IRI s2 = vf.createIRI("urn:s2"); | ||
conn.add(s1, RDFS.LABEL, l1); | ||
conn.add(s2, RDFS.LABEL, l2); | ||
|
||
String query = "SELECT * WHERE { ?s rdfs:label ?l . FILTER(?l >= \"2008\"^^xsd:gYear) }"; | ||
|
||
List<BindingSet> result = QueryResults.asList(conn.prepareTupleQuery(query).evaluate()); | ||
assertEquals(2, result.size()); | ||
} | ||
} | ||
|
||
/** | ||
* Gets a configuration object for the base Sail that should be tested. | ||
* | ||
* @return a {@link BaseSailConfig}. | ||
*/ | ||
protected abstract BaseSailConfig getBaseSailConfig(); | ||
} |