0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CellStoreTrailerV3.cc
Go to the documentation of this file.
1 
22 #include "Common/Compat.h"
23 #include <cassert>
24 #include <iostream>
25 
26 #include "Common/Serialization.h"
27 #include "Common/Logger.h"
28 
29 #include "Hypertable/Lib/KeySpec.h"
30 #include "Hypertable/Lib/Schema.h"
31 
32 #include "CellStoreTrailerV3.h"
33 
34 using namespace std;
35 using namespace Hypertable;
36 using namespace Serialization;
37 
38 
42 CellStoreTrailerV3::CellStoreTrailerV3() {
43  assert(sizeof(float) == 4);
44  clear();
45 }
46 
47 
50 void CellStoreTrailerV3::clear() {
51  fix_index_offset = 0;
52  var_index_offset = 0;
53  filter_offset = 0;
54  index_entries = 0;
55  total_entries = 0;
56  filter_length = 0;
57  filter_items_estimate = 0;
58  filter_items_actual = 0;
59  blocksize = 0;
60  revision = TIMESTAMP_MIN;
61  timestamp_min = TIMESTAMP_MAX;
62  timestamp_max = TIMESTAMP_MIN;
63  expiration_time = TIMESTAMP_NULL;
64  create_time = 0;
65  expirable_data = 0;
66  table_id = 0xffffffff;
67  table_generation = 0;
68  flags = 0;
69  compression_ratio = 0.0;
70  compression_type = 0;
71  key_compression_scheme = 0;
72  bloom_filter_mode = BLOOM_FILTER_DISABLED;
73  bloom_filter_hash_count = 0;
74  version = 3;
75 }
76 
77 
78 
81 void CellStoreTrailerV3::serialize(uint8_t *buf) {
82  uint8_t *base = buf;
83  encode_i64(&buf, fix_index_offset);
84  encode_i64(&buf, var_index_offset);
85  encode_i64(&buf, filter_offset);
86  encode_i64(&buf, index_entries);
87  encode_i64(&buf, total_entries);
88  encode_i64(&buf, filter_length);
89  encode_i64(&buf, filter_items_estimate);
90  encode_i64(&buf, filter_items_actual);
91  encode_i64(&buf, blocksize);
92  encode_i64(&buf, revision);
93  encode_i64(&buf, timestamp_min);
94  encode_i64(&buf, timestamp_max);
95  encode_i64(&buf, expiration_time);
96  encode_i64(&buf, create_time);
97  encode_i64(&buf, expirable_data);
98  encode_i32(&buf, table_id);
99  encode_i32(&buf, table_generation);
100  encode_i32(&buf, flags);
101  encode_i32(&buf, compression_ratio_i32);
102  encode_i16(&buf, compression_type);
103  encode_i16(&buf, key_compression_scheme);
104  encode_i8(&buf, bloom_filter_mode);
105  encode_i8(&buf, bloom_filter_hash_count);
106  encode_i16(&buf, version);
107  assert(version == 3);
108  assert((buf-base) == (int)CellStoreTrailerV3::size());
109  (void)base;
110 }
111 
112 
113 
116 void CellStoreTrailerV3::deserialize(const uint8_t *buf) {
117  HT_TRY("deserializing cellstore trailer",
118  size_t remaining = CellStoreTrailerV3::size();
119  fix_index_offset = decode_i64(&buf, &remaining);
120  var_index_offset = decode_i64(&buf, &remaining);
121  filter_offset = decode_i64(&buf, &remaining);
122  index_entries = decode_i64(&buf, &remaining);
123  total_entries = decode_i64(&buf, &remaining);
124  filter_length = decode_i64(&buf, &remaining);
125  filter_items_estimate = decode_i64(&buf, &remaining);
126  filter_items_actual = decode_i64(&buf, &remaining);
127  blocksize = decode_i64(&buf, &remaining);
128  revision = decode_i64(&buf, &remaining);
129  timestamp_min = decode_i64(&buf, &remaining);
130  timestamp_max = decode_i64(&buf, &remaining);
131  expiration_time = decode_i64(&buf, &remaining);
132  create_time = decode_i64(&buf, &remaining);
133  expirable_data = decode_i64(&buf, &remaining);
134  table_id = decode_i32(&buf, &remaining);
135  table_generation = decode_i32(&buf, &remaining);
136  flags = decode_i32(&buf, &remaining);
137  compression_ratio_i32 = decode_i32(&buf, &remaining);
138  compression_type = decode_i16(&buf, &remaining);
139  key_compression_scheme = decode_i16(&buf, &remaining);
140  bloom_filter_mode = decode_i8(&buf, &remaining);
141  bloom_filter_hash_count = decode_i8(&buf, &remaining);
142  version = decode_i16(&buf, &remaining));
143 }
144 
145 
146 
149 void CellStoreTrailerV3::display(std::ostream &os) {
150  os << "{CellStoreTrailerV3: ";
151  os << "fix_index_offset=" << fix_index_offset;
152  os << ", var_index_offset=" << var_index_offset;
153  os << ", filter_offset=" << filter_offset;
154  os << ", index_entries=" << index_entries;
155  os << ", total_entries=" << total_entries;
156  os << ", filter_length = " << filter_length;
157  os << ", filter_items_estimate = " << filter_items_estimate;
158  os << ", filter_items_actual = " << filter_items_actual;
159  os << ", blocksize=" << blocksize;
160  os << ", revision=" << revision;
161  os << ", timestamp_min=" << timestamp_min;
162  os << ", timestamp_max=" << timestamp_max;
163  os << ", expiration_time=" << expiration_time;
164  os << ", create_time=" << create_time;
165  os << ", expirable_data=" << expirable_data;
166  os << ", table_id=" << table_id;
167  os << ", table_generation=" << table_generation;
168  if (flags & INDEX_64BIT)
169  os << ", flags=64BIT_INDEX";
170  else
171  os << ", flags=" << flags;
172  os << ", compression_ratio=" << compression_ratio;
173  os << ", compression_type=" << compression_type;
174  os << ", key_compression_scheme=" << key_compression_scheme;
175  if (bloom_filter_mode == BLOOM_FILTER_DISABLED)
176  os << ", bloom_filter_mode=DISABLED";
177  else if (bloom_filter_mode == BLOOM_FILTER_ROWS)
178  os << ", bloom_filter_mode=ROWS";
179  else if (bloom_filter_mode == BLOOM_FILTER_ROWS_COLS)
180  os << ", bloom_filter_mode=ROWS_COLS";
181  else
182  os << ", bloom_filter_mode=?(" << bloom_filter_mode << ")";
183  os << ", bloom_filter_hash_count=" << bloom_filter_hash_count;
184  os << ", version=" << version << "}";
185 }
186 
189 void CellStoreTrailerV3::display_multiline(std::ostream &os) {
190  os << "[CellStoreTrailerV3]\n";
191  os << " fix_index_offset: " << fix_index_offset << "\n";
192  os << " var_index_offset: " << var_index_offset << "\n";
193  os << " filter_offset: " << filter_offset << "\n";
194  os << " index_entries: " << index_entries << "\n";
195  os << " total_entries: " << total_entries << "\n";
196  os << " filter_length: " << filter_length << "\n";
197  os << " filter_items_estimate: " << filter_items_estimate << "\n";
198  os << " filter_items_actual: " << filter_items_actual << "\n";
199  os << " blocksize: " << blocksize << "\n";
200  os << " revision: " << revision << "\n";
201  os << " timestamp_min: " << timestamp_min << "\n";
202  os << " timestamp_max: " << timestamp_max << "\n";
203  os << " expiration_time: " << expiration_time << "\n";
204  os << " create_time: " << create_time << "\n";
205  os << " expirable_data: " << expirable_data << "\n";
206  os << " table_id: " << table_id << "\n";
207  os << " table_generation: " << table_generation << "\n";
208  if (flags & INDEX_64BIT)
209  os << " flags: 64BIT_INDEX\n";
210  else
211  os << " flags=" << flags << "\n";
212  os << " compression_ratio: " << compression_ratio << "\n";
213  os << " compression_type: " << compression_type << "\n";
214  os << " key_compression_scheme: " << key_compression_scheme << "\n";
215  if (bloom_filter_mode == BLOOM_FILTER_DISABLED)
216  os << " bloom_filter_mode=DISABLED\n";
217  else if (bloom_filter_mode == BLOOM_FILTER_ROWS)
218  os << " bloom_filter_mode=ROWS\n";
219  else if (bloom_filter_mode == BLOOM_FILTER_ROWS_COLS)
220  os << " bloom_filter_mode=ROWS_COLS\n";
221  else
222  os << " bloom_filter_mode=?(" << bloom_filter_mode << ")\n";
223  os << " bloom_filter_hash_count=" << (int)bloom_filter_hash_count << "\n";
224  os << " version: " << version << std::endl;
225 }
226 
STL namespace.
Declarations for Schema.
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
static const int64_t TIMESTAMP_MIN
Definition: KeySpec.h:34
uint8_t decode_i8(const uint8_t **bufp, size_t *remainp)
Decode a 8-bit integer (a byte/character)
Definition: Serialization.h:60
uint64_t decode_i64(const uint8_t **bufp, size_t *remainp)
Decode a 64-bit integer in little-endian order.
uint16_t decode_i16(const uint8_t **bufp, size_t *remainp)
Decode a 16-bit integer in little-endian order.
Logging routines and macros.
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
void encode_i16(uint8_t **bufp, uint16_t val)
Encode a 16-bit integer in little-endian order.
void encode_i64(uint8_t **bufp, uint64_t val)
Encode a 64-bit integer in little-endian order.
Functions to serialize/deserialize primitives to/from a memory buffer.
static const int64_t TIMESTAMP_NULL
Definition: KeySpec.h:36
Hypertable definitions
static const int64_t TIMESTAMP_MAX
Definition: KeySpec.h:35
#define HT_TRY(_s_, _code_)
Definition: Error.h:517
void encode_i8(uint8_t **bufp, uint8_t val)
Encodes a byte into the given buffer.
Definition: Serialization.h:49