44 CellStoreTrailerV6::CellStoreTrailerV6() {
45 assert(
sizeof(
float) == 4);
52 void CellStoreTrailerV6::clear() {
57 replaced_files_offset = 0;
61 filter_items_estimate = 0;
62 filter_items_actual = 0;
63 replaced_files_length = 0;
64 replaced_files_entries = 0;
75 table_id = 0xffffffff;
79 compression_ratio = 0.0;
81 key_compression_scheme = 0;
83 bloom_filter_hash_count = 0;
91 void CellStoreTrailerV6::serialize(uint8_t *buf) {
123 encode_i8(&buf, bloom_filter_hash_count);
126 trailer_checksum = (int32_t)
fletcher32(base+4, buf-(base+4));
130 assert(version == 6);
131 assert((buf-base) == (
int)CellStoreTrailerV6::size());
139 void CellStoreTrailerV6::deserialize(
const uint8_t *buf) {
140 const uint8_t *base = buf+4;
141 HT_TRY(
"deserializing cellstore trailer",
142 size_t remaining = CellStoreTrailerV6::size();
143 trailer_checksum =
decode_i32(&buf, &remaining);
144 fix_index_offset =
decode_i64(&buf, &remaining);
145 var_index_offset =
decode_i64(&buf, &remaining);
147 replaced_files_offset =
decode_i64(&buf, &remaining);
151 filter_items_estimate =
decode_i64(&buf, &remaining);
152 filter_items_actual =
decode_i64(&buf, &remaining);
153 replaced_files_length =
decode_i64(&buf, &remaining);
154 replaced_files_entries =
decode_i32(&buf, &remaining);
159 expiration_time =
decode_i64(&buf, &remaining);
161 expirable_data =
decode_i64(&buf, &remaining);
166 table_generation =
decode_i32(&buf, &remaining);
169 compression_ratio_i32 =
decode_i32(&buf, &remaining);
170 compression_type =
decode_i16(&buf, &remaining);
171 key_compression_scheme =
decode_i16(&buf, &remaining);
172 bloom_filter_mode =
decode_i8(&buf, &remaining);
173 bloom_filter_hash_count =
decode_i8(&buf, &remaining);
175 int32_t checksum = (int32_t)
fletcher32(base, buf-base);
176 if (checksum != trailer_checksum)
178 (
int)trailer_checksum, (
int)checksum);
185 void CellStoreTrailerV6::display(std::ostream &os) {
186 os <<
"{CellStoreTrailerV6: ";
187 os <<
"trailer_checksum=" << std::hex << trailer_checksum << std::dec;
188 os <<
", fix_index_offset=" << fix_index_offset;
189 os <<
", var_index_offset=" << var_index_offset;
190 os <<
", filter_offset=" << filter_offset;
191 os <<
", replaced_files_offset=" << replaced_files_offset;
192 os <<
", index_entries=" << index_entries;
193 os <<
", total_entries=" << total_entries;
194 os <<
", filter_length = " << filter_length;
195 os <<
", filter_items_estimate = " << filter_items_estimate;
196 os <<
", filter_items_actual = " << filter_items_actual;
197 os <<
", replaced_files_length=" << replaced_files_length;
198 os <<
", replaced_files_entries=" << replaced_files_entries;
199 os <<
", blocksize=" << blocksize;
200 os <<
", revision=" << revision;
201 os <<
", timestamp_min=" << timestamp_min;
202 os <<
", timestamp_max=" << timestamp_max;
203 os <<
", expiration_time=" << expiration_time;
204 os <<
", create_time=" << create_time;
205 os <<
", expirable_data=" << expirable_data;
206 os <<
", delete_count=" << delete_count;
207 os <<
", key_bytes=" << key_bytes;
208 os <<
", value_bytes=" << value_bytes;
209 os <<
", table_id=" << table_id;
210 os <<
", table_generation=" << table_generation;
211 os <<
", flags=" << flags <<
" (";
212 if (flags & INDEX_64BIT)
213 os <<
" 64BIT_INDEX";
214 if (flags & MAJOR_COMPACTION)
215 os <<
" MAJOR_COMPACTION";
217 os <<
", alignment=" << alignment;
218 os <<
", compression_ratio=" << compression_ratio;
219 os <<
", compression_type=" << compression_type;
220 os <<
", key_compression_scheme=" << key_compression_scheme;
222 os <<
", bloom_filter_mode=DISABLED";
224 os <<
", bloom_filter_mode=ROWS";
226 os <<
", bloom_filter_mode=ROWS_COLS";
228 os <<
", bloom_filter_mode=?(" << bloom_filter_mode <<
")";
229 os <<
", bloom_filter_hash_count=" << bloom_filter_hash_count;
230 os <<
", version=" << version <<
"}";
235 void CellStoreTrailerV6::display_multiline(std::ostream &os) {
236 os <<
"[CellStoreTrailerV6]\n";
237 os <<
" trailer_checksum: " << std::hex << trailer_checksum << std::dec <<
"\n";
238 os <<
" fix_index_offset: " << fix_index_offset <<
"\n";
239 os <<
" var_index_offset: " << var_index_offset <<
"\n";
240 os <<
" filter_offset: " << filter_offset <<
"\n";
241 os <<
" replaced_files_offset: " << replaced_files_offset <<
"\n";
242 os <<
" index_entries: " << index_entries <<
"\n";
243 os <<
" total_entries: " << total_entries <<
"\n";
244 os <<
" filter_length: " << filter_length <<
"\n";
245 os <<
" filter_items_estimate: " << filter_items_estimate <<
"\n";
246 os <<
" filter_items_actual: " << filter_items_actual <<
"\n";
247 os <<
" replaced_files_length: " << replaced_files_length <<
"\n";
248 os <<
" replaced_files_entries: " << replaced_files_entries <<
"\n";
249 os <<
" blocksize: " << blocksize <<
"\n";
250 os <<
" revision: " << revision <<
"\n";
251 os <<
" timestamp_min: " << timestamp_min <<
"\n";
252 os <<
" timestamp_max: " << timestamp_max <<
"\n";
253 os <<
" expiration_time: " << expiration_time <<
"\n";
254 os <<
" create_time: " << create_time <<
"\n";
255 os <<
" expirable_data: " << expirable_data <<
"\n";
256 os <<
" delete_count: " << delete_count <<
"\n";
257 os <<
" key_bytes: " << key_bytes <<
"\n";
258 os <<
" value_bytes: " << value_bytes <<
"\n";
259 os <<
" table_id: " << table_id <<
"\n";
260 os <<
" table_generation: " << table_generation <<
"\n";
261 if (flags & INDEX_64BIT)
262 os <<
" flags: 64BIT_INDEX\n";
264 os <<
" flags=" << flags <<
"\n";
265 os <<
" alignment=" << alignment <<
"\n";
266 os <<
" compression_ratio: " << compression_ratio <<
"\n";
267 os <<
" compression_type: " << compression_type <<
"\n";
268 os <<
" key_compression_scheme: " << key_compression_scheme <<
"\n";
270 os <<
" bloom_filter_mode=DISABLED\n";
272 os <<
" bloom_filter_mode=ROWS\n";
274 os <<
" bloom_filter_mode=ROWS_COLS\n";
276 os <<
" bloom_filter_mode=?(" << bloom_filter_mode <<
")\n";
277 os <<
" bloom_filter_hash_count=" << (int)bloom_filter_hash_count <<
"\n";
278 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_,...)
#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