提交 27d06cae 编写于 作者: M Minghao Li

refactor(sync): add syncEntryCacheTest

上级 48fd4d8c
...@@ -182,26 +182,21 @@ void delSkipListFirst(SSkipList* pSkipList, int n) { ...@@ -182,26 +182,21 @@ void delSkipListFirst(SSkipList* pSkipList, int n) {
SSyncRaftEntry* getLogEntry2(SSkipList* pSkipList, SyncIndex index) { SSyncRaftEntry* getLogEntry2(SSkipList* pSkipList, SyncIndex index) {
sTrace("get index: %ld -------------", index);
SyncIndex index2 = index; SyncIndex index2 = index;
SSyncRaftEntry *pEntry = NULL; SSyncRaftEntry *pEntry = NULL;
int arraySize = 0;
SArray* nodes = tSkipListGet(pSkipList, (char*)(&index2));
if (taosArrayGetSize(nodes) > 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);
sTrace("get index2: %ld, arraySize:%d -------------", index, arraySize);
SSkipListIterator* pIter = tSkipListCreateIterFromVal(pSkipList, (const char *)&index2, TSDB_DATA_TYPE_BINARY, TSDB_ORDER_ASC); syncEntryLog2((char*)"getLogEntry2", pEntry);
if (tSkipListIterNext(pIter)) {
SSkipListNode* pNode = tSkipListIterGet(pIter);
ASSERT(pNode != NULL);
pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
}
syncEntryLog2((char*)"", pEntry);
return pEntry; return pEntry;
} }
...@@ -217,7 +212,7 @@ SSyncRaftEntry* getLogEntry(SSkipList* pSkipList, SyncIndex index) { ...@@ -217,7 +212,7 @@ SSyncRaftEntry* getLogEntry(SSkipList* pSkipList, SyncIndex index) {
pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode); pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode);
} }
syncEntryLog2((char*)"", pEntry); syncEntryLog2((char*)"getLogEntry", pEntry);
return pEntry; return pEntry;
} }
...@@ -257,6 +252,11 @@ void test5() { ...@@ -257,6 +252,11 @@ void test5() {
getLogEntry(pSkipList, 7); getLogEntry(pSkipList, 7);
getLogEntry(pSkipList, 7); getLogEntry(pSkipList, 7);
getLogEntry2(pSkipList, 2);
getLogEntry2(pSkipList, 5);
getLogEntry2(pSkipList, 7);
getLogEntry2(pSkipList, 7);
tSkipListDestroy(pSkipList); tSkipListDestroy(pSkipList);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册