0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ParallelLoad.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef Tools_load_generator_ParallelLoad_h
23 #define Tools_load_generator_ParallelLoad_h
24 
25 #include <Hypertable/Lib/Cell.h>
26 #include <Hypertable/Lib/KeySpec.h>
27 
28 #include <condition_variable>
29 #include <list>
30 #include <mutex>
31 
32 namespace Hypertable {
33 
34  class LoadRec {
35  public:
36  LoadRec() : is_delete(false) { }
37 
38  LoadRec(Cell &other, bool is_del=false) : is_delete(is_del) {
39  size_t data_len = strlen((const char *)other.row_key) +
40  + strlen(other.column_family)
41  + (other.column_qualifier ? strlen(other.column_qualifier) : 0)
42  + (is_delete ? 0 : other.value_len) + 3;
43 
44  arena = new char [data_len];
45  char *ptr = arena;
46 
47  // row
48  strcpy(ptr, other.row_key);
49  key.row_len = strlen(ptr);
50  key.row = ptr;
51  ptr += strlen(ptr) + 1;
52 
53  // column family
54  strcpy(ptr, other.column_family);
55  key.column_family = ptr;
56  ptr += strlen(ptr) + 1;
57 
58  // column qualifier
59  if (other.column_qualifier) {
60  strcpy(ptr, other.column_qualifier);
61  key.column_qualifier = ptr;
62  }
63  else
65  ptr += strlen(ptr) + 1;
66 
67  // timestamp & revision
68  key.timestamp = other.timestamp;
69  key.revision = other.revision;
70 
71  if (!is_delete && other.value_len) {
72  memcpy(ptr, other.value, other.value_len);
73  value = ptr;
74  value_len = other.value_len;
75  }
76  else
77  value_len = 0;
78  }
79 
81  delete [] arena;
82  }
83 
85  bool is_delete;
86  char *arena;
87  const void *value;
88  ::uint32_t value_len;
89  unsigned long amount;
90  };
91 
93  public:
95 
97  total_cells = other.total_cells;
98  total_bytes = other.total_bytes;
99  finished = other.finished;
100  cum_latency = other.cum_latency;
102  min_latency = other.min_latency;
103  max_latency = other.max_latency;
104  elapsed_time = other.elapsed_time;
105  }
106 
108  std::condition_variable cond;
109  std::list<LoadRec *> requests;
110  std::list<LoadRec *> garbage;
111  int64_t total_cells {};
112  int64_t total_bytes {};
113  bool finished {};
114  double cum_latency {};
115  double cum_sq_latency {};
116  double min_latency {};
117  double max_latency {};
118  double elapsed_time {};
119  };
120 
121 }
122 
123 #endif // Tools_load_generator_ParallelLoad_h
int64_t timestamp
Definition: KeySpec.h:130
std::list< LoadRec * > garbage
Definition: ParallelLoad.h:110
static std::mutex mutex
Definition: Logger.cc:43
const char * column_qualifier
Definition: KeySpec.h:128
const char * column_qualifier
Definition: Cell.h:68
int64_t revision
Definition: KeySpec.h:131
const void * row
Definition: KeySpec.h:125
const void * value
Definition: ParallelLoad.h:87
uint64_t revision
Definition: Cell.h:70
const char * row_key
Definition: Cell.h:66
std::list< LoadRec * > requests
Definition: ParallelLoad.h:109
::uint32_t value_len
Definition: ParallelLoad.h:88
LoadRec(Cell &other, bool is_del=false)
Definition: ParallelLoad.h:38
std::condition_variable cond
Definition: ParallelLoad.h:108
Hypertable definitions
const char * column_family
Definition: Cell.h:67
uint32_t value_len
Definition: Cell.h:72
ParallelStateRec(const ParallelStateRec &other)
Definition: ParallelLoad.h:96
Encapsulates decomposed key and value.
Definition: Cell.h:32
const char * column_family
Definition: KeySpec.h:127
const uint8_t * value
Definition: Cell.h:71
unsigned long amount
Definition: ParallelLoad.h:89
int64_t timestamp
Definition: Cell.h:69