|
|
|
@ -54,6 +54,8 @@ struct DBParams {
|
|
|
|
|
DBOptions options{};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline auto CharCast(const std::byte* data) { return reinterpret_cast<const char*>(data); }
|
|
|
|
|
|
|
|
|
|
class dbwrapper_error : public std::runtime_error
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
@ -113,12 +115,12 @@ public:
|
|
|
|
|
{
|
|
|
|
|
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
|
|
|
|
ssKey << key;
|
|
|
|
|
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
|
|
|
|
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
|
|
|
|
|
|
|
|
|
ssValue.reserve(DBWRAPPER_PREALLOC_VALUE_SIZE);
|
|
|
|
|
ssValue << value;
|
|
|
|
|
ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent));
|
|
|
|
|
leveldb::Slice slValue((const char*)ssValue.data(), ssValue.size());
|
|
|
|
|
leveldb::Slice slValue(CharCast(ssValue.data()), ssValue.size());
|
|
|
|
|
|
|
|
|
|
batch.Put(slKey, slValue);
|
|
|
|
|
// LevelDB serializes writes as:
|
|
|
|
@ -138,7 +140,7 @@ public:
|
|
|
|
|
{
|
|
|
|
|
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
|
|
|
|
ssKey << key;
|
|
|
|
|
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
|
|
|
|
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
|
|
|
|
|
|
|
|
|
batch.Delete(slKey);
|
|
|
|
|
// LevelDB serializes erases as:
|
|
|
|
@ -177,7 +179,7 @@ public:
|
|
|
|
|
DataStream ssKey{};
|
|
|
|
|
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
|
|
|
|
ssKey << key;
|
|
|
|
|
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
|
|
|
|
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
|
|
|
|
piter->Seek(slKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -265,7 +267,7 @@ public:
|
|
|
|
|
DataStream ssKey{};
|
|
|
|
|
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
|
|
|
|
ssKey << key;
|
|
|
|
|
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
|
|
|
|
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
|
|
|
|
|
|
|
|
|
std::string strValue;
|
|
|
|
|
leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);
|
|
|
|
@ -307,7 +309,7 @@ public:
|
|
|
|
|
DataStream ssKey{};
|
|
|
|
|
ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
|
|
|
|
ssKey << key;
|
|
|
|
|
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
|
|
|
|
leveldb::Slice slKey(CharCast(ssKey.data()), ssKey.size());
|
|
|
|
|
|
|
|
|
|
std::string strValue;
|
|
|
|
|
leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);
|
|
|
|
@ -351,8 +353,8 @@ public:
|
|
|
|
|
ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
|
|
|
|
ssKey1 << key_begin;
|
|
|
|
|
ssKey2 << key_end;
|
|
|
|
|
leveldb::Slice slKey1((const char*)ssKey1.data(), ssKey1.size());
|
|
|
|
|
leveldb::Slice slKey2((const char*)ssKey2.data(), ssKey2.size());
|
|
|
|
|
leveldb::Slice slKey1(CharCast(ssKey1.data()), ssKey1.size());
|
|
|
|
|
leveldb::Slice slKey2(CharCast(ssKey2.data()), ssKey2.size());
|
|
|
|
|
uint64_t size = 0;
|
|
|
|
|
leveldb::Range range(slKey1, slKey2);
|
|
|
|
|
pdb->GetApproximateSizes(&range, 1, &size);
|
|
|
|
|