https://slatedb.io logo
More accurate SST size estimation for the memtable...
# general
m
@almog I'm having some trouble modifying the code. Do you have time to help me?
How can we estimate the size of an entry after it is encoded by row_codec? I realize that knowing the original entry size doesn’t seem to help with this estimation. I’m unclear on how to set hypothetical values, such as key_prefix_len, key_size + key_len, or value_size + value_len
a
I'm not totally sure I understand your question, I was suggesting that we account for all the fixed size elements in a row. Specifically, we have everything here that is not a
var
or optional:
Copy code
/// | Field            | Type  | Description                                            |
/// |------------------|-------|--------------------------------------------------------|
/// | `key_prefix_len` | `u16` | Length of the key prefix                               |
/// | `key_suffix_len` | `u16` | Length of the key suffix                               |
/// | `key_suffix`     | `var` | Suffix of the key                                      |
/// | `seq`            | `u64` | Sequence Number                                        |
/// | `flags`          | `u8`  | Flags of the row                                       |
/// | `expire_ts`      | `u64` | Optional, only has value when flags & HAS_EXPIRE_TS    |
/// | `create_ts`      | `u64` | Optional, only has value when flags & HAS_CREATE_TS    |
/// | `value_len`      | `u32` | Length of the value                                    |
/// | `value`          | `var` | Value bytes                                            |
m
I understand,i will finish it in today night.
I'm having difficulty splitting the Index Block and Metadata Block, both of which are encoded with FlatBuffers. I'm unsure where to place the calculation code for these two components.
I currently keep the calculation logic for these two blocks in SsTableFormat::estimate_encoded_size. I've uploaded the code for your review. Please provide feedback (you can comment directly on GitHub). Once you confirm the code is correct, I'll proceed to write tests for the new functions.