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
| 1675 | * 'keyStep': the interval of each key, usually this value is 1. |
| 1676 | * */ |
| 1677 | int genericGetKeys(int storeKeyOfs, int keyCountOfs, int firstKeyOfs, int keyStep, |
| 1678 | robj **argv, int argc, getKeysResult *result) { |
| 1679 | int i, num, *keys; |
| 1680 | |
| 1681 | num = atoi(argv[keyCountOfs]->ptr); |
| 1682 | /* Sanity check. Don't return any key if the command is going to |
| 1683 | * reply with syntax error. (no input keys). */ |
| 1684 | if (num < 1 || num > (argc - firstKeyOfs)/keyStep) { |
| 1685 | result->numkeys = 0; |
| 1686 | return 0; |
| 1687 | } |
| 1688 | |
| 1689 | int numkeys = storeKeyOfs ? num + 1 : num; |
| 1690 | keys = getKeysPrepareResult(result, numkeys); |
| 1691 | result->numkeys = numkeys; |
| 1692 | |
| 1693 | /* Add all key positions for argv[firstKeyOfs...n] to keys[] */ |
| 1694 | for (i = 0; i < num; i++) keys[i] = firstKeyOfs+(i*keyStep); |
| 1695 | |
| 1696 | if (storeKeyOfs) keys[num] = storeKeyOfs; |
| 1697 | return result->numkeys; |
| 1698 | } |
| 1699 | |
| 1700 | int zunionInterDiffStoreGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) { |
| 1701 | UNUSED(cmd); |
no test coverage detected