-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move redis keyspace from the system keyspace
- Loading branch information
Showing
16 changed files
with
531 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "redis/commands/lindex.hh" | ||
#include "redis/commands/unexpected.hh" | ||
#include "redis/reply_builder.hh" | ||
#include "redis/request.hh" | ||
#include "redis/reply.hh" | ||
#include "timeout_config.hh" | ||
#include "service/client_state.hh" | ||
#include "service/storage_proxy.hh" | ||
#include "db/system_keyspace.hh" | ||
#include "partition_slice_builder.hh" | ||
#include "gc_clock.hh" | ||
#include "dht/i_partitioner.hh" | ||
#include "log.hh" | ||
namespace redis { | ||
namespace commands { | ||
|
||
shared_ptr<abstract_command> lindex::prepare(service::storage_proxy& proxy, request&& req) | ||
{ | ||
if (req._args_count < 2) { | ||
return unexpected::prepare(std::move(req._command), std::move(bytes { msg_syntax_err }) ); | ||
} | ||
return make_shared<lindex>(std::move(req._command), lists_schema(proxy), std::move(req._args[0]), bytes2long(req._args[1])); | ||
} | ||
|
||
future<reply> lindex::execute(service::storage_proxy& proxy, db::consistency_level cl, db::timeout_clock::time_point now, const timeout_config& tc, service::client_state& cs) | ||
{ | ||
auto timeout = now + tc.read_timeout; | ||
auto fetched = prefetch_partition_helper::prefetch_list(proxy, _schema, _key, cl, timeout, cs, _index); | ||
return fetched.then([this, &proxy, cl, timeout, &cs] (auto pd) { | ||
if (pd && pd->fetched()) { | ||
auto& e = pd->cells().front(); | ||
return reply_builder::build<message_tag>(e._value); | ||
} | ||
return reply_builder::build<null_message_tag>(); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
#include "redis/command_with_single_schema.hh" | ||
#include "redis/request.hh" | ||
|
||
namespace service { | ||
class storage_proxy; | ||
} | ||
class timeout_config; | ||
namespace redis { | ||
namespace commands { | ||
class lindex : public command_with_single_schema { | ||
protected: | ||
bytes _key; | ||
long _index; | ||
public: | ||
lindex(bytes&& name, const schema_ptr schema, bytes&& key, long index) | ||
: command_with_single_schema(std::move(name), schema) | ||
, _key(std::move(key)) | ||
, _index(index) | ||
{ | ||
} | ||
~lindex() {} | ||
static shared_ptr<abstract_command> prepare(service::storage_proxy& proxy, request&& req); | ||
virtual future<reply> execute(service::storage_proxy&, | ||
db::consistency_level, | ||
db::timeout_clock::time_point, | ||
const timeout_config& tc, | ||
service::client_state& cs | ||
) override; | ||
}; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "redis/commands/llen.hh" | ||
#include "redis/commands/unexpected.hh" | ||
#include "redis/reply_builder.hh" | ||
#include "redis/request.hh" | ||
#include "redis/reply.hh" | ||
#include "timeout_config.hh" | ||
#include "service/client_state.hh" | ||
#include "service/storage_proxy.hh" | ||
#include "db/system_keyspace.hh" | ||
#include "partition_slice_builder.hh" | ||
#include "gc_clock.hh" | ||
#include "dht/i_partitioner.hh" | ||
#include "log.hh" | ||
namespace redis { | ||
namespace commands { | ||
|
||
shared_ptr<abstract_command> llen::prepare(service::storage_proxy& proxy, request&& req) | ||
{ | ||
if (req._args_count < 1) { | ||
return unexpected::prepare(std::move(req._command), std::move(bytes { msg_syntax_err }) ); | ||
} | ||
return make_shared<llen>(std::move(req._command), lists_schema(proxy), std::move(req._args[0])); | ||
} | ||
|
||
future<reply> llen::execute(service::storage_proxy& proxy, db::consistency_level cl, db::timeout_clock::time_point now, const timeout_config& tc, service::client_state& cs) | ||
{ | ||
auto timeout = now + tc.read_timeout; | ||
auto fetched = prefetch_partition_helper::prefetch_list(proxy, _schema, _key, cl, timeout, cs, only_size_tag {}); | ||
return fetched.then([this, &proxy, cl, timeout, &cs] (auto pd) { | ||
if (pd && pd->fetched()) { | ||
return reply_builder::build<number_tag>(pd->only_size()); | ||
} | ||
return reply_builder::build<error_message_tag>(); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
#include "redis/command_with_single_schema.hh" | ||
#include "redis/request.hh" | ||
|
||
namespace service { | ||
class storage_proxy; | ||
} | ||
class timeout_config; | ||
namespace redis { | ||
namespace commands { | ||
class llen : public command_with_single_schema { | ||
protected: | ||
bytes _key; | ||
public: | ||
llen(bytes&& name, const schema_ptr schema, bytes&& key) | ||
: command_with_single_schema(std::move(name), schema) | ||
, _key(std::move(key)) | ||
{ | ||
} | ||
~llen() {} | ||
static shared_ptr<abstract_command> prepare(service::storage_proxy& proxy, request&& req); | ||
virtual future<reply> execute(service::storage_proxy&, | ||
db::consistency_level, | ||
db::timeout_clock::time_point, | ||
const timeout_config& tc, | ||
service::client_state& cs | ||
) override; | ||
}; | ||
|
||
} | ||
} |
Oops, something went wrong.