Strabon

changeset 303:b553a8023a07

merge with 301
author George Garbis <ggarbis@di.uoa.gr>
date Tue Jun 19 18:26:33 2012 +0300 (2012-06-19)
parents 36acd78a9455 f20534cb72e9
children 43d00ac76683
files
line diff
     1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/TripleTable.java	Tue Jun 19 17:56:09 2012 +0300
     1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/TripleTable.java	Tue Jun 19 18:26:33 2012 +0300
     1.3 @@ -9,6 +9,7 @@
     1.4  import java.util.List;
     1.5  import java.util.Map;
     1.6  
     1.7 +import org.apache.log4j.Logger;
     1.8  import org.openrdf.sail.rdbms.schema.RdbmsTable;
     1.9  import org.openrdf.sail.rdbms.schema.ValueTypes;
    1.10  import org.openrdf.sail.rdbms.schema.ValueType;
    1.11 @@ -151,16 +152,47 @@
    1.12  	public void createIndex()
    1.13  		throws SQLException
    1.14  	{
    1.15 +//		if (isPredColumnPresent()) {
    1.16 +//			table.index(PRED_INDEX);
    1.17 +//			total_st++;
    1.18 +//		}
    1.19 +//		table.index(SUBJ_INDEX);
    1.20 +//		total_st++;
    1.21 +//		table.index(CTX_INDEX);
    1.22 +//		total_st++;
    1.23 +//		table.index(EXPL_INDEX);
    1.24 +//		total_st++;
    1.25 +		
    1.26 +		///////
    1.27  		if (isPredColumnPresent()) {
    1.28 -			table.index(PRED_INDEX);
    1.29 +			String[] PRED_OBJ_SUBJ_INDEX = {"pred", "obj", "subj"};
    1.30 +			table.index(PRED_OBJ_SUBJ_INDEX);
    1.31 +			total_st++;
    1.32 +			String[] PRED_SUBJ_OBJ_INDEX = {"pred", "subj", "obj"};
    1.33 +			table.index(PRED_SUBJ_OBJ_INDEX);
    1.34 +			total_st++;
    1.35 +			String[] OBJ_PRED_SUBJ_INDEX = { "obj", "pred", "subj"};
    1.36 +			table.index(OBJ_PRED_SUBJ_INDEX);
    1.37 +			total_st++;
    1.38 +			String[] OBJ_SUBJ_PRED_INDEX = { "obj", "subj", "pred"};
    1.39 +			table.index(OBJ_SUBJ_PRED_INDEX);
    1.40 +			total_st++;
    1.41 +			String[] SUBJ_OBJ_PRED_INDEX = {"subj", "obj", "pred"};
    1.42 +			table.index(SUBJ_OBJ_PRED_INDEX);
    1.43 +			total_st++;
    1.44 +			String[] SUBJ_PRED_OBJ_INDEX = {"subj", "pred", "obj"};
    1.45 +			table.index(SUBJ_PRED_OBJ_INDEX);
    1.46 +			total_st++;
    1.47 +		} else {
    1.48 +//			String[] OBJ_SUBJ_INDEX = {"obj", "subj"};
    1.49 +//			table.index(OBJ_SUBJ_INDEX);
    1.50 +//			total_st++;
    1.51 +			String[] SUBJ_OBJ_INDEX = {"subj", "obj"};
    1.52 +			table.index(SUBJ_OBJ_INDEX);
    1.53  			total_st++;
    1.54  		}
    1.55 -		table.index(SUBJ_INDEX);
    1.56 -		total_st++;
    1.57 -		table.index(CTX_INDEX);
    1.58 -		total_st++;
    1.59 -		table.index(EXPL_INDEX);
    1.60 -		total_st++;
    1.61 +		//////
    1.62 +		
    1.63  	}
    1.64  
    1.65  	public void dropIndex()
    1.66 @@ -253,10 +285,12 @@
    1.67  			sb.append("  pred ").append(ids.getSqlType()).append(" NOT NULL,\n");
    1.68  		}
    1.69  		sb.append("  obj ").append(ids.getSqlType()).append(" NOT NULL,\n");
    1.70 -		sb.append("  expl ").append("BOOL").append(" NOT NULL,\n");
    1.71 +//		sb.append("  expl ").append("BOOL").append(" NOT NULL,\n");
    1.72 +		sb.append("  expl ").append("BOOL").append(" NOT NULL\n");
    1.73  		//FIXME
    1.74 -		sb.append("  interval_start ").append("TIMESTAMP DEFAULT NULL").append(",\n");
    1.75 -		sb.append("  interval_end ").append("TIMESTAMP DEFAULT NULL").append("\n");
    1.76 +//		sb.append("  interval_start ").append("TIMESTAMP DEFAULT NULL").append(",\n");
    1.77 +//		sb.append("  interval_end ").append("TIMESTAMP DEFAULT NULL").append("\n");
    1.78 +		
    1.79  		return sb;
    1.80  	}
    1.81  }
     2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTableFactory.java	Tue Jun 19 17:56:09 2012 +0300
     2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTableFactory.java	Tue Jun 19 18:26:33 2012 +0300
     2.3 @@ -158,6 +158,9 @@
     2.4  		if (!sequenced) {
     2.5  			table.setTemporaryTable(factory.createTemporaryTable(conn, "INSERT_" + name));
     2.6  		}
     2.7 +		if ( name.equals(TIMES) )
     2.8 +			initValueTable(table, queue, sqlType, length, true);
     2.9 +		else
    2.10  		initValueTable(table, queue, sqlType, length, INDEX_VALUES);
    2.11  		return table;
    2.12  	}
     3.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java	Tue Jun 19 17:56:09 2012 +0300
     3.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java	Tue Jun 19 18:26:33 2012 +0300
     3.3 @@ -24,7 +24,7 @@
     3.4  	@BeforeClass
     3.5  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
     3.6  	{
     3.7 -		strabon = TemplateTests.beforeClass("/grouo-tests-srid.nt");
     3.8 +		strabon = TemplateTests.beforeClass("/group-tests-srid.nt");
     3.9  	}
    3.10  	
    3.11  	@AfterClass
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/runtime/src/test/resources/aggregate-tests-srid.nt	Tue Jun 19 18:26:33 2012 +0300
     4.3 @@ -0,0 +1,46 @@
     4.4 +<http://linkedgeodata.org/triplify/node823767430> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.87631 50.7213)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
     4.5 +<http://linkedgeodata.org/triplify/node742231352> <http://www.w3.org/2000/01/rdf-schema#label> "Rosie's".
     4.6 +<http://linkedgeodata.org/triplify/node817345828> <http://www.w3.org/2000/01/rdf-schema#label> "Coffee Republic".
     4.7 +<http://linkedgeodata.org/triplify/node344800922> <http://www.w3.org/2000/01/rdf-schema#label> "Norwegian Wood".
     4.8 +<http://linkedgeodata.org/triplify/node817345828> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.87647 50.721)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
     4.9 +<http://linkedgeodata.org/triplify/node742231354> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.83702 50.7272)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
    4.10 +<http://linkedgeodata.org/triplify/node817345828> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.11 +<http://linkedgeodata.org/triplify/node344800922> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.12 +<http://linkedgeodata.org/triplify/node278571210> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.13 +<http://linkedgeodata.org/triplify/node278982153> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.14 +<http://linkedgeodata.org/triplify/node742231354> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.15 +<http://linkedgeodata.org/triplify/node666779036> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.16 +<http://linkedgeodata.org/triplify/node742231352> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.17 +<http://linkedgeodata.org/triplify/node823767430> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.18 +<http://linkedgeodata.org/triplify/node823767435> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Cafe>.
    4.19 +<http://linkedgeodata.org/triplify/node278982153> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.81769 50.7218)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
    4.20 +<http://linkedgeodata.org/triplify/node278571210> <http://www.w3.org/2000/01/rdf-schema#label> "The Clock Café".
    4.21 +<http://linkedgeodata.org/triplify/node278571210> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.84845 50.7231)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
    4.22 +<http://linkedgeodata.org/triplify/node666779036> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.84667 50.7317)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
    4.23 +<http://linkedgeodata.org/triplify/node344800922> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.87346 50.7214)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
    4.24 +<http://linkedgeodata.org/ontology/Node122> <http://linkedgeodata.org/ontology/bufferExtent> "2"^^<http://www.w3.org/2001/XMLSchema#integer>.
    4.25 +<http://linkedgeodata.org/triplify/node823767435> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.87652 50.7214)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
    4.26 +<http://linkedgeodata.org/triplify/node278982153> <http://www.w3.org/2000/01/rdf-schema#label> "Café Riva".
    4.27 +<http://linkedgeodata.org/triplify/node666779036> <http://www.w3.org/2000/01/rdf-schema#label> "Curzon Diner".
    4.28 +<http://linkedgeodata.org/triplify/node742231352> <http://www.w3.org/2003/01/geo/wgs84_pos#geometry> "POINT(-1.84186 50.7255)"^^<http://strdf.di.uoa.gr/ontology#WKT>.
    4.29 +<http://linkedgeodata.org/triplify/node742231354> <http://www.w3.org/2000/01/rdf-schema#label> "Boscanova".
    4.30 +<http://linkedgeodata.org/triplify/node823767430> <http://www.w3.org/2000/01/rdf-schema#label> "Caffe Nero".
    4.31 +<http://linkedgeodata.org/triplify/node823767435> <http://www.w3.org/2000/01/rdf-schema#label> "Costa".
    4.32 +<http://linkedgeodata.org/triplify/node817345828> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.33 +<http://linkedgeodata.org/triplify/node344800922> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.34 +<http://linkedgeodata.org/triplify/node278571210> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.35 +<http://linkedgeodata.org/triplify/node278982153> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.36 +<http://linkedgeodata.org/triplify/node742231354> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.37 +<http://linkedgeodata.org/triplify/node666779036> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.38 +<http://linkedgeodata.org/triplify/node742231352> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.39 +<http://linkedgeodata.org/triplify/node823767430> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.40 +<http://linkedgeodata.org/triplify/node823767435> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Node>.
    4.41 +<http://linkedgeodata.org/triplify/node817345828> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
    4.42 +<http://linkedgeodata.org/triplify/node344800922> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
    4.43 +<http://linkedgeodata.org/triplify/node278571210> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
    4.44 +<http://linkedgeodata.org/triplify/node278982153> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
    4.45 +<http://linkedgeodata.org/triplify/node742231354> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
    4.46 +<http://linkedgeodata.org/triplify/node666779036> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
    4.47 +<http://linkedgeodata.org/triplify/node742231352> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
    4.48 +<http://linkedgeodata.org/triplify/node823767430> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
    4.49 +<http://linkedgeodata.org/triplify/node823767435> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://linkedgeodata.org/ontology/Amenity>.
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/scripts/v2/DeleteInSea.sparql	Tue Jun 19 18:26:33 2012 +0300
     5.3 @@ -0,0 +1,20 @@
     5.4 +PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
     5.5 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
     5.6 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
     5.7 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
     5.8 +
     5.9 +INSERT {?h noa:isDiscarded "1"^^xsd:int} 
    5.10 +WHERE {
    5.11 +  ?h rdf:type noa:Hotspot; 
    5.12 +     noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime; 
    5.13 +     noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string; 
    5.14 +     noa:isDerivedFromSensor "SENSOR"^^xsd:string;
    5.15 +     noa:hasGeometry ?hGeo;
    5.16 +     ?property ?object . 
    5.17 +  OPTIONAL {
    5.18 +    ?c rdf:type noa:Coastline;
    5.19 +       noa:hasGeometry ?cGeo . 
    5.20 +    FILTER(strdf:anyInteract(?hGeo, ?cGeo)) .
    5.21 +  } 
    5.22 +  FILTER(!bound(?c)) . 
    5.23 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/scripts/v2/Refine.sparql	Tue Jun 19 18:26:33 2012 +0300
     6.3 @@ -0,0 +1,35 @@
     6.4 +PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
     6.5 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
     6.6 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
     6.7 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
     6.8 +
     6.9 +
    6.10 +INSERT { ?h noa:isDiscarded "1"^^xsd:int . 
    6.11 +	 ?valid rdf:type noa:Hotspot ;
    6.12 +		noa:hasConfidence ?conf ;
    6.13 +	        noa:hasGeometry ?dif ;
    6.14 +		noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime ; 
    6.15 +	        noa:isDerivedFromSensor "SENSOR"^^xsd:string ;
    6.16 +		noa:hasConfirmation noa:unknown ;
    6.17 +	        noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ; 
    6.18 +		noa:isProducedBy noa:noa ;
    6.19 +		noa:isDerivedFromSatellite ?sat .
    6.20 +}
    6.21 +WHERE { 
    6.22 +  SELECT DISTINCT ?h ?hGeo (strdf:intersection(?hGeo, strdf:union(?cGeo)) AS ?dif) (BNODE() AS ?valid) ?conf ?sat
    6.23 +  WHERE { 
    6.24 +    ?h rdf:type noa:Hotspot ; 
    6.25 +       noa:hasAcquisitionTime ?hAcqTime ; 
    6.26 +       noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string ; 
    6.27 +       noa:isDerivedFromSensor "SENSOR"^^xsd:string ;
    6.28 +       noa:hasGeometry ?hGeo ;
    6.29 +       noa:hasConfidence ?conf ;
    6.30 +       noa:isDerivedFromSatellite ?sat .
    6.31 +    FILTER("TIMESTAMP"^^xsd:dateTime = ?hAcqTime) .
    6.32 +    ?c rdf:type noa:Coastline ;
    6.33 +       noa:hasGeometry ?cGeo .
    6.34 +    FILTER(strdf:anyInteract(?hGeo, ?cGeo)) . 
    6.35 +  }
    6.36 +  GROUP BY ?h ?hGeo ?conf ?sat
    6.37 +  HAVING strdf:overlap(?hGeo, strdf:union(?cGeo))
    6.38 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/scripts/v2/TimePersistence.sparql	Tue Jun 19 18:26:33 2012 +0300
     7.3 @@ -0,0 +1,47 @@
     7.4 +PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> 
     7.5 +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
     7.6 +PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> 
     7.7 +PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
     7.8 +
     7.9 +INSERT {
    7.10 +  ?newHotspot rdf:type noa:Hotspot ;
    7.11 +	      noa:hasConfidence ?hConfidence ;
    7.12 +	      noa:hasGeometry ?hGeometry1 ;
    7.13 +	      noa:hasAcquisitionTime "TIMESTAMP"^^xsd:dateTime ;
    7.14 +	      noa:isDerivedFromSensor "SENSOR"^^xsd:string ;
    7.15 +	      noa:hasConfirmation noa:unknown ;
    7.16 + 	      noa:producedFromProcessingChain ?hProcessingChain ;
    7.17 +	      noa:isProducedBy noa:noa .
    7.18 +}
    7.19 +WHERE {
    7.20 +  SELECT (BNODE() AS ?newHotspot)
    7.21 +  (SUM(?hConfidence1)/ACQUISITIONS_IN_HALF_AN_HOUR AS ?hConfidence)
    7.22 +  ?hGeometry1
    7.23 +  (CONCAT("PROCESSING_CHAIN"^^xsd:string,"-TimePersistence") AS ?hProcessingChain)
    7.24 +  WHERE {
    7.25 +    ?H1 rdf:type noa:Hotspot .
    7.26 +    ?H1 noa:hasConfidence ?hConfidence1 .
    7.27 +    ?H1 noa:hasGeometry ?hGeometry1 .
    7.28 +    ?H1 noa:hasAcquisitionTime ?hAcquisitionTime1 .
    7.29 +    ?H1 noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    7.30 +    ?H1 noa:hasConfirmation noa:unknown .
    7.31 +    ?H1 noa:producedFromProcessingChain "PROCESSING_CHAIN"^^xsd:string .
    7.32 +    OPTIONAL { ?H1 noa:isDiscarded ?z } .
    7.33 +    FILTER (!BOUND(?z)) .
    7.34 +    ?H1 noa:isProducedBy noa:noa .
    7.35 +    FILTER( "MIN_ACQUISITION_TIME"^^xsd:dateTime <= ?hAcquisitionTime1 && ?hAcquisitionTime1 < "TIMESTAMP"^^xsd:dateTime ) .
    7.36 +    OPTIONAL {
    7.37 +      ?H2 rdf:type noa:Hotspot .
    7.38 +      ?H2 noa:hasGeometry ?HGEO2 .
    7.39 +      ?H2 noa:hasAcquisitionTime ?hAcquisitionTime2 .
    7.40 +      ?H2 noa:isDerivedFromSensor "SENSOR"^^xsd:string .
    7.41 +      ?H2 noa:producedFromProcessingChain ?hProcessingChain2 .
    7.42 +      FILTER(regex("PROCESSING_CHAIN"^^xsd:string, ?hProcessingChain2)).
    7.43 +      FILTER( strdf:equals(?hGeometry1, ?HGEO2) ) .
    7.44 +      FILTER(?hAcquisitionTime2 = "TIMESTAMP"^^xsd:dateTime) .
    7.45 +    }
    7.46 +    FILTER( !BOUND(?H2) ) .
    7.47 +  }
    7.48 +  GROUP BY ?hGeometry1
    7.49 +  HAVING(SUM(?hConfidence1)>0.0)
    7.50 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/scripts/v2/count.sparql	Tue Jun 19 18:26:33 2012 +0300
     8.3 @@ -0,0 +1,2 @@
     8.4 +SELECT (count(*) AS ?count)
     8.5 +WHERE {?s ?p ?o}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/scripts/v2/runNoaRefinementChain.sh	Tue Jun 19 18:26:33 2012 +0300
     9.3 @@ -0,0 +1,167 @@
     9.4 +#!/bin/bash
     9.5 +LOC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
     9.6 +
     9.7 +ENDPOINT="http://localhost:8080/endpoint"
     9.8 +DB="endpoint"
     9.9 +GRIDURL="http://kk.di.uoa.gr/grid_4.nt"
    9.10 +
    9.11 +#dataDir="http://localhost/noa-teleios/out_triples/"
    9.12 +dataDir="http://kk.di.uoa.gr/out_triples/"
    9.13 +name="HMSG2_IR_039_s7_070825"
    9.14 +suffix=".hotspots.n3"
    9.15 +
    9.16 +logFile="chain.log"
    9.17 +#countWTime="/usr/bin/time -p   %e"
    9.18 +#echo > ${logFile}
    9.19 +
    9.20 +function timer()
    9.21 +{
    9.22 +    if [[ $# -eq 0 ]]; then
    9.23 +        echo $(date '+%s')
    9.24 +    else
    9.25 +        local  stime=$1
    9.26 +        etime=$(date '+%s')
    9.27 +
    9.28 +        if [[ -z "$stime" ]]; then stime=$etime; fi
    9.29 +
    9.30 +        dt=$((etime - stime))
    9.31 +        ds=$((dt % 60))
    9.32 +        dm=$(((dt / 60) % 60))
    9.33 +        dh=$((dt / 3600))
    9.34 +        printf '%d:%02d:%02d' $dh $dm $ds
    9.35 +    fi
    9.36 +}
    9.37 +
    9.38 +#prin
    9.39 +#tmr1=$(timer)
    9.40 +#meta
    9.41 +#tmr2=$(timer)
    9.42 +#ektypwsi
    9.43 +#printf 'LALA %s %s\n' $((tmr2-tmr1)) $(timer $tmr1)
    9.44 +
    9.45 +
    9.46 +deleteSeaHotspots=`cat ${LOC}/DeleteInSea.sparql` # | sed 's/\"/\\\"/g'`
    9.47 +refinePartialSeaHotspots=`cat ${LOC}/Refine.sparql` # | sed 's/\"/\\\"/g'`
    9.48 +refineTimePersistence=`cat ${LOC}/TimePersistence.sparql` # | sed 's/\"/\\\"/g'`
    9.49 +
    9.50 +# Initialize
    9.51 +sudo service postgresql restart
    9.52 +echo "Dropping endpoint database";
    9.53 +sudo -u postgres dropdb ${DB}
    9.54 +echo "Creating endpoint database"
    9.55 +sudo -u postgres createdb ${DB} -T template_postgis
    9.56 +echo "restarting tomcat"
    9.57 +sudo service tomcat7 restart
    9.58 +
    9.59 +echo "initializing database"
    9.60 +echo "S D R TP" >>stderr.txt
    9.61 +
    9.62 + ../endpoint store ${ENDPOINT} N-Triples -u ${GRIDURL}
    9.63 +
    9.64 +#./scripts/endpoint query ${ENDPOINT} "SELECT (COUNT(*) AS ?C) WHERE {?s ?p ?o}" 
    9.65 +#sudo -u postgres psql -d endpoint -c 'CREATE INDEX datetime_values_idx_value ON datetime_values USING btree(value)';
    9.66 +#sudo -u postgres psql -d endpoint -c 'VACUUM ANALYZE;';
    9.67 +
    9.68 +
    9.69 +#echo "Continue?"
    9.70 +#read a
    9.71 +
    9.72 +
    9.73 +
    9.74 +
    9.75 +for h in `seq 0 23 `; do
    9.76 +    for m in `seq 0 15 45`; do
    9.77 +            time=`printf "%02d%02d\n" $h $m`
    9.78 +            time2=`printf "%02d:%02d\n" $h $m`
    9.79 +            file=${dataDir}${name}_${time}$suffix
    9.80 +#            file=${dataUrl}${name}_${time}$suffix
    9.81 +    
    9.82 +            # store file
    9.83 +            echo -n "storing " $file; echo; echo; 
    9.84 +	  # echo "Hotspot : " $h:$m >> stderr.txt
    9.85 +#            ${countTime} ./strabon -db endpoint store $file      
    9.86 +
    9.87 + tmr1=$(timer)
    9.88 +            ../endpoint store ${ENDPOINT} N-Triples -u ${file} 
    9.89 + tmr2=$(timer)
    9.90 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
    9.91 +           
    9.92 +	   # sudo -u postgres psql -d endpoint -c 'VACUUM ANALYZE;';
    9.93 +
    9.94 +            echo;echo;echo;echo "File ${file} stored!" >> ${logFile}
    9.95 +#            echo "Continue?"
    9.96 +#            read a
    9.97 +         
    9.98 +            # deleteSeaHotspots
    9.99 +            echo -n "Going to deleteSeaHotspots 2007-08-25T${time2}:00 " ;echo; echo; echo;
   9.100 +            query=`echo "${deleteSeaHotspots}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   9.101 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   9.102 +                sed "s/SENSOR/MSG2/g"`
   9.103 +#            ${countTime} ./strabon -db endpoint update "${query}"
   9.104 +
   9.105 +tmr1=$(timer)           
   9.106 +  ../endpoint update ${ENDPOINT} "${query}"  
   9.107 +            
   9.108 +tmr2=$(timer)
   9.109 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
   9.110 +
   9.111 +            echo;echo;echo;echo "File ${file} deleteSeaHotspots done!"
   9.112 +#            echo "Continue?"
   9.113 +#            read a
   9.114 +            
   9.115 +            # refinePartialSeaHotspots
   9.116 +            echo -n "refinePartialSeaHotspots 2007-08-25T${time2}:00 "  ; echo; echo ; echo;
   9.117 +            query=`echo "${refinePartialSeaHotspots}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   9.118 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   9.119 +                sed "s/SENSOR/MSG2/g"`
   9.120 +#            ${countTime} ./strabon -db endpoint update "${query}"
   9.121 +tmr1=$(timer)
   9.122 +              ../endpoint update ${ENDPOINT} "${query}"
   9.123 +            
   9.124 +tmr2=$(timer)
   9.125 +printf '%s ' $((tmr2-tmr1)) >>stderr.txt
   9.126 +
   9.127 +            echo "File ${file} refinePartialSeaHotspots done!"
   9.128 +#            echo "Continue?"
   9.129 +#            read a
   9.130 +
   9.131 +            # refineTimePersistence
   9.132 +            echo -n "Going to refineTimePersistence 2007-08-25T${time2}:00 ";echo;echo;echo; 
   9.133 +            min_acquisition_time=`date --date="2007-08-25 ${time2}:00 EEST -30 minutes" +%Y-%m-%dT%H:%m:00`
   9.134 +            query=`echo "${refineTimePersistence}" | sed "s/TIMESTAMP/2007-08-25T${time2}:00/g" | \
   9.135 +                sed "s/PROCESSING_CHAIN/DynamicThresholds/g" | \
   9.136 +                sed "s/SENSOR/MSG2/g" | \
   9.137 +                sed "s/ACQUISITIONS_IN_HALF_AN_HOUR/3.0/g" | \
   9.138 +                sed "s/MIN_ACQUISITION_TIME/${min_acquisition_time}/g"`
   9.139 +
   9.140 +#            echo "Query:"
   9.141 +#            echo "${query}"
   9.142 +#            echo "Continue?"
   9.143 +#            read a
   9.144 +#            ${countTime} ./strabon -db endpoint update "${query}"
   9.145 +#            ${countTime} ../endpoint update ${ENDPOINT} "${query}"
   9.146 +
   9.147 + sudo -u postgres psql -d ${DB} -c 'VACUUM ANALYZE;';
   9.148 +
   9.149 +
   9.150 +tmr1=$(timer)
   9.151 +              ../endpoint update ${ENDPOINT} "${query}"
   9.152 + tmr2=$(timer)
   9.153 +printf '%s \n' $((tmr2-tmr1)) >>stderr.txt
   9.154 +           
   9.155 +            echo;echo;echo;echo "File ${file} timePersistence done!"
   9.156 +#            echo "Continue?"
   9.157 +#            read a
   9.158 +    done
   9.159 +done
   9.160 +
   9.161 +
   9.162 +#for f in `ls /home/konstantina/noa-teleios/out_triples/HMSG2_IR_039_s7_070825_*.hotspots.n3`
   9.163 +#do
   9.164 +
   9.165 +#    echo "Store $f"
   9.166 +#	${countTime} ./scripts/strabon -db endpoint store $f
   9.167 +#	
   9.168 +#	
   9.169 +#done
   9.170 +