0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CellStoreTrailerV5.cc
Go to the documentation of this file.
1 
22 #include "Common/Compat.h"
23 #include <cassert>
24 #include <iostream>
25 
26 #include "Common/Filesystem.h"
27 #include "Common/Serialization.h"
28 #include "Common/Logger.h"
29 
30 #include "Hypertable/Lib/KeySpec.h"
31 #include "Hypertable/Lib/Schema.h"
32 
33 #include "CellStoreTrailerV5.h"
34 
35 using namespace std;
36 using namespace Hypertable;
37 using namespace Serialization;
38 
39 
43 CellStoreTrailerV5::CellStoreTrailerV5() {
44  assert(sizeof(float) == 4);
45  clear();
46 }
47 
48 
51 void CellStoreTrailerV5::clear() {
52  fix_index_offset = 0;
53  var_index_offset = 0;
54  filter_offset = 0;
55  replaced_files_offset = 0;
56  index_entries = 0;
57  total_entries = 0;
58  filter_length = 0;
59  filter_items_estimate = 0;
60  filter_items_actual = 0;
61  replaced_files_length = 0;
62  replaced_files_entries = 0;
63  blocksize = 0;
64  revision = TIMESTAMP_MIN;
65  timestamp_min = TIMESTAMP_MAX;
66  timestamp_max = TIMESTAMP_MIN;
67  expiration_time = TIMESTAMP_NULL;
68  create_time = 0;
69  expirable_data = 0;
70  delete_count = 0;
71  key_bytes = 0;
72  value_bytes = 0;
73  table_id = 0xffffffff;
74  table_generation = 0;
75  flags = 0;
76  alignment = HT_DIRECT_IO_ALIGNMENT;
77  compression_ratio = 0.0;
78  compression_type = 0;
79  key_compression_scheme = 0;
80  bloom_filter_mode = BLOOM_FILTER_DISABLED;
81  bloom_filter_hash_count = 0;
82  version = 5;
83 }
84 
85 
86 
89 void CellStoreTrailerV5::serialize(uint8_t *buf) {
90  uint8_t *base = buf;
91  encode_i64(&buf, fix_index_offset);
92  encode_i64(&buf, var_index_offset);
93  encode_i64(&buf, filter_offset);
94  encode_i64(&buf, replaced_files_offset);
95  encode_i64(&buf, index_entries);
96  encode_i64(&buf, total_entries);
97  encode_i64(&buf, filter_length);
98  encode_i64(&buf, filter_items_estimate);
99  encode_i64(&buf, filter_items_actual);
100  encode_i64(&buf, replaced_files_length);
101  encode_i32(&buf, replaced_files_entries);
102  encode_i64(&buf, blocksize);
103  encode_i64(&buf, revision);
104  encode_i64(&buf, timestamp_min);
105  encode_i64(&buf, timestamp_max);
106  encode_i64(&buf, expiration_time);
107  encode_i64(&buf, create_time);
108  encode_i64(&buf, expirable_data);
109  encode_i64(&buf, delete_count);
110  encode_i64(&buf, key_bytes);
111  encode_i64(&buf, value_bytes);
112  encode_i32(&buf, table_id);
113  encode_i32(&buf, table_generation);
114  encode_i32(&buf, flags);
115  encode_i32(&buf, alignment);
116  encode_i32(&buf, compression_ratio_i32);
117  encode_i16(&buf, compression_type);
118  encode_i16(&buf, key_compression_scheme);
119  encode_i8(&buf, bloom_filter_mode);
120  encode_i8(&buf, bloom_filter_hash_count);
121  encode_i16(&buf, version);
122  assert(version == 5);
123  assert((buf-base) == (int)CellStoreTrailerV5::size());
124  (void)base;
125 }
126 
127 
128 
131 void CellStoreTrailerV5::deserialize(const uint8_t *buf) {
132  HT_TRY("deserializing cellstore trailer",
133  size_t remaining = CellStoreTrailerV5::size();
134  fix_index_offset = decode_i64(&buf, &remaining);
135  var_index_offset = decode_i64(&buf, &remaining);
136  filter_offset = decode_i64(&buf, &remaining);
137  replaced_files_offset = decode_i64(&buf, &remaining);
138  index_entries = decode_i64(&buf, &remaining);
139  total_entries = decode_i64(&buf, &remaining);
140  filter_length = decode_i64(&buf, &remaining);
141  filter_items_estimate = decode_i64(&buf, &remaining);
142  filter_items_actual = decode_i64(&buf, &remaining);
143  replaced_files_length = decode_i64(&buf, &remaining);
144  replaced_files_entries = decode_i32(&buf, &remaining);
145  blocksize = decode_i64(&buf, &remaining);
146  revision = decode_i64(&buf, &remaining);
147  timestamp_min = decode_i64(&buf, &remaining);
148  timestamp_max = decode_i64(&buf, &remaining);
149  expiration_time = decode_i64(&buf, &remaining);
150  create_time = decode_i64(&buf, &remaining);
151  expirable_data = decode_i64(&buf, &remaining);
152  delete_count = decode_i64(&buf, &remaining);
153  key_bytes = decode_i64(&buf, &remaining);
154  value_bytes = decode_i64(&buf, &remaining);
155  table_id = decode_i32(&buf, &remaining);
156  table_generation = decode_i32(&buf, &remaining);
157  flags = decode_i32(&buf, &remaining);
158  alignment = decode_i32(&buf, &remaining);
159  compression_ratio_i32 = decode_i32(&buf, &remaining);
160  compression_type = decode_i16(&buf, &remaining);
161  key_compression_scheme = decode_i16(&buf, &remaining);
162  bloom_filter_mode = decode_i8(&buf, &remaining);
163  bloom_filter_hash_count = decode_i8(&buf, &remaining);
164  version = decode_i16(&buf, &remaining));
165 }
166 
167 
168 
171 void CellStoreTrailerV5::display(std::ostream &os) {
172  os << "{CellStoreTrailerV5: ";
173  os << "fix_index_offset=" << fix_index_offset;
174  os << ", var_index_offset=" << var_index_offset;
175  os << ", filter_offset=" << filter_offset;
176  os << ", replaced_files_offset=" << replaced_files_offset;
177  os << ", index_entries=" << index_entries;
178  os << ", total_entries=" << total_entries;
179  os << ", filter_length = " << filter_length;
180  os << ", filter_items_estimate = " << filter_items_estimate;
181  os << ", filter_items_actual = " << filter_items_actual;
182  os << ", replaced_files_length=" << replaced_files_length;
183  os << ", replaced_files_entries=" << replaced_files_entries;
184  os << ", blocksize=" << blocksize;
185  os << ", revision=" << revision;
186  os << ", timestamp_min=" << timestamp_min;
187  os << ", timestamp_max=" << timestamp_max;
188  os << ", expiration_time=" << expiration_time;
189  os << ", create_time=" << create_time;
190  os << ", expirable_data=" << expirable_data;
191  os << ", delete_count=" << delete_count;
192  os << ", key_bytes=" << key_bytes;
193  os << ", value_bytes=" << value_bytes;
194  os << ", table_id=" << table_id;
195  os << ", table_generation=" << table_generation;
196  os << ", flags=" << flags << " (";
197  if (flags & INDEX_64BIT)
198  os << " 64BIT_INDEX";
199  if (flags & MAJOR_COMPACTION)
200  os << " MAJOR_COMPACTION";
201  os << " )";
202  os << ", alignment=" << alignment;
203  os << ", compression_ratio=" << compression_ratio;
204  os << ", compression_type=" << compression_type;
205  os << ", key_compression_scheme=" << key_compression_scheme;
206  if (bloom_filter_mode == BLOOM_FILTER_DISABLED)
207  os << ", bloom_filter_mode=DISABLED";
208  else if (bloom_filter_mode == BLOOM_FILTER_ROWS)
209  os << ", bloom_filter_mode=ROWS";
210  else if (bloom_filter_mode == BLOOM_FILTER_ROWS_COLS)
211  os << ", bloom_filter_mode=ROWS_COLS";
212  else
213  os << ", bloom_filter_mode=?(" << bloom_filter_mode << ")";
214  os << ", bloom_filter_hash_count=" << bloom_filter_hash_count;
215  os << ", version=" << version << "}";
216 }
217 
220 void CellStoreTrailerV5::display_multiline(std::ostream &os) {
221  os << "[CellStoreTrailerV5]\n";
222  os << " fix_index_offset: " << fix_index_offset << "\n";
223  os << " var_index_offset: " << var_index_offset << "\n";
224  os << " filter_offset: " << filter_offset << "\n";
225  os << " replaced_files_offset: " << replaced_files_offset << "\n";
226  os << " index_entries: " << index_entries << "\n";
227  os << " total_entries: " << total_entries << "\n";
228  os << " filter_length: " << filter_length << "\n";
229  os << " filter_items_estimate: " << filter_items_estimate << "\n";
230  os << " filter_items_actual: " << filter_items_actual << "\n";
231  os << " replaced_files_length: " << replaced_files_length << "\n";
232  os << " replaced_files_entries: " << replaced_files_entries << "\n";
233  os << " blocksize: " << blocksize << "\n";
234  os << " revision: " << revision << "\n";
235  os << " timestamp_min: " << timestamp_min << "\n";
236  os << " timestamp_max: " << timestamp_max << "\n";
237  os << " expiration_time: " << expiration_time << "\n";
238  os << " create_time: " << create_time << "\n";
239  os << " expirable_data: " << expirable_data << "\n";
240  os << " delete_count: " << delete_count << "\n";
241  os << " key_bytes: " << key_bytes << "\n";
242  os << " value_bytes: " << value_bytes << "\n";
243  os << " table_id: " << table_id << "\n";
244  os << " table_generation: " << table_generation << "\n";
245  if (flags & INDEX_64BIT)
246  os << " flags: 64BIT_INDEX\n";
247  else
248  os << " flags=" << flags << "\n";
249  os << " alignment=" << alignment << "\n";
250  os << " compression_ratio: " << compression_ratio << "\n";
251  os << " compression_type: " << compression_type << "\n";
252  os << " key_compression_scheme: " << key_compression_scheme << "\n";
253  if (bloom_filter_mode == BLOOM_FILTER_DISABLED)
254  os << " bloom_filter_mode=DISABLED\n";
255  else if (bloom_filter_mode == BLOOM_FILTER_ROWS)
256  os << " bloom_filter_mode=ROWS\n";
257  else if (bloom_filter_mode == BLOOM_FILTER_ROWS_COLS)
258  os << " bloom_filter_mode=ROWS_COLS\n";
259  else
260  os << " bloom_filter_mode=?(" << bloom_filter_mode << ")\n";
261  os << " bloom_filter_hash_count=" << (int)bloom_filter_hash_count << "\n";
262  os << " version: " << version << std::endl;
263 }
264 
Abstract base class for a filesystem.
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
#define HT_DIRECT_IO_ALIGNMENT
Definition: Filesystem.h:49