Ignore:
Timestamp:
05/03/16 15:17:36 (9 years ago)
Author:
sherbold
Message:
  • updated new result storage concept and cross-project experiments to first check if a result is available. If this is the case, the experiment is not executed.
Location:
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/IResultStorage.java

    r68 r69  
    44 
    55    public void addResult(ExperimentResult result); 
     6     
     7    public boolean containsResult(String experimentName, String productName); 
    68} 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/MySQLResultStorage.java

    r68 r69  
    44import java.sql.Connection; 
    55import java.sql.DriverManager; 
     6import java.sql.ResultSet; 
    67import java.sql.SQLException; 
    78import java.sql.Statement; 
     
    3435 
    3536    public void addResult(ExperimentResult result) { 
    36         Statement stmt; 
    37         try { 
    38             stmt = con.createStatement(); 
    39         } 
    40         catch (SQLException e) { 
    41             Console.printerr("Problem with MySQL connection: "); 
    42             Console.printerr("SQLException: " + e.getMessage()); 
    43             Console.printerr("SQLState: " + e.getSQLState()); 
    44             Console.printerr("VendorError: " + e.getErrorCode()); 
    45             return; 
    46         } 
    4737        StringBuilder sql = new StringBuilder(); 
    4838        sql.append("INSERT INTO crosspare.results VALUES (NULL,"); 
     
    7262        sql.append(result.getTn()+","); 
    7363        sql.append(result.getFp()+");"); 
     64         
     65        Statement stmt; 
    7466        try { 
     67            stmt = con.createStatement(); 
    7568            stmt.executeUpdate(sql.toString().replace("NaN", "NULL")); 
    7669        } 
     
    8477    } 
    8578     
    86     //public boolean containsResult(String configurationName, String productName, String classifier); 
     79    @Override 
     80    public boolean containsResult(String experimentName, String productName) { 
     81        String sql = "SELECT COUNT(*) as cnt FROM crosspare.results WHERE configurationName=\'" + experimentName + "\' AND productName=\'" + productName + "\';"; 
     82        Statement stmt; 
     83        boolean contained = false; 
     84        try { 
     85            stmt = con.createStatement(); 
     86            ResultSet results = stmt.executeQuery(sql); 
     87            results.next(); 
     88            int count = results.getInt("cnt"); 
     89            contained = count>0; 
     90        } 
     91        catch (SQLException e) { 
     92            Console.printerr("Problem with MySQL connection: \n"); 
     93            Console.printerr("SQLException: " + e.getMessage() + "\n"); 
     94            Console.printerr("SQLState: " + e.getSQLState() + "\n"); 
     95            Console.printerr("VendorError: " + e.getErrorCode() + "\n"); 
     96        } 
     97        return contained; 
     98    } 
    8799} 
Note: See TracChangeset for help on using the changeset viewer.