GPUdb C++ API  Version 6.0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
GPUdbIngestor.hpp
Go to the documentation of this file.
1 #ifndef __GPUDB_INGESTOR_HPP__
2 #define __GPUDB_INGESTOR_HPP__
3 
4 
5 #include <map>
6 #include <string>
7 #include <vector>
8 #include <boost/noncopyable.hpp>
9 
10 
11 namespace gpudb
12 {
13 
14 // Forward declaration
15 class GPUdb;
16 
17 
18 
20 {
21 private:
22 
23  std::vector<std::string> m_worker_urls;
24 
25  static std::vector<std::string>& split_string( const std::string &in_string,
26  char delim,
27  std::vector<std::string> &elements );
28 
29 public:
30 
31  WorkerList( const GPUdb &gpudb );
32 
33 }; // end class WorkerList
34 
35 
36 
37 class RecordKey
38 {
39 private:
40 
41  unsigned char *m_buffer;
42  int32_t m_hash_code;
43  int64_t m_routing_hash;
44 
45  RecordKey();
46 
47 public:
48 
49  RecordKey( size_t buffer_size );
50  ~RecordKey();
51 
52  // void add_string( std::string value );
53 
54  // void add_double( double value ):
55 
56  // void add_float( float value ):
57 
58  // void add_int8( int32_t value ):
59 
60  // void add_int16( int32_t value ):
61 
62  // void add_int( int32_t value ):
63 
64  // void add_long( int64_t value ):
65 
66  void compute_hashes();
67 
68 
69 }; // end class RecordKey
70 
71 
72 
73 
75 {
76 private:
77 
78  enum ColumnType_T
79  {
80  CHAR1,
81  CHAR2,
82  CHAR4,
83  CHAR8,
84  CHAR16,
85  DOUBLE,
86  FLOAT,
87  INT,
88  INT8,
89  INT16,
90  LONG,
91  STRING
92  };
93 
94  std::vector<int32_t> m_pk_shard_key_indices;
95  std::vector<ColumnType_T> m_column_types;
96  size_t m_key_buffer_size;
97 
98  RecordKeyBuilder() {}
99 
100 public:
101 
102 
103 
104 
105 }; // end class RecordKeyBuilder
106 
107 
108 
109 /*
110  * The WorkerQueue class maintains queues of record to be inserted
111  * into GPUdb. It is templated on the type of the record that is to
112  * be ingested into the DB server.
113  */
114 template<typename T>
116 {
117 private:
118 
119  std::string m_url;
120  size_t m_capacity;
121  bool m_has_primary_key;
122  bool m_update_on_existing_pk;
123  std::vector<T> m_queue;
125  typedef std::map<RecordKey, size_t> primary_key_map_t;
126  primary_key_map_t m_primary_key_map;
127 
128  WorkerQueue();
129 
130 public:
131 
132  WorkerQueue( std::string url, size_t capacity, bool has_primary_key,
133  bool update_on_existing_pk );
134 
136  std::vector<T>& flush();
137 
139  std::vector<T>& insert( T record, RecordKey key );
140 
141 
142 }; // end class WorkerQueue
143 
144 
145 
146 
147 template<typename T>
148 class GPUdbIngestor : private boost::noncopyable
149 {
150 
151 public:
152 
153  T x;
154 
155  GPUdbIngestor() { x = 0; }
156 
157 
158 
159 
160 }; // end class GPUdbIngestor
161 
162 
163 
164 } // namespace gpudb
165 
166 
167 
168 #endif // __GPUDB_INGESTOR_HPP__
169 
170 
std::vector< T > & flush()
Returns the current queue and creates a new internal queue.
WorkerList(const GPUdb &gpudb)
std::vector< T > & insert(T record, RecordKey key)
Inserts a record into the queue.