Helper function to extract keys from following commands: * COMMAND [destkey] [...] [...] ... * * eg: * ZUNION ... * ZUNIONSTORE ... * * 'storeKeyOfs': destkey index, 0 means destkey not exists. * 'keyCountOfs': num-keys index. * 'firstKeyOfs': firstkey index. * 'keySte
| 2224 | * 'keyStep': the interval of each key, usually this value is 1. |
| 2225 | * */ |
| 2226 | int genericGetKeys(int storeKeyOfs, int keyCountOfs, int firstKeyOfs, int keyStep, |
| 2227 | robj **argv, int argc, getKeysResult *result) { |
| 2228 | int i, num, *keys; |
| 2229 | |
| 2230 | num = atoi(szFromObj(argv[keyCountOfs])); |
| 2231 | /* Sanity check. Don't return any key if the command is going to |
| 2232 | * reply with syntax error. (no input keys). */ |
| 2233 | if (num < 1 || num > (argc - firstKeyOfs)/keyStep) { |
| 2234 | result->numkeys = 0; |
| 2235 | return 0; |
| 2236 | } |
| 2237 | |
| 2238 | int numkeys = storeKeyOfs ? num + 1 : num; |
| 2239 | keys = getKeysPrepareResult(result, numkeys); |
| 2240 | result->numkeys = numkeys; |
| 2241 | |
| 2242 | /* Add all key positions for argv[firstKeyOfs...n] to keys[] */ |
| 2243 | for (i = 0; i < num; i++) keys[i] = firstKeyOfs+(i*keyStep); |
| 2244 | |
| 2245 | if (storeKeyOfs) keys[num] = storeKeyOfs; |
| 2246 | return result->numkeys; |
| 2247 | } |
| 2248 | |
| 2249 | int zunionInterDiffStoreGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { |
| 2250 | UNUSED(cmd); |
no test coverage detected