Skip to content

Commit 4749107

Browse files
jameseh96daverigby
authored andcommitted
RocksDB: Do not return value in Get if isMetaOnly
Change-Id: I3692f06da71be4e4bb108d49e2440320d11fff34 Reviewed-on: http://review.couchbase.org/82744 Reviewed-by: Dave Rigby <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 25ae6e7 commit 4749107

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

engines/ep/src/rocksdb-kvstore/rocksdb-kvstore.cc

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,11 @@ GetValue RocksDBKVStore::get(const DocKey& key, uint16_t vb, bool fetchDelete) {
146146
return getWithHeader(nullptr, key, vb, GetMetaOnly::No, fetchDelete);
147147
}
148148

149-
GetValue RocksDBKVStore::getWithHeader(
150-
void* dbHandle,
151-
const DocKey& key,
152-
uint16_t vb,
153-
GetMetaOnly getMetaOnly, // TODO RDB: get meta only
154-
bool fetchDelete) {
149+
GetValue RocksDBKVStore::getWithHeader(void* dbHandle,
150+
const DocKey& key,
151+
uint16_t vb,
152+
GetMetaOnly getMetaOnly,
153+
bool fetchDelete) {
155154
std::string k(mkKeyStr(vb, key));
156155
std::string value;
157156

@@ -160,7 +159,7 @@ GetValue RocksDBKVStore::getWithHeader(
160159
if (!s.ok()) {
161160
return GetValue{NULL, ENGINE_KEY_ENOENT};
162161
}
163-
return makeGetValue(vb, key, value);
162+
return makeGetValue(vb, key, value, getMetaOnly);
164163
}
165164

166165
void RocksDBKVStore::getMulti(uint16_t vb, vb_bgfetch_queue_t& itms) {
@@ -171,7 +170,8 @@ void RocksDBKVStore::getMulti(uint16_t vb, vb_bgfetch_queue_t& itms) {
171170
std::string value;
172171
rocksdb::Status s = db->Get(rocksdb::ReadOptions(), vbAndKey, &value);
173172
if (s.ok()) {
174-
it.second.value = makeGetValue(vb, key, value);
173+
it.second.value =
174+
makeGetValue(vb, key, value, it.second.isMetaOnly);
175175
GetValue* rv = &it.second.value;
176176
for (auto& fetch : it.second.bgfetched_list) {
177177
fetch->value = rv;
@@ -312,7 +312,8 @@ rocksdb::Slice RocksDBKVStore::mkValSlice(const Item& item) {
312312

313313
std::unique_ptr<Item> RocksDBKVStore::grokValSlice(uint16_t vb,
314314
const DocKey& key,
315-
const rocksdb::Slice& s) {
315+
const rocksdb::Slice& s,
316+
GetMetaOnly getMetaOnly) {
316317
// Reverse of mkValSlice - deserialize back into an Item.
317318

318319
assert(s.size() >= sizeof(ItemMetaData) + sizeof(uint64_t) +
@@ -342,11 +343,13 @@ std::unique_ptr<Item> RocksDBKVStore::grokValSlice(uint16_t vb,
342343
uint8_t extMeta[EXT_META_LEN];
343344
extMeta[0] = datatype;
344345

346+
bool includeValue = getMetaOnly == GetMetaOnly::No && valueLen;
347+
345348
auto item = std::make_unique<Item>(key,
346349
meta.flags,
347350
meta.exptime,
348-
src,
349-
valueLen,
351+
includeValue ? src : nullptr,
352+
includeValue ? valueLen : 0,
350353
extMeta,
351354
EXT_META_LEN,
352355
meta.cas,
@@ -363,9 +366,11 @@ std::unique_ptr<Item> RocksDBKVStore::grokValSlice(uint16_t vb,
363366

364367
GetValue RocksDBKVStore::makeGetValue(uint16_t vb,
365368
const DocKey& key,
366-
const std::string& value) {
369+
const std::string& value,
370+
GetMetaOnly getMetaOnly) {
367371
rocksdb::Slice sval(value);
368-
return GetValue(grokValSlice(vb, key, sval), ENGINE_SUCCESS, -1, 0);
372+
return GetValue(
373+
grokValSlice(vb, key, sval, getMetaOnly), ENGINE_SUCCESS, -1, 0);
369374
}
370375

371376
ScanContext* RocksDBKVStore::initScanContext(

engines/ep/src/rocksdb-kvstore/rocksdb-kvstore.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,13 @@ class RocksDBKVStore : public KVStore {
276276
rocksdb::SliceParts mkValSliceParts(const Item& item);
277277
std::unique_ptr<Item> grokValSlice(uint16_t vb,
278278
const DocKey& key,
279-
const rocksdb::Slice& s);
279+
const rocksdb::Slice& s,
280+
GetMetaOnly getMetaOnly);
280281

281282
GetValue makeGetValue(uint16_t vb,
282283
const DocKey& key,
283-
const std::string& value);
284+
const std::string& value,
285+
GetMetaOnly getMetaOnly = GetMetaOnly::No);
284286

285287
void storeItem(const Item& item);
286288

engines/ep/tests/ep_testsuite_xdcr.cc

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,15 +2513,8 @@ BaseTestCase testsuite_testcases[] = {
25132513
// XDCR unit tests
25142514
TestCase("get meta", test_get_meta, test_setup,
25152515
teardown, NULL, prepare, cleanup),
2516-
TestCase("get meta with extras",
2517-
test_get_meta_with_extras,
2518-
test_setup,
2519-
teardown,
2520-
NULL,
2521-
/* TODO RDB: Enable after making getMeta with
2522-
* isMetaOnly not return value */
2523-
prepare_skip_broken_under_rocks,
2524-
cleanup),
2516+
TestCase("get meta with extras", test_get_meta_with_extras,
2517+
test_setup, teardown, NULL, prepare, cleanup),
25252518
TestCase("get meta deleted", test_get_meta_deleted,
25262519
test_setup, teardown, NULL, prepare, cleanup),
25272520
TestCase("get meta nonexistent", test_get_meta_nonexistent,

0 commit comments

Comments
 (0)