0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StatsTable.cc
Go to the documentation of this file.
1 
21 #include "Common/Compat.h"
22 #include "Common/Logger.h"
23 #include "Common/Serialization.h"
24 
25 #include "StatsTable.h"
26 
27 using namespace Hypertable;
28 
29 namespace {
30  enum Group {
31  MAIN_GROUP = 0
32  };
33 }
34 
36  clear();
37  group_ids[0] = MAIN_GROUP;
38 }
39 
40 
42  table_id = "";
43  range_count = 0;
44  scanner_count = 0;
45  cell_count = 0;
46  file_count = 0;
47  scans = 0;
48  cells_scanned = 0;
49  cells_returned = 0;
50  bytes_scanned = 0;
51  bytes_returned = 0;
52  updates = 0;
53  cells_written = 0;
54  bytes_written = 0;
55  disk_bytes_read = 0;
56  disk_used = 0;
57  key_bytes = 0;
58  value_bytes = 0;
59  compression_ratio = 0.0;
60  memory_used = 0;
61  memory_allocated = 0;
67 }
68 
69 size_t StatsTable::encoded_length_group(int group) const {
70 
71  if (group == MAIN_GROUP) {
97  }
98  else
99  HT_FATALF("Invalid group number (%d)", group);
100  return 0;
101 }
102 
103 void StatsTable::encode_group(int group, uint8_t **bufp) const {
104  if (group == MAIN_GROUP) {
130  }
131  else
132  HT_FATALF("Invalid group number (%d)", group);
133 }
134 
135 void StatsTable::decode_group(int group, uint16_t len, const uint8_t **bufp, size_t *remainp) {
136  if (group == MAIN_GROUP) {
137  table_id = Serialization::decode_vstr(bufp, remainp);
138  range_count = Serialization::decode_vi32(bufp, remainp);
139  scanner_count = Serialization::decode_vi32(bufp, remainp);
140  cell_count = Serialization::decode_vi64(bufp, remainp);
141  file_count = Serialization::decode_vi64(bufp, remainp);
142  scans = Serialization::decode_vi64(bufp, remainp);
143  cells_scanned = Serialization::decode_vi64(bufp, remainp);
145  bytes_scanned = Serialization::decode_vi64(bufp, remainp);
147  updates = Serialization::decode_vi64(bufp, remainp);
148  cells_written = Serialization::decode_vi64(bufp, remainp);
149  bytes_written = Serialization::decode_vi64(bufp, remainp);
151  disk_used = Serialization::decode_vi64(bufp, remainp);
152  key_bytes = Serialization::decode_vi64(bufp, remainp);
153  value_bytes = Serialization::decode_vi64(bufp, remainp);
155  memory_used = Serialization::decode_vi64(bufp, remainp);
162  }
163  else
164  HT_FATALF("Invalid group number (%d)", group);
165 }
166 
167 bool StatsTable::operator==(const StatsTable &other) const {
168  if (*((StatsSerializable *)this) != *((StatsSerializable *)&other))
169  return false;
170  if (table_id == other.table_id &&
171  range_count == other.range_count &&
172  scanner_count == other.scanner_count &&
173  cell_count == other.cell_count &&
174  file_count == other.file_count &&
175  scans == other.scans &&
176  cells_scanned == other.cells_scanned &&
177  cells_returned == other.cells_returned &&
178  bytes_scanned == other.bytes_scanned &&
179  bytes_returned == other.bytes_returned &&
180  updates == other.updates &&
181  cells_written == other.cells_written &&
182  bytes_written == other.bytes_written &&
183  disk_bytes_read == other.disk_bytes_read &&
184  disk_used == other.disk_used &&
185  key_bytes == other.key_bytes &&
186  value_bytes == other.value_bytes &&
188  memory_used == other.memory_used &&
195  return true;
196  return false;
197 }
Abstract base class for managing serialized statistics.
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
virtual void encode_group(int group, uint8_t **bufp) const
Abstruct function to serialize a group into a memory buffer.
Definition: StatsTable.cc:103
int encoded_length_double()
Length of an encoded double (16 bytes)
uint64_t block_index_memory
Definition: StatsTable.h:91
uint64_t disk_bytes_read
Definition: StatsTable.h:83
uint64_t memory_allocated
Definition: StatsTable.h:89
virtual void decode_group(int group, uint16_t len, const uint8_t **bufp, size_t *remainp)
Abstruct function to deserialize a group from a memory buffer.
Definition: StatsTable.cc:135
uint64_t bloom_filter_memory
Definition: StatsTable.h:92
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
int encoded_length_vi32(uint32_t val)
Length of a variable length encoded 32-bit integer (up to 5 bytes)
void encode_vi64(uint8_t **bufp, uint64_t val)
Encode a integer (up to 64-bit) in variable length encoding.
Group
Definition: StatsSystem.cc:38
Logging routines and macros.
Compatibility Macros for C/C++.
std::string table_id
Definition: StatsTable.h:70
Functions to serialize/deserialize primitives to/from a memory buffer.
uint64_t shadow_cache_memory
Definition: StatsTable.h:90
void encode_vstr(uint8_t **bufp, const void *buf, size_t len)
Encode a buffer as variable length string (vint64, data, null)
Hypertable definitions
#define HT_FATALF(msg,...)
Definition: Logger.h:343
uint64_t decode_vi64(const uint8_t **bufp, size_t *remainp)
Decode a variable length encoded integer up to 64-bit.
void encode_vi32(uint8_t **bufp, uint32_t val)
Encode a integer (up to 32-bit) in variable length encoding.
double decode_double(const uint8_t **bufp, size_t *remainp)
Decodes a double as 64-bit left-of-decimal, followed by 64-bit right-of-decimal, both in little-endia...
bool equal(double a, double b)
Compare doubles that may have been serialized and unserialized.
bool operator==(const StatsTable &other) const
Definition: StatsTable.cc:167
uint8_t group_ids[32]
The actual group IDs.
uint64_t bloom_filter_maybes
Definition: StatsTable.h:94
uint64_t bloom_filter_accesses
Definition: StatsTable.h:93
virtual size_t encoded_length_group(int group) const
Abstruct function returning the serialized length of a group.
Definition: StatsTable.cc:69
uint32_t decode_vi32(const uint8_t **bufp, size_t *remainp)
Decode a variable length encoded integer up to 32-bit.
void encode_double(uint8_t **bufp, double val)
Encodes a double with 18 decimal digits of precision as 64-bit left-of-decimal, followed by 64-bit ri...
int encoded_length_vi64(uint64_t val)
Length of a variable length encoded 64-bit integer (up to 9 bytes)