1 package compbio.cassandra.readers;
4 import java.util.Calendar;
6 import java.util.ArrayList;
8 import org.apache.log4j.Logger;
10 import com.datastax.driver.core.Row;
11 import com.datastax.driver.core.Session;
12 import com.datastax.driver.core.ResultSet;
13 import com.datastax.driver.core.PreparedStatement;
14 import com.datastax.driver.core.BoundStatement;
16 import compbio.cassandra.CassandraReader;
17 import compbio.cassandra.Pair;
18 import compbio.engine.ProteoCachePropertyHelperManager;
19 import compbio.util.PropertyHelper;
21 public class CassandraReaderExecutionTime {
22 private Session session;
24 public static String CASSANDRA_HOSTNAME = "localhost";
25 public static boolean READ_WEB_JPRED = false;
26 public static boolean READ_LOCALFILE_JPRED = false;
28 public void setSession(Session s) {
33 private void setConditions() {
37 public boolean JobisNotInsterted(String jobid) {
38 ResultSet results1 = session.execute("SELECT * FROM ProteinLog WHERE JobID = '" + jobid + "';");
39 if (results1.isExhausted()) {
45 public boolean JobisNotArchived(String jobid) {
46 ResultSet results1 = session.execute("SELECT * FROM JpredArchive WHERE JobID = '" + jobid + "';");
47 if (results1.isExhausted()) {
54 * getting data from the db
56 public List<Pair<String, String>> ReadProteinDataTable() {
57 final long startTime = System.currentTimeMillis();
58 String com = "SELECT DataBegin,DataEnd FROM ProteinKeyspace.ProteinLog;";
59 System.out.println("Command: " + com);
60 ResultSet results = session.execute(com);
61 final long queryTime = System.currentTimeMillis();
62 List<Row> rows = results.all();
63 System.out.println("Query time is " + (queryTime - startTime) + " msec");
65 List<Pair<String, String>> res = new ArrayList<Pair<String, String>>();
68 Pair<String, String> pair = new Pair<String, String>(r.getString("DataBegin"), r.getString("DataEnd"));
72 final long endTime = System.currentTimeMillis();
73 System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
78 * getting earlest date of jobs from the db
80 public long getEarliestDateInDB() {
81 final long startTime = System.currentTimeMillis();
82 String com = "SELECT jobtime FROM ProteinKeyspace.ProteinData;";
83 System.out.println("Command: " + com);
84 ResultSet results = session.execute(com);
85 final long queryTime = System.currentTimeMillis();
86 System.out.println("Query time is " + (queryTime - startTime) + " msec");
88 Calendar cal = Calendar.getInstance();
89 long res = cal.getTimeInMillis();
91 while (!results.isExhausted()) {
92 Row r = results.one();
93 long d1 = r.getLong("jobtime");
99 final long endTime = System.currentTimeMillis();
100 System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");