diff --git a/arangod/RocksDBEngine/RocksDBCollection.cpp b/arangod/RocksDBEngine/RocksDBCollection.cpp index 02b5230e16..7a96ab613a 100644 --- a/arangod/RocksDBEngine/RocksDBCollection.cpp +++ b/arangod/RocksDBEngine/RocksDBCollection.cpp @@ -105,7 +105,7 @@ arangodb::Result RocksDBCollection::persistProperties() { RocksDBKey key(RocksDBKey::Collection(_logicalCollection->vocbase()->id(), _objectId)); RocksDBValue value(RocksDBValue::Document(infoBuilder.slice())); - res = globalRocksDBPut(key.string(), *value.string()); + res = globalRocksDBPut(key.string(), value.string()); } catch (arangodb::basics::Exception const& ex) { res.reset(ex.code()); @@ -810,7 +810,7 @@ int RocksDBCollection::insertDocument(arangodb::transaction::Methods* trx, << "INSERT DOCUMENT. COLLECTION '" << _logicalCollection->name() << "', OBJECTID: " << _objectId << ", REVISIONID: " << revisionId; - rocksdb::Status status = rtrx->Put(key.string(), *value.string()); + rocksdb::Status status = rtrx->Put(key.string(), value.string()); if (!status.ok()) { auto converted = rocksutils::convertStatus(status, rocksutils::StatusHint::document); diff --git a/arangod/RocksDBEngine/RocksDBEngine.cpp b/arangod/RocksDBEngine/RocksDBEngine.cpp index 89472c5ec0..e6cba72778 100644 --- a/arangod/RocksDBEngine/RocksDBEngine.cpp +++ b/arangod/RocksDBEngine/RocksDBEngine.cpp @@ -245,14 +245,14 @@ void RocksDBEngine::getCollectionInfo(TRI_vocbase_t* vocbase, TRI_voc_cid_t cid, auto key = RocksDBKey::Collection(vocbase->id(), cid); auto value = RocksDBValue::Empty(RocksDBEntryType::Collection); rocksdb::ReadOptions options; - rocksdb::Status res = _db->Get(options, key.string(), value.string()); + rocksdb::Status res = _db->Get(options, key.string(), value.buffer()); auto result = rocksutils::convertStatus(res); if (result.errorNumber() != TRI_ERROR_NO_ERROR) { THROW_ARANGO_EXCEPTION(result.errorNumber()); } - builder.add("parameters", VPackSlice(value.string()->data())); + builder.add("parameters", VPackSlice(value.buffer()->data())); if (includeIndexes) { // dump index information @@ -386,7 +386,7 @@ int RocksDBEngine::writeCreateDatabaseMarker(TRI_voc_tick_t id, auto value = RocksDBValue::Database(slice); rocksdb::WriteOptions options; // TODO: check which options would make sense - rocksdb::Status res = _db->Put(options, key.string(), *value.string()); + rocksdb::Status res = _db->Put(options, key.string(), value.string()); auto result = rocksutils::convertStatus(res); return result.errorNumber(); } @@ -398,7 +398,7 @@ int RocksDBEngine::writeCreateCollectionMarker(TRI_voc_tick_t databaseId, auto value = RocksDBValue::Collection(slice); rocksdb::WriteOptions options; // TODO: check which options would make sense - rocksdb::Status res = _db->Put(options, key.string(), *value.string()); + rocksdb::Status res = _db->Put(options, key.string(), value.string()); auto result = rocksutils::convertStatus(res); return result.errorNumber(); } @@ -499,7 +499,7 @@ void RocksDBEngine::createIndex(TRI_vocbase_t* vocbase, auto key = RocksDBKey::Index(vocbase->id(), collectionId, indexId); auto value = RocksDBValue::Index(data); - rocksdb::Status res = _db->Put(options, key.string(), *value.string()); + rocksdb::Status res = _db->Put(options, key.string(), value.string()); auto result = rocksutils::convertStatus(res); if (!result.ok()) { THROW_ARANGO_EXCEPTION(result.errorNumber()); diff --git a/arangod/RocksDBEngine/RocksDBPrimaryIndex.cpp b/arangod/RocksDBEngine/RocksDBPrimaryIndex.cpp index 6dab4a641c..eedc1118a5 100644 --- a/arangod/RocksDBEngine/RocksDBPrimaryIndex.cpp +++ b/arangod/RocksDBEngine/RocksDBPrimaryIndex.cpp @@ -216,7 +216,8 @@ RocksDBToken RocksDBPrimaryIndex::lookupKey(transaction::Methods* trx, auto f = _cache->find(key.string().data(), static_cast(key.string().size())); if (f.found()) { - value.string()->append(reinterpret_cast(f.value()->value()), + f.value(); + value.buffer()->append(reinterpret_cast(f.value()->value()), static_cast(f.value()->valueSize)); return RocksDBToken(RocksDBValue::revisionId(value)); } @@ -227,7 +228,7 @@ RocksDBToken RocksDBPrimaryIndex::lookupKey(transaction::Methods* trx, rocksdb::Transaction* rtrx = state->rocksTransaction(); auto options = state->readOptions(); - auto status = rtrx->Get(options, key.string(), value.string()); + auto status = rtrx->Get(options, key.string(), value.buffer()); if (!status.ok()) { return RocksDBToken(); } @@ -236,7 +237,7 @@ RocksDBToken RocksDBPrimaryIndex::lookupKey(transaction::Methods* trx, // write entry back to cache auto entry = cache::CachedValue::construct( key.string().data(), static_cast(key.string().size()), - value.string()->data(), static_cast(value.string()->size())); + value.buffer()->data(), static_cast(value.buffer()->size())); bool cached = _cache->insert(entry); if (!cached) { delete entry; @@ -257,7 +258,7 @@ RocksDBToken RocksDBPrimaryIndex::lookupKey( rocksdb::Transaction* rtrx = state->rocksTransaction(); auto options = state->readOptions(); - auto status = rtrx->Get(options, key.string(), value.string()); + auto status = rtrx->Get(options, key.string(), value.buffer()); if (!status.ok()) { return RocksDBToken(); } @@ -291,7 +292,7 @@ int RocksDBPrimaryIndex::insert(transaction::Methods* trx, } } - auto status = rtrx->Put(key.string(), *value.string()); + auto status = rtrx->Put(key.string(), value.string()); if (!status.ok()) { auto converted = rocksutils::convertStatus(status, rocksutils::StatusHint::index); diff --git a/arangod/RocksDBEngine/RocksDBVPackIndex.cpp b/arangod/RocksDBEngine/RocksDBVPackIndex.cpp index 1dbd4eda78..67fa1aca69 100644 --- a/arangod/RocksDBEngine/RocksDBVPackIndex.cpp +++ b/arangod/RocksDBEngine/RocksDBVPackIndex.cpp @@ -503,14 +503,14 @@ int RocksDBVPackIndex::insert(transaction::Methods* trx, if (_unique) { RocksDBValue existing = RocksDBValue::Empty(RocksDBEntryType::UniqueIndexValue); - auto status = rtrx->Get(options, key.string(), existing.string()); + auto status = rtrx->Get(options, key.string(), existing.buffer()); if (!status.IsNotFound()) { res = TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED; } } if (res == TRI_ERROR_NO_ERROR) { - auto s = rtrx->Put(key.string(), *value.string()); + auto s = rtrx->Put(key.string(), value.string()); auto status = rocksutils::convertStatus(s, rocksutils::StatusHint::index); if (!status.ok()) { diff --git a/arangod/RocksDBEngine/RocksDBValue.cpp b/arangod/RocksDBEngine/RocksDBValue.cpp index 04437a15db..5bf6f51fab 100644 --- a/arangod/RocksDBEngine/RocksDBValue.cpp +++ b/arangod/RocksDBEngine/RocksDBValue.cpp @@ -105,8 +105,6 @@ VPackSlice RocksDBValue::data(std::string const& s) { return data(s.data(), s.size()); } -std::string* RocksDBValue::string() { return &_buffer; } - RocksDBValue::RocksDBValue(RocksDBEntryType type) : _type(type), _buffer() {} RocksDBValue::RocksDBValue(RocksDBEntryType type, uint64_t data) diff --git a/arangod/RocksDBEngine/RocksDBValue.h b/arangod/RocksDBEngine/RocksDBValue.h index b2f60ea2d1..b9d7d6ec6c 100644 --- a/arangod/RocksDBEngine/RocksDBValue.h +++ b/arangod/RocksDBEngine/RocksDBValue.h @@ -94,7 +94,8 @@ class RocksDBValue { ////////////////////////////////////////////////////////////////////////////// /// @brief Returns a reference to the underlying string buffer. ////////////////////////////////////////////////////////////////////////////// - std::string* string(); + std::string const& string() { return _buffer; } // to be used with put + std::string* buffer() { return &_buffer; } // to be used with get private: RocksDBValue();