diff --git a/source/libs/sync/test/syncEntryCacheTest.cpp b/source/libs/sync/test/syncEntryCacheTest.cpp index f902d244894c11b255f3f10130721c468045250f..6250181b25d5bb88319532cb53fac5843aac361a 100644 --- a/source/libs/sync/test/syncEntryCacheTest.cpp +++ b/source/libs/sync/test/syncEntryCacheTest.cpp @@ -182,26 +182,21 @@ void delSkipListFirst(SSkipList* pSkipList, int n) { SSyncRaftEntry* getLogEntry2(SSkipList* pSkipList, SyncIndex index) { - sTrace("get index: %ld -------------", index); SyncIndex index2 = index; SSyncRaftEntry *pEntry = NULL; - - SArray* nodes = tSkipListGet(pSkipList, (char*)(&index2)); - if (taosArrayGetSize(nodes) > 0) { - + int arraySize = 0; + + SArray* entryPArray = tSkipListGet(pSkipList, (char*)(&index2)); + arraySize = taosArrayGetSize(entryPArray); + if (arraySize > 0) { + SSkipListNode** ppNode = (SSkipListNode**)taosArrayGet(entryPArray, 0); + ASSERT(*ppNode != NULL); + pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(*ppNode); } - taosArrayDestroy(nodes); - + taosArrayDestroy(entryPArray); - - SSkipListIterator* pIter = tSkipListCreateIterFromVal(pSkipList, (const char *)&index2, TSDB_DATA_TYPE_BINARY, TSDB_ORDER_ASC); - if (tSkipListIterNext(pIter)) { - SSkipListNode* pNode = tSkipListIterGet(pIter); - ASSERT(pNode != NULL); - pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode); - } - - syncEntryLog2((char*)"", pEntry); + sTrace("get index2: %ld, arraySize:%d -------------", index, arraySize); + syncEntryLog2((char*)"getLogEntry2", pEntry); return pEntry; } @@ -217,7 +212,7 @@ SSyncRaftEntry* getLogEntry(SSkipList* pSkipList, SyncIndex index) { pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode); } - syncEntryLog2((char*)"", pEntry); + syncEntryLog2((char*)"getLogEntry", pEntry); return pEntry; } @@ -257,6 +252,11 @@ void test5() { getLogEntry(pSkipList, 7); getLogEntry(pSkipList, 7); + getLogEntry2(pSkipList, 2); + getLogEntry2(pSkipList, 5); + getLogEntry2(pSkipList, 7); + getLogEntry2(pSkipList, 7); + tSkipListDestroy(pSkipList); }