Commit f0b5437a authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Drop list commands, repurpose implementation as deque

See changelog for rationale behind this.
parent 5a9d1b00
Pipeline #484626 passed with stages
in 32 minutes and 16 seconds
# Changelog
All notable changes to this project will be documented in this file.
## Unreleased
### Changed
- Dropped list commands, as the underlying implementation makes it impossible to support all list commands found in official redis. (most notably `linsert`)
Still, the old implementation makes for an excellent deque. Renamed list commands `lpush`, `lpop`, `rpush`, `rpop`, `rlen` to `deque-push-front`, `deque-pop-front`, `deque-push-back`, `deque-pop-back`, `deque-len`. The underlying data format did not change, only the command names.
This makes it possible to implement lists properly in the future.
No-one has been using the list operations, which gives us the opportunity to change the command names.
## 0.3.2 (2018-08-14)
### Added
- Protection against 1-way network partitions, in which a cluster node
......
......@@ -55,7 +55,7 @@ struct cmdMapInit {
redis_cmd_map["smembers"] = {RedisCommand::SMEMBERS, CommandType::READ};
redis_cmd_map["scard"] = {RedisCommand::SCARD, CommandType::READ};
redis_cmd_map["sscan"] = {RedisCommand::SSCAN, CommandType::READ};
redis_cmd_map["llen"] = {RedisCommand::LLEN, CommandType::READ};
redis_cmd_map["deque_len"] = {RedisCommand::DEQUE_LEN, CommandType::READ};
redis_cmd_map["config_get"] = {RedisCommand::CONFIG_GET, CommandType::READ};
redis_cmd_map["config_getall"] = {RedisCommand::CONFIG_GETALL, CommandType::READ};
redis_cmd_map["lhget"] = {RedisCommand::LHGET, CommandType::READ};
......@@ -79,10 +79,10 @@ struct cmdMapInit {
redis_cmd_map["sadd"] = {RedisCommand::SADD, CommandType::WRITE};
redis_cmd_map["srem"] = {RedisCommand::SREM, CommandType::WRITE};
redis_cmd_map["smove"] = {RedisCommand::SMOVE, CommandType::WRITE};
redis_cmd_map["lpush"] = {RedisCommand::LPUSH, CommandType::WRITE};
redis_cmd_map["lpop"] = {RedisCommand::LPOP, CommandType::WRITE};
redis_cmd_map["rpush"] = {RedisCommand::RPUSH, CommandType::WRITE};
redis_cmd_map["rpop"] = {RedisCommand::RPOP, CommandType::WRITE};
redis_cmd_map["deque_push_front"] = {RedisCommand::DEQUE_PUSH_FRONT, CommandType::WRITE};
redis_cmd_map["deque_pop_front"] = {RedisCommand::DEQUE_POP_FRONT, CommandType::WRITE};
redis_cmd_map["deque_push_back"] = {RedisCommand::DEQUE_PUSH_BACK, CommandType::WRITE};
redis_cmd_map["deque_pop_back"] = {RedisCommand::DEQUE_POP_BACK, CommandType::WRITE};
redis_cmd_map["config_set"] = {RedisCommand::CONFIG_SET, CommandType::WRITE};
redis_cmd_map["lhset"] = {RedisCommand::LHSET, CommandType::WRITE};
redis_cmd_map["lhdel"] = {RedisCommand::LHDEL, CommandType::WRITE};
......
......@@ -84,11 +84,11 @@ enum class RedisCommand {
SCARD,
SSCAN,
LPUSH,
LPOP,
RPUSH,
RPOP,
LLEN,
DEQUE_PUSH_FRONT,
DEQUE_POP_FRONT,
DEQUE_PUSH_BACK,
DEQUE_POP_BACK,
DEQUE_LEN,
RAW_SCAN,
RAW_GET_ALL_VERSIONS,
......
......@@ -263,21 +263,21 @@ RedisEncodedResponse RedisDispatcher::dispatchWrite(StagingArea &stagingArea, Re
if(!st.ok()) return Formatter::fromStatus(st);
return Formatter::integer(count);
}
case RedisCommand::LPUSH: {
case RedisCommand::DEQUE_PUSH_FRONT: {
if(request.size() < 3) return errArgs(request);
int64_t length;
rocksdb::Status st = store.dequePushFront(stagingArea, request[1], request.begin()+2, request.end(), length);
if(!st.ok()) return Formatter::fromStatus(st);
return Formatter::integer(length);
}
case RedisCommand::RPUSH: {
case RedisCommand::DEQUE_PUSH_BACK: {
if(request.size() < 3) return errArgs(request);
int64_t length;
rocksdb::Status st = store.dequePushBack(stagingArea, request[1], request.begin()+2, request.end(), length);
if(!st.ok()) return Formatter::fromStatus(st);
return Formatter::integer(length);
}
case RedisCommand::LPOP: {
case RedisCommand::DEQUE_POP_FRONT: {
if(request.size() != 2) return errArgs(request);
std::string item;
rocksdb::Status st = store.dequePopFront(stagingArea, request[1], item);
......@@ -285,7 +285,7 @@ RedisEncodedResponse RedisDispatcher::dispatchWrite(StagingArea &stagingArea, Re
if(!st.ok()) return Formatter::fromStatus(st);
return Formatter::string(item);
}
case RedisCommand::RPOP: {
case RedisCommand::DEQUE_POP_BACK: {
if(request.size() != 2) return errArgs(request);
std::string item;
rocksdb::Status st = store.dequePopBack(stagingArea, request[1], item);
......@@ -588,7 +588,7 @@ RedisEncodedResponse RedisDispatcher::dispatchRead(StagingArea &stagingArea, Red
else newcursor = "next:" + newcursor;
return Formatter::scan(newcursor, vec);
}
case RedisCommand::LLEN: {
case RedisCommand::DEQUE_LEN: {
if(request.size() != 2) return errArgs(request);
size_t len;
rocksdb::Status st = store.dequeLen(stagingArea, request[1], len);
......
......@@ -507,24 +507,24 @@ TEST_F(Raft_e2e, test_many_redis_commands) {
ASSERT_REPLY(futures[11], 3);
futures.clear();
futures.emplace_back(tunnel(leaderID)->exec("lpush", "list_test", "i1", "i2", "i3", "i4"));
futures.emplace_back(tunnel(leaderID)->exec("deque-push-front", "list_test", "i1", "i2", "i3", "i4"));
futures.emplace_back(tunnel(leaderID)->exec("exists", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("llen", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("lpop", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("llen", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("rpop", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("llen", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-len", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-pop-front", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-len", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-pop-back", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-len", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("del", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("llen", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("lpop", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("rpush", "list_test", "i5", "i6", "i7", "i8"));
futures.emplace_back(tunnel(leaderID)->exec("deque-len", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-pop-front", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-push-back", "list_test", "i5", "i6", "i7", "i8"));
futures.emplace_back(tunnel(leaderID)->exec("set", "list_test", "asdf"));
futures.emplace_back(tunnel(leaderID)->exec("lpop", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("rpop", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("rpop", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("lpop", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-pop-front", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-pop-back", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-pop-back", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-pop-front", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("set", "list_test", "asdf"));
futures.emplace_back(tunnel(leaderID)->exec("lpop", "list_test"));
futures.emplace_back(tunnel(leaderID)->exec("deque-pop-front", "list_test"));
int i = 0;
ASSERT_REPLY(futures[i++], 4);
......
Markdown is supported
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