5 #ifndef TCPSPSUITE_DB_OBJECTS_HPP
6 #define TCPSPSUITE_DB_OBJECTS_HPP
10 #include <odb/core.hxx>
11 #include <odb/lazy-ptr.hxx>
12 #include <odb/nullable.hxx>
16 #include <boost/date_time/posix_time/posix_time_types.hpp>
18 #include "../../datastructures/maybe.hpp"
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
27 class DBResourcesInfo;
28 class DBPapiMeasurement;
30 class DBExtendedMeasure;
33 #pragma db namespace() session
34 #pragma db namespace() pointer(std::shared_ptr)
40 std::weak_ptr<DBConfig> cfg;
44 DBConfigKV(std::shared_ptr<DBConfig> cfg,
const std::string & key,
45 const std::string & value);
46 DBConfigKV(std::shared_ptr<const DBConfigKV> src);
48 #pragma db index member(cfg)
56 friend class odb::access;
65 std::shared_ptr<unsigned int> time_limit;
67 #pragma db value_not_null inverse(cfg)
68 std::vector<std::shared_ptr<DBConfigKV>> entries;
70 DBConfig(
const std::string & name, Maybe<unsigned int> time_limit);
71 DBConfig(std::shared_ptr<const DBConfig> src);
73 #pragma db index member(name)
80 friend class odb::access;
86 DBInvocation(std::string cmdline, std::string git_revision,
87 std::string hostname,
unsigned long time);
88 DBInvocation(std::shared_ptr<const DBInvocation> src);
91 std::string git_revision;
95 #pragma db value_not_null inverse(invocation)
96 std::vector<std::shared_ptr<DBResult>> results;
98 unsigned long get_id() const noexcept;
106 friend class odb::access;
112 DBResult(std::string run, std::string instance,
double score,
113 std::string algorithm, std::string config_name,
int seed,
114 bool optimal,
bool feasible, Maybe<double> lower_bound,
115 double elapsed, std::shared_ptr<DBConfig> cfg,
116 std::shared_ptr<DBInvocation> invocation);
117 DBResult(std::shared_ptr<const DBResult> src);
121 std::string instance;
123 std::string algorithm;
129 std::shared_ptr<double> lower_bound;
132 std::shared_ptr<DBInvocation> invocation;
135 std::shared_ptr<DBConfig> cfg;
138 #pragma db inverse(res)
139 std::vector<std::shared_ptr<DBResourcesInfo>> resource_infos;
140 #pragma db inverse(res)
141 std::vector<std::shared_ptr<DBPapiMeasurement>> papi_measurements;
142 #pragma db inverse(res)
143 std::vector<std::shared_ptr<DBSolution>> solutions;
144 #pragma db inverse(res)
145 std::vector<std::shared_ptr<DBIntermediate>> intermediates;
146 #pragma db inverse(res)
147 std::vector<std::shared_ptr<DBExtendedMeasure>> extended_measures;
149 #pragma db index member(instance)
150 #pragma db index member(algorithm)
151 #pragma db index member(cfg)
154 get_id() const noexcept
165 friend class odb::access;
169 class DBResourcesInfo {
171 DBResourcesInfo(std::shared_ptr<DBResult> res,
172 odb::nullable<size_t> max_rss_size,
173 odb::nullable<size_t> max_data_size,
174 odb::nullable<size_t> malloc_max_size,
175 odb::nullable<size_t> malloc_count,
size_t major_pagefaults,
176 size_t minor_pagefaults,
unsigned long user_usecs,
177 unsigned long system_usecs);
178 DBResourcesInfo(std::shared_ptr<const DBResourcesInfo> src);
181 std::shared_ptr<DBResult> res;
183 size_t major_pagefaults;
184 size_t minor_pagefaults;
185 unsigned long user_usecs;
186 unsigned long system_usecs;
188 odb::nullable<size_t> max_rss_size;
189 odb::nullable<size_t> max_data_size;
190 odb::nullable<size_t> malloc_max_size;
191 odb::nullable<size_t> malloc_count;
193 #pragma db index member(res)
201 friend class odb::access;
205 class DBPapiMeasurement {
207 DBPapiMeasurement(std::shared_ptr<DBResult> res, std::string event_type,
208 long long event_count);
209 DBPapiMeasurement(std::shared_ptr<const DBPapiMeasurement> src);
212 std::shared_ptr<DBResult> res;
214 std::string event_type;
215 long long event_count;
217 #pragma db index member(res)
220 DBPapiMeasurement() {}
225 friend class odb::access;
231 DBSolution(std::shared_ptr<DBResult> res);
232 DBSolution(std::shared_ptr<const DBSolution> src);
235 std::shared_ptr<DBResult> res;
237 #pragma db value_not_null inverse(sol)
238 std::vector<std::shared_ptr<DBSolutionJob>> jobs;
239 #pragma db inverse(solution)
240 std::vector<std::shared_ptr<DBIntermediate>> intermediates;
242 #pragma db index member(res)
256 friend class odb::access;
260 class DBSolutionJob {
262 DBSolutionJob(std::shared_ptr<DBSolution> sol,
unsigned int job_id,
263 unsigned int start_time);
264 DBSolutionJob(std::shared_ptr<const DBSolutionJob> src);
267 std::shared_ptr<DBSolution> sol;
270 unsigned int start_time;
278 friend class odb::access;
282 class DBIntermediate {
284 DBIntermediate(std::shared_ptr<DBResult> res, Maybe<double> time,
285 Maybe<unsigned int> iteration, Maybe<double> costs,
286 Maybe<double> bound, std::shared_ptr<DBSolution> solution);
287 DBIntermediate(std::shared_ptr<const DBIntermediate> src);
290 std::shared_ptr<DBResult> res;
292 std::shared_ptr<double> time;
293 std::shared_ptr<unsigned int> iteration;
294 std::shared_ptr<double> costs;
295 std::shared_ptr<double> bound;
297 std::shared_ptr<DBSolution> solution;
305 #pragma db index member(res)
313 friend class odb::access;
320 DBError(
unsigned long timestamp, std::string run, std::string instance,
321 std::string algorithm, std::string config_name,
int seed,
322 int fault_code,
int error_id);
323 DBError(std::shared_ptr<const DBError> src);
325 unsigned long timestamp;
327 std::string instance;
328 std::string algorithm;
334 std::string git_revision;
342 friend class odb::access;
346 class DBExtendedMeasure {
348 DBExtendedMeasure(std::shared_ptr<DBResult> res, std::string key,
349 Maybe<unsigned int> iteration, Maybe<double> time,
350 Maybe<int> v_int, Maybe<double> v_double);
351 DBExtendedMeasure(std::shared_ptr<const DBExtendedMeasure> src);
354 std::shared_ptr<DBResult> res;
358 std::shared_ptr<unsigned int> iteration;
360 std::shared_ptr<double> time;
362 std::shared_ptr<int> v_int;
364 std::shared_ptr<double> v_double;
366 #pragma db index member(res)
369 DBExtendedMeasure() {}
374 friend class odb::access;
380 #pragma db view query("SELECT DBConfig.id from DBConfig INNER JOIN (")
381 struct ConfigGetterView
383 #pragma db type("INTEGER")
384 unsigned long config_id;
387 #pragma GCC diagnostic pop
389 #endif // TCPSPSUITE_DB_OBJECTS_HPP