Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConcurrencyTest.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet;
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file ConcurrencyTest.hh
11 ///
12 /// @brief
13 /// @author Tim Jacobs
14 
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <time.h>
18 
20 
21 //Core
22 #include <core/types.hh>
25 
26 //External
27 #include <boost/uuid/uuid.hpp>
28 
29 //Devel
32 
33 //Utility and basic
34 #include <numeric/random/random.hh>
35 #include <basic/database/sql_utils.hh>
36 #include <utility/sql_database/DatabaseSessionManager.hh>
37 
38 //C++
39 #include <string>
40 #include <math.h>
41 
42 //External Headers
43 #include <cppdb/frontend.h>
44 
45 //Basic
46 #include <basic/Tracer.hh>
47 #include <basic/options/util.hh>
48 #include <basic/options/keys/helixAssembly.OptionKeys.gen.hh>
49 #include <basic/database/schema_generator/PrimaryKey.hh>
50 #include <basic/database/schema_generator/ForeignKey.hh>
51 #include <basic/database/schema_generator/Column.hh>
52 #include <basic/database/schema_generator/Schema.hh>
53 
54 namespace protocols {
55 namespace features {
56 namespace helixAssembly {
57 
58  void
59  ConcurrencyTest::write_schema_to_db(utility::sql_database::sessionOP db_session) const{
60 
61  using namespace basic::database::schema_generator;
62 
63  PrimaryKey id(Column("id", new DbUUID(), false));
64  Column random_number(Column("description", new DbInteger()));
65 
66  Schema concurrency_test("concurrency_test", id);
67  concurrency_test.add_column(random_number);
68 
69  concurrency_test.write(db_session);
70 
71  }
72 
73  ///@brief collect all the feature data for the pose
76  core::pose::Pose const &,
77  utility::vector1<bool> const &,
78  boost::uuids::uuid struct_id,
79  utility::sql_database::sessionOP db_session
80  ){
81 
82 
83  std::string test_insert = "INSERT INTO concurrency_test (id, random_num) VALUES (?);";
84  for(int i=1; i<=100000; i++){
85  cppdb::statement test_stmt(basic::database::safely_prepare_statement(test_insert,db_session));
86  test_stmt.bind(1,struct_id);
87  test_stmt.bind(2,numeric::random::random_range(0,INT_MAX));
88  basic::database::safely_write_to_database(test_stmt);
89  }
90  return 0;
91  }
92 
93 }
94 }
95 }