Retrieves the next field of the current stream ID and its corresponding value * in a stream iteration. This function should be called repeatedly after calling * RedisModule_StreamIteratorNextID() to fetch each field-value pair. * * - `key`: Key where a stream iterator has been started. * - `field_ptr`: This is where the field is returned. * - `value_ptr`: This is where the value is returned.
| 3706 | * See the example at RedisModule_StreamIteratorStart(). |
| 3707 | */ |
| 3708 | int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_ptr, RedisModuleString **value_ptr) { |
| 3709 | if (!key) { |
| 3710 | errno = EINVAL; |
| 3711 | return REDISMODULE_ERR; |
| 3712 | } else if (!key->value || key->value->type != OBJ_STREAM) { |
| 3713 | errno = ENOTSUP; |
| 3714 | return REDISMODULE_ERR; |
| 3715 | } else if (!key->iter) { |
| 3716 | errno = EBADF; |
| 3717 | return REDISMODULE_ERR; |
| 3718 | } else if (key->u.stream.numfieldsleft <= 0) { |
| 3719 | errno = ENOENT; |
| 3720 | return REDISMODULE_ERR; |
| 3721 | } |
| 3722 | streamIterator *si = (streamIterator*)key->iter; |
| 3723 | unsigned char *field, *value; |
| 3724 | int64_t field_len, value_len; |
| 3725 | streamIteratorGetField(si, &field, &value, &field_len, &value_len); |
| 3726 | if (field_ptr) { |
| 3727 | *field_ptr = createRawStringObject((char *)field, field_len); |
| 3728 | autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, *field_ptr); |
| 3729 | } |
| 3730 | if (value_ptr) { |
| 3731 | *value_ptr = createRawStringObject((char *)value, value_len); |
| 3732 | autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, *value_ptr); |
| 3733 | } |
| 3734 | key->u.stream.numfieldsleft--; |
| 3735 | return REDISMODULE_OK; |
| 3736 | } |
| 3737 | |
| 3738 | /* Deletes the current stream entry while iterating. |
| 3739 | * |
nothing calls this directly
no test coverage detected