Strabon

changeset 32:070de580b6cc

Added simple classes for executing multiple queries
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Thu Mar 01 02:10:49 2012 +0200 (2012-03-01)
parents a1238b3d2000
children e8c6881d0fff
files query.sh query2.sh runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryDir.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryDir.java strabon
line diff
     1.1 --- a/query.sh	Wed Feb 29 13:46:32 2012 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,17 +0,0 @@
     1.4 -#!/bin/bash
     1.5 -#BASE=/home/strabon/experiments/data/naive/10mil
     1.6 -#10mil  0.01     11552771
     1.7 -#100mil 0.0034   99758140
     1.8 -#500mil 0.0015  512505143
     1.9 -#1bil   0.001  1153249211
    1.10 -
    1.11 -DB="noa-d4_1"
    1.12 -LOGPATH="/home/strabon/experiments/logs"
    1.13 -STEP="0.01"
    1.14 -TOTALTRIPLES="11552771"
    1.15 -
    1.16 -(cd jars/target &&
    1.17 -java -cp $(for file in `ls -1 *.jar`; do myVar=$myVar./$file":"; done; echo $myVar;) eu.earthobservatory.runtime.monetdb.QueryOp localhost 50000 $DB monetdb monetdb 
    1.18 -"PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> PREFIX clc: <http://teleios.di.uoa.gr/ontologies/clcOntology.owl#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> PREFIX teleios: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> PREFIX gag: <http://www.semanticweb.org/ontologies/2011/gagKallikratis.rdf#> PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX georss: <http://www.georss.org/georss/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX lgdo: <http://linkedgeodata.org/ontology/> PREFIX gn: <http://www.geonames.org/ontology#> PREFIX iman: <http://teleios.di.uoa.gr/ontologies/imageAnnotationOntology.owl#> PREFIX eolo: <http://www.dlr.de/ontologies/EOLO.owl#> SELECT ?h ?hGeo ?hAcqTime ?hConfidence ?hProvider ?hConfirmation ?hSensor WHERE { ?h a noa:Hotspot ;    noa:hasGeometry ?hGeo ;    noa:hasAcquisitionTime ?hAcqTime ;    noa:hasConfidence ?hConfidence ;    noa:isProducedBy ?hProvider ;    noa:hasConfirmation ?hConfirmation ;    noa:isDerivedFromSensor ?hSensor ;    FILTER( \"2007-08-23T00:00:00\" <= str(?hAcqTime)    && str(?hAcqTime) <= \"2007-08-26T23:59:59\" ) .    FILTER( strdf:contains(\"POLYGON((21.027 38.36, 23.77 38.36, 23.77 36.05, 21.027 36.05, 21.027 38.36))\"^^strdf:WKT, ?hGeo) ) .}" 
    1.19 -XML)
    1.20 -
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/query2.sh	Thu Mar 01 02:10:49 2012 +0200
     2.3 @@ -0,0 +1,12 @@
     2.4 +#!/bin/bash
     2.5 +#BASE=/home/strabon/experiments/data/naive/10mil
     2.6 +#10mil  0.01     11552771
     2.7 +#100mil 0.0034   99758140
     2.8 +#500mil 0.0015  512505143
     2.9 +#1bil   0.001  1153249211
    2.10 +
    2.11 +DB="test"
    2.12 +
    2.13 +(cd jars/target &&
    2.14 +java -cp $(for file in `ls -1 *.jar`; do myVar=$myVar./$file":"; done; echo $myVar;) eu.earthobservatory.runtime.monetdb.QueryOp localhost 50000 $DB monetdb monetdb "SELECT * WHERE {?s ?p ?o} LIMIT 1" XML)
    2.15 +
     3.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryDir.java	Wed Feb 29 13:46:32 2012 +0200
     3.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/QueryDir.java	Thu Mar 01 02:10:49 2012 +0200
     3.3 @@ -3,6 +3,7 @@
     3.4  import java.io.BufferedReader;
     3.5  import java.io.File;
     3.6  import java.io.FileReader;
     3.7 +import java.io.FilenameFilter;
     3.8  import java.io.IOException;
     3.9  
    3.10  
    3.11 @@ -14,15 +15,16 @@
    3.12  	 */
    3.13  	public static void main(String[] args) throws Exception {
    3.14  
    3.15 -		if (args.length < 6) {
    3.16 +		if (args.length < 7) {
    3.17  			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <PATH> [<FORMAT>]");
    3.18  			System.err.println("       where <HOST>       is the postgis database host to connect to");
    3.19  			System.err.println("             <PORT>       is the port to connect to on the database host");		
    3.20  			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
    3.21  			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    3.22  			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    3.23 -			System.err.println("             <PATH>      is the path containing all stSPARQL queries to evaluate.");
    3.24 -			System.err.println("             [<FORMAT>]     is the format of your results (XML)");
    3.25 +			System.err.println("             <PATH>       is the path containing all stSPARQL queries to evaluate.");
    3.26 +			System.err.println("             <EXTENSION>  is the extention of the files that contain the stSPARQL queries. (e.g., '.rq')");
    3.27 +			System.err.println("             [<FORMAT>]   is the format of your results (XML)");
    3.28  			System.exit(0);
    3.29  		}
    3.30  
    3.31 @@ -32,18 +34,23 @@
    3.32  		String user = args[3];
    3.33  		String passwd = args[4];		
    3.34  		String path = args[5];
    3.35 +		final String extension = args[6];
    3.36  		String resultsFormat = "";
    3.37 -		if ( args.length == 7 ) {
    3.38 -			resultsFormat = args[6];
    3.39 +		if ( args.length == 8 ) {
    3.40 +			resultsFormat = args[7];
    3.41  		}
    3.42  
    3.43 -
    3.44 -
    3.45 -
    3.46  		Strabon strabon = new Strabon(db, user, passwd, port, host, true);
    3.47  
    3.48  		File dir = new File(path);
    3.49 -		String[] children = dir.list();
    3.50 +
    3.51 +		FilenameFilter filter = new FilenameFilter() {
    3.52 +			public boolean accept(File dir, String name) {
    3.53 +				return name.endsWith(extension);
    3.54 +			}
    3.55 +		};
    3.56 +
    3.57 +		String[] children = dir.list(filter);
    3.58  		if (children != null) {
    3.59  			for (int i=0; i<children.length; i++) {
    3.60  				String filename = children[i];
     4.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryDir.java	Wed Feb 29 13:46:32 2012 +0200
     4.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryDir.java	Thu Mar 01 02:10:49 2012 +0200
     4.3 @@ -3,6 +3,7 @@
     4.4  import java.io.BufferedReader;
     4.5  import java.io.File;
     4.6  import java.io.FileReader;
     4.7 +import java.io.FilenameFilter;
     4.8  import java.io.IOException;
     4.9  
    4.10  
    4.11 @@ -14,15 +15,16 @@
    4.12  	 */
    4.13  	public static void main(String[] args) throws Exception {
    4.14  
    4.15 -		if (args.length < 6) {
    4.16 +		if (args.length < 7) {
    4.17  			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <PATH> [<FORMAT>]");
    4.18  			System.err.println("       where <HOST>       is the postgis database host to connect to");
    4.19  			System.err.println("             <PORT>       is the port to connect to on the database host");		
    4.20  			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
    4.21  			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    4.22  			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    4.23 -			System.err.println("             <PATH>      is the path containing all stSPARQL queries to evaluate.");
    4.24 -			System.err.println("             [<FORMAT>]     is the format of your results (XML)");
    4.25 +			System.err.println("             <PATH>       is the path containing all stSPARQL queries to evaluate.");
    4.26 +			System.err.println("             <EXTENSION>  is the extention of the files that contain the stSPARQL queries. (e.g., '.rq')");
    4.27 +			System.err.println("             [<FORMAT>]   is the format of your results (XML)");
    4.28  			System.exit(0);
    4.29  		}
    4.30  
    4.31 @@ -30,25 +32,32 @@
    4.32  		Integer port = new Integer(args[1]);
    4.33  		String db = args[2];
    4.34  		String user = args[3];
    4.35 -		String passwd = args[4];		
    4.36 +		String passwd = args[4];
    4.37  		String path = args[5];
    4.38 +		final String extension = args[6];
    4.39  		String resultsFormat = "";
    4.40 -		if ( args.length == 7 ) {
    4.41 -			resultsFormat = args[6];
    4.42 +		if ( args.length == 8 ) {
    4.43 +			resultsFormat = args[7];
    4.44  		}
    4.45  
    4.46 -
    4.47 -
    4.48 -
    4.49  		Strabon strabon = new Strabon(db, user, passwd, port, host, true);
    4.50  
    4.51  		File dir = new File(path);
    4.52 -		String[] children = dir.list();
    4.53 +
    4.54 +		FilenameFilter filter = new FilenameFilter() {
    4.55 +			public boolean accept(File dir, String name) {
    4.56 +				return name.endsWith(extension);
    4.57 +			}
    4.58 +		};
    4.59 +
    4.60 +		String[] children = dir.list(filter);
    4.61  		if (children != null) {
    4.62  			for (int i=0; i<children.length; i++) {
    4.63  				String filename = children[i];
    4.64  				try {
    4.65 +					System.out.println("Evaluating query from '" + path + System.getProperty("file.separator") + filename  +"'.");
    4.66  					String queryString = readFile(path + System.getProperty("file.separator") + filename);
    4.67 +					System.out.println("Evaluating stSPARQL query: \n"+queryString+"\n");
    4.68  					strabon.query(queryString, resultsFormat, strabon.getSailRepoConnection());
    4.69  				} catch (IOException e) {
    4.70  					System.err.println("IOException while reading " + filename);
     5.1 --- a/strabon	Wed Feb 29 13:46:32 2012 +0200
     5.2 +++ b/strabon	Thu Mar 01 02:10:49 2012 +0200
     5.3 @@ -15,6 +15,7 @@
     5.4  PASSWORD='monetdb'
     5.5  FORMAT=''
     5.6  DIRS=$2
     5.7 +EXT=$3
     5.8  
     5.9  # Construct classpath with dependencies
    5.10  cd $dir &&
    5.11 @@ -24,4 +25,4 @@
    5.12  done;
    5.13  
    5.14  # Evaluate a query
    5.15 -java -Xmx5000M -cp $myVar eu.earthobservatory.runtime.monetdb.QueryDir $HOST $PORT $DATABASE $USERNAME $PASSWORD "$DIRS" $FORMAT
    5.16 +java -Xmx5000M -cp $myVar eu.earthobservatory.runtime.monetdb.QueryDir $HOST $PORT $DATABASE $USERNAME $PASSWORD "$DIRS" "$EXT" $FORMAT