From a0b44608a9a58fab66a171c834601e10157f67cc Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 17 Nov 2020 05:47:38 +0000 Subject: [PATCH] fix skiplist put batch bug --- src/util/src/tskiplist.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 4ae13bd7e5..a36f7f0261 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -145,6 +145,7 @@ void tSkipListPutBatch(SSkipList *pSkipList, void **ppData, int ndata) { // forward to put the rest of data for (int idata = 1; idata < ndata; idata++) { pDataKey = pSkipList->keyFn(ppData[idata]); + hasDup = false; // Compare max key pKey = SL_GET_MAX_KEY(pSkipList); @@ -153,8 +154,6 @@ void tSkipListPutBatch(SSkipList *pSkipList, void **ppData, int ndata) { for (int i = 0; i < pSkipList->maxLevel; i++) { forward[i] = SL_NODE_GET_BACKWARD_POINTER(pSkipList->pTail, i); } - - hasDup = false; } else { SSkipListNode *px = pSkipList->pHead; for (int i = pSkipList->maxLevel - 1; i >= 0; --i) { @@ -173,7 +172,7 @@ void tSkipListPutBatch(SSkipList *pSkipList, void **ppData, int ndata) { compare = pSkipList->comparFn(pKey, pDataKey); if (compare >= 0) { - if (compare == 0) hasDup = true; + if (compare == 0 && !hasDup) hasDup = true; break; } else { px = p; -- GitLab