mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Streams: refactoring of next entry seek in the iterator.
After #5161 the code could be made a bit more obvious for newcomers.
This commit is contained in:
parent
41a886605a
commit
8513f31be0
@ -548,15 +548,19 @@ int streamIteratorGetID(streamIterator *si, streamID *id, int64_t *numfields) {
|
|||||||
si->master_fields_count = lpGetInteger(si->lp_ele);
|
si->master_fields_count = lpGetInteger(si->lp_ele);
|
||||||
si->lp_ele = lpNext(si->lp,si->lp_ele); /* Seek first field. */
|
si->lp_ele = lpNext(si->lp,si->lp_ele); /* Seek first field. */
|
||||||
si->master_fields_start = si->lp_ele;
|
si->master_fields_start = si->lp_ele;
|
||||||
/* We are now pointing the start filed of the master entry. If
|
/* We are now pointing to the first field of the master entry.
|
||||||
* we are iterating in reverse order, we need to seek the
|
* We need to seek either the first or the last entry depending
|
||||||
* end of the listpack. */
|
* on the direction of the iteration. */
|
||||||
if (si->rev) {
|
if (!si->rev) {
|
||||||
si->lp_ele = lpLast(si->lp);
|
/* If we are iterating in normal order, skip the master fields
|
||||||
} else {
|
* to seek the first actual entry. */
|
||||||
/* Skip master fileds to seek the first entry. */
|
|
||||||
for (uint64_t i = 0; i < si->master_fields_count; i++)
|
for (uint64_t i = 0; i < si->master_fields_count; i++)
|
||||||
si->lp_ele = lpNext(si->lp,si->lp_ele);
|
si->lp_ele = lpNext(si->lp,si->lp_ele);
|
||||||
|
} else {
|
||||||
|
/* If we are iterating in reverse direction, just seek the
|
||||||
|
* last part of the last entry in the listpack (that is, the
|
||||||
|
* fields count). */
|
||||||
|
si->lp_ele = lpLast(si->lp);
|
||||||
}
|
}
|
||||||
} else if (si->rev) {
|
} else if (si->rev) {
|
||||||
/* If we are itereating in the reverse order, and this is not
|
/* If we are itereating in the reverse order, and this is not
|
||||||
|
Loading…
x
Reference in New Issue
Block a user