Rebuild tables for queries
[proteocache.git] / datadb / compbio / cassandra / CassandraReader.java
index c71243b..c7d08bf 100644 (file)
@@ -1,6 +1,6 @@
 package compbio.cassandra;
 
-import java.util.Calendar;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.ArrayList;
@@ -54,23 +54,20 @@ public class CassandraReader {
        }
 
        /*
-        * getting data from the db ProteinData
+        * getting data from the db JobDateInfo
         */
-       public Integer ReadDateTable(long queryDate) {
-               final long startTime = System.currentTimeMillis();
-               String com = "SELECT jobtime, JobID FROM ProteinData WHERE jobtime = " + queryDate + ";";
-               System.out.println("Command: " + com);
-               ResultSet results = session.execute(com);
-               final long queryTime = System.currentTimeMillis();
-               System.out.println("Query time is " + (queryTime - startTime) + " msec");
+       public long ReadDateTable(long queryDate) {
+               ResultSet results = session.execute("SELECT Total FROM JobDateInfo WHERE jobday = " + queryDate + ";");
                if (results.isExhausted())
                        return 0;
-               List<Row> rows = results.all();
-               final long endTime = System.currentTimeMillis();
-               System.out.println("Processing time is " + (endTime - queryTime) + " msec");
-               return rows.size();
+               Row therow = results.one();
+               long res = therow.getLong("Total");
+               if (!results.isExhausted()) {
+                       Date date = new Date (queryDate);
+                       log.warn("CassandraReader.ReadDateTable: date row for " + date.toString () + " ("+ queryDate + ") duplicated ");
+               }
+               return res;
        }
-
        /*
         * getting whole protein sequence from the db ProteinRow
         */
@@ -131,7 +128,7 @@ public class CassandraReader {
        /*
         * getting protein sequences by counter
         */
-       public Map<String, Integer> ReadProteinDataByCounter() {
+       public Map<String, Integer> ReadProteinSequenceByCounter() {
                final long startTime = System.currentTimeMillis();
                String com = "SELECT Protein FROM ProteinRow;";
                System.out.println("Command: " + com);