rocker 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/ext/rocker/rocker.h CHANGED
@@ -64,6 +64,9 @@ public:
64
64
 
65
65
  updater(*action);
66
66
 
67
+ // Make sure to actually save the results.
68
+ action->commit();
69
+
67
70
  delete action;
68
71
  }
69
72
 
@@ -74,7 +77,7 @@ public:
74
77
 
75
78
  // Return the mean AUC calculated -- requires that process_results was called,
76
79
  // which happens in the constructor, so it's okay.
77
- double mean_auc() { return mean_auc_; }
80
+ double mean_auc() { return updater.mean_auc; }
78
81
 
79
82
  // Go through the results directory
80
83
  map<uint,auc_info> process_results() {
@@ -99,9 +102,9 @@ public:
99
102
 
100
103
  // Calculate the mean AUC
101
104
  if (divide_by > 0)
102
- mean_auc_ = temp_auc_accum / (double)(divide_by);
105
+ updater.mean_auc = temp_auc_accum / (double)(divide_by);
103
106
  else
104
- mean_auc_ = 0;
107
+ updater.mean_auc = 0;
105
108
 
106
109
  return rocs;
107
110
  }
data/ext/rocker/updater.h CHANGED
@@ -49,7 +49,8 @@ public:
49
49
 
50
50
  uint experiment_id;
51
51
  map<uint,auc_info> aucs;
52
- string query;
52
+ double mean_auc;
53
+ string insert_query, update_query;
53
54
 
54
55
  void operator()(argument_type &T) {
55
56
  result R;
@@ -59,14 +60,21 @@ public:
59
60
  return;
60
61
  }
61
62
 
62
- query = make_known_correct_query().c_str();
63
+ insert_query = make_insertion_sql().c_str();
64
+ update_query = make_update_total_auc_sql().c_str();
63
65
 
64
66
  try {
65
- R = T.exec(query);
67
+ // Insert the AUCs
68
+ R = T.exec(insert_query);
66
69
  cout << "Query:" << endl;
67
- cout << query << endl;
70
+ cout << insert_query << endl;
71
+
72
+ // Update the average AUC
73
+ R = T.exec(update_query);
74
+ cout << "Query:" << endl;
75
+ cout << update_query << endl;
68
76
  } catch (pqxx::sql_error e) {
69
- cerr << "SQL error in Fetcher transactor." << endl;
77
+ cerr << "SQL error in Updater transactor." << endl;
70
78
  cerr << "Query: " << e.query() << endl;
71
79
  cerr << "Error: " << e.what() << endl;
72
80
  //FIXME: Needs to throw a Rails exception of some kind. (Or does it?)
@@ -74,7 +82,7 @@ public:
74
82
  }
75
83
 
76
84
  protected:
77
- string make_known_correct_query() const {
85
+ string make_insertion_sql() const {
78
86
  ostringstream q;
79
87
  q << "INSERT INTO rocs " << AUC_COLUMNS << " VALUES \n";
80
88
  list<string> insertions;
@@ -84,4 +92,11 @@ protected:
84
92
  q << join(insertions, ",\n") << ';';
85
93
  return q.str();
86
94
  }
95
+
96
+ string make_update_total_auc_sql() const {
97
+ ostringstream q;
98
+ q << "UPDATE experiments SET total_auc = " << mean_auc
99
+ << " WHERE experiments.id = " << experiment_id << ';';
100
+
101
+ }
87
102
  };
data/lib/rocker.rb CHANGED
@@ -4,5 +4,5 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'rocker.so'
5
5
 
6
6
  class Rocker
7
- VERSION = '0.0.7'
7
+ VERSION = '0.0.8'
8
8
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 7
9
- version: 0.0.7
8
+ - 8
9
+ version: 0.0.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Woods
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-23 00:00:00 -05:00
17
+ date: 2010-04-24 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency