49 CellStoreTrailerV7::CellStoreTrailerV7() {
50 assert(
sizeof(
float) == 4);
57 void CellStoreTrailerV7::clear() {
62 replaced_files_offset = 0;
66 filter_items_estimate = 0;
67 filter_items_actual = 0;
68 replaced_files_length = 0;
69 replaced_files_entries = 0;
80 table_id = 0xffffffff;
84 compression_ratio = 0.0;
86 key_compression_scheme = 0;
87 block_header_version = 1;
89 bloom_filter_hash_count = 0;
97 void CellStoreTrailerV7::serialize(uint8_t *buf) {
130 encode_i8(&buf, bloom_filter_hash_count);
133 trailer_checksum = (int32_t)
fletcher32(base+4, buf-(base+4));
137 assert(version == 7);
138 assert((buf-base) == (
int)CellStoreTrailerV7::size());
146 void CellStoreTrailerV7::deserialize(
const uint8_t *buf) {
147 const uint8_t *base = buf+4;
148 HT_TRY(
"deserializing cellstore trailer",
149 size_t remaining = CellStoreTrailerV7::size();
150 trailer_checksum =
decode_i32(&buf, &remaining);
151 fix_index_offset =
decode_i64(&buf, &remaining);
152 var_index_offset =
decode_i64(&buf, &remaining);
154 replaced_files_offset =
decode_i64(&buf, &remaining);
158 filter_items_estimate =
decode_i64(&buf, &remaining);
159 filter_items_actual =
decode_i64(&buf, &remaining);
160 replaced_files_length =
decode_i64(&buf, &remaining);
161 replaced_files_entries =
decode_i32(&buf, &remaining);
166 expiration_time =
decode_i64(&buf, &remaining);
168 expirable_data =
decode_i64(&buf, &remaining);
173 table_generation =
decode_i32(&buf, &remaining);
176 compression_ratio_i32 =
decode_i32(&buf, &remaining);
177 compression_type =
decode_i16(&buf, &remaining);
178 key_compression_scheme =
decode_i16(&buf, &remaining);
179 block_header_version =
decode_i16(&buf, &remaining);
180 bloom_filter_mode =
decode_i8(&buf, &remaining);
181 bloom_filter_hash_count =
decode_i8(&buf, &remaining);
183 int32_t checksum = (int32_t)
fletcher32(base, buf-base);
184 if (checksum != trailer_checksum)
186 (
int)trailer_checksum, (
int)checksum);
193 void CellStoreTrailerV7::display(std::ostream &os) {
194 os <<
"{CellStoreTrailerV7: ";
195 os <<
"trailer_checksum=" << std::hex << trailer_checksum << std::dec;
196 os <<
", fix_index_offset=" << fix_index_offset;
197 os <<
", var_index_offset=" << var_index_offset;
198 os <<
", filter_offset=" << filter_offset;
199 os <<
", replaced_files_offset=" << replaced_files_offset;
200 os <<
", index_entries=" << index_entries;
201 os <<
", total_entries=" << total_entries;
202 os <<
", filter_length = " << filter_length;
203 os <<
", filter_items_estimate = " << filter_items_estimate;
204 os <<
", filter_items_actual = " << filter_items_actual;
205 os <<
", replaced_files_length=" << replaced_files_length;
206 os <<
", replaced_files_entries=" << replaced_files_entries;
207 os <<
", blocksize=" << blocksize;
208 os <<
", revision=" << revision;
209 os <<
", timestamp_min=" << timestamp_min;
210 os <<
", timestamp_max=" << timestamp_max;
211 os <<
", expiration_time=" << expiration_time;
212 os <<
", create_time=" << create_time;
213 os <<
", expirable_data=" << expirable_data;
214 os <<
", delete_count=" << delete_count;
215 os <<
", key_bytes=" << key_bytes;
216 os <<
", value_bytes=" << value_bytes;
217 os <<
", table_id=" << table_id;
218 os <<
", table_generation=" << table_generation;
219 os <<
", flags=" << flags <<
" (";
220 if (flags & INDEX_64BIT)
221 os <<
" 64BIT_INDEX";
222 if (flags & MAJOR_COMPACTION)
223 os <<
" MAJOR_COMPACTION";
225 os <<
", alignment=" << alignment;
226 os <<
", compression_ratio=" << compression_ratio;
227 os <<
", compression_type=" << compression_type;
228 os <<
", key_compression_scheme=" << key_compression_scheme;
229 os <<
", block_header_version=" << block_header_version;
231 os <<
", bloom_filter_mode=DISABLED";
233 os <<
", bloom_filter_mode=ROWS";
235 os <<
", bloom_filter_mode=ROWS_COLS";
237 os <<
", bloom_filter_mode=?(" << bloom_filter_mode <<
")";
238 os <<
", bloom_filter_hash_count=" << bloom_filter_hash_count;
239 os <<
", version=" << version <<
"}";
244 void CellStoreTrailerV7::display_multiline(std::ostream &os) {
245 os <<
"[CellStoreTrailerV7]\n";
246 os <<
" trailer_checksum: " << std::hex << trailer_checksum << std::dec <<
"\n";
247 os <<
" fix_index_offset: " << fix_index_offset <<
"\n";
248 os <<
" var_index_offset: " << var_index_offset <<
"\n";
249 os <<
" filter_offset: " << filter_offset <<
"\n";
250 os <<
" replaced_files_offset: " << replaced_files_offset <<
"\n";
251 os <<
" index_entries: " << index_entries <<
"\n";
252 os <<
" total_entries: " << total_entries <<
"\n";
253 os <<
" filter_length: " << filter_length <<
"\n";
254 os <<
" filter_items_estimate: " << filter_items_estimate <<
"\n";
255 os <<
" filter_items_actual: " << filter_items_actual <<
"\n";
256 os <<
" replaced_files_length: " << replaced_files_length <<
"\n";
257 os <<
" replaced_files_entries: " << replaced_files_entries <<
"\n";
258 os <<
" blocksize: " << blocksize <<
"\n";
259 os <<
" revision: " << revision <<
"\n";
260 os <<
" timestamp_min: " << timestamp_min <<
"\n";
261 os <<
" timestamp_max: " << timestamp_max <<
"\n";
262 os <<
" expiration_time: " << expiration_time <<
"\n";
263 os <<
" create_time: " << create_time <<
"\n";
264 os <<
" expirable_data: " << expirable_data <<
"\n";
265 os <<
" delete_count: " << delete_count <<
"\n";
266 os <<
" key_bytes: " << key_bytes <<
"\n";
267 os <<
" value_bytes: " << value_bytes <<
"\n";
268 os <<
" table_id: " << table_id <<
"\n";
269 os <<
" table_generation: " << table_generation <<
"\n";
270 if (flags & INDEX_64BIT)
271 os <<
" flags: 64BIT_INDEX\n";
273 os <<
" flags=" << flags <<
"\n";
274 os <<
" alignment=" << alignment <<
"\n";
275 os <<
" compression_ratio: " << compression_ratio <<
"\n";
276 os <<
" compression_type: " << compression_type <<
"\n";
277 os <<
" key_compression_scheme: " << key_compression_scheme <<
"\n";
278 os <<
" block_header_version: " << block_header_version <<
"\n";
280 os <<
" bloom_filter_mode=DISABLED\n";
282 os <<
" bloom_filter_mode=ROWS\n";
284 os <<
" bloom_filter_mode=ROWS_COLS\n";
286 os <<
" bloom_filter_mode=?(" << bloom_filter_mode <<
")\n";
287 os <<
" bloom_filter_hash_count=" << (int)bloom_filter_hash_count <<
"\n";
288 os <<
" version: " << version << std::endl;
Abstract base class for a filesystem.
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
uint32_t fletcher32(const void *data8, size_t len8)
Compute fletcher32 checksum for arbitary data.
uint8_t decode_i8(const uint8_t **bufp, size_t *remainp)
Decode a 8-bit integer (a byte/character)
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
Implementation of checksum routines.
static const int64_t TIMESTAMP_MAX
#define HT_THROWF(_code_, _fmt_,...)
Declarations for CellStoreTrailerV7.
#define HT_TRY(_s_, _code_)
void encode_i8(uint8_t **bufp, uint8_t val)
Encodes a byte into the given buffer.
#define HT_DIRECT_IO_ALIGNMENT