Commit 04bc6d8e authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Implement redis command to scan through tombstone keys

parent 0e5fc91b
Pipeline #822543 passed with stages
in 65 minutes and 2 seconds
......@@ -63,6 +63,7 @@ struct cmdMapInit {
redis_cmd_map["lhlen"] = {RedisCommand::LHLEN, CommandType::READ};
redis_cmd_map["lhscan"] = {RedisCommand::LHSCAN, CommandType::READ};
redis_cmd_map["lhget_with_fallback"] = {RedisCommand::LHGET_WITH_FALLBACK, CommandType::READ};
redis_cmd_map["raw_scan_tombstones"] = {RedisCommand::RAW_SCAN_TOMBSTONES, CommandType::READ};
redis_cmd_map["raw_scan"] = {RedisCommand::RAW_SCAN, CommandType::READ};
redis_cmd_map["raw_get_all_versions"] = {RedisCommand::RAW_GET_ALL_VERSIONS, CommandType::READ};
redis_cmd_map["clock_get"] = {RedisCommand::CLOCK_GET, CommandType::READ};
......
......@@ -94,6 +94,7 @@ enum class RedisCommand {
DEQUE_SCAN_BACK,
RAW_SCAN,
RAW_SCAN_TOMBSTONES,
RAW_GET_ALL_VERSIONS,
TYPE,
......
......@@ -447,7 +447,6 @@ RedisEncodedResponse RedisDispatcher::dispatchWrite(StagingArea &stagingArea, Re
qdb_throw("internal dispatching error in RedisDispatcher for " << request);
}
}
}
RedisEncodedResponse RedisDispatcher::dispatchHGET(StagingArea &stagingArea, std::string_view key, std::string_view field) {
......@@ -721,12 +720,20 @@ RedisEncodedResponse RedisDispatcher::dispatchRead(StagingArea &stagingArea, Red
return Formatter::integer(len);
}
case RedisCommand::RAW_SCAN: {
if(request.size() != 2 && request.size() != 4) return errArgs(request);
case RedisCommand::RAW_SCAN_TOMBSTONES:
bool withTombstones = request.getCommand() == RedisCommand::RAW_SCAN_TOMBSTONES;
if(request.size() != 1 && request.size() != 2 && request.size() != 4) return errArgs(request);
std::string_view cursor;
if(request.size() > 1) {
cursor = request[1];
}
rocksdb::Status st;
std::vector<std::string> results;
if(request.size() == 2) {
st = store.rawScan(stagingArea, request[1], 50, results);
if(request.size() == 1 || request.size() == 2) {
st = store.rawScanMaybeTombstones(stagingArea, cursor, 50, results, withTombstones);
}
else {
if(!caseInsensitiveEquals(request[2], "count")) {
......@@ -738,7 +745,7 @@ RedisEncodedResponse RedisDispatcher::dispatchRead(StagingArea &stagingArea, Red
return Formatter::err("syntax error");
}
st = store.rawScan(stagingArea, request[1], count, results);
st = store.rawScanMaybeTombstones(stagingArea, cursor, count, results, withTombstones);
}
if(!st.ok()) return Formatter::fromStatus(st);
......
......@@ -641,6 +641,14 @@ inline uint64_t DecodeFixed64(const char* ptr) {
return result;
}
rocksdb::Status StateMachine::rawScanMaybeTombstones(StagingArea &stagingArea, std::string_view seek, size_t count, std::vector<std::string> &elements, bool tombstones) {
if(tombstones) {
return rawScanTombstones(stagingArea, seek, count, elements);
}
return rawScan(stagingArea, seek, count, elements);
}
rocksdb::Status StateMachine::rawScanTombstones(StagingArea &stagingArea, std::string_view key, size_t count, std::vector<std::string> &elements) {
elements.clear();
......
......@@ -118,6 +118,7 @@ public:
rocksdb::Status keys(StagingArea &stagingArea, std::string_view pattern, std::vector<std::string> &result);
rocksdb::Status exists(StagingArea &stagingArea, const ReqIterator &start, const ReqIterator &end, int64_t &count);
rocksdb::Status rawScanTombstones(StagingArea &stagingArea, std::string_view seek, size_t count, std::vector<std::string> &elements);
rocksdb::Status rawScanMaybeTombstones(StagingArea &stagingArea, std::string_view seek, size_t count, std::vector<std::string> &elements, bool tombstones);
// hashes
rocksdb::Status hget(StagingArea &stagingArea, std::string_view key, std::string_view field, std::string &value);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment