Skip to content

Commit

Permalink
Add reversed options when query the partition
Browse files Browse the repository at this point in the history
  • Loading branch information
fastio committed Mar 9, 2019
1 parent ea5d36b commit 64400f2
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 317 deletions.
4 changes: 3 additions & 1 deletion query-request.hh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ public:
void set_partition_row_limit(uint32_t limit) {
_partition_row_limit = limit;
}

void set_reversed() {
options.set<query::partition_slice::option::reversed>();
}
friend std::ostream& operator<<(std::ostream& out, const partition_slice& ps);
friend std::ostream& operator<<(std::ostream& out, const specific_ranges& ps);
};
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/lindex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ shared_ptr<abstract_command> lindex::prepare(service::storage_proxy& proxy, requ
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;
return prefetch_list(proxy, _schema, _key, fetch_options::values, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs] (auto pd) {
return prefetch_list(proxy, _schema, _key, fetch_options::values, false, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs] (auto pd) {
if (pd && pd->has_data()) {
auto& data = pd->data();
if (static_cast<size_t>(_index) < data.size()) {
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/llen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ shared_ptr<abstract_command> llen::prepare(service::storage_proxy& proxy, reques
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;
return prefetch_list(proxy, _schema, _key, fetch_options::values, cl, timeout, cs).then([] (auto pd) {
return prefetch_list(proxy, _schema, _key, fetch_options::values, false, cl, timeout, cs).then([] (auto pd) {
if (pd && pd->has_data()) {
return reply_builder::build<number_tag>(static_cast<size_t>(pd->data().size()));
}
Expand Down
4 changes: 2 additions & 2 deletions redis/commands/lpop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ future<reply> rpop::execute(service::storage_proxy& proxy, db::consistency_level
future<reply> pop::do_execute(service::storage_proxy& proxy, db::consistency_level cl, db::timeout_clock::time_point now, const timeout_config& tc, service::client_state& cs, bool left)
{
auto timeout = now + tc.read_timeout;
return prefetch_list(proxy, _schema, _key, fetch_options::all, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs, left] (auto pd) {
return prefetch_list(proxy, _schema, _key, fetch_options::all, !left, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs, left] (auto pd) {
if (pd && pd->has_data()) {
auto removed = [left, &pd] () { return left ? pd->data().front() : pd->data().back(); } ();
auto removed = pd->data().front();
return [this, removed_cell_key = removed.first, &proxy, &cs, timeout, cl, pd] () {
// The last cell, delete this partition.
if (pd->data_size() == 1) {
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/lrange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ shared_ptr<abstract_command> lrange::prepare(service::storage_proxy& proxy, requ
future<reply> lrange::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;
return prefetch_list(proxy, _schema, _key, fetch_options::values, cl, timeout, cs).then([] (auto pd) {
return prefetch_list(proxy, _schema, _key, fetch_options::values, false, cl, timeout, cs).then([] (auto pd) {
if (pd && pd->has_data()) {
auto&& vals = boost::copy_range<std::vector<std::optional<bytes>>> (pd->data() | boost::adaptors::transformed([] (auto& data) {
return std::move(data.first);
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/lrem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ shared_ptr<abstract_command> lrem::prepare(service::storage_proxy& proxy, reques
future<reply> lrem::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;
return prefetch_list(proxy, _schema, _key, fetch_options::all, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs] (auto pd) {
return prefetch_list(proxy, _schema, _key, fetch_options::all, false, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs] (auto pd) {
if (pd && pd->has_data()) {
std::vector<std::optional<bytes>> removed;
auto& data = pd->data();
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/lset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ shared_ptr<abstract_command> lset::prepare(service::storage_proxy& proxy, reques
future<reply> lset::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;
return prefetch_list(proxy, _schema, _key, fetch_options::keys, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs] (auto pd) {
return prefetch_list(proxy, _schema, _key, fetch_options::keys, false, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs] (auto pd) {
if (pd && pd->has_data()) {
auto& e = pd->data().front();
std::vector<std::pair<std::optional<bytes>, std::optional<bytes>>> new_cells { { std::move(e.first), std::move(e.second) } };
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/ltrim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ shared_ptr<abstract_command> ltrim::prepare(service::storage_proxy& proxy, reque
future<reply> ltrim::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;
return prefetch_list(proxy, _schema, _key, fetch_options::all, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs] (auto pd) {
return prefetch_list(proxy, _schema, _key, fetch_options::all, false, cl, timeout, cs).then([this, &proxy, cl, timeout, &cs] (auto pd) {
if (pd && pd->has_data()) {
std::vector<std::optional<bytes>> removed;
auto& data = pd->data();
Expand Down
Loading

0 comments on commit 64400f2

Please sign in to comment.