Commit 86aa35a1 authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Set-up dispatching for VHSET, VHGETALL

parent 1576c73e
Pipeline #717559 passed with stages
in 37 minutes and 14 seconds
......@@ -67,6 +67,7 @@ struct cmdMapInit {
redis_cmd_map["raw_get_all_versions"] = {RedisCommand::RAW_GET_ALL_VERSIONS, CommandType::READ};
redis_cmd_map["clock_get"] = {RedisCommand::CLOCK_GET, CommandType::READ};
redis_cmd_map["type"] = {RedisCommand::TYPE, CommandType::READ};
redis_cmd_map["vhgetall"] = {RedisCommand::VHGETALL, CommandType::READ};
redis_cmd_map["flushall"] = {RedisCommand::FLUSHALL, CommandType::WRITE};
redis_cmd_map["set"] = {RedisCommand::SET, CommandType::WRITE};
......@@ -100,6 +101,7 @@ struct cmdMapInit {
redis_cmd_map["timestamped_lease_acquire"] = {RedisCommand::TIMESTAMPED_LEASE_ACQUIRE, CommandType::WRITE};
redis_cmd_map["timestamped_lease_get"] = {RedisCommand::TIMESTAMPED_LEASE_GET, CommandType::WRITE};
redis_cmd_map["timestamped_lease_release"] = {RedisCommand::TIMESTAMPED_LEASE_RELEASE, CommandType::WRITE};
redis_cmd_map["vhset"] = {RedisCommand::VHSET, CommandType::WRITE};
redis_cmd_map["exec"] = {RedisCommand::EXEC, CommandType::CONTROL};
redis_cmd_map["discard"] = {RedisCommand::DISCARD, CommandType::CONTROL};
......
......@@ -110,6 +110,9 @@ enum class RedisCommand {
LEASE_ACQUIRE,
LEASE_RELEASE,
VHSET,
VHGETALL,
TIMESTAMPED_LEASE_GET,
TIMESTAMPED_LEASE_ACQUIRE,
TIMESTAMPED_LEASE_RELEASE,
......
......@@ -421,6 +421,14 @@ RedisEncodedResponse RedisDispatcher::dispatchWrite(StagingArea &stagingArea, Re
if(!st.ok()) return Formatter::fromStatus(st);
return Formatter::ok();
}
case RedisCommand::VHSET: {
if(request.size() != 4) return Formatter::errArgs("vhset");
uint64_t version;
rocksdb::Status st = store.vhset(stagingArea, request[1], request[2], request[3], version);
if(!st.ok()) return Formatter::fromStatus(st);
return Formatter::integer(version);
}
case RedisCommand::TX_READWRITE: {
// Unpack transaction and process
Transaction transaction;
......@@ -760,6 +768,14 @@ RedisEncodedResponse RedisDispatcher::dispatchRead(StagingArea &stagingArea, Red
return Formatter::statusVector(reply);
}
case RedisCommand::VHGETALL: {
if(request.size() != 2) return errArgs(request);
std::vector<std::string> vec;
uint64_t version = 0u;
rocksdb::Status st = store.vhgetall(stagingArea, request[1], vec, version);
if(!st.ok()) return Formatter::fromStatus(st);
return Formatter::versionedVector(version, vec);
}
case RedisCommand::TX_READONLY: {
// Unpack transaction and process
Transaction transaction;
......
......@@ -1816,3 +1816,34 @@ TEST_F(Raft_e2e, pubsub) {
ASSERT_EQ(mq->size(), 0u);
}
TEST_F(Raft_e2e, vhset) {
spinup(0); spinup(1); spinup(2);
RETRY_ASSERT_TRUE(checkStateConsensus(0, 1, 2));
int leaderID = getLeaderID();
std::vector<std::future<redisReplyPtr>> replies;
replies.emplace_back(tunnel(leaderID)->exec("set", "key-0", "val"));
replies.emplace_back(tunnel(leaderID)->exec("vhset", "key-0", "f1", "v1"));
replies.emplace_back(tunnel(leaderID)->exec("vhset", "key-1", "f1", "v1"));
ASSERT_REPLY(replies[0], "OK");
ASSERT_REPLY(replies[1], "ERR Invalid argument: WRONGTYPE Operation against a key holding the wrong kind of value");
ASSERT_REPLY(replies[2], 1);
ASSERT_REPLY(tunnel(leaderID)->exec("vhset", "key-1", "f2", "v2"), 2);
ASSERT_REPLY(tunnel(leaderID)->exec("vhset", "key-1", "f3", "v3"), 3);
ASSERT_REPLY(tunnel(leaderID)->exec("vhset", "key-1", "f4", "v4"), 4);
ASSERT_REPLY_DESCRIBE(tunnel(leaderID)->exec("vhgetall", "key-1").get(),
"1) (integer) 4\n"
"2) 1) \"f1\"\n"
" 2) \"v1\"\n"
" 3) \"f2\"\n"
" 4) \"v2\"\n"
" 5) \"f3\"\n"
" 6) \"v3\"\n"
" 7) \"f4\"\n"
" 8) \"v4\"\n"
);
}
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