diff --git a/src/yb/common/redis_protocol.proto b/src/yb/common/redis_protocol.proto index 5fa9281e36e7..fbf72bc5c63f 100644 --- a/src/yb/common/redis_protocol.proto +++ b/src/yb/common/redis_protocol.proto @@ -70,7 +70,6 @@ message RedisIndexRangePB { message RedisIndexBoundPB { required int64 index = 1; - optional bool is_exclusive = 2 [default = false]; } // Wrapper for a subkey which denotes an upper/lower bound for a range request. diff --git a/src/yb/docdb/doc_operation.cc b/src/yb/docdb/doc_operation.cc index e0ca93ade747..0eedff109e13 100644 --- a/src/yb/docdb/doc_operation.cc +++ b/src/yb/docdb/doc_operation.cc @@ -1324,13 +1324,9 @@ Status RedisReadOperation::ExecuteCollectionGetRange() { PrimitiveValue(ValueType::kSSForward).AppendToKey(&encoded_doc_key); bool add_keys = request_.get_collection_range_request().with_scores(); - bool low_is_exclusive = low_index_bound.is_exclusive(); - bool high_is_exclusive = high_index_bound.is_exclusive(); - IndexBound low_bound = - IndexBound(low_idx_normalized, low_is_exclusive, true /* is_lower */); - IndexBound high_bound = - IndexBound(high_idx_normalized, high_is_exclusive, false /* is_lower */); + IndexBound low_bound = IndexBound(low_idx_normalized, true /* is_lower */); + IndexBound high_bound = IndexBound(high_idx_normalized, false /* is_lower */); SubDocument doc; bool doc_found = false; diff --git a/src/yb/docdb/docdb.h b/src/yb/docdb/docdb.h index 5f5af13f915a..f094f049a05b 100644 --- a/src/yb/docdb/docdb.h +++ b/src/yb/docdb/docdb.h @@ -296,30 +296,23 @@ class IndexBound { public: IndexBound() : index_(-1), - is_exclusive_(false), is_lower_bound_(false) {} - IndexBound(int64 index, bool is_exclusive, bool is_lower_bound) : + IndexBound(int64 index, bool is_lower_bound) : index_(index), - is_exclusive_(is_exclusive), is_lower_bound_(is_lower_bound) {} bool CanInclude(int64 curr_index) const { if (index_ == -1 ) { return true; } - if (is_lower_bound_) { - return (is_exclusive_) ? (index_ < curr_index) : (index_ <= curr_index); - } else { - return (is_exclusive_) ? (index_ > curr_index) : (index_ >= curr_index); - } + return is_lower_bound_ ? index_ <= curr_index : index_ >= curr_index; } static const IndexBound& Empty(); private: const int64 index_; - const bool is_exclusive_; const bool is_lower_bound_; }; diff --git a/src/yb/yql/redis/redisserver/redis_parser.cc b/src/yb/yql/redis/redisserver/redis_parser.cc index 2efcf122f9bc..c07dcf787584 100644 --- a/src/yb/yql/redis/redisserver/redis_parser.cc +++ b/src/yb/yql/redis/redisserver/redis_parser.cc @@ -505,11 +505,10 @@ CHECKED_STATUS ParseTsBoundArg(const Slice& slice, RedisSubKeyBoundPB* bound_pb, } CHECKED_STATUS -ParseIndexBoundArg(const Slice& slice, RedisIndexBoundPB* bound_pb, bool exclusive) { +ParseIndexBoundArg(const Slice& slice, RedisIndexBoundPB* bound_pb) { auto index_bound = util::CheckedStoll(slice); RETURN_NOT_OK(index_bound); bound_pb->set_index(*index_bound); - bound_pb->set_is_exclusive(exclusive); return Status::OK(); } @@ -534,14 +533,7 @@ CHECKED_STATUS ParseIndexBound(const Slice& slice, RedisIndexBoundPB* bound_pb) if (slice.empty()) { return STATUS(InvalidArgument, "range bound index cannot be empty"); } - - if (slice[0] == '(' && slice.size() > 1) { - auto slice_copy = slice; - slice_copy.remove_prefix(1); - RETURN_NOT_OK(ParseIndexBoundArg(slice_copy, bound_pb, /* exclusive */ true)); - } else { - RETURN_NOT_OK(ParseIndexBoundArg(slice, bound_pb, /* exclusive */ false)); - } + RETURN_NOT_OK(ParseIndexBoundArg(slice, bound_pb)); return Status::OK(); } diff --git a/src/yb/yql/redis/redisserver/redisserver-test.cc b/src/yb/yql/redis/redisserver/redisserver-test.cc index b93e50306888..96a502f8506e 100644 --- a/src/yb/yql/redis/redisserver/redisserver-test.cc +++ b/src/yb/yql/redis/redisserver/redisserver-test.cc @@ -1633,7 +1633,6 @@ TEST_F(TestRedisService, TestZRevRange) { {1, 1, 1, 0, 0, 0}, {"v5", "v4", "v3", "v2", "v1", "v0"}); DoRedisTestArray(__LINE__, {"ZREVRANGE", "z_multi", "0", "1"}, {"v5", "v4"}); - DoRedisTestArray(__LINE__, {"ZREVRANGE", "z_multi", "(0", "(1"}, {}); DoRedisTestArray(__LINE__, {"ZREVRANGE", "z_multi", "2", "3"}, {"v3", "v2"}); DoRedisTestArray(__LINE__, {"ZREVRANGE", "z_multi", "6", "7"}, {}); DoRedisTestArray(__LINE__, {"ZREVRANGE", "z_multi", "0", "-1"}, @@ -1650,6 +1649,9 @@ TEST_F(TestRedisService, TestZRevRange) { DoRedisTestExpectError(__LINE__, {"ZREVRANGE", "z_multi", "1", "2", "WITHSCORES", "1"}); DoRedisTestExpectError(__LINE__, {"ZREVRANGE", "z_multi", "1.0", "2.0"}); DoRedisTestExpectError(__LINE__, {"ZREVRANGE", "1", "2"}); + DoRedisTestExpectError(__LINE__, {"ZREVRANGE", "z_multi", "0", "(2"}); + DoRedisTestExpectError(__LINE__, {"ZREVRANGE", "z_multi", "(0", "2"}); + DoRedisTestExpectError(__LINE__, {"ZREVRANGE", "z_multi", "(0", "(2"}); // Test key with wrong type. DoRedisTestOk(__LINE__, {"SET", "s_key", "s_val"});