Add store test case for GeoRadiusByMember (#2210)

* Add store test case for GeoRadiusByMember;Parsing code for STORE and STOREDIST

---------

Signed-off-by: azuredream <zhaozixuan67@gmail.com>
This commit is contained in:
zixuan zhao 2023-11-27 03:01:22 -08:00 committed by GitHub
parent 92614477b7
commit 3f7e42b099
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 4 deletions

View file

@ -241,7 +241,6 @@ void Transaction::InitByKeys(KeyIndex key_index) {
bool is_stub = multi_ && multi_->role == SQUASHED_STUB;
if ((key_index.HasSingleKey() && !IsAtomicMulti()) || is_stub) {
DCHECK_GT(key_index.step, 0u);
// We don't have to split the arguments by shards, so we can copy them directly.
StoreKeysInArgs(key_index, needs_reverse_mapping);
@ -260,8 +259,8 @@ void Transaction::InitByKeys(KeyIndex key_index) {
}
shard_data_.resize(shard_set->size()); // shard_data isn't sparse, so we must allocate for all :(
CHECK(key_index.step == 1 || key_index.step == 2);
DCHECK(key_index.step == 1 || (args.size() % 2) == 0);
DCHECK(key_index.step == 1 || key_index.step == 2);
DCHECK(key_index.step != 2 || (args.size() % 2) == 0);
// Safe, because flow below is not preemptive.
auto& shard_index = tmp_space.GetShardIndex(shard_data_.size());
@ -1494,6 +1493,7 @@ OpResult<KeyIndex> DetermineKeys(const CommandId* cid, CmdArgList args) {
if (cid->first_key_pos() > 0) {
key_index.start = cid->first_key_pos() - 1;
int last = cid->last_key_pos();
if (num_custom_keys >= 0) {
key_index.end = key_index.start + num_custom_keys;
} else {
@ -1501,6 +1501,18 @@ OpResult<KeyIndex> DetermineKeys(const CommandId* cid, CmdArgList args) {
}
key_index.step = cid->opt_mask() & CO::INTERLEAVED_KEYS ? 2 : 1;
if (cid->opt_mask() & CO::STORE_LAST_KEY) {
string_view name{cid->name()};
if (name == "GEORADIUSBYMEMBER" && args.size() >= 5) {
// key member radius .. STORE destkey
string_view opt = ArgS(args, args.size() - 2);
if (absl::EqualsIgnoreCase(opt, "STORE") || absl::EqualsIgnoreCase(opt, "STOREDIST")) {
key_index.bonus = args.size() - 1;
}
}
}
return key_index;
}