Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
27618538
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
27618538
编写于
12月 01, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/TD-1925' of
https://github.com/taosdata/TDengine
into feature/TD-1925
上级
7ad83106
bcbb4506
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
10 deletion
+25
-10
src/client/src/tscSub.c
src/client/src/tscSub.c
+3
-3
src/util/inc/tarray.h
src/util/inc/tarray.h
+12
-2
src/util/src/tarray.c
src/util/src/tarray.c
+9
-4
src/util/src/tcompare.c
src/util/src/tcompare.c
+1
-1
未找到文件。
src/client/src/tscSub.c
浏览文件 @
27618538
...
@@ -61,7 +61,7 @@ TSKEY tscGetSubscriptionProgress(void* sub, int64_t uid, TSKEY dflt) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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
);
...
...
src/util/inc/tarray.h
浏览文件 @
27618538
...
@@ -21,9 +21,11 @@ extern "C" {
...
@@ -21,9 +21,11 @@ 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))
#define TARRAY_ELEM_IDX(array, ele) (POINTER_DISTANCE(ele, (array)->pData) / (array)->elemSize)
typedef
struct
SArray
{
typedef
struct
SArray
{
size_t
size
;
size_t
size
;
...
@@ -92,6 +94,14 @@ size_t taosArrayGetSize(const SArray* pArray);
...
@@ -92,6 +94,14 @@ size_t taosArrayGetSize(const SArray* pArray);
*/
*/
void
*
taosArrayInsert
(
SArray
*
pArray
,
size_t
index
,
void
*
pData
);
void
*
taosArrayInsert
(
SArray
*
pArray
,
size_t
index
,
void
*
pData
);
/**
* set data in array
* @param pArray
* @param index
* @param pData
*/
void
taosArraySet
(
SArray
*
pArray
,
size_t
index
,
void
*
pData
);
/**
/**
* remove data entry of the given index
* remove data entry of the given index
* @param pArray
* @param pArray
...
@@ -150,14 +160,14 @@ void taosArraySortString(SArray* pArray, __compar_fn_t comparFn);
...
@@ -150,14 +160,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
}
}
...
...
src/util/src/tarray.c
浏览文件 @
27618538
...
@@ -133,6 +133,11 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
...
@@ -133,6 +133,11 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
return
dst
;
return
dst
;
}
}
void
taosArraySet
(
SArray
*
pArray
,
size_t
index
,
void
*
pData
)
{
assert
(
index
<
pArray
->
size
);
memcpy
(
TARRAY_GET_ELEM
(
pArray
,
index
),
pData
,
pArray
->
elemSize
);
}
void
taosArrayRemove
(
SArray
*
pArray
,
size_t
index
)
{
void
taosArrayRemove
(
SArray
*
pArray
,
size_t
index
)
{
assert
(
index
<
pArray
->
size
);
assert
(
index
<
pArray
->
size
);
...
@@ -217,11 +222,11 @@ void taosArraySort(SArray* pArray, int (*compar)(const void*, const void*)) {
...
@@ -217,11 +222,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 +234,11 @@ void taosArraySortString(SArray* pArray, __compar_fn_t comparFn) {
...
@@ -229,11 +234,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
;
}
}
...
...
src/util/src/tcompare.c
浏览文件 @
27618538
...
@@ -239,7 +239,7 @@ int32_t taosArrayCompareString(const void* a, const void* b) {
...
@@ -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
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录