Merge pull request #5161 from soloestoy/optimize-stream-iterator

Streams: skip master fileds only when we are going forward in streamIteratorGetID
This commit is contained in:
Salvatore Sanfilippo 2018-07-24 10:59:55 +02:00 committed by GitHub
commit 41a886605a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -548,13 +548,16 @@ 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;
/* Skip master fileds to seek the first entry. */ /* We are now pointing the start filed of the master entry. If
for (uint64_t i = 0; i < si->master_fields_count; i++)
si->lp_ele = lpNext(si->lp,si->lp_ele);
/* We are now pointing the zero term of the master entry. If
* we are iterating in reverse order, we need to seek the * we are iterating in reverse order, we need to seek the
* end of the listpack. */ * end of the listpack. */
if (si->rev) si->lp_ele = lpLast(si->lp); if (si->rev) {
si->lp_ele = lpLast(si->lp);
} else {
/* Skip master fileds to seek the first entry. */
for (uint64_t i = 0; i < si->master_fields_count; i++)
si->lp_ele = lpNext(si->lp,si->lp_ele);
}
} 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
* the first entry emitted for this listpack, then we already * the first entry emitted for this listpack, then we already