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
| 3562 | * See the example at RedisModule_StreamIteratorStart(). |
| 3563 | */ |
| 3564 | int RM_StreamIteratorNextID(RedisModuleKey *key, RedisModuleStreamID *id, long *numfields) { |
| 3565 | if (!key) { |
| 3566 | errno = EINVAL; |
| 3567 | return REDISMODULE_ERR; |
| 3568 | } else if (!key->value || key->value->type != OBJ_STREAM) { |
| 3569 | errno = ENOTSUP; |
| 3570 | return REDISMODULE_ERR; |
| 3571 | } else if (!key->iter) { |
| 3572 | errno = EBADF; |
| 3573 | return REDISMODULE_ERR; |
| 3574 | } |
| 3575 | streamIterator *si = key->iter; |
| 3576 | int64_t *num_ptr = &key->u.stream.numfieldsleft; |
| 3577 | streamID *streamid_ptr = &key->u.stream.currentid; |
| 3578 | if (streamIteratorGetID(si, streamid_ptr, num_ptr)) { |
| 3579 | if (id) { |
| 3580 | id->ms = streamid_ptr->ms; |
| 3581 | id->seq = streamid_ptr->seq; |
| 3582 | } |
| 3583 | if (numfields) *numfields = *num_ptr; |
| 3584 | return REDISMODULE_OK; |
| 3585 | } else { |
| 3586 | /* No entry found. */ |
| 3587 | key->u.stream.currentid.ms = 0; /* for RM_StreamIteratorDelete() */ |
| 3588 | key->u.stream.currentid.seq = 0; |
| 3589 | key->u.stream.numfieldsleft = 0; /* for RM_StreamIteratorNextField() */ |
| 3590 | errno = ENOENT; |
| 3591 | return REDISMODULE_ERR; |
| 3592 | } |
| 3593 | } |
| 3594 | |
| 3595 | /* Retrieves the next field of the current stream ID and its corresponding value |
| 3596 | * in a stream iteration. This function should be called repeatedly after calling |
nothing calls this directly
no test coverage detected