package dk.aau.kah.bits.evaluation;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

import org.apache.commons.io.FileUtils;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ReadWrite;
import org.apache.jena.query.ResultSet;
import org.apache.jena.query.ResultSetFormatter;

import dk.aau.kah.bits.database.DatabaseHandler;

public class EvaluationHandlerTPCH extends AbstractEvaluationHandler {
	private HashMap <String, String> results = new HashMap<String,String>();
	EvaluationHandlerTPCH(DatabaseHandler dh) {
		super(dh);
	}


	private String queriesPath = "src/test/resources/TPC-H/QueriesSeed100/";
	
	@Override
	public void run() throws IOException {
		Dataset dataset = databaseHandler.getDataset();;
		
		for (final File fileEntry : new File(queriesPath).listFiles()) {
			String rawQuery = FileUtils.readFileToString(fileEntry);
			Query query = QueryFactory.create(rawQuery) ;

			dataset.begin(ReadWrite.READ) ;
		    QueryExecution qexec = QueryExecutionFactory.create(query, dataset);
		    /*Execute the Query*/
		    System.out.println(fileEntry);
		    ResultSet resultSet = qexec.execSelect();
		    ResultSetFormatter.out(System.out, resultSet, query) ;
		    while (resultSet.hasNext()) {
			    QuerySolution row=resultSet.nextSolution();
			    System.out.println(fileEntry.toString());
			    System.out.println(row.toString());
			    results.put(fileEntry.toString(), row.toString());
			  }
		    qexec.close();
		    dataset.commit();
		    
	        }
		dataset.close();
		
	    }
		// TODO Auto-generated method stub

	@Override
	public HashMap<String, String> getResults() {
		return results;
	}


	@Override
	public void getResultTimes() {
		// TODO Auto-generated method stub
		
	}

}

@@ -791,17 +791,16 @@
 h);%0A%09%7D%0A%0A
-%0A
 %09private
@@ -1370,32 +1370,34 @@
 Select();%0A%09%09    
+//
 ResultSetFormatt
@@ -1774,45 +1774,8 @@
    %7D
-%0A%09%09// TODO Auto-generated method stub
 %0A%0A%09@

Clean up