Strabon
changeset 873:4b408b8a06a9 temporals
resolved merge issues
author | Konstantina Bereta <Konstantina.Bereta@di.uoa.gr> |
---|---|
date | Fri Feb 08 17:47:14 2013 +0200 (2013-02-08) |
parents | 74ffcfcb691d |
children | 4762a336fc31 |
files | pom.xml runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryDir.java runtime/src/main/java/eu/earthobservatory/utils/ExperimentsReal.java runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemplateTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemporalConstructTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemporalRelationTests.java |
line diff
1.1 --- a/pom.xml Fri Feb 08 16:42:42 2013 +0200 1.2 +++ b/pom.xml Fri Feb 08 17:47:14 2013 +0200 1.3 @@ -258,7 +258,7 @@ 1.4 <dependency> 1.5 <groupId>org.openrdf.sesame</groupId> 1.6 <artifactId>sesame-rio-api</artifactId> 1.7 - <version>${sesame.version}</version> 1.8 + <version>2.6.9</version> 1.9 </dependency> 1.10 <dependency> 1.11 <groupId>org.openrdf.sesame</groupId>
2.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Fri Feb 08 16:42:42 2013 +0200 2.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Fri Feb 08 17:47:14 2013 +0200 2.3 @@ -246,7 +246,7 @@ 2.4 logger.info("[Strabon.query] Executing query: \n{}", queryString); 2.5 2.6 // check for null stream 2.7 - if ((out == null) && (resultsFormat != org.openrdf.query.resultio.Format.EXP)) { 2.8 + if ((out == null) && (resultsFormat != eu.earthobservatory.utils.Format.EXP)) { 2.9 logger.error("[Strabon.query] Cannot write to null stream."); 2.10 2.11 return false;
3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryDir.java Fri Feb 08 16:42:42 2013 +0200 3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryDir.java Fri Feb 08 17:47:14 2013 +0200 3.3 @@ -9,8 +9,6 @@ 3.4 */ 3.5 package eu.earthobservatory.runtime.monetdb; 3.6 3.7 -import eu.earthobservatory.utils.Format; 3.8 - 3.9 import java.io.BufferedReader; 3.10 import java.io.File; 3.11 import java.io.FileReader; 3.12 @@ -20,6 +18,8 @@ 3.13 import org.slf4j.Logger; 3.14 import org.slf4j.LoggerFactory; 3.15 3.16 +import eu.earthobservatory.utils.Format; 3.17 + 3.18 3.19 public class QueryDir { 3.20
4.1 --- a/runtime/src/main/java/eu/earthobservatory/utils/ExperimentsReal.java Fri Feb 08 16:42:42 2013 +0200 4.2 +++ b/runtime/src/main/java/eu/earthobservatory/utils/ExperimentsReal.java Fri Feb 08 17:47:14 2013 +0200 4.3 @@ -215,7 +215,7 @@ 4.4 4.5 System.out.println("Executing query. Caches: " + cacheState + ". Repetition: " + repetition); 4.6 4.7 - long[] resp = (long[])strabon.query(query, org.openrdf.query.resultio.Format.EXP, null); 4.8 + long[] resp = (long[])strabon.query(query, eu.earthobservatory.utils.Format.EXP, null); 4.9 4.10 // Statement st; 4.11 // System.out.println("Evaluating query (naive).");
5.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemplateTests.java Fri Feb 08 16:42:42 2013 +0200 5.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemplateTests.java Fri Feb 08 17:47:14 2013 +0200 5.3 @@ -76,7 +76,13 @@ 5.4 } 5.5 stmt.close(); 5.6 5.7 - Strabon strabon = new eu.earthobservatory.runtime.postgis.Strabon(databaseName, username, password, port, serverName, true); 5.8 + Strabon strabon=null; 5.9 + try { 5.10 + strabon = new eu.earthobservatory.runtime.postgis.Strabon(databaseName, username, password, port, serverName, true); 5.11 + } catch (Exception e) { 5.12 + // TODO Auto-generated catch block 5.13 + e.printStackTrace(); 5.14 + } 5.15 5.16 loadTestData(inputFile, strabon, format); 5.17
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemporalConstructTests.java Fri Feb 08 17:47:14 2013 +0200 6.3 @@ -0,0 +1,220 @@ 6.4 +/** 6.5 + * This Source Code Form is subject to the terms of the Mozilla Public 6.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 6.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 6.8 + * 6.9 + * Copyright (C) 2010, 2011, 2012, Pyravlos Team 6.10 + * 6.11 + * http://www.strabon.di.uoa.gr/ 6.12 + */ 6.13 + 6.14 +/** 6.15 + * A set of simple tests on temporal selection functionality 6.16 + * 6.17 + * @author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr> 6.18 + * 6.19 + * This class includes a set of junit tests that test the temporal relations between periods 6.20 + */ 6.21 + 6.22 +package eu.earthobservatory.runtime.postgres.temporals; 6.23 + 6.24 + 6.25 +import static org.junit.Assert.*; 6.26 + 6.27 +import java.io.IOException; 6.28 +import java.sql.SQLException; 6.29 +import java.util.ArrayList; 6.30 + 6.31 +import org.junit.AfterClass; 6.32 +import org.junit.BeforeClass; 6.33 +import org.junit.Test; 6.34 +import org.openrdf.query.MalformedQueryException; 6.35 +import org.openrdf.query.QueryEvaluationException; 6.36 +import org.openrdf.query.TupleQueryResult; 6.37 +import org.openrdf.query.TupleQueryResultHandlerException; 6.38 +///import org.openrdf.query.resultio.Format; 6.39 +import org.openrdf.query.resultio.TupleQueryResultWriter; 6.40 +import org.openrdf.query.resultio.stSPARQLQueryResultWriterFactory; 6.41 +import org.openrdf.repository.RepositoryException; 6.42 +import org.openrdf.rio.RDFHandlerException; 6.43 +import org.openrdf.rio.RDFParseException; 6.44 + 6.45 +import eu.earthobservatory.utils.Format; 6.46 + 6.47 + 6.48 +import eu.earthobservatory.runtime.generaldb.*; 6.49 +import eu.earthobservatory.runtime.postgres.temporals.TemplateTests; 6.50 + 6.51 + 6.52 +/** 6.53 + * A set of simple tests on query rewriting functionality 6.54 + * 6.55 + * @author Konstantina Bereta <Konstantina.Bereta@di.uoa.gr> 6.56 + * 6.57 + * This class includes a set of junit tests that test the temporal constructs that appear in 6.58 + * the select clause of the query 6.59 + * 6.60 + */ 6.61 + 6.62 +public class TemporalConstructTests { 6.63 + 6.64 + protected static Strabon strabon; 6.65 + 6.66 + protected static final String prefixes = 6.67 + "PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> \n" + 6.68 + "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> \n" + 6.69 + "PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> \n"; 6.70 + 6.71 + 6.72 + @BeforeClass 6.73 + public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault 6.74 + { 6.75 + strabon = TemplateTests.beforeClass("/temporal-periods.nq","NQUADS"); 6.76 + } 6.77 + 6.78 + @AfterClass 6.79 + public static void afterClass() throws SQLException 6.80 + { 6.81 + TemplateTests.afterClass(strabon); 6.82 + } 6.83 + 6.84 + @Test 6.85 + public void testIntersection() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException 6.86 + { 6.87 + 6.88 + String query = 6.89 + prefixes+ 6.90 + "SELECT distinct (strdf:period_intersect(?t1, ?t2) AS ?intersection) "+ 6.91 + "WHERE { "+ 6.92 + "?x1 ?y1 ?z1 ?t1 . "+ 6.93 + "?x2 ?y2 ?z2 ?t2 . "+ 6.94 + "FILTER(strdf:PeriodOverlaps(?t1, ?t2) && str(?x1) != str(?x2))."+ 6.95 + "}"; 6.96 + 6.97 + ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection()); 6.98 + 6.99 + for(String result: bindings) 6.100 + { 6.101 + System.out.println(result.toString()); 6.102 + } 6.103 + assertEquals(5, bindings.size()); 6.104 + //assertTrue(-1 < bindings.indexOf("")); 6.105 + assertTrue(bindings.contains("intersection=\"[2012-11-19 12:41:00+02, 2012-11-19 13:41:00.000001+02)\"")); 6.106 + assertTrue(bindings.contains("intersection=\"[2012-11-19 13:41:00+02, 2012-11-19 13:41:00.000001+02)\"")); 6.107 + assertTrue(bindings.contains("intersection=\"[2012-11-19 10:41:00+02, 2012-11-19 11:41:00.000001+02)\"")); 6.108 + assertTrue(bindings.contains("intersection=\"[2012-11-19 13:41:00+02, 2012-11-19 14:41:00.000001+02)\"")); 6.109 + assertTrue(bindings.contains("intersection=\"[2012-11-19 14:41:00.000001+02, 2012-11-19 15:41:00.000001+02)\"")); 6.110 +} 6.111 + 6.112 + @Test 6.113 + public void testUnion() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException 6.114 + { 6.115 + 6.116 + String query = 6.117 + prefixes+ 6.118 + "SELECT distinct (strdf:period_union(?t1, ?t2) AS ?union) "+ 6.119 + "WHERE { "+ 6.120 + "?x1 ?y1 ?z1 ?t1 . "+ 6.121 + "?x2 ?y2 ?z2 ?t2 . "+ 6.122 + "FILTER(strdf:PeriodOverlaps(?t1, ?t2) && str(?x1) != str(?x2))."+ 6.123 + "}"; 6.124 + 6.125 + ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection()); 6.126 + 6.127 + for(String result: bindings) 6.128 + { 6.129 + System.out.println(result.toString()); 6.130 + } 6.131 + assertEquals(3, bindings.size()); 6.132 + //assertTrue(-1 < bindings.indexOf("")); 6.133 + assertTrue(bindings.contains("union=\"[2012-11-19 12:41:00+02, 2012-11-19 13:41:00.000001+02)\"")); 6.134 + assertTrue(bindings.contains("union=\"[2012-11-19 12:41:00+02, 2012-11-19 14:41:00.000001+02)\"")); 6.135 + assertTrue(bindings.contains("union=\"[2012-11-19 10:41:00+02, 2012-11-19 15:41:00.000001+02)\"")); 6.136 +} 6.137 + 6.138 + @Test 6.139 + public void testMinus() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException 6.140 + { 6.141 + 6.142 + String query = 6.143 + prefixes+ 6.144 + "SELECT distinct (strdf:period_minus(?t1, ?t2) AS ?minus) "+ 6.145 + "WHERE { "+ 6.146 + "?x1 ?y1 ?z1 ?t1 . "+ 6.147 + "?x2 ?y2 ?z2 ?t2 . "+ 6.148 + "FILTER(strdf:during(?t1, ?t2) && str(?x1) != str(?x2))."+ 6.149 + "}"; 6.150 + 6.151 + ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection()); 6.152 + 6.153 + for(String result: bindings) 6.154 + { 6.155 + System.out.println(result.toString()); 6.156 + } 6.157 + assertEquals(4, bindings.size()); 6.158 + //assertTrue(-1 < bindings.indexOf("")); 6.159 + assertTrue(bindings.contains("minus=\"[2012-11-19 13:41:00.000001+02, 2012-11-19 13:41:00.000001+02)\"")); 6.160 + assertTrue(bindings.contains("minus=\"[2012-11-19 11:41:00.000001+02, 2012-11-19 11:41:00.000001+02)\"")); 6.161 + assertTrue(bindings.contains("minus=\"[2012-11-19 14:41:00.000001+02, 2012-11-19 14:41:00.000001+02)\"")); 6.162 + assertTrue(bindings.contains("minus=\"[2012-11-19 15:41:00.000001+02, 2012-11-19 15:41:00.000001+02)\"")); 6.163 +} 6.164 + 6.165 + @Test 6.166 + public void testStart() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException 6.167 + { 6.168 + 6.169 + String query = 6.170 + prefixes+ 6.171 + "SELECT distinct (strdf:period_start(?t1, ?t2) AS ?start) "+ 6.172 + "WHERE { "+ 6.173 + "?x1 ?y1 ?z1 ?t1 . "+ 6.174 + //"FILTER(strdf:during(?t1, ?t2) && str(?x1) != str(?x2))."+ 6.175 + "}"; 6.176 + 6.177 + ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection()); 6.178 + 6.179 + for(String result: bindings) 6.180 + { 6.181 + System.out.println(result.toString()); 6.182 + } 6.183 + assertEquals(7, bindings.size()); 6.184 + //assertTrue(-1 < bindings.indexOf("")); 6.185 + assertTrue(bindings.contains("2012-01-19T12:41:00+02")); 6.186 + assertTrue(bindings.contains("start=\"2012-11-19T12:41:00+02\"")); 6.187 + assertTrue(bindings.contains("start=\"2012-11-19T10:41:00+02\"")); 6.188 + assertTrue(bindings.contains("start=\"2012-01-19T10:41:00+02\"")); 6.189 + assertTrue(bindings.contains("start=\"2012-11-19T13:41:00+02\"")); 6.190 + assertTrue(bindings.contains("start=\"2012-01-19T11:41:00+02\"")); 6.191 + assertTrue(bindings.contains("start=\"2012-11-19T14:41:00.000001+02\"")); 6.192 +} 6.193 + 6.194 + @Test 6.195 + public void testEnd() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException 6.196 + { 6.197 + 6.198 + String query = 6.199 + prefixes+ 6.200 + "SELECT distinct (strdf:period_end(?t1, ?t2) AS ?end) "+ 6.201 + "WHERE { "+ 6.202 + "?x1 ?y1 ?z1 ?t1 . "+ 6.203 + //"FILTER(strdf:during(?t1, ?t2) && str(?x1) != str(?x2))."+ 6.204 + "}"; 6.205 + 6.206 + ArrayList<String> bindings = (ArrayList<String>) strabon.query(strabon.queryRewriting(query),strabon.getSailRepoConnection()); 6.207 + 6.208 + for(String result: bindings) 6.209 + { 6.210 + System.out.println(result.toString()); 6.211 + } 6.212 + assertEquals(7, bindings.size()); 6.213 + //assertTrue(-1 < bindings.indexOf("")); 6.214 + assertTrue(bindings.contains("2012-01-19T12:41:00+02")); 6.215 + assertTrue(bindings.contains("start=\"2012-11-19T12:41:00+02\"")); 6.216 + assertTrue(bindings.contains("start=\"2012-01-19T10:41:00+02\"")); 6.217 + assertTrue(bindings.contains("start=\"2012-11-19T13:41:00+02\"")); 6.218 + assertTrue(bindings.contains("start=\"2012-01-19T11:41:00+02\"")); 6.219 + assertTrue(bindings.contains("start=\"2012-11-19T14:41:00.000001+02\"")); 6.220 + assertTrue(bindings.contains("start=\"2012-11-19T15:41:00.000001+02\"")); 6.221 + 6.222 +} 6.223 +} 6.224 \ No newline at end of file
7.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemporalRelationTests.java Fri Feb 08 16:42:42 2013 +0200 7.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgres/temporals/TemporalRelationTests.java Fri Feb 08 17:47:14 2013 +0200 7.3 @@ -32,7 +32,8 @@ 7.4 import org.openrdf.query.QueryEvaluationException; 7.5 import org.openrdf.query.TupleQueryResult; 7.6 import org.openrdf.query.TupleQueryResultHandlerException; 7.7 -import org.openrdf.query.resultio.Format; 7.8 +//import org.openrdf.query.resultio.Format; 7.9 +import eu.earthobservatory.utils.Format; 7.10 import org.openrdf.query.resultio.TupleQueryResultWriter; 7.11 import org.openrdf.query.resultio.stSPARQLQueryResultWriterFactory; 7.12 import org.openrdf.repository.RepositoryException;