refact
This commit is contained in:
parent
acda511468
commit
9e14eb778b
|
@ -61,7 +61,7 @@ TSKEY tscGetSubscriptionProgress(void* sub, int64_t uid, TSKEY dflt) {
|
||||||
SSub* pSub = (SSub*)sub;
|
SSub* pSub = (SSub*)sub;
|
||||||
|
|
||||||
SSubscriptionProgress target = {.uid = uid, .key = 0};
|
SSubscriptionProgress target = {.uid = uid, .key = 0};
|
||||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
|
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress, TD_EQ);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return dflt;
|
return dflt;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ void tscUpdateSubscriptionProgress(void* sub, int64_t uid, TSKEY ts) {
|
||||||
SSub* pSub = (SSub*)sub;
|
SSub* pSub = (SSub*)sub;
|
||||||
|
|
||||||
SSubscriptionProgress target = {.uid = uid, .key = ts};
|
SSubscriptionProgress target = {.uid = uid, .key = ts};
|
||||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
|
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress, TD_EQ);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
p->key = ts;
|
p->key = ts;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ static int tscUpdateSubscription(STscObj* pObj, SSub* pSub) {
|
||||||
if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) {
|
if (UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) {
|
||||||
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
|
STableMeta * pTableMeta = pTableMetaInfo->pTableMeta;
|
||||||
SSubscriptionProgress target = {.uid = pTableMeta->id.uid, .key = 0};
|
SSubscriptionProgress target = {.uid = pTableMeta->id.uid, .key = 0};
|
||||||
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress);
|
SSubscriptionProgress* p = taosArraySearch(pSub->progress, &target, tscCompareSubscriptionProgress, TD_EQ);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
taosArrayClear(pSub->progress);
|
taosArrayClear(pSub->progress);
|
||||||
taosArrayPush(pSub->progress, &target);
|
taosArrayPush(pSub->progress, &target);
|
||||||
|
|
|
@ -21,6 +21,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "talgo.h"
|
||||||
|
|
||||||
#define TARRAY_MIN_SIZE 8
|
#define TARRAY_MIN_SIZE 8
|
||||||
#define TARRAY_GET_ELEM(array, index) ((void*)((char*)((array)->pData) + (index) * (array)->elemSize))
|
#define TARRAY_GET_ELEM(array, index) ((void*)((char*)((array)->pData) + (index) * (array)->elemSize))
|
||||||
|
@ -150,14 +151,14 @@ void taosArraySortString(SArray* pArray, __compar_fn_t comparFn);
|
||||||
* @param compar
|
* @param compar
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
void* taosArraySearch(const SArray* pArray, const void* key, __compar_fn_t comparFn);
|
void* taosArraySearch(const SArray* pArray, const void* key, __compar_fn_t comparFn, int flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* search the array
|
* search the array
|
||||||
* @param pArray
|
* @param pArray
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
char* taosArraySearchString(const SArray* pArray, const char* key, __compar_fn_t comparFn);
|
char* taosArraySearchString(const SArray* pArray, const char* key, __compar_fn_t comparFn, int flags);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,11 +217,11 @@ void taosArraySort(SArray* pArray, int (*compar)(const void*, const void*)) {
|
||||||
qsort(pArray->pData, pArray->size, pArray->elemSize, compar);
|
qsort(pArray->pData, pArray->size, pArray->elemSize, compar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* taosArraySearch(const SArray* pArray, const void* key, __compar_fn_t comparFn) {
|
void* taosArraySearch(const SArray* pArray, const void* key, __compar_fn_t comparFn, int flags) {
|
||||||
assert(pArray != NULL && comparFn != NULL);
|
assert(pArray != NULL && comparFn != NULL);
|
||||||
assert(key != NULL);
|
assert(key != NULL);
|
||||||
|
|
||||||
return bsearch(key, pArray->pData, pArray->size, pArray->elemSize, comparFn);
|
return taosbsearch(key, pArray->pData, pArray->size, pArray->elemSize, comparFn, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosArraySortString(SArray* pArray, __compar_fn_t comparFn) {
|
void taosArraySortString(SArray* pArray, __compar_fn_t comparFn) {
|
||||||
|
@ -229,11 +229,11 @@ void taosArraySortString(SArray* pArray, __compar_fn_t comparFn) {
|
||||||
qsort(pArray->pData, pArray->size, pArray->elemSize, comparFn);
|
qsort(pArray->pData, pArray->size, pArray->elemSize, comparFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taosArraySearchString(const SArray* pArray, const char* key, __compar_fn_t comparFn) {
|
char* taosArraySearchString(const SArray* pArray, const char* key, __compar_fn_t comparFn, int flags) {
|
||||||
assert(pArray != NULL);
|
assert(pArray != NULL);
|
||||||
assert(key != NULL);
|
assert(key != NULL);
|
||||||
|
|
||||||
void* p = bsearch(&key, pArray->pData, pArray->size, pArray->elemSize, comparFn);
|
void* p = taosbsearch(&key, pArray->pData, pArray->size, pArray->elemSize, comparFn, flags);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ int32_t taosArrayCompareString(const void* a, const void* b) {
|
||||||
|
|
||||||
static int32_t compareFindStrInArray(const void* pLeft, const void* pRight) {
|
static int32_t compareFindStrInArray(const void* pLeft, const void* pRight) {
|
||||||
const SArray* arr = (const SArray*) pRight;
|
const SArray* arr = (const SArray*) pRight;
|
||||||
return taosArraySearchString(arr, pLeft, taosArrayCompareString) == NULL ? 0 : 1;
|
return taosArraySearchString(arr, pLeft, taosArrayCompareString, TD_EQ) == NULL ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) {
|
static int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) {
|
||||||
|
|
Loading…
Reference in New Issue