Permalink
Browse files

Remove StageExecutor from reasoner factory arguments

PostProcessingStageExecutor is default for test reasoners, LoggingStageExecutor
is default otherwise.
  • Loading branch information...
aifargonos committed Jan 12, 2017
1 parent b346564 commit dee0aa24368cd290e3a7821fdc55cf7b363b23f0
Showing with 115 additions and 232 deletions.
  1. +1 −2 elk-cli/src/main/java/org/semanticweb/elk/cli/Main.java
  2. +2 −5 elk-cli/src/test/java/org/semanticweb/elk/cli/CliReasoningTestDelegate.java
  3. +1 −2 elk-cli/src/test/java/org/semanticweb/elk/cli/util/ComputeExpectedTaxonomies.java
  4. +1 −2 elk-cli/src/test/java/org/semanticweb/elk/cli/util/ComputeTaxonomyHashCodes.java
  5. +2 −8 elk-ore-parent/elk-ore/src/main/java/org/semanticweb/elk/ore/NativeRunner.java
  6. +3 −5 ...wlapi/src/test/java/org/semanticweb/elk/owlapi/OWLAPIRandomWalkIncrementalClassificationTest.java
  7. +4 −15 elk-owlapi/src/test/java/org/semanticweb/elk/owlapi/OWLAPITestUtils.java
  8. +4 −9 elk-owlapi/src/test/java/org/semanticweb/elk/owlapi/OwlApiIncrementalReasoningTestDelegate.java
  9. +1 −3 elk-owlapi/src/test/java/org/semanticweb/elk/owlapi/OwlApiReasoningTestDelegate.java
  10. +1 −3 elk-proofs/src/test/java/org/semanticweb/elk/owl/inferences/ProofTest.java
  11. +5 −10 elk-reasoner/src/main/java/org/semanticweb/elk/reasoner/ReasonerFactory.java
  12. +6 −12 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/ComplexClassQueryTest.java
  13. +1 −2 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/ReasonerFactoryTest.java
  14. +30 −52 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/TestReasonerUtils.java
  15. +1 −2 .../test/java/org/semanticweb/elk/reasoner/incremental/BaseRandomWalkIncrementalCorrectnessTest.java
  16. +4 −10 ...r/src/test/java/org/semanticweb/elk/reasoner/incremental/CliIncrementalReasoningTestDelegate.java
  17. +2 −6 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/incremental/IncrementalModeSwitchTest.java
  18. +4 −9 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/incremental/LowLevelIncrementalABoxTest.java
  19. +20 −40 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/incremental/LowLevelIncrementalTBoxTest.java
  20. +1 −3 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/incremental/RandomWalkRunnerIO.java
  21. +1 −2 ...reasoner/src/test/java/org/semanticweb/elk/reasoner/incremental/TaxonomyCleaningDeadlockTest.java
  22. +8 −10 ...asoner/src/test/java/org/semanticweb/elk/reasoner/taxonomy/ClassTaxonomyMemberComparisonTest.java
  23. +8 −10 ...ner/src/test/java/org/semanticweb/elk/reasoner/taxonomy/InstanceTaxonomyMemberComparisonTest.java
  24. +1 −2 ...c/test/java/org/semanticweb/elk/reasoner/taxonomy/ObjectPropertyTaxonomyMemberComparisonTest.java
  25. +2 −5 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/taxonomy/TaxonomyIOTest.java
  26. +1 −3 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/tracing/TracingTest.java
