MCPcopy Create free account
hub / github.com/apple/foundationdb / getEncodedKVFragmentSize

Function getEncodedKVFragmentSize

fdbserver/KeyValueStoreSQLite.actor.cpp:573–583  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)
573int 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.

Callers 2

DefragmentingReaderMethod · 0.85
getPrefixMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected