Finds the next stream entry and returns its stream ID and the number of * fields. * * - `key`: Key for which a stream iterator has been started using * RedisModule_StreamIteratorStart(). * - `id`: The stream ID returned. NULL if you don't care. * - `numfields`: The number of fields in the found stream entry. NULL if you * don't care. * * Returns REDISMODULE_OK and sets `*id` and `*num
| 3650 | * See the example at RedisModule_StreamIteratorStart(). |
| 3651 | */ |
| 3652 | int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long *numfields) { |
| 3653 | if (!key) { |
| 3654 | errno = EINVAL; |
| 3655 | return REDISMODULE_ERR; |
| 3656 | } else if (!key->value || key->value->type != OBJ_STREAM) { |
| 3657 | errno = ENOTSUP; |
| 3658 | return REDISMODULE_ERR; |
| 3659 | } else if (!key->iter) { |
| 3660 | errno = EBADF; |
| 3661 | return REDISMODULE_ERR; |
| 3662 | } |
| 3663 | streamIterator *si = (streamIterator*)key->iter; |
| 3664 | int64_t *num_ptr = &key->u.stream.numfieldsleft; |
| 3665 | streamID *streamid_ptr = &key->u.stream.currentid; |
| 3666 | if (streamIteratorGetID(si, streamid_ptr, num_ptr)) { |
| 3667 | if (id) { |
| 3668 | id->ms = streamid_ptr->ms; |
| 3669 | id->seq = streamid_ptr->seq; |
| 3670 | } |
| 3671 | if (numfields) *numfields = *num_ptr; |
| 3672 | return REDISMODULE_OK; |
| 3673 | } else { |
| 3674 | /* No entry found. */ |
| 3675 | key->u.stream.currentid.ms = 0; /* for RM_StreamIteratorDelete() */ |
| 3676 | key->u.stream.currentid.seq = 0; |
| 3677 | key->u.stream.numfieldsleft = 0; /* for RM_StreamIteratorNextField() */ |
| 3678 | errno = ENOENT; |
| 3679 | return REDISMODULE_ERR; |
| 3680 | } |
| 3681 | } |
| 3682 | |
| 3683 | /* Retrieves the next field of the current stream ID and its corresponding value |
| 3684 | * in a stream iteration. This function should be called repeatedly after calling |
nothing calls this directly
no test coverage detected