MCPcopy Create free account
hub / github.com/F-Stack/f-stack / genericGetKeys

Function genericGetKeys

app/redis-6.2.6/src/db.c:1677–1698  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1675 * 'keyStep': the interval of each key, usually this value is 1.
1676 * */
1677int 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
1700int zunionInterDiffStoreGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
1701 UNUSED(cmd);

Callers 3

zunionInterDiffGetKeysFunction · 0.85
evalGetKeysFunction · 0.85

Calls 1

getKeysPrepareResultFunction · 0.85

Tested by

no test coverage detected