Merge branch 'master' of github.com:taosdata/TDengine into test/chr
This commit is contained in:
commit
3be4d00caa
|
@ -96,6 +96,7 @@ typedef struct tSkipListState {
|
||||||
} tSkipListState;
|
} tSkipListState;
|
||||||
|
|
||||||
typedef struct SSkipList {
|
typedef struct SSkipList {
|
||||||
|
unsigned int seed;
|
||||||
__compar_fn_t comparFn;
|
__compar_fn_t comparFn;
|
||||||
__sl_key_fn_t keyFn;
|
__sl_key_fn_t keyFn;
|
||||||
pthread_rwlock_t *lock;
|
pthread_rwlock_t *lock;
|
||||||
|
|
|
@ -50,6 +50,7 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _
|
||||||
pSkipList->len = keyLen;
|
pSkipList->len = keyLen;
|
||||||
pSkipList->flags = flags;
|
pSkipList->flags = flags;
|
||||||
pSkipList->keyFn = fn;
|
pSkipList->keyFn = fn;
|
||||||
|
pSkipList->seed = rand();
|
||||||
if (comparFn == NULL) {
|
if (comparFn == NULL) {
|
||||||
pSkipList->comparFn = getKeyComparFunc(keyType);
|
pSkipList->comparFn = getKeyComparFunc(keyType);
|
||||||
} else {
|
} else {
|
||||||
|
@ -545,7 +546,12 @@ static FORCE_INLINE int32_t getSkipListNodeRandomHeight(SSkipList *pSkipList) {
|
||||||
const uint32_t factor = 4;
|
const uint32_t factor = 4;
|
||||||
|
|
||||||
int32_t n = 1;
|
int32_t n = 1;
|
||||||
|
|
||||||
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
while ((rand() % factor) == 0 && n <= pSkipList->maxLevel) {
|
while ((rand() % factor) == 0 && n <= pSkipList->maxLevel) {
|
||||||
|
#else
|
||||||
|
while ((rand_r(&(pSkipList->seed)) % factor) == 0 && n <= pSkipList->maxLevel) {
|
||||||
|
#endif
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue