MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / insert

Method insert

src/storage/rocksdb.cpp:47–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47void RocksDBStorageProvider::insert(const char *key, size_t cchKey, void *data, size_t cb, bool fOverwrite)
48{
49 rocksdb::Status status;
50 std::unique_lock<fastlock> l(m_lock);
51 std::string prefixed_key = prefixKey(key, cchKey);
52 if (m_spbatch != nullptr)
53 status = m_spbatch->Put(m_spcolfamily.get(), rocksdb::Slice(prefixed_key), rocksdb::Slice((const char*)data, cb));
54 else
55 status = m_spdb->Put(WriteOptions(), m_spcolfamily.get(), rocksdb::Slice(prefixed_key), rocksdb::Slice((const char*)data, cb));
56 if (!status.ok())
57 throw status.ToString();
58
59 if (!fOverwrite)
60 ++m_count;
61}
62
63void RocksDBStorageProvider::bulkInsert(char **rgkeys, size_t *rgcbkeys, char **rgvals, size_t *rgcbvals, size_t celem)
64{

Callers 1

createMetadataDbMethod · 0.45

Calls 3

prefixKeyFunction · 0.85
okMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected