Given a key size and value prefix size, get the minimum bytes that must be read from the underlying btree tuple to safely read the prefix length from the value bytes (if the value is long enough)
| 571 | // Given a key size and value prefix size, get the minimum bytes that must be read from the underlying |
| 572 | // btree tuple to safely read the prefix length from the value bytes (if the value is long enough) |
| 573 | int getEncodedKVFragmentSize(int keySize, int valuePrefixSize) { |
| 574 | int keyCode = keySize * 2 + 12; |
| 575 | int header_size = sqlite3VarintLen(keyCode) + 1 // index code length |
| 576 | + 8; // worst case for value size (larger than fdb api allows) |
| 577 | int hh = sqlite3VarintLen(header_size); |
| 578 | header_size += hh; |
| 579 | if (hh < sqlite3VarintLen(header_size)) |
| 580 | header_size++; |
| 581 | return header_size + keySize + 4 // Max width allowed of index value |
| 582 | + valuePrefixSize; |
| 583 | } |
| 584 | |
| 585 | // Decode (key, index, value) tuple. |
| 586 | // A present() Optional will always be returned UNLESS partial is true. |
no outgoing calls
no test coverage detected