Strabon

changeset 25:47efa6a1ae1e

Changes for MonetDB added
author Giorgos Garbis <ggarbis@di.uoa.gr>
date Fri Feb 24 18:14:01 2012 +0200 (2012-02-24)
parents e8f9e1b518b4
children dbc0ec959bfa
files generaldb/pom.xml generaldb/src/main/java/org/openrdf/generaldb/managers/base/ManagerBase.java generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBConnectionFactory.java generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBSqlTable.java generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBSqlExprBuilder.java generaldb/src/main/java/org/openrdf/sail/generaldb/managers/HashManager.java generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TransTableManager.java generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TripleTableManager.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/Batch.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/HashBatch.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/TransactionTable.java generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTable.java monetdb/pom.xml monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBConnectionFactory.java monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBSqlTable.java monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBTripleRepository.java monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBEvaluation.java monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBEvaluationFactory.java monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBSqlExprBuilder.java postgis/src/main/java/org/openrdf/sail/postgis/PostGISConnectionFactory.java postgis/src/main/java/org/openrdf/sail/postgis/PostGISSqlTable.java postgis/src/main/java/org/openrdf/sail/postgis/PostGISTripleRepository.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISSqlExprBuilder.java query.sh runtime/pom.xml runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java runtime/src/main/java/eu/earthobservatory/runtime/monetdb/Strabon.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java
line diff
     1.1 --- a/generaldb/pom.xml	Fri Feb 24 15:58:11 2012 +0200
     1.2 +++ b/generaldb/pom.xml	Fri Feb 24 18:14:01 2012 +0200
     1.3 @@ -96,12 +96,12 @@
     1.4  	      <version>4.7</version>
     1.5  	      <scope>test</scope>
     1.6  	    </dependency>
     1.7 -	<!--
     1.8 +	
     1.9  	    <dependency>
    1.10  	    	<groupId>net.sf</groupId>
    1.11  	    	<artifactId>log4jdbc3</artifactId>
    1.12  	    	<version>1.2beta2</version>
    1.13  	    </dependency>
    1.14 -	-->
    1.15 +	
    1.16  	</dependencies>
    1.17  </project>
     2.1 --- a/generaldb/src/main/java/org/openrdf/generaldb/managers/base/ManagerBase.java	Fri Feb 24 15:58:11 2012 +0200
     2.2 +++ b/generaldb/src/main/java/org/openrdf/generaldb/managers/base/ManagerBase.java	Fri Feb 24 18:14:01 2012 +0200
     2.3 @@ -26,7 +26,7 @@
     2.4  	public static int MAX_QUEUE = 96 * 1024;
     2.5  
     2.6  	private static final boolean USE_THREAD = true;
     2.7 -
     2.8 +	
     2.9  	Exception exc;
    2.10  
    2.11  	private Logger logger = LoggerFactory.getLogger(ManagerBase.class);
     3.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBConnectionFactory.java	Fri Feb 24 15:58:11 2012 +0200
     3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBConnectionFactory.java	Fri Feb 24 18:14:01 2012 +0200
     3.3 @@ -117,8 +117,7 @@
     3.4  	public void setDataSource(DataSource ds) {
     3.5  		if (Tracer.isTraceEnabled()) {
     3.6  			this.ds = Tracer.traceDataSource(ds);
     3.7 -		}
     3.8 -		else {
     3.9 +		} else {
    3.10  			this.ds = ds;
    3.11  		}
    3.12  	}
    3.13 @@ -157,12 +156,10 @@
    3.14  			try {
    3.15  				if (triplesIndexed) {
    3.16  					tripleTableManager.createTripleIndexes();
    3.17 -				}
    3.18 -				else {
    3.19 +				} else {
    3.20  					tripleTableManager.dropTripleIndexes();
    3.21  				}
    3.22 -			}
    3.23 -			catch (SQLException e) {
    3.24 +			} catch (SQLException e) {
    3.25  				throw new RdbmsException(e);
    3.26  			}
    3.27  		}
    3.28 @@ -203,8 +200,7 @@
    3.29  				hashManager.setUriManager(uriManager);
    3.30  				hashManager.setIdSequence(ids);
    3.31  				hashManager.init();
    3.32 -			}
    3.33 -			else {
    3.34 +			} else {
    3.35  				ids = new LongIdSequence();
    3.36  				ids.init();
    3.37  				tables.setIdSequence(ids);
    3.38 @@ -245,8 +241,7 @@
    3.39  			tripleTableManager.initialize();
    3.40  			if (triplesIndexed) {
    3.41  				tripleTableManager.createTripleIndexes();
    3.42 -			}
    3.43 -			else {
    3.44 +			} else {
    3.45  				tripleTableManager.dropTripleIndexes();
    3.46  			}
    3.47  			bnodeManager.setTable(bnodeTable);
    3.48 @@ -257,29 +252,22 @@
    3.49  			literalManager.init();
    3.50  			vf.setLiteralManager(literalManager);
    3.51  			vf.setPredicateManager(predicateManager);
    3.52 -		}
    3.53 -		catch (SQLException e) {
    3.54 +		} catch (SQLException e) {
    3.55  			throw new RdbmsException(e);
    3.56  		}
    3.57  	}
    3.58  
    3.59 -	public boolean isWritable()
    3.60 -		throws SailException
    3.61 -	{
    3.62 +	public boolean isWritable() throws SailException {
    3.63  		try {
    3.64  			return !nsAndTableIndexes.isReadOnly();
    3.65 -		}
    3.66 -		catch (SQLException e) {
    3.67 +		} catch (SQLException e) {
    3.68  			throw new RdbmsException(e);
    3.69  		}
    3.70  	}
    3.71  
    3.72 -	public abstract SailConnection createConnection()
    3.73 -		throws SailException;
    3.74 +	public abstract SailConnection createConnection() throws SailException;
    3.75  
    3.76 -	public void shutDown()
    3.77 -		throws SailException
    3.78 -	{
    3.79 +	public void shutDown() throws SailException {
    3.80  		try {
    3.81  			if (tripleTableManager != null) {
    3.82  				tripleTableManager.close();
    3.83 @@ -312,19 +300,16 @@
    3.84  				nsAndTableIndexes.close();
    3.85  				nsAndTableIndexes = null;
    3.86  			}
    3.87 -		}
    3.88 -		catch (SQLException e) {
    3.89 +		} catch (SQLException e) {
    3.90  			throw new RdbmsException(e);
    3.91 -		}
    3.92 -		finally {
    3.93 +		} finally {
    3.94  			if (databaseLock != null) {
    3.95  				databaseLock.release();
    3.96  			}
    3.97  		}
    3.98  	}
    3.99  
   3.100 -	protected abstract Lock createDatabaseLock()
   3.101 -		throws SailException;
   3.102 +	protected abstract Lock createDatabaseLock() throws SailException;
   3.103  
   3.104  	protected abstract GeneralDBQueryBuilderFactory createQueryBuilderFactory();
   3.105  
   3.106 @@ -354,7 +339,7 @@
   3.107  	}
   3.108  
   3.109  	protected Connection getConnection()
   3.110 -		throws SQLException
   3.111 +		throws SQLException 
   3.112  	{
   3.113  		Connection conn;
   3.114  		if (user == null)
   3.115 @@ -365,7 +350,7 @@
   3.116  			conn = ds.getConnection(user, password);
   3.117  
   3.118  		return conn;
   3.119 -		//return new net.sf.log4jdbc.ConnectionSpy(conn);
   3.120 +//		return new net.sf.log4jdbc.ConnectionSpy(conn);
   3.121  	}
   3.122  
   3.123  }
     4.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBSqlTable.java	Fri Feb 24 15:58:11 2012 +0200
     4.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBSqlTable.java	Fri Feb 24 18:14:01 2012 +0200
     4.3 @@ -34,4 +34,18 @@
     4.4  	@Override
     4.5  	protected abstract String buildClear();
     4.6  
     4.7 +	public abstract String buildGeometryCollumn();
     4.8 +	
     4.9 +	public abstract String buildIndexOnGeometryCollumn();
    4.10 +
    4.11 +	public abstract String buildInsertGeometryValue();
    4.12 +	
    4.13 +	public abstract String buildInsertValue(String type);
    4.14 +	
    4.15 +	@Override
    4.16 +	protected abstract String buildCreateTemporaryTable(CharSequence columns) ;
    4.17 +	
    4.18 +	public abstract String buildDummyFromAndWhere(String fromDummy);
    4.19 +	
    4.20 +	public abstract String buildDynamicParameterInteger();
    4.21  }
     5.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java	Fri Feb 24 15:58:11 2012 +0200
     5.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/GeneralDBTripleRepository.java	Fri Feb 24 18:14:01 2012 +0200
     5.3 @@ -169,27 +169,9 @@
     5.4  	}
     5.5  
     5.6  	public synchronized void commit()
     5.7 -		throws SQLException, RdbmsException, InterruptedException
     5.8 +		throws SQLException, RdbmsException, InterruptedException 
     5.9  	{
    5.10 -		synchronized (queue) {
    5.11 -			while (!queue.isEmpty()) {
    5.12 -				insert(queue.removeFirst());
    5.13 -			}
    5.14 -		}
    5.15 -		manager.flush();
    5.16 -		conn.commit();
    5.17 -		conn.setAutoCommit(true);
    5.18 -		releaseLock();
    5.19 -		Lock writeLock = vf.tryIdWriteLock();
    5.20 -		try {
    5.21 -			vf.flush();
    5.22 -			statements.committed(writeLock != null);
    5.23 -		}
    5.24 -		finally {
    5.25 -			if (writeLock != null) {
    5.26 -				writeLock.release();
    5.27 -			}
    5.28 -		}
    5.29 +	
    5.30  	}
    5.31  
    5.32  	public void rollback()
    5.33 @@ -389,24 +371,8 @@
    5.34  		return query.toString();
    5.35  	}
    5.36  
    5.37 -	protected String buildCountQuery(RdbmsResource... ctxs)
    5.38 -		throws SQLException
    5.39 -	{
    5.40 -		String tableName = statements.getCombinedTableName();
    5.41 -		StringBuilder sb = new StringBuilder();
    5.42 -		sb.append("SELECT COUNT(*) FROM ");
    5.43 -		sb.append(tableName).append(" t");
    5.44 -		if (ctxs != null && ctxs.length > 0) {
    5.45 -			sb.append("\nWHERE ");
    5.46 -			for (int i = 0; i < ctxs.length; i++) {
    5.47 -				sb.append("t.ctx = ?");
    5.48 -				if (i < ctxs.length - 1) {
    5.49 -					sb.append(" OR ");
    5.50 -				}
    5.51 -			}
    5.52 -		}
    5.53 -		return sb.toString();
    5.54 -	}
    5.55 +	protected abstract String buildCountQuery(RdbmsResource... ctxs)
    5.56 +		throws SQLException;
    5.57  
    5.58  	protected abstract String buildDeleteQuery(String tableName, RdbmsResource subj, RdbmsURI pred, RdbmsValue obj,
    5.59  			RdbmsResource... ctxs)
     6.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Fri Feb 24 15:58:11 2012 +0200
     6.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Fri Feb 24 18:14:01 2012 +0200
     6.3 @@ -587,8 +587,8 @@
     6.4  			throws UnsupportedRdbmsOperatorException, RdbmsQueryEvaluationException;
     6.5  
     6.6  	protected String toQueryString(GeneralDBSelectQuery qb, QueryBindingSet bindings, List<Object> parameters)
     6.7 -			throws RdbmsException, UnsupportedRdbmsOperatorException
     6.8 -			{
     6.9 +		throws RdbmsException, UnsupportedRdbmsOperatorException
    6.10 +	{
    6.11  		GeneralDBQueryBuilder query = factory.createQueryBuilder();
    6.12  		if (qb.isDistinct()) {
    6.13  			query.distinct();
    6.14 @@ -712,7 +712,7 @@
    6.15  			logger.debug(parameters.toString());
    6.16  		}
    6.17  		return query.toString();
    6.18 -			}
    6.19 +	}
    6.20  
    6.21  	/**
    6.22  	 * Function used to locate all ColumnVars from the select's spatial constructs so that they can later 
     7.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBSqlExprBuilder.java	Fri Feb 24 15:58:11 2012 +0200
     7.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBSqlExprBuilder.java	Fri Feb 24 18:14:01 2012 +0200
     7.3 @@ -91,11 +91,7 @@
     7.4  		where.append(" AS ").append(column);
     7.5  	}
     7.6  
     7.7 -	public GeneralDBSqlExprBuilder number(Number time) {
     7.8 -		where.append(" ? ");
     7.9 -		parameters.add(time);
    7.10 -		return this;
    7.11 -	}
    7.12 +	public abstract GeneralDBSqlExprBuilder number(Number time) ;
    7.13  
    7.14  	public GeneralDBSqlCaseBuilder caseBegin() {
    7.15  		return new GeneralDBSqlCaseBuilder(this);
    7.16 @@ -226,16 +222,7 @@
    7.17  		return where.toString();
    7.18  	}
    7.19  
    7.20 -	public GeneralDBSqlExprBuilder varchar(String stringValue) {
    7.21 -		if (stringValue == null) {
    7.22 -			appendNull();
    7.23 -		}
    7.24 -		else {
    7.25 -			where.append(" ? ");
    7.26 -			parameters.add(stringValue);
    7.27 -		}
    7.28 -		return this;
    7.29 -	}
    7.30 +	public abstract GeneralDBSqlExprBuilder varchar(String stringValue) ;
    7.31  
    7.32  	public void addParameters(List<Object> params) {
    7.33  		parameters.addAll(params);
     8.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/HashManager.java	Fri Feb 24 15:58:11 2012 +0200
     8.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/HashManager.java	Fri Feb 24 18:14:01 2012 +0200
     8.3 @@ -44,9 +44,9 @@
     8.4  public class HashManager extends ManagerBase {
     8.5  
     8.6  	public static HashManager instance;
     8.7 -
     8.8 +	
     8.9  	private static final boolean USE_THREAD = true;
    8.10 -
    8.11 +	
    8.12  	private Logger logger = LoggerFactory.getLogger(HashManager.class);
    8.13  
    8.14  	private HashTable table;
    8.15 @@ -122,7 +122,6 @@
    8.16  				public void run()  {
    8.17  					try {
    8.18  						lookupThread(working, assignIds);
    8.19 -
    8.20  					}
    8.21  					catch (Exception e) {
    8.22  						exc = e;
     9.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TransTableManager.java	Fri Feb 24 15:58:11 2012 +0200
     9.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TransTableManager.java	Fri Feb 24 18:14:01 2012 +0200
     9.3 @@ -7,20 +7,20 @@
     9.4  
     9.5  import java.sql.Connection;
     9.6  import java.sql.SQLException;
     9.7 -import java.sql.Timestamp;
     9.8  import java.util.Collection;
     9.9  import java.util.HashMap;
    9.10  import java.util.Map;
    9.11  import java.util.concurrent.BlockingQueue;
    9.12  
    9.13 -import org.openrdf.sail.helpers.DefaultSailChangedEvent;
    9.14 +import org.openrdf.sail.generaldb.GeneralDBSqlTable;
    9.15  import org.openrdf.sail.generaldb.schema.Batch;
    9.16  import org.openrdf.sail.generaldb.schema.IdSequence;
    9.17 -import org.openrdf.sail.rdbms.schema.RdbmsTable;
    9.18 -import org.openrdf.sail.rdbms.schema.TableFactory;
    9.19  import org.openrdf.sail.generaldb.schema.TransactionTable;
    9.20  import org.openrdf.sail.generaldb.schema.TripleTable;
    9.21  import org.openrdf.sail.generaldb.schema.ValueTable;
    9.22 +import org.openrdf.sail.helpers.DefaultSailChangedEvent;
    9.23 +import org.openrdf.sail.rdbms.schema.RdbmsTable;
    9.24 +import org.openrdf.sail.rdbms.schema.TableFactory;
    9.25  import org.openrdf.sail.rdbms.schema.ValueTypes;
    9.26  
    9.27  /**
    9.28 @@ -306,14 +306,14 @@
    9.29  
    9.30  	private String getEmptyTableName() {
    9.31  		StringBuilder sb = new StringBuilder(256);
    9.32 +		GeneralDBSqlTable temp = (GeneralDBSqlTable)temporaryTable;
    9.33  		sb.append("(");
    9.34  		sb.append("SELECT ");
    9.35  		sb.append(getZeroBigInt()).append(" AS ctx, ");
    9.36  		sb.append(getZeroBigInt()).append(" AS subj, ");
    9.37  		sb.append(getZeroBigInt()).append(" AS pred, ");
    9.38  		sb.append(getZeroBigInt()).append(" AS obj ");
    9.39 -		sb.append(fromDummy);
    9.40 -		sb.append("\nWHERE 1=0");
    9.41 +		sb.append(temp.buildDummyFromAndWhere(fromDummy));
    9.42  		sb.append(")");
    9.43  		return sb.toString();
    9.44  	}
    10.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TripleTableManager.java	Fri Feb 24 15:58:11 2012 +0200
    10.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/managers/TripleTableManager.java	Fri Feb 24 18:14:01 2012 +0200
    10.3 @@ -41,7 +41,7 @@
    10.4  	private static final String OTHER_TRIPLES_TABLE = "TRIPLES";
    10.5  
    10.6  	private static final boolean USE_THREAD = true;
    10.7 -
    10.8 +	
    10.9  	public static int MAX_TABLES = Integer.MAX_VALUE;// 1000;
   10.10  
   10.11  	public static final boolean INDEX_TRIPLES = true;
    11.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/Batch.java	Fri Feb 24 15:58:11 2012 +0200
    11.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/Batch.java	Fri Feb 24 18:14:01 2012 +0200
    11.3 @@ -1,10 +1,11 @@
    11.4  
    11.5  package org.openrdf.sail.generaldb.schema;
    11.6  
    11.7 -import org.openrdf.sail.rdbms.schema.RdbmsTable;
    11.8  import java.sql.PreparedStatement;
    11.9  import java.sql.SQLException;
   11.10  
   11.11 +import org.openrdf.sail.rdbms.schema.RdbmsTable;
   11.12 +
   11.13  
   11.14  
   11.15  public class Batch {
   11.16 @@ -59,7 +60,7 @@
   11.17  	public void setObject(int parameterIndex, Object x)
   11.18  		throws SQLException
   11.19  	{
   11.20 -		insertBatch.setObject(parameterIndex, x);
   11.21 +			insertBatch.setObject(parameterIndex, x);
   11.22  	}
   11.23  
   11.24  	public void setString(int parameterIndex, String x)
   11.25 @@ -69,14 +70,14 @@
   11.26  	}
   11.27  	
   11.28  	public void setBytes(int parameterIndex, byte[] x)
   11.29 -	throws SQLException
   11.30 +		throws SQLException
   11.31  	{
   11.32  //		byte[] part1 = "ST_GeomFromWKB(".getBytes();
   11.33  //		byte[] part3 = ")".getBytes();
   11.34  //		byte[] all = ArrayUtils.addAll(ArrayUtils.addAll(part1,x),part3);
   11.35  		insertBatch.setBytes(parameterIndex, x);
   11.36  	}
   11.37 -
   11.38 +	
   11.39  	public void addBatch()
   11.40  		throws SQLException
   11.41  	{
    12.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java	Fri Feb 24 15:58:11 2012 +0200
    12.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java	Fri Feb 24 18:14:01 2012 +0200
    12.3 @@ -2,6 +2,7 @@
    12.4  package org.openrdf.sail.generaldb.schema;
    12.5  
    12.6  
    12.7 +import org.openrdf.sail.generaldb.GeneralDBSqlTable;
    12.8  import org.openrdf.sail.rdbms.schema.RdbmsTable;
    12.9  import java.sql.PreparedStatement;
   12.10  import java.sql.ResultSet;
   12.11 @@ -224,6 +225,7 @@
   12.12  	//			PreparedStatement insertStmt = conn.prepareStatement(psqlInsertLine);
   12.13  	//			
   12.14  	//			System.out.println("//////////////////////// INCONSISTENT" + geom);
   12.15 +	//			
   12.16  	//			[B@62f4739
   12.17  	//			insertStmt.setLong(1, id.longValue());
   12.18  	//			//insertStmt.setString(2, constraint);
   12.19 @@ -261,7 +263,7 @@
   12.20  
   12.21  
   12.22  	public synchronized void insert(Number id, Integer srid,/*String constraint, Timestamp interval_start, Timestamp interval_end,*/ byte[] geom)
   12.23 -	throws SQLException, InterruptedException, NullPointerException
   12.24 +		throws SQLException, InterruptedException, NullPointerException
   12.25  	{
   12.26  
   12.27  	
   12.28 @@ -285,6 +287,7 @@
   12.29  		}
   12.30  		batch.setObject(3, srid); //adding original srid-constant
   12.31  		batch.setObject(4, srid);
   12.32 +		
   12.33  		batch.addBatch();
   12.34  		queue(batch);
   12.35  
   12.36 @@ -479,7 +482,7 @@
   12.37  	 * CURRENT FIELDS: id, value (byte[] form of Polyhedron, strdfgeo(wkt version of Polyhedron)
   12.38  	 */
   12.39  	protected void createTable(RdbmsTable table)
   12.40 -	throws SQLException
   12.41 +		throws SQLException
   12.42  	{
   12.43  		StringBuilder sb = new StringBuilder();
   12.44  		sb.append("  id ").append(sql(idType, -1)).append(" NOT NULL,");
   12.45 @@ -500,19 +503,12 @@
   12.46  
   12.47  		//sb.append("  constr ").append("BYTEA");
   12.48  		table.createTable(sb);
   12.49 -		// george 
   12.50 -		//refixed - Manos. Do not alter
   12.51 -//		String extension = "SELECT AddGeometryColumn('','geo_values','strdfgeo',32630,'GEOMETRY',2)";
   12.52 -		String extension = "SELECT AddGeometryColumn('','geo_values','strdfgeo',4326,'GEOMETRY',2)";
   12.53 -//		String extension = "ALTER TABLE geo_values ADD strdfgeo GEOMETRY";
   12.54 +		
   12.55 +		String extension = ((GeneralDBSqlTable)table).buildGeometryCollumn();
   12.56  		table.execute(extension);
   12.57 -		// george
   12.58 -		//refixed - Manos. Do not alter
   12.59 -		table.execute("CREATE INDEX geoindex ON geo_values USING GIST (strdfgeo)");
   12.60 -//		table.execute("CREATE INDEX geoindex ON geo_values (strdfgeo)");
   12.61 -		//System.out.println("------------------------");
   12.62 -		//System.out.println(sb);
   12.63 -		//System.out.println("------------------------");
   12.64 +		
   12.65 +		String index = ((GeneralDBSqlTable)table).buildIndexOnGeometryCollumn();
   12.66 +		table.execute(index);
   12.67  	}
   12.68  
   12.69  	/**
   12.70 @@ -540,10 +536,8 @@
   12.71  
   12.72  		table.createTemporaryTable(sb);
   12.73  //		String extension = "SELECT AddGeometryColumn('','geo_values','value',32630,'GEOMETRY',2)";
   12.74 -		String extension = "SELECT AddGeometryColumn('','geo_values','value',4326,'GEOMETRY',2)";
   12.75 +		String extension = ((GeneralDBSqlTable)table).buildGeometryCollumn();
   12.76  		table.execute(extension);
   12.77  	}
   12.78 -	
   12.79 -
   12.80  }
   12.81  
    13.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/HashBatch.java	Fri Feb 24 15:58:11 2012 +0200
    13.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/HashBatch.java	Fri Feb 24 18:14:01 2012 +0200
    13.3 @@ -5,6 +5,7 @@
    13.4   */
    13.5  package org.openrdf.sail.generaldb.schema;
    13.6  
    13.7 +import java.math.BigDecimal;
    13.8  import java.sql.SQLException;
    13.9  import java.util.ArrayList;
   13.10  import java.util.List;
    14.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/TransactionTable.java	Fri Feb 24 15:58:11 2012 +0200
    14.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/TransactionTable.java	Fri Feb 24 18:14:01 2012 +0200
    14.3 @@ -12,6 +12,7 @@
    14.4  import java.util.concurrent.BlockingQueue;
    14.5  
    14.6  import org.openrdf.sail.rdbms.schema.RdbmsTable;
    14.7 +import org.openrdf.sail.generaldb.GeneralDBSqlTable;
    14.8  import org.openrdf.sail.helpers.DefaultSailChangedEvent;
    14.9  
   14.10  /**
   14.11 @@ -232,6 +233,9 @@
   14.12  	protected String buildInsert(String tableName, boolean predColumnPresent)
   14.13  		throws SQLException
   14.14  	{
   14.15 +		GeneralDBSqlTable temp = (GeneralDBSqlTable)temporary;
   14.16 +		String dynVarInt = temp.buildDynamicParameterInteger();
   14.17 +		
   14.18  		StringBuilder sb = new StringBuilder();
   14.19  		sb.append("INSERT INTO ").append(tableName);
   14.20  		sb.append(" (ctx, subj, ");
   14.21 @@ -241,9 +245,10 @@
   14.22  		//FIXME edit to accommodate temporal
   14.23  		sb.append("obj, expl)\n");
   14.24  //		sb.append("obj, expl,interval_start,interval_end)\n");
   14.25 -		sb.append("VALUES (?, ?, ");
   14.26 +		 
   14.27 +		sb.append("VALUES ( "+dynVarInt+", "+dynVarInt+", ");
   14.28  		if (predColumnPresent) {
   14.29 -			sb.append("?, ");
   14.30 +			sb.append(dynVarInt+", ");
   14.31  		}
   14.32  		sb.append("?, ?)");
   14.33  //		sb.append("?, ?, ?, ?)");
    15.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTable.java	Fri Feb 24 15:58:11 2012 +0200
    15.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/ValueTable.java	Fri Feb 24 18:14:01 2012 +0200
    15.3 @@ -13,6 +13,7 @@
    15.4  import java.util.List;
    15.5  import java.util.concurrent.BlockingQueue;
    15.6  
    15.7 +import org.openrdf.sail.generaldb.GeneralDBSqlTable;
    15.8  import org.openrdf.sail.rdbms.schema.RdbmsTable;
    15.9  
   15.10  
   15.11 @@ -125,8 +126,13 @@
   15.12  		throws SQLException
   15.13  	{
   15.14  		StringBuilder sb = new StringBuilder();
   15.15 +		/****************/
   15.16 +//		sb.append("INSERT INTO ").append(getInsertTable().getName());
   15.17 +//		sb.append(" (id, value) VALUES (?, ?)");
   15.18  		sb.append("INSERT INTO ").append(getInsertTable().getName());
   15.19 -		sb.append(" (id, value) VALUES (?, ?)");
   15.20 +		GeneralDBSqlTable table = (GeneralDBSqlTable)getInsertTable();
   15.21 +		sb.append(table.buildInsertValue(sql(sqlType, length)));
   15.22 +		/*******************/
   15.23  		INSERT = sb.toString();
   15.24  		sb.delete(0, sb.length());
   15.25  		sb.append("DELETE FROM ").append(table.getName()).append("\n");
    16.1 --- a/monetdb/pom.xml	Fri Feb 24 15:58:11 2012 +0200
    16.2 +++ b/monetdb/pom.xml	Fri Feb 24 18:14:01 2012 +0200
    16.3 @@ -95,17 +95,18 @@
    16.4  	      <version>4.7</version>
    16.5  	      <scope>test</scope>
    16.6  	    </dependency>
    16.7 +	    
    16.8  	    <dependency>
    16.9  	    	<groupId>monetdb</groupId>
   16.10  	    	<artifactId>jdbcclient</artifactId>
   16.11 -	    	<version>3.1.0</version>
   16.12 +	    	<version>3.2.0</version>
   16.13  	    </dependency>
   16.14 -	<!--
   16.15 +
   16.16  	    <dependency>
   16.17  	    	<groupId>net.sf</groupId>
   16.18  	    	<artifactId>log4jdbc3</artifactId>
   16.19  	    	<version>1.2beta2</version>
   16.20  	    </dependency>
   16.21 -	-->
   16.22 +	
   16.23  	</dependencies>
   16.24  </project>
    17.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBConnectionFactory.java	Fri Feb 24 15:58:11 2012 +0200
    17.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBConnectionFactory.java	Fri Feb 24 18:14:01 2012 +0200
    17.3 @@ -6,6 +6,7 @@
    17.4  package org.openrdf.sail.monetdb;
    17.5  
    17.6  import static java.sql.Connection.TRANSACTION_READ_COMMITTED;
    17.7 +import static java.sql.Connection.TRANSACTION_SERIALIZABLE;
    17.8  import info.aduna.concurrent.locks.Lock;
    17.9  
   17.10  import java.sql.Connection;
   17.11 @@ -71,9 +72,15 @@
   17.12  		try {
   17.13  			Connection db = getConnection();
   17.14  			db.setAutoCommit(true);
   17.15 -			if (db.getTransactionIsolation() != TRANSACTION_READ_COMMITTED) {
   17.16 -				db.setTransactionIsolation(TRANSACTION_READ_COMMITTED);
   17.17 +			/**************************/
   17.18 +//			if (db.getTransactionIsolation() != TRANSACTION_READ_COMMITTED) {
   17.19 +//				db.setTransactionIsolation(TRANSACTION_READ_COMMITTED);
   17.20 +//			}
   17.21 +			// giorgos
   17.22 +			if (db.getTransactionIsolation() != TRANSACTION_SERIALIZABLE) {
   17.23 +				db.setTransactionIsolation(TRANSACTION_SERIALIZABLE);
   17.24  			}
   17.25 +			/***********************/
   17.26  			TripleManager tripleManager = new TripleManager();
   17.27  			GeneralDBTripleRepository s = new MonetDBTripleRepository();
   17.28  			s.setTripleManager(tripleManager);
   17.29 @@ -121,6 +128,7 @@
   17.30  			optimizer.setHashTable(hashTable);
   17.31  			conn.setRdbmsQueryOptimizer(optimizer);
   17.32  			conn.setLockManager(lock);
   17.33 +			
   17.34  			return conn;
   17.35  		}
   17.36  		catch (SQLException e) {
    18.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBSqlTable.java	Fri Feb 24 15:58:11 2012 +0200
    18.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBSqlTable.java	Fri Feb 24 18:14:01 2012 +0200
    18.3 @@ -32,7 +32,45 @@
    18.4  	@Override
    18.5  	protected String buildClear() {
    18.6  //		return "TRUNCATE " + getName();
    18.7 -		return null; // TODO vacuum analyze in monetdb
    18.8 +		return "DELETE FROM "+ getName();
    18.9  	}
   18.10  
   18.11 +	@Override
   18.12 +	public String buildGeometryCollumn() {
   18.13 +		return "ALTER TABLE geo_values ADD strdfgeo GEOMETRY";
   18.14 +	}
   18.15 +	
   18.16 +	@Override
   18.17 +	public String buildIndexOnGeometryCollumn() {
   18.18 +		return "CREATE INDEX geoindex ON geo_values (strdfgeo)";
   18.19 +	}
   18.20 +	
   18.21 +	@Override
   18.22 +	public String buildInsertGeometryValue() { // FIXME for srid
   18.23 +		return " (id, strdfgeo) VALUES (CAST(? AS INTEGER),GeomFromWKB(?))";
   18.24 +	}
   18.25 +	
   18.26 +	@Override
   18.27 +	public String buildInsertValue(String type) {
   18.28 +		return " (id, value) VALUES (CAST(? AS INTEGER), CAST( ? AS "+type+"))";
   18.29 +	}
   18.30 +	
   18.31 +	@Override
   18.32 +	protected String buildCreateTemporaryTable(CharSequence columns) {
   18.33 +		StringBuilder sb = new StringBuilder();
   18.34 +		sb.append("CREATE TEMPORARY TABLE ").append(getName());
   18.35 +		sb.append(" (\n").append(columns).append(")");
   18.36 +		sb.append(" ON COMMIT PRESERVE ROWS ");
   18.37 +		return sb.toString();
   18.38 +	}
   18.39 +	
   18.40 +	@Override
   18.41 +	public String buildDummyFromAndWhere(String fromDummy) {
   18.42 +		return "";
   18.43 +	}
   18.44 +	
   18.45 +	@Override
   18.46 +	public String buildDynamicParameterInteger() {
   18.47 +			return "CAST( ? AS INTEGER)";
   18.48 +	}
   18.49  }
   18.50 \ No newline at end of file
    19.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBTripleRepository.java	Fri Feb 24 15:58:11 2012 +0200
    19.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/MonetDBTripleRepository.java	Fri Feb 24 18:14:01 2012 +0200
    19.3 @@ -5,17 +5,19 @@
    19.4   */
    19.5  package org.openrdf.sail.monetdb;
    19.6  
    19.7 +import info.aduna.concurrent.locks.Lock;
    19.8 +
    19.9  import java.sql.SQLException;
   19.10  
   19.11  import org.openrdf.sail.generaldb.GeneralDBTripleRepository;
   19.12  import org.openrdf.sail.rdbms.exceptions.RdbmsException;
   19.13 -import org.openrdf.sail.rdbms.managers.TransTableManager;
   19.14  import org.openrdf.sail.rdbms.model.RdbmsResource;
   19.15  import org.openrdf.sail.rdbms.model.RdbmsURI;
   19.16  import org.openrdf.sail.rdbms.model.RdbmsValue;
   19.17 -import org.openrdf.sail.rdbms.schema.BNodeTable;
   19.18 -import org.openrdf.sail.rdbms.schema.LiteralTable;
   19.19 -import org.openrdf.sail.rdbms.schema.URITable;
   19.20 +import org.openrdf.sail.generaldb.schema.BNodeTable;
   19.21 +import org.openrdf.sail.generaldb.schema.LiteralTable;
   19.22 +import org.openrdf.sail.generaldb.schema.URITable;
   19.23 +
   19.24  
   19.25  /**
   19.26   * Facade to {@link GeneralDBTransTableManager}, {@link URITable}, {@link BNodeTable} and
   19.27 @@ -44,7 +46,7 @@
   19.28  		if (ctxs != null && ctxs.length > 0) {
   19.29  			sb.append(" (");
   19.30  			for (int i = 0; i < ctxs.length; i++) {
   19.31 -				sb.append("ctx = ?");
   19.32 +				sb.append("ctx = CAST( ? AS INTEGER) ");
   19.33  				if (i < ctxs.length - 1) {
   19.34  					sb.append(" OR ");
   19.35  				}
   19.36 @@ -52,21 +54,67 @@
   19.37  			sb.append(") AND ");
   19.38  		}
   19.39  		if (subj != null) {
   19.40 -			sb.append("subj = ? ");
   19.41 +			sb.append("subj = CAST( ? AS INTEGER) ");
   19.42  			sb.append(" AND ");
   19.43  		}
   19.44  		if (pred != null) {
   19.45 -			sb.append("pred = ? ");
   19.46 +			sb.append("pred = CAST( ? AS INTEGER) ");
   19.47  			sb.append(" AND ");
   19.48  		}
   19.49  		if (obj != null) {
   19.50 -			sb.append("obj = ?");
   19.51 +			sb.append("obj = CAST( ? AS INTEGER) ");
   19.52  			sb.append(" AND ");
   19.53  		}
   19.54  		sb.append(" 1=1 ");
   19.55  		return sb.toString();
   19.56  	}
   19.57  	
   19.58 +	@Override
   19.59 +	public synchronized void commit()
   19.60 +		throws SQLException, RdbmsException, InterruptedException
   19.61 +	{
   19.62 +		synchronized (queue) {
   19.63 +			while (!queue.isEmpty()) {
   19.64 +				insert(queue.removeFirst());
   19.65 +			}
   19.66 +		}
   19.67 +		manager.flush();
   19.68 +		if ( !conn.getAutoCommit() )
   19.69 +			conn.commit();
   19.70 +		conn.setAutoCommit(true);
   19.71 +		releaseLock();
   19.72 +		Lock writeLock = vf.tryIdWriteLock();
   19.73 +		try {
   19.74 +			vf.flush();
   19.75 +			statements.committed(writeLock != null);
   19.76 +		}
   19.77 +		finally {
   19.78 +			if (writeLock != null) {
   19.79 +				writeLock.release();
   19.80 +			}
   19.81 +		}
   19.82 +	}
   19.83 +
   19.84 +	@Override
   19.85 +	protected String buildCountQuery(RdbmsResource... ctxs)
   19.86 +		throws SQLException
   19.87 +	{
   19.88 +		String tableName = statements.getCombinedTableName();
   19.89 +		StringBuilder sb = new StringBuilder();
   19.90 +		sb.append("SELECT COUNT(*) FROM ");
   19.91 +		sb.append(tableName).append(" t");
   19.92 +		if (ctxs != null && ctxs.length > 0) {
   19.93 +			sb.append("\nWHERE ");
   19.94 +			for (int i = 0; i < ctxs.length; i++) {
   19.95 +				sb.append("t.ctx = CAST( ? AS INTEGER) ");
   19.96 +				if (i < ctxs.length - 1) {
   19.97 +					sb.append(" OR ");
   19.98 +				}
   19.99 +			}
  19.100 +		}
  19.101 +		return sb.toString();
  19.102 +	}
  19.103 +	
  19.104  //	private String buildWhere(String tableName, StringBuilder sb, RdbmsResource subj, RdbmsURI pred, RdbmsValue obj,
  19.105  //			RdbmsResource... ctxs)
  19.106  //	{
    20.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBEvaluation.java	Fri Feb 24 15:58:11 2012 +0200
    20.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBEvaluation.java	Fri Feb 24 18:14:01 2012 +0200
    20.3 @@ -18,12 +18,13 @@
    20.4  import org.openrdf.query.Dataset;
    20.5  import org.openrdf.query.QueryEvaluationException;
    20.6  import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    20.7 -import org.openrdf.sail.monetdb.iteration.MonetDBBindingIteration;
    20.8  import org.openrdf.sail.generaldb.GeneralDBTripleRepository;
    20.9  import org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar;
   20.10  import org.openrdf.sail.generaldb.algebra.GeneralDBSelectQuery;
   20.11  import org.openrdf.sail.generaldb.evaluation.GeneralDBEvaluation;
   20.12  import org.openrdf.sail.generaldb.evaluation.GeneralDBQueryBuilderFactory;
   20.13 +import org.openrdf.sail.generaldb.iteration.GeneralDBBindingIteration;
   20.14 +import org.openrdf.sail.monetdb.iteration.MonetDBBindingIteration;
   20.15  import org.openrdf.sail.rdbms.exceptions.RdbmsException;
   20.16  import org.openrdf.sail.rdbms.exceptions.RdbmsQueryEvaluationException;
   20.17  import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException;
   20.18 @@ -56,6 +57,9 @@
   20.19  		try {
   20.20  			QueryBindingSet bindings = new QueryBindingSet(b);
   20.21  			String query = toQueryString(qb, bindings, parameters);
   20.22 +			// FIXME MonetDB doesn't handle outer joins correctly so I replace them with inner
   20.23 +			query = query.replace("LEFT", "INNER");
   20.24 +			
   20.25  			try {
   20.26  				Connection conn = triples.getConnection();
   20.27  				PreparedStatement stmt = conn.prepareStatement(query);
   20.28 @@ -69,7 +73,7 @@
   20.29  					}
   20.30  				}
   20.31  				Collection<GeneralDBColumnVar> proj = qb.getProjections();
   20.32 -				MonetDBBindingIteration result = new MonetDBBindingIteration(stmt);
   20.33 +				GeneralDBBindingIteration result = new MonetDBBindingIteration(stmt);
   20.34  				result.setProjections(proj);
   20.35  				result.setBindings(bindings);
   20.36  				result.setValueFactory(vf);
    21.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBEvaluationFactory.java	Fri Feb 24 15:58:11 2012 +0200
    21.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBEvaluationFactory.java	Fri Feb 24 18:14:01 2012 +0200
    21.3 @@ -1,25 +1,8 @@
    21.4  package org.openrdf.sail.monetdb.evaluation;
    21.5  
    21.6 -import static java.sql.Connection.TRANSACTION_READ_COMMITTED;
    21.7 -
    21.8 -import java.sql.Connection;
    21.9 -import java.sql.SQLException;
   21.10 -
   21.11  import org.openrdf.query.Dataset;
   21.12 -import org.openrdf.sail.SailConnection;
   21.13 -import org.openrdf.sail.SailException;
   21.14 -import org.openrdf.sail.helpers.DefaultSailChangedEvent;
   21.15 -import org.openrdf.sail.generaldb.GeneralDBConnection;
   21.16 -import org.openrdf.sail.generaldb.GeneralDBTripleRepository;
   21.17  import org.openrdf.sail.generaldb.evaluation.GeneralDBEvaluation;
   21.18  import org.openrdf.sail.generaldb.evaluation.GeneralDBEvaluationFactory;
   21.19 -import org.openrdf.sail.generaldb.evaluation.GeneralDBQueryBuilderFactory;
   21.20 -import org.openrdf.sail.generaldb.optimizers.GeneralDBQueryOptimizer;
   21.21 -import org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizerFactory;
   21.22 -import org.openrdf.sail.rdbms.exceptions.RdbmsException;
   21.23 -import org.openrdf.sail.generaldb.managers.TransTableManager;
   21.24 -import org.openrdf.sail.generaldb.managers.TripleManager;
   21.25 -import org.openrdf.sail.rdbms.schema.TableFactory;
   21.26  
   21.27  public class MonetDBEvaluationFactory extends GeneralDBEvaluationFactory{
   21.28  
    22.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBSqlExprBuilder.java	Fri Feb 24 15:58:11 2012 +0200
    22.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBSqlExprBuilder.java	Fri Feb 24 18:14:01 2012 +0200
    22.3 @@ -62,13 +62,47 @@
    22.4  		return this;
    22.5  	}
    22.6  
    22.7 -// TODO should this be overriden ??
    22.8 -//	public MonetDBSqlExprBuilder number(Number time) {
    22.9 -//		where.append(" ? ");
   22.10 -//		parameters.add(time);
   22.11 -//		return this;
   22.12 -//	}
   22.13 -
   22.14 +	public GeneralDBSqlExprBuilder number(Number time) {
   22.15 +		String dataType = null;
   22.16 +		
   22.17 +		if ( time instanceof Integer ){
   22.18 +			dataType = "INTEGER";
   22.19 +		} else if (time instanceof Long ) {
   22.20 +			dataType = "BIGINT";
   22.21 +		} else if ( time instanceof BigDecimal ) {
   22.22 +			int precision = ((BigDecimal)time).precision();
   22.23 +			int scale = ((BigDecimal)time).scale();
   22.24 +			dataType = "DECIMAL(,"+precision+","+scale+")";
   22.25 +		} else if ( time instanceof Byte ) {
   22.26 +			dataType = "TINYINT";
   22.27 +		} else if ( time instanceof Double ) {
   22.28 +			dataType = "DOUBLE";
   22.29 +		} else if ( time instanceof Float ) {
   22.30 +			dataType = "REAL";
   22.31 +		} else if ( time instanceof Short ) {
   22.32 +			dataType = "SMALLINT";
   22.33 +		} else {
   22.34 +			where.append(" ? ");
   22.35 +			parameters.add(time);
   22.36 +			return this;
   22.37 +		}
   22.38 +		
   22.39 +		where.append(" CAST( ? AS "+dataType+") ");
   22.40 +		parameters.add(time);
   22.41 +		return this;
   22.42 +	}
   22.43 + 
   22.44 +	public GeneralDBSqlExprBuilder varchar(String stringValue) {
   22.45 +		if (stringValue == null) {
   22.46 +			appendNull();
   22.47 +		}
   22.48 +		else {
   22.49 +			where.append(" CAST( ? AS STRING) ");
   22.50 +			parameters.add(stringValue);
   22.51 +		}
   22.52 +		return this;
   22.53 +	}
   22.54 +	
   22.55  //	// TODO should this be overriden ??
   22.56  //	protected String getSqlNull() {
   22.57  ////		return "false"; // FIXME
    23.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/PostGISConnectionFactory.java	Fri Feb 24 15:58:11 2012 +0200
    23.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/PostGISConnectionFactory.java	Fri Feb 24 18:14:01 2012 +0200
    23.3 @@ -23,12 +23,12 @@
    23.4  import org.openrdf.sail.helpers.DefaultSailChangedEvent;
    23.5  import org.openrdf.sail.postgis.evaluation.PostGISEvaluationFactory;
    23.6  import org.openrdf.sail.postgis.evaluation.PostGISQueryBuilderFactory;
    23.7 +import org.openrdf.sail.rdbms.util.DatabaseLockManager;
    23.8  import org.openrdf.sail.rdbms.exceptions.RdbmsException;
    23.9  import org.openrdf.sail.generaldb.managers.TransTableManager;
   23.10  import org.openrdf.sail.generaldb.managers.TripleManager;
   23.11  import org.openrdf.sail.rdbms.schema.TableFactory;
   23.12  import org.openrdf.sail.generaldb.schema.ValueTableFactory;
   23.13 -import org.openrdf.sail.rdbms.util.DatabaseLockManager;
   23.14  
   23.15  /**
   23.16   * Responsible to initialise and wire all components together that will be
    24.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/PostGISSqlTable.java	Fri Feb 24 15:58:11 2012 +0200
    24.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/PostGISSqlTable.java	Fri Feb 24 18:14:01 2012 +0200
    24.3 @@ -32,4 +32,45 @@
    24.4  	protected String buildClear() {
    24.5  		return "TRUNCATE " + getName();
    24.6  	}
    24.7 +	
    24.8 +	@Override
    24.9 +	public String buildGeometryCollumn() {
   24.10 +		return "SELECT AddGeometryColumn('','geo_values','strdfgeo',4326,'GEOMETRY',2)";
   24.11 +	}
   24.12 +	
   24.13 +	@Override
   24.14 +	public String buildIndexOnGeometryCollumn() {
   24.15 +		return "CREATE INDEX geoindex ON geo_values USING GIST (strdfgeo)";
   24.16 +	}
   24.17 +	
   24.18 +	@Override
   24.19 +	public String buildInsertGeometryValue() {
   24.20 +		return " (id, strdfgeo,srid) VALUES (?,ST_Transform(ST_GeomFromWKB(?,?),4326),?)";
   24.21 +	}
   24.22 +	
   24.23 +	@Override
   24.24 +	public String buildInsertValue(String type) {
   24.25 +		return " (id, value) VALUES ( ?, ?) ";
   24.26 +	}
   24.27 +	
   24.28 +	@Override
   24.29 +	protected String buildCreateTemporaryTable(CharSequence columns) {
   24.30 +		StringBuilder sb = new StringBuilder();
   24.31 +		sb.append("CREATE TEMPORARY TABLE ").append(getName());
   24.32 +		sb.append(" (\n").append(columns).append(")");
   24.33 +		return sb.toString();
   24.34 +	}
   24.35 +	
   24.36 +	@Override
   24.37 +	public String buildDummyFromAndWhere(String fromDummy) {
   24.38 +		StringBuilder sb = new StringBuilder(256);
   24.39 +		sb.append(fromDummy); 
   24.40 +		sb.append("\nWHERE 1=0");
   24.41 +		return sb.toString();
   24.42 +	}
   24.43 +	
   24.44 +	@Override
   24.45 +	public String buildDynamicParameterInteger() {
   24.46 +			return "?";
   24.47 +	}
   24.48  }
   24.49 \ No newline at end of file
    25.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/PostGISTripleRepository.java	Fri Feb 24 15:58:11 2012 +0200
    25.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/PostGISTripleRepository.java	Fri Feb 24 18:14:01 2012 +0200
    25.3 @@ -6,9 +6,10 @@
    25.4  package org.openrdf.sail.postgis;
    25.5  
    25.6  
    25.7 +import info.aduna.concurrent.locks.Lock;
    25.8 +
    25.9  import java.sql.SQLException;
   25.10  
   25.11 -
   25.12  import org.openrdf.sail.generaldb.GeneralDBTripleRepository;
   25.13  import org.openrdf.sail.rdbms.exceptions.RdbmsException;
   25.14  import org.openrdf.sail.rdbms.model.RdbmsResource;
   25.15 @@ -65,8 +66,48 @@
   25.16  		return sb.toString();
   25.17  	}	
   25.18  	
   25.19 -
   25.20 +	@Override
   25.21 +	public synchronized void commit()
   25.22 +		throws SQLException, RdbmsException, InterruptedException
   25.23 +	{
   25.24 +		synchronized (queue) {
   25.25 +			while (!queue.isEmpty()) {
   25.26 +				insert(queue.removeFirst());
   25.27 +			}
   25.28 +		}
   25.29 +		manager.flush();
   25.30 +		conn.commit();
   25.31 +		conn.setAutoCommit(true);
   25.32 +		releaseLock();
   25.33 +		Lock writeLock = vf.tryIdWriteLock();
   25.34 +		try {
   25.35 +			vf.flush();
   25.36 +			statements.committed(writeLock != null);
   25.37 +		}
   25.38 +		finally {
   25.39 +			if (writeLock != null) {
   25.40 +				writeLock.release();
   25.41 +			}
   25.42 +		}
   25.43 +	}
   25.44  	
   25.45 -	
   25.46 -
   25.47 +	@Override
   25.48 +	protected String buildCountQuery(RdbmsResource... ctxs)
   25.49 +		throws SQLException
   25.50 +	{
   25.51 +		String tableName = statements.getCombinedTableName();
   25.52 +		StringBuilder sb = new StringBuilder();
   25.53 +		sb.append("SELECT COUNT(*) FROM ");
   25.54 +		sb.append(tableName).append(" t");
   25.55 +		if (ctxs != null && ctxs.length > 0) {
   25.56 +			sb.append("\nWHERE ");
   25.57 +			for (int i = 0; i < ctxs.length; i++) {
   25.58 +				sb.append("t.ctx = ?");
   25.59 +				if (i < ctxs.length - 1) {
   25.60 +					sb.append(" OR ");
   25.61 +				}
   25.62 +			}
   25.63 +		}
   25.64 +		return sb.toString();
   25.65 +	}
   25.66  }
    26.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Fri Feb 24 15:58:11 2012 +0200
    26.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Fri Feb 24 18:14:01 2012 +0200
    26.3 @@ -759,31 +759,31 @@
    26.4  
    26.5  			if(sridNeeded)
    26.6  			{
    26.7 -			filter.appendFunction("ST_SRID");
    26.8 -			filter.openBracket();
    26.9 -			if(expr.getArg() instanceof GeneralDBStringValue)
   26.10 -			{
   26.11 -				appendWKT(expr.getArg(),filter);
   26.12 -			}
   26.13 -			else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructBinary)
   26.14 -			{
   26.15 -				appendConstructFunction(expr.getArg(), filter);
   26.16 -			}
   26.17 -			else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructUnary)
   26.18 -			{
   26.19 -				appendConstructFunction(expr.getArg(), filter);
   26.20 -			}
   26.21 -			else if(expr.getArg() instanceof GeneralDBSqlCase)
   26.22 -			{
   26.23 -				GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getArg()).getEntries().get(0).getResult();
   26.24 -				appendMBB(onlyLabel,filter); 
   26.25 -			}
   26.26 -			else
   26.27 -			{
   26.28 -				appendMBB((GeneralDBLabelColumn)(expr.getArg()),filter);
   26.29 -			}
   26.30 -
   26.31 -			filter.closeBracket();
   26.32 +				filter.appendFunction("ST_SRID");
   26.33 +				filter.openBracket();
   26.34 +				if(expr.getArg() instanceof GeneralDBStringValue)
   26.35 +				{
   26.36 +					appendWKT(expr.getArg(),filter);
   26.37 +				}
   26.38 +				else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructBinary)
   26.39 +				{
   26.40 +					appendConstructFunction(expr.getArg(), filter);
   26.41 +				}
   26.42 +				else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructUnary)
   26.43 +				{
   26.44 +					appendConstructFunction(expr.getArg(), filter);
   26.45 +				}
   26.46 +				else if(expr.getArg() instanceof GeneralDBSqlCase)
   26.47 +				{
   26.48 +					GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getArg()).getEntries().get(0).getResult();
   26.49 +					appendMBB(onlyLabel,filter); 
   26.50 +				}
   26.51 +				else
   26.52 +				{
   26.53 +					appendMBB((GeneralDBLabelColumn)(expr.getArg()),filter);
   26.54 +				}
   26.55 +	
   26.56 +				filter.closeBracket();
   26.57  			}
   26.58  			else
   26.59  			{
   26.60 @@ -793,7 +793,7 @@
   26.61  		}
   26.62  
   26.63  		filter.closeBracket();
   26.64 -			}
   26.65 +	}
   26.66  
   26.67  	@Override
   26.68  	protected void append(GeneralDBSqlGeoIsSimple expr, GeneralDBSqlExprBuilder filter)
   26.69 @@ -1009,7 +1009,10 @@
   26.70  	//Used in all the generaldb stsparql boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
   26.71  	protected void appendGeneralDBSpatialFunctionBinary(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func)
   26.72  			throws UnsupportedRdbmsOperatorException
   26.73 -			{
   26.74 +	{
   26.75 +		//In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))")
   26.76 +		boolean sridNeeded = true;
   26.77 +		
   26.78  		filter.openBracket();
   26.79  
   26.80  		boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull");
   26.81 @@ -1054,10 +1057,18 @@
   26.82  						//						((GeneralDBSqlSpatialConstructBinary)expr).setSrid(alias);
   26.83  						break;
   26.84  					}
   26.85 +					else if (tmp instanceof GeneralDBStringValue) //Constant!!
   26.86 +					{
   26.87 +						sridNeeded  = false;
   26.88 +						break;
   26.89 +					}
   26.90  
   26.91  				}
   26.92 -				filter.appendFunction("ST_Transform");
   26.93 -				filter.openBracket();
   26.94 +				if(sridNeeded)
   26.95 +				{
   26.96 +					filter.appendFunction("ST_Transform");
   26.97 +					filter.openBracket();
   26.98 +				}
   26.99  			}
  26.100  			/////
  26.101  
    27.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISSqlExprBuilder.java	Fri Feb 24 15:58:11 2012 +0200
    27.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISSqlExprBuilder.java	Fri Feb 24 18:14:01 2012 +0200
    27.3 @@ -39,13 +39,25 @@
    27.4  		return this;
    27.5  	}
    27.6  
    27.7 -// TODO should this be overriden ??
    27.8 -//	public MonetDBSqlExprBuilder number(Number time) {
    27.9 -//		where.append(" ? ");
   27.10 -//		parameters.add(time);
   27.11 -//		return this;
   27.12 -//	}
   27.13 -
   27.14 +	@Override
   27.15 +	public GeneralDBSqlExprBuilder number(Number time) {
   27.16 +		where.append(" ? ");
   27.17 +		parameters.add(time);
   27.18 +		return this;
   27.19 +	}
   27.20 +	
   27.21 +	@Override
   27.22 +	public GeneralDBSqlExprBuilder varchar(String stringValue) {
   27.23 +		if (stringValue == null) {
   27.24 +			appendNull();
   27.25 +		}
   27.26 +		else {
   27.27 +			where.append(" ? ");
   27.28 +			parameters.add(stringValue);
   27.29 +		}
   27.30 +		return this;
   27.31 +	}
   27.32 +	
   27.33  //	// TODO should this be overriden ??
   27.34  //	protected String getSqlNull() {
   27.35  ////		return "false"; // FIXME
    28.1 --- a/query.sh	Fri Feb 24 15:58:11 2012 +0200
    28.2 +++ b/query.sh	Fri Feb 24 18:14:01 2012 +0200
    28.3 @@ -5,11 +5,13 @@
    28.4  #500mil 0.0015  512505143
    28.5  #1bil   0.001  1153249211
    28.6  
    28.7 -DB="10mil"
    28.8 +DB="noa-d4_1"
    28.9  LOGPATH="/home/strabon/experiments/logs"
   28.10  STEP="0.01"
   28.11  TOTALTRIPLES="11552771"
   28.12  
   28.13  (cd jars/target &&
   28.14 -java -cp $(for file in `ls -1 *.jar`; do myVar=$myVar./$file":"; done; echo $myVar;) eu.earthobservatory.runtime.monetdb.QueryOp localhost 50000 10mil monetdb monetdb "SELECT ?x WHERE {?x ?y ?z} LIMIT 10")
   28.15 +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 
   28.16 +"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) ) .}" 
   28.17 +XML)
   28.18  
    29.1 --- a/runtime/pom.xml	Fri Feb 24 15:58:11 2012 +0200
    29.2 +++ b/runtime/pom.xml	Fri Feb 24 18:14:01 2012 +0200
    29.3 @@ -299,8 +299,9 @@
    29.4  			<dependency>
    29.5  				<groupId>monetdb</groupId>
    29.6  				<artifactId>jdbcclient</artifactId>
    29.7 -				<version>3.1.0</version>
    29.8 +				<version>3.2.0</version>
    29.9  			</dependency>
   29.10 +
   29.11  			<!--
   29.12  			<dependency>
   29.13  				<groupId>net.sf</groupId>
    30.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Fri Feb 24 15:58:11 2012 +0200
    30.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java	Fri Feb 24 18:14:01 2012 +0200
    30.3 @@ -74,7 +74,9 @@
    30.4  
    30.5  	}
    30.6  
    30.7 -	public Strabon(String databaseName, String user, String password, int port, String serverName, boolean checkForLockTable) throws SQLException, ClassNotFoundException {
    30.8 +	public Strabon(String databaseName, String user, String password, int port, String serverName, boolean checkForLockTable) 
    30.9 +		throws SQLException, ClassNotFoundException 
   30.10 +	{
   30.11  		if (checkForLockTable == true) {
   30.12  			checkAndDeleteLock(databaseName, user, password, port, serverName);
   30.13  		}
   30.14 @@ -171,8 +173,6 @@
   30.15  			TupleQueryResult result = tupleQuery.evaluate();
   30.16  			long t2 = System.nanoTime();
   30.17  			while (result.hasNext()) {
   30.18 -				BindingSet bindingSet = result.next();				
   30.19 -				String test = bindingSet.toString();
   30.20  				results++;
   30.21  			}
   30.22  			long t3 = System.nanoTime();
   30.23 @@ -725,7 +725,8 @@
   30.24  
   30.25  		try {
   30.26  			update.execute();
   30.27 -		} catch (UpdateExecutionException e) {			e.printStackTrace();
   30.28 +		} catch (UpdateExecutionException e) {
   30.29 +			e.printStackTrace();
   30.30  		}
   30.31  
   30.32  		System.out.println("-------------------------------------------");
    31.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/Strabon.java	Fri Feb 24 15:58:11 2012 +0200
    31.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/monetdb/Strabon.java	Fri Feb 24 18:14:01 2012 +0200
    31.3 @@ -1,10 +1,14 @@
    31.4  package eu.earthobservatory.runtime.monetdb;
    31.5  
    31.6 +import info.aduna.concurrent.locks.Properties;
    31.7 +
    31.8  import java.sql.Connection;
    31.9  import java.sql.DriverManager;
   31.10  import java.sql.ResultSet;
   31.11  import java.sql.SQLException;
   31.12 +import java.util.Map;
   31.13  
   31.14 +import org.apache.commons.collections.map.HashedMap;
   31.15  import org.openrdf.sail.monetdb.MonetDBSqlStore;
   31.16  
   31.17  public class Strabon extends eu.earthobservatory.runtime.generaldb.Strabon {
   31.18 @@ -19,6 +23,10 @@
   31.19  
   31.20  		MonetDBSqlStore monetDB_store = (MonetDBSqlStore)db_store;
   31.21  		
   31.22 +//		Map<String, String> properties = new HashedMap();
   31.23 +//		properties.put("debug", "true");
   31.24 +//		monetDB_store.setProperties(properties);
   31.25 +		
   31.26  		monetDB_store.setDatabaseName(databaseName);
   31.27  		monetDB_store.setUser(user);
   31.28  		monetDB_store.setPassword(password);
   31.29 @@ -40,9 +48,9 @@
   31.30  			Connection conn = DriverManager.getConnection(url);
   31.31  			java.sql.Statement st = conn.createStatement();
   31.32  			// change
   31.33 -			ResultSet resultSet = st.executeQuery("SELECT true FROM sys._tables WHERE name='locked' AND system=false;");
   31.34 +			ResultSet resultSet = st.executeQuery("SELECT true FROM sys._tables WHERE name='locked' AND system=false");
   31.35  			if ( resultSet.next() )
   31.36 -				st.execute("DROP TABLE \"locked\";");
   31.37 +				st.execute("DROP TABLE \"locked\"");
   31.38  			st.close();
   31.39  			conn.close();
   31.40  		} catch (SQLException e) {
    32.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java	Fri Feb 24 15:58:11 2012 +0200
    32.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/QueryOp.java	Fri Feb 24 18:14:01 2012 +0200
    32.3 @@ -17,7 +17,7 @@
    32.4  			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
    32.5  			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
    32.6  			System.err.println("             <QUERY>      is the stSPARQL query to evaluate.");
    32.7 -			System.err.println("             [<FORMAT>]     is the format of your results (XML)");
    32.8 +			System.err.println("             [<FORMAT>]   is the format of your results (default: XML)");
    32.9  			System.exit(0);
   32.10  		}
   32.11  
    33.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java	Fri Feb 24 15:58:11 2012 +0200
    33.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/postgis/StoreOp.java	Fri Feb 24 18:14:01 2012 +0200
    33.3 @@ -12,14 +12,15 @@
    33.4  	public static void main(String[] args) throws Exception {
    33.5  
    33.6  		if (args.length < 6) {
    33.7 -			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <QUERY> ");
    33.8 +			System.err.println("Usage: eu.ist.semsorgrid4env.strabon.Strabon <HOST> <PORT> <DATABASE> <USERNAME> <PASSWORD> <FILE> [<FORMAT>]");
    33.9  			System.err.println("       where <HOST>       is the postgis database host to connect to");
   33.10  			System.err.println("             <PORT>       is the port to connect to on the database host");		
   33.11  			System.err.println("             <DATABASE>   is the spatially enabled postgis database that Strabon will use as a backend, ");
   33.12  			System.err.println("             <USERNAME>   is the username to use when connecting to the database ");
   33.13  			System.err.println("             <PASSWORD>   is the password to use when connecting to the database");
   33.14  			System.err.println("             <FILE>       is the file to be stored");
   33.15 -			System.err.println("             [<FORMAT>]   is the format of the file (NTRIPLES)");
   33.16 +			System.err.println("             [<FORMAT>]   is the format of the file (default: NTRIPLES)");
   33.17 +			System.err.println("Args: "+args.length);
   33.18  			System.exit(0);
   33.19  		}
   33.20