package cn.edu.ruc.iir.rainbow.eva;

import cn.edu.ruc.iir.rainbow.eva.metrics.StageMetrics;

import java.sql.*;
import java.util.Properties;

public class PrestoEvaluator
{
    public static StageMetrics execute (String jdbcUrl, Properties jdbcProperties, String tableName, String columns, String orderByColumn)
    {
        StageMetrics stageMetrics = new StageMetrics();

        try (Connection connection = DriverManager.getConnection(jdbcUrl, jdbcProperties))
        {
            Statement statement = connection.createStatement();
            String sql = "select " + columns + " from " + tableName + " order by " + orderByColumn + " limit 10";
            long start = System.currentTimeMillis();
            ResultSet resultSet = statement.executeQuery(sql);
            resultSet.next();
            stageMetrics.setDuration(System.currentTimeMillis() - start);
            stageMetrics.setId(0);
            statement.close();
        } catch (SQLException e)
        {
            e.printStackTrace();
        }

        return stageMetrics;
    }
}

@@ -369,16 +369,164 @@
 ics();%0A%0A
+        try%0A        %7B%0A            Thread.sleep(1000);%0A        %7D catch (InterruptedException e)%0A        %7B%0A            e.printStackTrace();%0A        %7D%0A
         

fix bug in PrestoEvaluator