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.
| 3618 | * See the example at RedisModule_StreamIteratorStart(). |
| 3619 | */ |
| 3620 | int RM_StreamIteratorNextField(RedisModuleKey *key, RedisModuleString **field_ptr, RedisModuleString **value_ptr) { |
| 3621 | if (!key) { |
| 3622 | errno = EINVAL; |
| 3623 | return REDISMODULE_ERR; |
| 3624 | } else if (!key->value || key->value->type != OBJ_STREAM) { |
| 3625 | errno = ENOTSUP; |
| 3626 | return REDISMODULE_ERR; |
| 3627 | } else if (!key->iter) { |
| 3628 | errno = EBADF; |
| 3629 | return REDISMODULE_ERR; |
| 3630 | } else if (key->u.stream.numfieldsleft <= 0) { |
| 3631 | errno = ENOENT; |
| 3632 | return REDISMODULE_ERR; |
| 3633 | } |
| 3634 | streamIterator *si = key->iter; |
| 3635 | unsigned char *field, *value; |
| 3636 | int64_t field_len, value_len; |
| 3637 | streamIteratorGetField(si, &field, &value, &field_len, &value_len); |
| 3638 | if (field_ptr) { |
| 3639 | *field_ptr = createRawStringObject((char *)field, field_len); |
| 3640 | autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, *field_ptr); |
| 3641 | } |
| 3642 | if (value_ptr) { |
| 3643 | *value_ptr = createRawStringObject((char *)value, value_len); |
| 3644 | autoMemoryAdd(key->ctx, REDISMODULE_AM_STRING, *value_ptr); |
| 3645 | } |
| 3646 | key->u.stream.numfieldsleft--; |
| 3647 | return REDISMODULE_OK; |
| 3648 | } |
| 3649 | |
| 3650 | /* Deletes the current stream entry while iterating. |
| 3651 | * |
nothing calls this directly
no test coverage detected