@@ -44,7 +44,6 @@
import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.ReasonerFactory;
import org.semanticweb.elk.reasoner.config.ReasonerConfiguration;
import org.semanticweb.elk.reasoner.stages.LoggingStageExecutor;
import org.semanticweb.elk.reasoner.taxonomy.TaxonomyPrinter;
import org.semanticweb.elk.reasoner.taxonomy.hashing.InstanceTaxonomyHasher;
import org.semanticweb.elk.reasoner.taxonomy.hashing.TaxonomyHasher;
@@ -177,7 +176,7 @@ public static void main(String[] args) throws Exception {
AxiomLoader.Factory loader = new Owl2StreamLoader.Factory(parserFactory,
options.valueOf(inputFile));
Reasoner reasoner = reasoningFactory.createReasoner(loader,
new LoggingStageExecutor(), configuration);
configuration);
try {
if (options.has(satisfiable)) {
@@ -32,7 +32,6 @@
import org.semanticweb.elk.reasoner.ReasoningTestWithOutputAndInterruptsDelegate;
import org.semanticweb.elk.reasoner.TestReasonerUtils;
import org.semanticweb.elk.reasoner.stages.ElkInterruptedException;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.elk.testing.TestManifest;
import org.semanticweb.elk.testing.TestOutput;
import org.semanticweb.elk.testing.UrlTestInput;
@@ -62,17 +61,15 @@ public Reasoner getReasoner() {
@Override
public void initWithOutput() throws Exception {
reasoner_ = TestReasonerUtils.createTestReasoner(
manifest_.getInput().getUrl().openStream(),
new SimpleStageExecutor());
manifest_.getInput().getUrl().openStream());
}
@Override
public void initWithInterrupts() throws Exception {
final Random random = new Random(RandomSeedProvider.VALUE);
reasoner_ = TestReasonerUtils.createTestReasoner(
manifest_.getInput().getUrl().openStream(),
new RandomReasonerInterrupter(random, INTERRUPTION_CHANCE),
new SimpleStageExecutor());
new RandomReasonerInterrupter(random, INTERRUPTION_CHANCE));
}
@Override
@@ -41,7 +41,6 @@
import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.ReasonerFactory;
import org.semanticweb.elk.reasoner.TestReasonerUtils;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.elk.reasoner.taxonomy.TaxonomyPrinter;
import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy;
import org.semanticweb.elk.reasoner.taxonomy.model.Taxonomy;
@@ -121,7 +120,7 @@ static void generateExpectedTaxonomy(String path, GetTaxonomy<ElkClass> gt)
// use just one worker to minimize the risk of errors
Reasoner reasoner = TestReasonerUtils.createTestReasoner(
new FileInputStream(ontFile), new SimpleStageExecutor(), 1);
new FileInputStream(ontFile), 1);
Taxonomy<ElkClass> taxonomy = gt.getTaxonomy(reasoner);
// create the expected result file
@@ -39,7 +39,6 @@
import org.semanticweb.elk.reasoner.ElkInconsistentOntologyException;
import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.TestReasonerUtils;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.elk.reasoner.taxonomy.hashing.InstanceTaxonomyHasher;
import org.semanticweb.elk.reasoner.taxonomy.hashing.TaxonomyHasher;
import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy;
@@ -122,7 +121,7 @@ static void generateHashCodes(String path, TestHasher hasher)
// use just one worker to minimize the risk of errors
Reasoner reasoner = TestReasonerUtils.createTestReasoner(
new FileInputStream(ontFile), new SimpleStageExecutor(), 1);
new FileInputStream(ontFile), 1);
int hash = hasher.hash(reasoner);
// create the expected result file
@@ -1,8 +1,3 @@
/**
*
*/
package org.semanticweb.elk.ore;
/*
* #%L
* ELK Command Line Interface
@@ -24,6 +19,7 @@
* limitations under the License.
* #L%
*/
package org.semanticweb.elk.ore;
import java.io.BufferedWriter;
import java.io.File;
@@ -40,7 +36,6 @@
import org.semanticweb.elk.reasoner.ElkInconsistentOntologyException;
import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.ReasonerFactory;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy;
import org.semanticweb.elk.reasoner.taxonomy.model.Taxonomy;
@@ -109,8 +104,7 @@ void run(String[] args, Task task) throws Exception {
Owl2ParserFactory parserFactory = new Owl2FunctionalStyleParserFactory();
AxiomLoader.Factory loaderFactory = new Owl2StreamLoader.Factory(
parserFactory, input);
Reasoner reasoner = reasoningFactory.createReasoner(loaderFactory,
new SimpleStageExecutor());
Reasoner reasoner = reasoningFactory.createReasoner(loaderFactory);
boolean printedStarted = false, printedTime = false;
@@ -50,8 +50,6 @@
import org.semanticweb.elk.reasoner.incremental.OnOffVector;
import org.semanticweb.elk.reasoner.incremental.RandomWalkIncrementalClassificationRunner;
import org.semanticweb.elk.reasoner.incremental.RandomWalkRunnerIO;
import org.semanticweb.elk.reasoner.stages.PostProcessingStageExecutor;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.elk.testing.ConfigurationUtils;
import org.semanticweb.elk.testing.ConfigurationUtils.TestManifestCreator;
import org.semanticweb.elk.testing.PolySuite;
@@ -143,8 +141,8 @@ public void randomWalk() throws Exception {
throw new Owl2ParseException(e);
}
incrementalReasoner = OWLAPITestUtils.createReasoner(ontology, true,
new PostProcessingStageExecutor());
incrementalReasoner = OWLAPITestUtils.createReasoner(ontology,
true);
// let the runner run..
RandomWalkRunnerIO<OWLAxiom> io = new OWLAPIBasedIO(ontology, incrementalReasoner);
@@ -207,7 +205,7 @@ public Reasoner createReasoner(Iterable<OWLAxiom> axioms) {
return OWLAPITestUtils.createReasoner(
TestOWLManager.createOWLOntologyManager()
.copyOntology(ontology_, OntologyCopy.SHALLOW),
false, new SimpleStageExecutor()).getInternalReasoner();
false).getInternalReasoner();
} catch (OWLOntologyCreationIOException e) {
throw new RuntimeException(e);
} catch (OWLOntologyCreationException e) {
@@ -29,8 +29,6 @@
import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.ReasonerInterrupter;
import org.semanticweb.elk.reasoner.TestReasonerUtils;
import org.semanticweb.elk.reasoner.stages.ReasonerStageExecutor;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.owlapi.model.OWLOntology;
/**
@@ -53,11 +51,10 @@ static ElkReasoner createReasoner(final OWLOntology ontology,
public static ElkReasoner createReasoner(final OWLOntology ontology,
final boolean isBufferingMode,
final ReasonerInterrupter interrupter,
final ReasonerStageExecutor stageExecutor) {
final ReasonerInterrupter interrupter) {
final ElkReasonerConfiguration elkConfig = new ElkReasonerConfiguration();
final Reasoner internalReasoner = TestReasonerUtils.createTestReasoner(
interrupter, stageExecutor, elkConfig.getElkConfiguration());
interrupter, elkConfig.getElkConfiguration());
return createReasoner(ontology, isBufferingMode, elkConfig,
internalReasoner);
}
@@ -67,20 +64,12 @@ public static ElkReasoner createReasoner(final OWLOntology ontology,
*
* @param ontology
* @param isBufferingMode
* @param stageExecutor
* @return
*/
public static ElkReasoner createReasoner(final OWLOntology ontology,
final boolean isBufferingMode,
final ReasonerStageExecutor stageExecutor) {
return createReasoner(ontology, isBufferingMode,
FailingReasonerInterrupter.INSTANCE, stageExecutor);
}
public static ElkReasoner createReasoner(final OWLOntology ontology,
final boolean isBufferingMode) {
return createReasoner(ontology, isBufferingMode,
new SimpleStageExecutor());
FailingReasonerInterrupter.INSTANCE);
}
/**
@@ -91,7 +80,7 @@ public static ElkReasoner createReasoner(final OWLOntology ontology,
*/
public static ElkReasoner createReasoner(final OWLOntology ontology) {
return createReasoner(ontology, false,
FailingReasonerInterrupter.INSTANCE, new SimpleStageExecutor());
FailingReasonerInterrupter.INSTANCE);
}
public static ElkProver createProver(ElkReasoner reasoner) {
@@ -33,8 +33,6 @@
import org.semanticweb.elk.reasoner.RandomReasonerInterrupter;
import org.semanticweb.elk.reasoner.incremental.IncrementalChangeType;
import org.semanticweb.elk.reasoner.incremental.IncrementalReasoningTestWithInterruptsDelegate;
import org.semanticweb.elk.reasoner.stages.PostProcessingStageExecutor;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.elk.testing.TestManifest;
import org.semanticweb.elk.testing.TestOutput;
import org.semanticweb.elk.testing.UrlTestInput;
@@ -113,11 +111,10 @@ public void initIncremental() throws Exception {
// important to use the buffering mode here
// otherwise we'd need to issue a query to the ElkReasoner
// before we could use the internal reasoner directly in the tests
standardReasoner_ = OWLAPITestUtils.createReasoner(testOntology_, true,
new PostProcessingStageExecutor());
standardReasoner_ = OWLAPITestUtils.createReasoner(testOntology_, true);
standardReasoner_.getInternalReasoner().setAllowIncrementalMode(false);
incrementalReasoner_ = OWLAPITestUtils.createReasoner(testOntology_,
true, new PostProcessingStageExecutor());
true);
incrementalReasoner_.getInternalReasoner()
.setAllowIncrementalMode(true);
@@ -132,14 +129,12 @@ public void initWithInterrupts() throws Exception {
* directly in the tests
*
*/
standardReasoner_ = OWLAPITestUtils.createReasoner(testOntology_, true,
new PostProcessingStageExecutor());
standardReasoner_ = OWLAPITestUtils.createReasoner(testOntology_, true);
standardReasoner_.getInternalReasoner().setAllowIncrementalMode(false);
final Random random = new Random(RandomSeedProvider.VALUE);
incrementalReasoner_ = OWLAPITestUtils.createReasoner(testOntology_,
false,
new RandomReasonerInterrupter(random, interruptionChance_),
new SimpleStageExecutor());
new RandomReasonerInterrupter(random, interruptionChance_));
incrementalReasoner_.getInternalReasoner()
.setAllowIncrementalMode(true);
@@ -27,7 +27,6 @@
import org.semanticweb.elk.RandomSeedProvider;
import org.semanticweb.elk.reasoner.RandomReasonerInterrupter;
import org.semanticweb.elk.reasoner.ReasoningTestWithOutputAndInterruptsDelegate;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.elk.testing.TestManifest;
import org.semanticweb.elk.testing.TestOutput;
import org.semanticweb.elk.testing.UrlTestInput;
@@ -82,8 +81,7 @@ public void initWithInterrupts() throws Exception {
final Random random = new Random(RandomSeedProvider.VALUE);
reasoner_ = OWLAPITestUtils.createReasoner(ontology, false,
new RandomReasonerInterrupter(random, interruptionChance_),
new SimpleStageExecutor());
new RandomReasonerInterrupter(random, interruptionChance_));
}
@Override
@@ -43,7 +43,6 @@
import org.semanticweb.elk.owl.parsing.Owl2ParseException;
import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.TestReasonerUtils;
import org.semanticweb.elk.reasoner.stages.PostProcessingStageExecutor;
import org.semanticweb.elk.reasoner.tracing.ComprehensiveSubsumptionTracingTests;
import org.semanticweb.elk.reasoner.tracing.TracingTestManifest;
import org.semanticweb.elk.reasoner.tracing.TracingTestVisitor;
@@ -99,8 +98,7 @@ public void provabilityTest() throws Exception {
.loadAxioms(manifest.getInput().getUrl().openStream());
final TestLoader loader = new TestLoader(ontology);
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader,
new PostProcessingStageExecutor());
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader);
try {
// reasoner.getTaxonomy();
@@ -29,8 +29,8 @@
import org.semanticweb.elk.owl.interfaces.ElkObject;
import org.semanticweb.elk.owl.managers.ElkObjectEntityRecyclingFactory;
import org.semanticweb.elk.reasoner.config.ReasonerConfiguration;
import org.semanticweb.elk.reasoner.stages.LoggingStageExecutor;
import org.semanticweb.elk.reasoner.stages.ReasonerStageExecutor;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,24 +49,19 @@
final static Logger LOGGER_ = LoggerFactory
.getLogger(ReasonerFactory.class);
final static ReasonerStageExecutor DEFAULT_STAGE_EXECUTOR = new SimpleStageExecutor();
final static ReasonerStageExecutor DEFAULT_STAGE_EXECUTOR = new LoggingStageExecutor();
final static ReasonerInterrupter DEFAULT_INTERRUPTER = new ReasonerInterrupter();
public Reasoner createReasoner(AxiomLoader.Factory axiomLoaderFactory) {
return createReasoner(axiomLoaderFactory, DEFAULT_STAGE_EXECUTOR);
}
public Reasoner createReasoner(AxiomLoader.Factory axiomLoaderFactory,
ReasonerStageExecutor stageExecutor) {
return createReasoner(axiomLoaderFactory, stageExecutor,
return createReasoner(axiomLoaderFactory,
ReasonerConfiguration.getConfiguration());
}
public Reasoner createReasoner(AxiomLoader.Factory axiomLoaderFactory,
ReasonerStageExecutor stageExecutor, ReasonerConfiguration config) {
ReasonerConfiguration config) {
return createReasoner(axiomLoaderFactory, DEFAULT_INTERRUPTER,
stageExecutor, config);
DEFAULT_STAGE_EXECUTOR, config);
}
Reasoner createReasoner(AxiomLoader.Factory axiomLoaderFactory,
@@ -37,7 +37,6 @@
import org.semanticweb.elk.owl.interfaces.ElkObjectProperty;
import org.semanticweb.elk.owl.iris.ElkFullIri;
import org.semanticweb.elk.owl.managers.ElkObjectEntityRecyclingFactory;
import org.semanticweb.elk.reasoner.stages.SimpleStageExecutor;
import org.semanticweb.elk.reasoner.taxonomy.model.Node;
public class ComplexClassQueryTest {
@@ -47,8 +46,7 @@
@Test
public void testSimpleSubsumption() throws ElkException {
TestLoader loader = new TestLoader();
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader,
new SimpleStageExecutor());
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader);
ElkClass A = objectFactory.getClass(new ElkFullIri(":A"));
ElkClass B = objectFactory.getClass(new ElkFullIri(":B"));
@@ -64,8 +62,7 @@ public void testSimpleSubsumption() throws ElkException {
@Test
public void testSatisfiabilityExistential() throws ElkException {
TestLoader loader = new TestLoader();
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader,
new SimpleStageExecutor());
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader);
ElkClass A = objectFactory.getClass(new ElkFullIri(":A"));
ElkClass B = objectFactory.getClass(new ElkFullIri(":B"));
@@ -82,8 +79,7 @@ public void testSatisfiabilityExistential() throws ElkException {
@Test
public void testSatisfiabilityExistentialSubsumption() throws ElkException {
TestLoader loader = new TestLoader();
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader,
new SimpleStageExecutor());
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader);
ElkClass A = objectFactory.getClass(new ElkFullIri(":A"));
ElkClass B = objectFactory.getClass(new ElkFullIri(":B"));
@@ -105,8 +101,7 @@ public void testSatisfiabilityExistentialSubsumption() throws ElkException {
@Test
public void testSupSubClassConjunction() throws ElkException {
TestLoader loader = new TestLoader();
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader,
new SimpleStageExecutor());
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader);
ElkClass A = objectFactory.getClass(new ElkFullIri(":A"));
ElkClass B = objectFactory.getClass(new ElkFullIri(":B"));
@@ -133,7 +128,7 @@ public void testSupSubClassConjunction() throws ElkException {
@Test
public void testEquivalentClasses() throws ElkException {
Reasoner reasoner = TestReasonerUtils.createTestReasoner(
new EmptyAxiomLoader(), new SimpleStageExecutor());
new EmptyAxiomLoader());
// empty ontology, query for conjunction
ElkClass A = objectFactory.getClass(new ElkFullIri(":A"));
@@ -156,8 +151,7 @@ public void testEquivalentClasses() throws ElkException {
@Test
public void testPartiallySupportedExpression() throws ElkException {
TestLoader loader = new TestLoader();
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader,
new SimpleStageExecutor());
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader);
final ElkClass A = objectFactory.getClass(new ElkFullIri(":A"));
final ElkClass B = objectFactory.getClass(new ElkFullIri(":B"));
@@ -49,8 +49,7 @@
@Test
public void createReasonerDefaultConfig() {
Reasoner reasoner = new ReasonerFactory().createReasoner(
new TestAxiomLoaderFactory(new EmptyAxiomLoader()),
new SimpleStageExecutor());
new TestAxiomLoaderFactory(new EmptyAxiomLoader()));
assertEquals(Runtime.getRuntime().availableProcessors(),
reasoner.getNumberOfWorkers());
Oops, something went wrong.

0 comments on commit dee0aa2

Please sign in to comment.