Commit 32f2d38a authored by Christian Willms's avatar Christian Willms
Browse files

Fix for println() bug

removed system.out.println statements from tests; verbose flag in tuplestore & forwardchainer is set to false
parent 34a43248
......@@ -196,6 +196,23 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* generates a new forward chainer with the default namespace for XSD, RDF, RDFS, and OWL
* @throws IOException
* @throws FileNotFoundException
* @throws WrongFormatException
*/
public ForwardChainer(boolean verbose, String tupleFile, String ruleFile)
throws FileNotFoundException, IOException, WrongFormatException {
this();
this.verbose = verbose;
Namespace namespace = new Namespace();
this.tupleStore = new TupleStore(verbose, this.noOfAtoms, this.noOfTuples, namespace, tupleFile);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* this version allows to explicitly define the namespace
* @throws IOException
......@@ -212,6 +229,23 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* this version allows to explicitly define the namespace
* @throws IOException
* @throws WrongFormatException
* @throws FileNotFoundException
*/
public ForwardChainer(boolean verbose, String tupleFile, String ruleFile, String namespaceFile)
throws FileNotFoundException, WrongFormatException, IOException {
this();
this.verbose = verbose;
Namespace namespace = new Namespace(namespaceFile);
this.tupleStore = new TupleStore(false, this.noOfAtoms, this.noOfTuples, namespace, tupleFile);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* this version allows to explicitly define the namespace
* @throws IOException
......@@ -250,6 +284,28 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* generates a new forward chainer with the default namespace for XSD, RDF, RDFS, and OWL;
* noOfAtoms and noOfTuples are important parameters that affects the performance of the
* tuple store used by the forward chainer
* @throws IOException
* @throws FileNotFoundException
* @throws WrongFormatException
*/
public ForwardChainer(boolean verbose, int noOfAtoms, int noOfTuples, String tupleFile, String ruleFile)
throws FileNotFoundException, IOException, WrongFormatException {
this();
this.verbose = verbose;
this.noOfAtoms = noOfAtoms;
this.noOfTuples = noOfTuples;
//this.namespace = new Namespace();
this.tupleStore = new TupleStore(verbose, this.noOfAtoms, this.noOfTuples);
this.tupleStore.readTuples(tupleFile);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* this version allows to explicitly define the namespace
* @throws IOException
......@@ -268,6 +324,25 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* this version allows to explicitly define the namespace
* @throws IOException
* @throws WrongFormatException
* @throws FileNotFoundException
*/
public ForwardChainer(boolean verbose, int noOfAtoms, int noOfTuples, String tupleFile, String ruleFile, String namespaceFile)
throws FileNotFoundException, WrongFormatException, IOException {
this();
this.verbose = verbose;
this.noOfAtoms = noOfAtoms;
this.noOfTuples = noOfTuples;
Namespace namespace = new Namespace(namespaceFile);
this.tupleStore = new TupleStore(verbose, this.noOfAtoms, this.noOfTuples, namespace, tupleFile);
this.ruleStore = new RuleStore(this.tupleStore, ruleFile);
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* assumes a default of 100,000 atoms and 500,000 tuples
......@@ -280,6 +355,18 @@ public final class ForwardChainer {
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* assumes a default of 100,000 atoms and 500,000 tuples
*/
public ForwardChainer(boolean verbose, TupleStore tupleStore, RuleStore ruleStore) {
this();
this.verbose = verbose;
this.tupleStore = tupleStore;
this.ruleStore = ruleStore;
this.threadPool = Executors.newFixedThreadPool(this.noOfCores);
this.noOfTasks = this.ruleStore.allRules.size();
}
/**
* more options that will also affect namespace, tuple store, and rule store
* @throws IOException
......
......@@ -428,6 +428,22 @@ public final class TupleStore {
noOfAtoms, noOfTuples);
}
/**
* choose a proper noOfAtoms/noOfTuples in order not to arrive at copying (at all or
* too early) the elements into a larger structure; keep in mind that other services
* (e.g., rule application) can drastically increase the number of tuples;
* note: assigns an empty Namespace object to this.namespace
*/
public TupleStore(boolean verbose, int noOfAtoms, int noOfTuples) {
this.namespace = new Namespace();
this.indexStore = null;
this.verbose = verbose;
init(this.verbose, this.rdfCheck, this.equivalenceClassReduction,
this.minNoOfArgs, this.maxNoOfArgs,
this.subjectPosition, this.predicatePosition, this.objectPosition,
noOfAtoms, noOfTuples);
}
/**
* extends the binary constructor with the ability to read in a namespace
*/
......@@ -460,6 +476,25 @@ public final class TupleStore {
readTuples(tupleFile);
}
/**
* extends the binary constructor with the ability to read in a namespace and a
* textual representation of facts (basically N-Triples syntax), stored in a file
* @throws IOException
* @throws WrongFormatException
* @see #readTuples
*/
public TupleStore(boolean verbose, int noOfAtoms, int noOfTuples, Namespace namespace, String tupleFile)
throws IOException, WrongFormatException {
this.verbose = verbose;
this.namespace = namespace;
this.indexStore = null;
init(this.verbose, this.rdfCheck, this.equivalenceClassReduction,
this.minNoOfArgs, this.maxNoOfArgs,
this.subjectPosition, this.predicatePosition, this.objectPosition,
noOfAtoms, noOfTuples);
readTuples(tupleFile);
}
/**
* extends the binary constructor with the ability to read in a namespace, a index store, as well as a
......@@ -540,6 +575,19 @@ public final class TupleStore {
100000, 500000);
}
/**
* assumes a default of 100,000 atoms and 500,000 tuples
*/
public TupleStore(boolean verbose, Namespace namespace) {
this.verbose = false;
this.namespace = namespace;
this.indexStore = null;
init(this.verbose, this.rdfCheck, this.equivalenceClassReduction,
this.minNoOfArgs, this.maxNoOfArgs,
this.subjectPosition, this.predicatePosition, this.objectPosition,
100000, 500000);
}
/**
* assumes a default of 100,000 atoms and 500,000 tuples
* @throws IOException
......@@ -552,6 +600,18 @@ public final class TupleStore {
readTuples(tupleFile);
}
/**
* assumes a default of 100,000 atoms and 500,000 tuples
* @throws IOException
* @throws FileNotFoundException
* @throws WrongFormatException
*/
public TupleStore(boolean verbose, Namespace namespace, String tupleFile)
throws FileNotFoundException, IOException, WrongFormatException {
this(verbose,namespace);
readTuples(tupleFile);
}
/**
* a simple STATIC method, translating an int array into something readable (N-tuple syntax)
*/
......
......@@ -30,7 +30,7 @@ public class ForwardChainerTest {
//test constructor ForwardChainer(String tupleFile, String ruleFile)
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
ForwardChainer fc = new ForwardChainer(tupleFile, ruleFile);
ForwardChainer fc = new ForwardChainer(false, tupleFile, ruleFile);
assertNotNull(fc);
}
......@@ -40,7 +40,7 @@ public class ForwardChainerTest {
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
String namespaceFile = getTestResource("default.ns");
ForwardChainer fc = new ForwardChainer(tupleFile, ruleFile, namespaceFile);
ForwardChainer fc = new ForwardChainer(false,tupleFile, ruleFile, namespaceFile);
assertNotNull(fc);
}
......@@ -51,7 +51,7 @@ public class ForwardChainerTest {
int noOfTuples = 2;
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
ForwardChainer fc = new ForwardChainer(noOfAtoms, noOfTuples, tupleFile, ruleFile);
ForwardChainer fc = new ForwardChainer( false,noOfAtoms, noOfTuples, tupleFile, ruleFile);
assertNotNull(fc);
}
......@@ -63,7 +63,7 @@ public class ForwardChainerTest {
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
String namespaceFile = getTestResource("default.ns");
ForwardChainer fc = new ForwardChainer(noOfAtoms, noOfTuples, tupleFile, ruleFile, namespaceFile);
ForwardChainer fc = new ForwardChainer(false, noOfAtoms, noOfTuples, tupleFile, ruleFile, namespaceFile);
assertNotNull(fc);
}
......@@ -73,7 +73,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
assertNotNull(fc);
}
......@@ -144,7 +144,7 @@ public class ForwardChainerTest {
//test method setNoOfCores(int noOfCores)
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
ForwardChainer fc = new ForwardChainer(tupleFile, ruleFile);
ForwardChainer fc = new ForwardChainer(false,tupleFile, ruleFile);
fc.setNoOfCores(104);
assertEquals(fc.noOfCores, 104);
}
......@@ -154,7 +154,7 @@ public class ForwardChainerTest {
//test method nextBlankNode () that returns an int
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
ForwardChainer fc = new ForwardChainer(tupleFile, ruleFile);
ForwardChainer fc = new ForwardChainer(false, tupleFile, ruleFile);
assertEquals(51, fc.nextBlankNode());
assertTrue(fc.nextBlankNode() > 0);
}
......@@ -192,7 +192,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(2, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
//fc.deleteTuple(tuple); Null pointer exception
}
......@@ -207,7 +207,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
//fc.deleteTuples(tuples); Null pointer exception
}
......@@ -239,12 +239,12 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(false, true, true, 2, 5, 4, 2, namespace, getTestResource("default.nt"));
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc2 = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc2 = new ForwardChainer(false, tupleStore, ruleStore);
assertEquals(fc2.computeClosure(1, true), false);
assertEquals(fc2.computeClosure(1, false), false);
//
TupleStore tupleStore1 = new TupleStore(false, true, false, 2, 1, 2, 3, namespace, getTestResource("default.nt"));
ForwardChainer fc3 = new ForwardChainer(tupleStore1, ruleStore);
ForwardChainer fc3 = new ForwardChainer(false, tupleStore1, ruleStore);
assertEquals(fc3.computeClosure(2, true), false);
}
......@@ -254,7 +254,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(false, true, true, 2, 5, 4, 2, namespace, getTestResource("default.nt"));
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc2 = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc2 = new ForwardChainer(false, tupleStore, ruleStore);
assertEquals(fc2.computeClosure(), false);
}
......@@ -267,7 +267,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(false, true, true, 2, 5, 4, 2, namespace, getTestResource("default.nt"));
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
//no tuples were generated, so returns false
assertEquals(fc.computeClosure(newTuples, noOfIterations, cleanUpRepository), false);
//set verbose to false
......@@ -282,7 +282,7 @@ public class ForwardChainerTest {
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
String namespaceFile = getTestResource("default.ns");
ForwardChainer fc1 = new ForwardChainer(noOfCores, verboseF, rdfCheck, eqReduction, minNoOfArgs, maxNoOfArgs,
ForwardChainer fc1 = new ForwardChainer( noOfCores, verboseF, rdfCheck, eqReduction, minNoOfArgs, maxNoOfArgs,
noOfAtoms, noOfTuples, tupleFile, ruleFile, namespaceFile);
assertEquals(fc1.computeClosure(newTuples, noOfIterations, cleanUpRepository), false);
//newTuples not empty:
......@@ -291,7 +291,7 @@ public class ForwardChainerTest {
toadd[0] = 0;
toadd[1] = 1;
newTuplesfull.add(toadd);
ForwardChainer fc2 = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc2 = new ForwardChainer(false, tupleStore, ruleStore);
assertEquals(fc2.computeClosure(newTuplesfull, 1, false), false);
assertEquals(fc2.computeClosure(newTuplesfull, 1, true), false);
}
......@@ -322,7 +322,7 @@ public class ForwardChainerTest {
String filename = getTestResource("default.ns");
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
ForwardChainer fc = new ForwardChainer(tupleFile, ruleFile);
ForwardChainer fc = new ForwardChainer(false, tupleFile, ruleFile);
fc.uploadNamespaces(filename);
//TODO create a test
}
......@@ -334,7 +334,8 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
tupleStore.verbose = false;
fc.uploadTuples(filename);
//TODO create a test
}
......@@ -351,7 +352,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
assertEquals(false, fc.addTuplesToRepository(tuples));
}
......@@ -363,7 +364,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
fc.addTuples(tuples);
//TODO create a test
......@@ -381,7 +382,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
assertEquals(false, fc.removeTuplesFromRepository(tuples));
}
......@@ -396,7 +397,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
assertEquals(false, fc.deleteTuplesFromRepository(tuples));
}
......@@ -406,7 +407,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
assertEquals(false, fc.computeClosure());
}
......@@ -427,7 +428,7 @@ public class ForwardChainerTest {
Namespace namespace = new Namespace(getTestResource("default.ns"));
TupleStore tupleStore = new TupleStore(1, 2, namespace);
RuleStore ruleStore = new RuleStore(tupleStore);
ForwardChainer fc = new ForwardChainer(tupleStore, ruleStore);
ForwardChainer fc = new ForwardChainer(false, tupleStore, ruleStore);
fc.uploadRules(filename);
//TODO create a test
}
......@@ -490,7 +491,7 @@ public class ForwardChainerTest {
int levelx = 12900;
String tupleFile = getTestResource("default.nt");
String ruleFile = getTestResource("default.eqred.rdl");
ForwardChainer fc = new ForwardChainer(tupleFile, ruleFile);
ForwardChainer fc = new ForwardChainer(false, tupleFile, ruleFile);
fc.compress(level0);
fc.compress(level1);
fc.compress(level2);
......@@ -508,7 +509,7 @@ public class ForwardChainerTest {
fc.uncompressIndex();
//TODO create a test
TupleStore tupleconstructor5 = new TupleStore(false, true, true, 2, 5, 4, 2, namespace, getTestResource("default.nt"));
ForwardChainer fc1 = new ForwardChainer(tupleconstructor5, ruleStore);
ForwardChainer fc1 = new ForwardChainer(false, tupleconstructor5, ruleStore);
fc1.uncompressIndex();
//TODO create a test
}
......
......@@ -47,7 +47,7 @@ public class ISumThree {
};
Query q = new Query(fc.tupleStore);
BindingTable bt = q.query("SELECT ?s ?p ?o WHERE ?s ?p ?o");
printExpected(bt, fc.tupleStore); // TODO: THIS SHOULD BE REMOVED WHEN FINISHED
// printExpected(bt, fc.tupleStore); // TODO: THIS SHOULD BE REMOVED WHEN FINISHED
//checkResult(expected, bt, bt.getVars());
}
......
......@@ -38,14 +38,12 @@ public class NoValue {
@Test
public void test() throws QueryParseException {
// TODO: FIX EXPECTED DATA
String[][] expected = {
//tuple too short
};
Query q = new Query(fc.tupleStore);
BindingTable bt = q.query("SELECT ?s ?p ?o WHERE ?s ?p ?o");
printExpected(bt, fc.tupleStore); // TODO: THIS SHOULD BE REMOVED WHEN FINISHED
checkResult(expected, bt, bt.getVars());
}
......
......@@ -21,7 +21,7 @@ public class QueryTest_AllenRelations {
public static void init() throws Exception {
fcInterval = new ForwardChainer(4, // #cores
true, // verbose
false, // verbose
false, // RDF Check
false, // EQ reduction disabled
5, // min #args
......@@ -35,7 +35,7 @@ public class QueryTest_AllenRelations {
);
fcNoIndex = new ForwardChainer(4, // #cores
true, // verbose
false, // verbose
false, // RDF Check
false, // EQ reduction disabled
5, // min #args
......@@ -52,7 +52,7 @@ public class QueryTest_AllenRelations {
@Test
public void testTemp(){
public void testTemp() throws QueryParseException {
String[][] expected = {
// {"<test:Sensor1>", "\"1\"^^<xsd:int>", "\"100\"^^<xsd:long>" ,"\"1100\"^^<xsd:long>"},
// {"<test:Sensor1>", "\"2\"^^<xsd:int>", "\"180\"^^<xsd:long>", "\"800\"^^<xsd:long>"},
......@@ -67,18 +67,13 @@ public class QueryTest_AllenRelations {
TupleStore tupleStoreNoIdex = fcNoIndex.tupleStore;
Query queryInterval = new Query(tupleStoreInterval);
Query queryNoIndex = new Query(tupleStoreNoIdex);
try { // F
String input = "SELECT ?s ?o WHERE ?s <rdf:type> <test:sensor> \"0\"^^<xsd:long> \"999\"^^<xsd:long> & ?s <test:hasValue> ?o ?t1 ?t2 ";
BindingTable btInterval = queryInterval.query(input);
BindingTable btNoIndex = queryNoIndex.query(input);
System.out.println(btInterval.toString());
System.out.println(btNoIndex.toString());
// checkResult(fcInterval, btInterval, expected, btInterval.getVars());//"?s", "?o", "?rel1", "?rel2");
// checkResult(fcNoIndex, btNoIndex, expected, btNoIndex.getVars());//"?s", "?o", "?rel1", "?rel2");
} catch (QueryParseException e) {
e.printStackTrace();
fail();
}
}
/**
......@@ -94,7 +89,7 @@ public class QueryTest_AllenRelations {
*
*/
@Test
public void testBefore(){
public void testBefore() throws QueryParseException {
String[][] expected = {
// {"<test:Sensor1>", "\"1\"^^<xsd:int>", "\"100\"^^<xsd:long>" ,"\"1100\"^^<xsd:long>"},
// {"<test:Sensor1>", "\"2\"^^<xsd:int>", "\"180\"^^<xsd:long>", "\"800\"^^<xsd:long>"},
......@@ -109,16 +104,12 @@ public class QueryTest_AllenRelations {
TupleStore tupleStoreNoIdex = fcNoIndex.tupleStore;
Query queryInterval = new Query(tupleStoreInterval);
Query queryNoIndex = new Query(tupleStoreNoIdex);
try { // F
String input = "SELECT ?s ?o WHERE ?s <test:hasValue> ?o Bf \"1400\"^^<xsd:long> \"1600\"^^<xsd:long> ";
BindingTable btInterval = queryInterval.query(input);
BindingTable btNoIndex = queryNoIndex.query(input);
checkResult(fcInterval, btInterval, expected, btInterval.getVars());//"?s", "?o", "?rel1", "?rel2");
checkResult(fcNoIndex, btNoIndex, expected, btNoIndex.getVars());//"?s", "?o", "?rel1", "?rel2");
} catch (QueryParseException e) {
e.printStackTrace();
fail();
}
}
/**
......@@ -134,7 +125,7 @@ public class QueryTest_AllenRelations {
*
*/
@Test
public void testAfter(){
public void testAfter() throws QueryParseException {
String[][] expected = {
{"<test:Sensor1>", "\"8\"^^<xsd:int>"},
{"<test:Sensor2>", "\"7\"^^<xsd:int>"},
......@@ -144,16 +135,12 @@ public class QueryTest_AllenRelations {
TupleStore tupleStoreNoIdex = fcNoIndex.tupleStore;
Query queryInterval = new Query(tupleStoreInterval);
Query queryNoIndex = new Query(tupleStoreNoIdex);
try { // F
String input = "SELECT ?s ?o WHERE ?s <test:hasValue> ?o Af \"0\"^^<xsd:long> \"600\"^^<xsd:long> ";
BindingTable btInterval = queryInterval.query(input);
BindingTable btNoIndex = queryNoIndex.query(input);
checkResult(fcInterval, btInterval, expected, btInterval.getVars());//"?s", "?o", "?rel1", "?rel2");
checkResult(fcNoIndex, btNoIndex, expected, btNoIndex.getVars());//"?s", "?o", "?rel1", "?rel2");
} catch (QueryParseException e) {
e.printStackTrace();
fail();
}
}
/**
......@@ -166,7 +153,7 @@ public class QueryTest_AllenRelations {
*
*/
@Test
public void testEqual(){
public void testEqual() throws QueryParseException {
String[][] expected = {
{"<test:Sensor2>", "\"2\"^^<xsd:int>"}
};
......@@ -174,17 +161,13 @@ public class QueryTest_AllenRelations {
TupleStore tupleStoreNoIdex = fcNoIndex.tupleStore;
Query queryInterval = new Query(tupleStoreInterval);
Query queryNoIndex = new Query(tupleStoreNoIdex);
try { // F
String input = "SELECT ?s ?o WHERE ?s <test:hasValue> ?o EA \"200\"^^<xsd:long> \"1200\"^^<xsd:long> ";
BindingTable btInterval = queryInterval.query(input);
BindingTable btNoIndex = queryNoIndex.query(input);
checkResult(fcInterval, btInterval, expected, btInterval.getVars());//"?s", "?o", "?rel1", "?rel2");
checkResult(fcNoIndex, btNoIndex, expected, btNoIndex.getVars());//"?s", "?o", "?rel1", "?rel2");
} catch (QueryParseException e) {
e.printStackTrace();
fail();
}
}
/**
......@@ -194,7 +177,7 @@ public class QueryTest_AllenRelations {
* -------------------------------------------------------------------------------------
*/
@Test
public void testStart(){
public void testStart() throws QueryParseException {
String[][] expected = {
{"<test:Sensor2>", "\"2\"^^<xsd:int>"}
};
......@@ -203,17 +186,13 @@ public class QueryTest_AllenRelations {
Query queryInterval = new Query(tupleStoreInterval);
Query queryNoIndex = new Query(tupleStoreNoIdex);
try { // F
String input = "SELECT ?s ?o WHERE ?s <test:hasValue> ?o S \"200\"^^<xsd:long> \"1300\"^^<xsd:long> ";
BindingTable btInterval = queryInterval.query(input);
BindingTable btNoIndex = queryNoIndex.query(input);
checkResult(fcInterval, btInterval, expected, btInterval.getVars());//"?s", "?o", "?rel1", "?rel2");
checkResult(fcNoIndex