Commit 1abce35d authored by John Esmet's avatar John Esmet

FT-93 Fix a bug with aligned pivotkeys where we may overestimate how

much space is needed on disk
parent 71b54a74
......@@ -540,7 +540,7 @@ ftnode_memory_size (FTNODE node)
int n_children = node->n_children;
retval += sizeof(*node);
retval += (n_children)*(sizeof(node->bp[0]));
retval += node->pivotkeys.total_size();
retval += node->pivotkeys.serialized_size();
// now calculate the sizes of the partitions
for (int i = 0; i < n_children; i++) {
......
......@@ -436,7 +436,7 @@ void ftnode_pivot_keys::serialize_to_wbuf(struct wbuf *wb) const {
wbuf_nocrc_bytes(wb, fixed ? _fixed_key(i) : _dbt_keys[i].data, size);
written += size;
}
invariant(written == _total_size);
invariant(written == serialized_size());
}
int ftnode_pivot_keys::num_pivots() const {
......@@ -450,3 +450,9 @@ size_t ftnode_pivot_keys::total_size() const {
paranoid_invariant(_fixed_keys == nullptr || (_total_size == _fixed_keylen_aligned * _num_pivots));
return _total_size;
}
size_t ftnode_pivot_keys::serialized_size() const {
// we only return the size that will be used when serialized, so we calculate based
// on the fixed keylen and not the aligned keylen.
return _fixed_format() ? _num_pivots * _fixed_keylen : _total_size;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment