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

Function encodeKey

fdbserver/KeyValueStoreSQLite.actor.cpp:656–677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654}
655
656Value encodeKey(KeyRef key, bool using_fragments) {
657 int keyCode = key.size() * 2 + 12;
658 int header_size = sqlite3VarintLen(keyCode);
659 if (using_fragments) // will be encoded as key, 0 (where 0 is really a null)
660 ++header_size;
661 int hh = sqlite3VarintLen(header_size);
662 header_size += hh;
663 if (hh < sqlite3VarintLen(header_size))
664 header_size++;
665 int size = header_size + key.size();
666 Value v;
667 uint8_t* d = new (v.arena()) uint8_t[size];
668 ((ValueRef&)v) = KeyRef(d, size);
669 d += sqlite3PutVarint(d, header_size);
670 d += sqlite3PutVarint(d, keyCode);
671 if (using_fragments)
672 *d++ = 0;
673 memcpy(d, key.begin(), key.size());
674 d += key.size();
675 ASSERT(d == v.begin() + size);
676 return v;
677}
678
679struct SQLiteTransaction {
680 SQLiteDB& db;

Callers

nothing calls this directly

Calls 4

KeyRefClass · 0.85
memcpyFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected