Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f96ad1f4
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f96ad1f4
编写于
7月 20, 2021
作者:
D
dapan1121
提交者:
GitHub
7月 20, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into feature/TD-5331
上级
0f3c6dd7
8d48b77d
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
263 addition
and
230 deletion
+263
-230
src/client/src/taos.def
src/client/src/taos.def
+5
-2
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+27
-2
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+25
-32
src/inc/taos.h
src/inc/taos.h
+18
-16
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+14
-10
src/util/CMakeLists.txt
src/util/CMakeLists.txt
+2
-1
src/util/inc/tarray.h
src/util/inc/tarray.h
+16
-0
src/util/src/tarray.c
src/util/src/tarray.c
+81
-0
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+0
-140
src/util/tests/arrayTest.cpp
src/util/tests/arrayTest.cpp
+50
-0
src/util/tests/cacheTest.cpp
src/util/tests/cacheTest.cpp
+2
-6
src/util/tests/skiplistTest.cpp
src/util/tests/skiplistTest.cpp
+15
-12
src/util/tests/trefTest.c
src/util/tests/trefTest.c
+7
-9
tests/script/sh/prepare_udf.sh
tests/script/sh/prepare_udf.sh
+1
-0
未找到文件。
src/client/src/taos.def
浏览文件 @
f96ad1f4
...
...
@@ -7,11 +7,16 @@ taos_connect_auth
taos_close
taos_stmt_init
taos_stmt_prepare
taos_stmt_set_tbname_tags
taos_stmt_set_tbname
taos_stmt_is_insert
taos_stmt_num_params
taos_stmt_bind_param
taos_stmt_add_batch
taos_stmt_execute
taos_stmt_use_result
taos_stmt_close
taos_stmt_errstr
taos_query
taos_fetch_row
taos_result_precision
...
...
@@ -37,6 +42,4 @@ taos_consume
taos_unsubscribe
taos_open_stream
taos_close_stream
taos_fetch_block
taos_load_table_info
src/client/src/tscSQLParser.c
浏览文件 @
f96ad1f4
...
...
@@ -8037,6 +8037,28 @@ static void freeElem(void* p) {
tfree
(
*
(
char
**
)
p
);
}
int32_t
tnameComparFn
(
const
void
*
p1
,
const
void
*
p2
)
{
SName
*
pn1
=
(
SName
*
)
p1
;
SName
*
pn2
=
(
SName
*
)
p2
;
int32_t
ret
=
strncmp
(
pn1
->
acctId
,
pn2
->
acctId
,
tListLen
(
pn1
->
acctId
));
if
(
ret
!=
0
)
{
return
ret
>
0
?
1
:-
1
;
}
else
{
ret
=
strncmp
(
pn1
->
dbname
,
pn2
->
dbname
,
tListLen
(
pn1
->
dbname
));
if
(
ret
!=
0
)
{
return
ret
>
0
?
1
:-
1
;
}
else
{
ret
=
strncmp
(
pn1
->
tname
,
pn2
->
tname
,
tListLen
(
pn1
->
tname
));
if
(
ret
!=
0
)
{
return
ret
>
0
?
1
:-
1
;
}
else
{
return
0
;
}
}
}
}
int32_t
loadAllTableMeta
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -8091,6 +8113,9 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
plist
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pVgroupList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
taosArraySort
(
tableNameList
,
tnameComparFn
);
taosArrayRemoveDuplicate
(
tableNameList
,
tnameComparFn
,
NULL
);
size_t
numOfTables
=
taosArrayGetSize
(
tableNameList
);
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
SName
*
pname
=
taosArrayGet
(
tableNameList
,
i
);
...
...
@@ -8111,8 +8136,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
continue
;
}
}
else
if
(
pTableMeta
->
tableType
==
TSDB_SUPER_TABLE
)
{
// the vgroup list of a super table is not kept in local buffer, so here need retrieve it
// from the mnode each time
// the vgroup list of super table is not kept in local buffer, so here need retrieve it from the mnode each time
char
*
t
=
strdup
(
name
);
taosArrayPush
(
pVgroupList
,
&
t
);
}
...
...
@@ -8139,6 +8163,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
pInfo
->
funcs
)
{
funcSize
=
taosArrayGetSize
(
pInfo
->
funcs
);
}
if
(
funcSize
>
0
)
{
for
(
size_t
i
=
0
;
i
<
funcSize
;
++
i
)
{
SStrToken
*
t
=
taosArrayGet
(
pInfo
->
funcs
,
i
);
...
...
src/client/src/tscUtil.c
浏览文件 @
f96ad1f4
...
...
@@ -1315,8 +1315,7 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) {
return
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
SQueryInfo
*
pQueryInfo
=
pCmd
->
pQueryInfo
;
while
(
pQueryInfo
!=
NULL
)
{
SQueryInfo
*
p
=
pQueryInfo
->
sibling
;
...
...
@@ -1602,7 +1601,7 @@ void freeUdfInfo(SUdfInfo* pUdfInfo) {
taosCloseDll
(
pUdfInfo
->
handle
);
}
// todo refactor
void
*
tscDestroyUdfArrayList
(
SArray
*
pUdfList
)
{
if
(
pUdfList
==
NULL
)
{
return
NULL
;
...
...
@@ -3129,6 +3128,7 @@ void tscInitQueryInfo(SQueryInfo* pQueryInfo) {
int32_t
tscAddQueryInfo
(
SSqlCmd
*
pCmd
)
{
assert
(
pCmd
!=
NULL
);
SQueryInfo
*
pQueryInfo
=
calloc
(
1
,
sizeof
(
SQueryInfo
));
if
(
pQueryInfo
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
...
...
@@ -4111,17 +4111,21 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) {
//backup the total number of result first
int64_t
num
=
pRes
->
numOfTotal
+
pRes
->
numOfClauseTotal
;
// DON't free final since it may be recoreded and used later in APP
TAOS_FIELD
*
finalBk
=
pRes
->
final
;
pRes
->
final
=
NULL
;
tscFreeSqlResult
(
pSql
);
pRes
->
final
=
finalBk
;
pRes
->
numOfTotal
=
num
;
for
(
int32_t
i
=
0
;
i
<
pSql
->
subState
.
numOfSub
;
++
i
)
{
taos_free_result
(
pSql
->
pSubs
[
i
]);
}
tfree
(
pSql
->
pSubs
);
pSql
->
subState
.
numOfSub
=
0
;
pSql
->
fp
=
fp
;
tscDebug
(
"0x%"
PRIx64
" try data in the next subclause"
,
pSql
->
self
);
...
...
@@ -4761,6 +4765,20 @@ int32_t nameComparFn(const void* n1, const void* n2) {
}
}
static
void
freeContent
(
void
*
p
)
{
char
*
ptr
=
*
(
char
**
)
p
;
tfree
(
ptr
);
}
static
int32_t
contCompare
(
const
void
*
p1
,
const
void
*
p2
)
{
int32_t
ret
=
strcmp
(
p1
,
p2
);
if
(
ret
==
0
)
{
return
0
;
}
else
{
return
ret
>
0
?
1
:-
1
;
}
}
int
tscTransferTableNameList
(
SSqlObj
*
pSql
,
const
char
*
pNameList
,
int32_t
length
,
SArray
*
pNameArray
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -4808,32 +4826,7 @@ int tscTransferTableNameList(SSqlObj *pSql, const char *pNameList, int32_t lengt
}
taosArraySort
(
pNameArray
,
nameComparFn
);
int32_t
pos
=
0
;
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
char
**
p1
=
taosArrayGet
(
pNameArray
,
pos
);
char
**
p2
=
taosArrayGet
(
pNameArray
,
i
);
if
(
strcmp
(
*
p1
,
*
p2
)
==
0
)
{
// do nothing
}
else
{
if
(
pos
+
1
!=
i
)
{
char
*
p
=
taosArrayGetP
(
pNameArray
,
pos
+
1
);
tfree
(
p
);
taosArraySet
(
pNameArray
,
pos
+
1
,
p2
);
pos
+=
1
;
}
else
{
pos
+=
1
;
}
}
}
for
(
int32_t
i
=
pos
+
1
;
i
<
pNameArray
->
size
;
++
i
)
{
char
*
p
=
taosArrayGetP
(
pNameArray
,
i
);
tfree
(
p
);
}
pNameArray
->
size
=
pos
+
1
;
taosArrayRemoveDuplicate
(
pNameArray
,
contCompare
,
freeContent
);
return
TSDB_CODE_SUCCESS
;
}
...
...
src/inc/taos.h
浏览文件 @
f96ad1f4
...
...
@@ -72,6 +72,7 @@ DLL_EXPORT int taos_init();
DLL_EXPORT
void
taos_cleanup
(
void
);
DLL_EXPORT
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...);
DLL_EXPORT
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
);
DLL_EXPORT
TAOS
*
taos_connect_auth
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
DLL_EXPORT
void
taos_close
(
TAOS
*
taos
);
const
char
*
taos_data_type
(
int
type
);
...
...
@@ -110,22 +111,23 @@ typedef struct TAOS_MULTI_BIND {
}
TAOS_MULTI_BIND
;
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
);
int
taos_stmt_prepare
(
TAOS_STMT
*
stmt
,
const
char
*
sql
,
unsigned
long
length
);
int
taos_stmt_set_tbname_tags
(
TAOS_STMT
*
stmt
,
const
char
*
name
,
TAOS_BIND
*
tags
);
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
int
taos_stmt_is_insert
(
TAOS_STMT
*
stmt
,
int
*
insert
);
int
taos_stmt_num_params
(
TAOS_STMT
*
stmt
,
int
*
nums
);
DLL_EXPORT
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
);
DLL_EXPORT
int
taos_stmt_prepare
(
TAOS_STMT
*
stmt
,
const
char
*
sql
,
unsigned
long
length
);
DLL_EXPORT
int
taos_stmt_set_tbname_tags
(
TAOS_STMT
*
stmt
,
const
char
*
name
,
TAOS_BIND
*
tags
);
DLL_EXPORT
int
taos_stmt_set_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
DLL_EXPORT
int
taos_stmt_set_sub_tbname
(
TAOS_STMT
*
stmt
,
const
char
*
name
);
DLL_EXPORT
int
taos_stmt_is_insert
(
TAOS_STMT
*
stmt
,
int
*
insert
);
DLL_EXPORT
int
taos_stmt_num_params
(
TAOS_STMT
*
stmt
,
int
*
nums
);
int
taos_stmt_get_param
(
TAOS_STMT
*
stmt
,
int
idx
,
int
*
type
,
int
*
bytes
);
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND
*
bind
);
DLL_EXPORT
int
taos_stmt_bind_param
(
TAOS_STMT
*
stmt
,
TAOS_BIND
*
bind
);
int
taos_stmt_bind_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
);
int
taos_stmt_bind_single_param_batch
(
TAOS_STMT
*
stmt
,
TAOS_MULTI_BIND
*
bind
,
int
colIdx
);
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
);
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
);
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
);
int
taos_stmt_close
(
TAOS_STMT
*
stmt
);
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_add_batch
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_execute
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
TAOS_RES
*
taos_stmt_use_result
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
int
taos_stmt_close
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
char
*
taos_stmt_errstr
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
);
DLL_EXPORT
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
res
);
...
...
@@ -140,10 +142,10 @@ DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int n
DLL_EXPORT
void
taos_stop_query
(
TAOS_RES
*
res
);
DLL_EXPORT
bool
taos_is_null
(
TAOS_RES
*
res
,
int32_t
row
,
int32_t
col
);
int
taos_fetch_block
(
TAOS_RES
*
res
,
TAOS_ROW
*
rows
);
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
);
DLL_EXPORT
int
taos_fetch_block
(
TAOS_RES
*
res
,
TAOS_ROW
*
rows
);
DLL_EXPORT
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
);
int
*
taos_fetch_lengths
(
TAOS_RES
*
res
);
DLL_EXPORT
int
*
taos_fetch_lengths
(
TAOS_RES
*
res
);
// TAOS_RES *taos_list_tables(TAOS *mysql, const char *wild);
// TAOS_RES *taos_list_dbs(TAOS *mysql, const char *wild);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
f96ad1f4
...
...
@@ -3085,7 +3085,7 @@ int32_t checkForCachedLastRow(STsdbQueryHandle* pQueryHandle, STableGroupInfo *g
}
// update the tsdb query time range
if
(
pQueryHandle
->
cachelastrow
)
{
if
(
pQueryHandle
->
cachelastrow
!=
TSDB_CACHED_TYPE_NONE
)
{
pQueryHandle
->
window
=
TSWINDOW_INITIALIZER
;
pQueryHandle
->
checkFiles
=
false
;
pQueryHandle
->
activeIndex
=
-
1
;
// start from -1
...
...
@@ -3117,6 +3117,7 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) {
STimeWindow
window
=
{
INT64_MAX
,
INT64_MIN
};
int32_t
totalNumOfTable
=
0
;
SArray
*
emptyGroup
=
taosArrayInit
(
16
,
sizeof
(
int32_t
));
// NOTE: starts from the buffer in case of descending timestamp order check data blocks
size_t
numOfGroups
=
taosArrayGetSize
(
groupList
->
pGroupList
);
...
...
@@ -3159,27 +3160,30 @@ STimeWindow updateLastrowForEachGroup(STableGroupInfo *groupList) {
}
}
taosArrayClear
(
pGroup
);
// more than one table in each group, only one table left for each group
if
(
keyInfo
.
pTable
!=
NULL
)
{
totalNumOfTable
++
;
taosArrayPush
(
pGroup
,
&
keyInfo
);
}
else
{
if
(
taosArrayGetSize
(
pGroup
)
==
1
)
{
// do nothing
}
else
{
taosArrayClear
(
pGroup
);
taosArrayPush
(
pGroup
,
&
keyInfo
);
}
}
else
{
// mark all the empty groups, and remove it later
taosArrayDestroy
(
pGroup
);
taosArrayRemove
(
groupList
->
pGroupList
,
j
);
numOfGroups
-=
1
;
j
-=
1
;
taosArrayPush
(
emptyGroup
,
&
j
);
}
}
// window does not being updated, so set the original
if
(
window
.
skey
==
INT64_MAX
&&
window
.
ekey
==
INT64_MIN
)
{
window
=
TSWINDOW_INITIALIZER
;
assert
(
totalNumOfTable
==
0
&&
taosArrayGetSize
(
groupList
->
pGroupList
)
==
0
);
assert
(
totalNumOfTable
==
0
&&
taosArrayGetSize
(
groupList
->
pGroupList
)
==
numOfGroups
);
}
taosArrayRemoveBatch
(
groupList
->
pGroupList
,
TARRAY_GET_START
(
emptyGroup
),
(
int32_t
)
taosArrayGetSize
(
emptyGroup
));
taosArrayDestroy
(
emptyGroup
);
groupList
->
numOfTables
=
totalNumOfTable
;
return
window
;
}
...
...
src/util/CMakeLists.txt
浏览文件 @
f96ad1f4
...
...
@@ -4,13 +4,14 @@ PROJECT(TDengine)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/rpc/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/sync/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/rmonotonic/inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
ADD_LIBRARY
(
tutil
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
tutil pthread os lz4 z rmonotonic
)
IF
(
TD_LINUX
)
TARGET_LINK_LIBRARIES
(
tutil m rt
)
#
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY
(
tests
)
FIND_PATH
(
ICONV_INCLUDE_EXIST iconv.h /usr/include/ /usr/local/include/
)
IF
(
ICONV_INCLUDE_EXIST
)
...
...
src/util/inc/tarray.h
浏览文件 @
f96ad1f4
...
...
@@ -52,6 +52,22 @@ void* taosArrayInit(size_t size, size_t elemSize);
*/
void
*
taosArrayAddBatch
(
SArray
*
pArray
,
const
void
*
pData
,
int
nEles
);
/**
*
* @param pArray
* @param pData position array list
* @param numOfElems the number of removed position
*/
void
taosArrayRemoveBatch
(
SArray
*
pArray
,
const
int32_t
*
pData
,
int32_t
numOfElems
);
/**
*
* @param pArray
* @param comparFn
* @param fp
*/
void
taosArrayRemoveDuplicate
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
));
/**
* add all element from the source array list into the destination
* @param pArray
...
...
src/util/src/tarray.c
浏览文件 @
f96ad1f4
...
...
@@ -83,6 +83,87 @@ void* taosArrayAddBatch(SArray* pArray, const void* pData, int nEles) {
return
dst
;
}
void
taosArrayRemoveBatch
(
SArray
*
pArray
,
const
int32_t
*
pData
,
int32_t
numOfElems
)
{
assert
(
pArray
!=
NULL
&&
pData
!=
NULL
);
if
(
numOfElems
<=
0
)
{
return
;
}
size_t
size
=
taosArrayGetSize
(
pArray
);
if
(
numOfElems
>=
size
)
{
taosArrayClear
(
pArray
);
return
;
}
int32_t
i
=
pData
[
0
]
+
1
,
j
=
0
;
while
(
i
<
size
)
{
if
(
j
==
numOfElems
-
1
)
{
break
;
}
char
*
p
=
TARRAY_GET_ELEM
(
pArray
,
i
);
if
(
i
>
pData
[
j
]
&&
i
<
pData
[
j
+
1
])
{
char
*
dst
=
TARRAY_GET_ELEM
(
pArray
,
i
-
(
j
+
1
));
memmove
(
dst
,
p
,
pArray
->
elemSize
);
}
else
if
(
i
==
pData
[
j
+
1
])
{
j
+=
1
;
}
i
+=
1
;
}
assert
(
i
==
pData
[
numOfElems
-
1
]
+
1
);
int32_t
dstIndex
=
pData
[
numOfElems
-
1
]
-
numOfElems
+
1
;
int32_t
srcIndex
=
pData
[
numOfElems
-
1
]
+
1
;
char
*
dst
=
TARRAY_GET_ELEM
(
pArray
,
dstIndex
);
char
*
src
=
TARRAY_GET_ELEM
(
pArray
,
srcIndex
);
memmove
(
dst
,
src
,
pArray
->
elemSize
*
(
pArray
->
size
-
numOfElems
));
pArray
->
size
-=
numOfElems
;
}
void
taosArrayRemoveDuplicate
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
))
{
assert
(
pArray
);
size_t
size
=
pArray
->
size
;
if
(
size
<=
1
)
{
return
;
}
int32_t
pos
=
0
;
for
(
int32_t
i
=
1
;
i
<
size
;
++
i
)
{
char
*
p1
=
taosArrayGet
(
pArray
,
pos
);
char
*
p2
=
taosArrayGet
(
pArray
,
i
);
if
(
comparFn
(
p1
,
p2
)
==
0
)
{
// do nothing
}
else
{
if
(
pos
+
1
!=
i
)
{
void
*
p
=
taosArrayGet
(
pArray
,
pos
+
1
);
if
(
fp
!=
NULL
)
{
fp
(
p
);
}
taosArraySet
(
pArray
,
pos
+
1
,
p2
);
pos
+=
1
;
}
else
{
pos
+=
1
;
}
}
}
if
(
fp
!=
NULL
)
{
for
(
int32_t
i
=
pos
+
1
;
i
<
pArray
->
size
;
++
i
)
{
void
*
p
=
taosArrayGet
(
pArray
,
i
);
fp
(
p
);
}
}
pArray
->
size
=
pos
+
1
;
}
void
*
taosArrayAddAll
(
SArray
*
pArray
,
const
SArray
*
pInput
)
{
return
taosArrayAddBatch
(
pArray
,
pInput
->
pData
,
(
int32_t
)
taosArrayGetSize
(
pInput
));
}
...
...
src/util/src/tskiplist.c
浏览文件 @
f96ad1f4
...
...
@@ -681,143 +681,3 @@ static SSkipListNode *tSkipListPutImpl(SSkipList *pSkipList, void *pData, SSkipL
return
pNode
;
}
// static int32_t tSkipListEndParQuery(SSkipList *pSkipList, SSkipListNode *pStartNode, SSkipListKey *pEndKey,
// int32_t cond, SSkipListNode ***pRes) {
// pthread_rwlock_rdlock(&pSkipList->lock);
// SSkipListNode *p = pStartNode;
// int32_t numOfRes = 0;
//
// __compar_fn_t filterComparFn = getComparFunc(pSkipList, pEndKey->nType);
// while (p != NULL) {
// int32_t ret = filterComparFn(&p->key, pEndKey);
// if (ret > 0) {
// break;
// }
//
// if (ret < 0) {
// numOfRes++;
// p = p->pForward[0];
// } else if (ret == 0) {
// if (cond == TSDB_RELATION_LESS_EQUAL) {
// numOfRes++;
// p = p->pForward[0];
// } else {
// break;
// }
// }
// }
//
// (*pRes) = (SSkipListNode **)malloc(POINTER_BYTES * numOfRes);
// for (int32_t i = 0; i < numOfRes; ++i) {
// (*pRes)[i] = pStartNode;
// pStartNode = pStartNode->pForward[0];
// }
// pthread_rwlock_unlock(&pSkipList->lock);
//
// return numOfRes;
//}
//
///*
// * maybe return the copy of SSkipListNode would be better
// */
// int32_t tSkipListGets(SSkipList *pSkipList, SSkipListKey *pKey, SSkipListNode ***pRes) {
// (*pRes) = NULL;
//
// SSkipListNode *pNode = tSkipListGet(pSkipList, pKey);
// if (pNode == NULL) {
// return 0;
// }
//
// __compar_fn_t filterComparFn = getComparFunc(pSkipList, pKey->nType);
//
// // backward check if previous nodes are with the same value.
// SSkipListNode *pPrev = pNode->pBackward[0];
// while ((pPrev != &pSkipList->pHead) && filterComparFn(&pPrev->key, pKey) == 0) {
// pPrev = pPrev->pBackward[0];
// }
//
// return tSkipListEndParQuery(pSkipList, pPrev->pForward[0], &pNode->key, TSDB_RELATION_LESS_EQUAL, pRes);
//}
//
// static SSkipListNode *tSkipListParQuery(SSkipList *pSkipList, SSkipListKey *pKey, int32_t cond) {
// int32_t sLevel = pSkipList->level - 1;
// int32_t ret = -1;
//
// SSkipListNode *x = &pSkipList->pHead;
// __compar_fn_t filterComparFn = getComparFunc(pSkipList, pKey->nType);
//
// pthread_rwlock_rdlock(&pSkipList->lock);
//
// if (cond == TSDB_RELATION_GREATER_EQUAL || cond == TSDB_RELATION_GREATER) {
// for (int32_t i = sLevel; i >= 0; --i) {
// while (x->pForward[i] != NULL && (ret = filterComparFn(&x->pForward[i]->key, pKey)) < 0) {
// x = x->pForward[i];
// }
// }
//
// // backward check if previous nodes are with the same value.
// if (cond == TSDB_RELATION_GREATER_EQUAL && ret == 0) {
// SSkipListNode *pNode = x->pForward[0];
// while ((pNode->pBackward[0] != &pSkipList->pHead) && (filterComparFn(&pNode->pBackward[0]->key, pKey) == 0)) {
// pNode = pNode->pBackward[0];
// }
// pthread_rwlock_unlock(&pSkipList->lock);
// return pNode;
// }
//
// if (ret > 0 || cond == TSDB_RELATION_GREATER_EQUAL) {
// pthread_rwlock_unlock(&pSkipList->lock);
// return x->pForward[0];
// } else { // cond == TSDB_RELATION_GREATER && ret == 0
// SSkipListNode *pn = x->pForward[0];
// while (pn != NULL && filterComparFn(&pn->key, pKey) == 0) {
// pn = pn->pForward[0];
// }
// pthread_rwlock_unlock(&pSkipList->lock);
// return pn;
// }
// }
//
// pthread_rwlock_unlock(&pSkipList->lock);
// return NULL;
//}
//
//
// static bool removeSupport(SSkipList *pSkipList, SSkipListNode **forward, SSkipListKey *pKey) {
// __compar_fn_t filterComparFn = getComparFunc(pSkipList, pKey->nType);
//
// if (filterComparFn(&forward[0]->pForward[0]->key, pKey) == 0) {
// SSkipListNode *p = forward[0]->pForward[0];
// doRemove(pSkipList, p, forward);
// } else { // failed to find the node of specified value,abort
// return false;
// }
//
// // compress the minimum level of skip list
// while (pSkipList->level > 0 && SL_NODE_GET_FORWARD_POINTER(pSkipList->pHead, pSkipList->level - 1) == NULL) {
// pSkipList->level -= 1;
// }
//
// return true;
//}
//
// bool tSkipListRemove(SSkipList *pSkipList, SSkipListKey *pKey) {
// SSkipListNode *forward[MAX_SKIP_LIST_LEVEL] = {0};
// __compar_fn_t filterComparFn = getComparFunc(pSkipList, pKey->nType);
//
// pthread_rwlock_rdlock(&pSkipList->lock);
//
// SSkipListNode *x = &pSkipList->pHead;
// for (int32_t i = pSkipList->level - 1; i >= 0; --i) {
// while (x->pForward[i] != NULL && (filterComparFn(&x->pForward[i]->key, pKey) < 0)) {
// x = x->pForward[i];
// }
// forward[i] = x;
// }
//
// bool ret = removeSupport(pSkipList, forward, pKey);
// pthread_rwlock_unlock(&pSkipList->lock);
//
// return ret;
//}
src/util/tests/arrayTest.cpp
0 → 100644
浏览文件 @
f96ad1f4
#include <gtest/gtest.h>
#include <stdlib.h>
#include <time.h>
#include <random>
#include "tarray.h"
namespace
{
static
void
remove_batch_test
()
{
SArray
*
pa
=
(
SArray
*
)
taosArrayInit
(
4
,
sizeof
(
int32_t
));
for
(
int32_t
i
=
0
;
i
<
20
;
++
i
)
{
int32_t
a
=
i
;
taosArrayPush
(
pa
,
&
a
);
}
SArray
*
delList
=
(
SArray
*
)
taosArrayInit
(
4
,
sizeof
(
int32_t
));
taosArrayRemoveBatch
(
pa
,
(
const
int32_t
*
)
TARRAY_GET_START
(
delList
),
taosArrayGetSize
(
delList
));
EXPECT_EQ
(
taosArrayGetSize
(
pa
),
20
);
int32_t
a
=
5
;
taosArrayPush
(
delList
,
&
a
);
taosArrayRemoveBatch
(
pa
,
(
const
int32_t
*
)
TARRAY_GET_START
(
delList
),
taosArrayGetSize
(
delList
));
EXPECT_EQ
(
taosArrayGetSize
(
pa
),
19
);
EXPECT_EQ
(
*
(
int
*
)
taosArrayGet
(
pa
,
5
),
6
);
taosArrayInsert
(
pa
,
5
,
&
a
);
EXPECT_EQ
(
taosArrayGetSize
(
pa
),
20
);
EXPECT_EQ
(
*
(
int
*
)
taosArrayGet
(
pa
,
5
),
5
);
taosArrayClear
(
delList
);
a
=
6
;
taosArrayPush
(
delList
,
&
a
);
a
=
9
;
taosArrayPush
(
delList
,
&
a
);
a
=
14
;
taosArrayPush
(
delList
,
&
a
);
taosArrayRemoveBatch
(
pa
,
(
const
int32_t
*
)
TARRAY_GET_START
(
delList
),
taosArrayGetSize
(
delList
));
EXPECT_EQ
(
taosArrayGetSize
(
pa
),
17
);
}
}
// namespace
TEST
(
arrayTest
,
array_list_test
)
{
remove_batch_test
();
}
src/util/tests/cacheTest.cpp
浏览文件 @
f96ad1f4
...
...
@@ -5,10 +5,6 @@
#include "taos.h"
#include "tcache.h"
namespace
{
int32_t
tsMaxMgmtConnections
=
10000
;
int32_t
tsMaxMeterConnections
=
200
;
}
// test cache
TEST
(
testCase
,
client_cache_test
)
{
const
int32_t
REFRESH_TIME_IN_SEC
=
2
;
...
...
@@ -43,7 +39,7 @@ TEST(testCase, client_cache_test) {
sleep
(
3
);
char
*
d
=
(
char
*
)
taosCacheAcquireByKey
(
tscMetaCache
,
key3
,
strlen
(
key3
));
//
assert(d == NULL);
assert
(
d
==
NULL
);
char
key5
[]
=
"test5"
;
char
data5
[]
=
"data5kkkkk"
;
...
...
@@ -102,7 +98,7 @@ TEST(testCase, cache_resize_test) {
char
key
[
256
]
=
{
0
};
char
data
[
1024
]
=
"abcdefghijk"
;
int32_t
len
=
strlen
(
data
);
//
int32_t len = strlen(data);
uint64_t
startTime
=
taosGetTimestampUs
();
int32_t
num
=
10000
;
...
...
src/util/tests/skiplistTest.cpp
浏览文件 @
f96ad1f4
#include <gtest/gtest.h>
#include <limits.h>
#include <taosdef.h>
#include <tcompare.h>
#include <iostream>
#include "os.h"
...
...
@@ -8,12 +9,14 @@
#include "tskiplist.h"
#include "tutil.h"
#if 0
namespace {
char* getkey(const void* data) { return (char*)(data); }
void doubleSkipListTest() {
SSkipList
*
pSkipList
=
tSkipListCreate
(
10
,
TSDB_DATA_TYPE_DOUBLE
,
sizeof
(
double
),
0
,
false
,
true
,
getkey
);
SSkipList* pSkipList = tSkipListCreate(10, TSDB_DATA_TYPE_DOUBLE, sizeof(double),
getKeyComparFunc(TSDB_DATA_TYPE_DOUBLE), false, getkey);
double doubleVal[1000] = {0};
int32_t size = 20000;
...
...
@@ -25,18 +28,15 @@ void doubleSkipListTest() {
doubleVal[i] = i * 0.997;
}
int32_t
level
=
0
;
int32_t
size
=
0
;
tSkipListNewNodeInfo
(
pSkipList
,
&
level
,
&
size
);
auto
d
=
(
SSkipListNode
*
)
calloc
(
1
,
size
+
sizeof
(
double
)
*
2
);
d
->
level
=
level
;
// int32_t level = 0;
size = 0;
double
*
key
=
(
double
*
)
SL_GET_NODE_KEY
(
pSkipList
,
d
);
key
[
0
]
=
i
*
0.997
;
key
[
1
]
=
i
*
0.997
;
// tSkipListNewNodeInfo(pSkipList, &level, &size
);
// auto d = (SSkipListNode*)calloc(1, size + sizeof(double) * 2)
;
// d->level = level
;
tSkipListPut
(
pSkipList
,
d
);
double key = 0.997;
tSkipListPut(pSkipList, &key);
}
printf("the first level of skip list is:\n");
...
...
@@ -70,7 +70,8 @@ void doubleSkipListTest() {
}
void randKeyTest() {
SSkipList
*
pSkipList
=
tSkipListCreate
(
10
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
),
0
,
false
,
true
,
getkey
);
SSkipList* pSkipList = tSkipListCreate(10, TSDB_DATA_TYPE_INT, sizeof(int32_t), getKeyComparFunc(TSDB_DATA_TYPE_INT),
false, getkey);
int32_t size = 200000;
srand(time(NULL));
...
...
@@ -375,3 +376,5 @@ TEST(testCase, skiplist_test) {
free(pKeys);*/
}
#endif
\ No newline at end of file
src/util/tests/trefTest.c
浏览文件 @
f96ad1f4
...
...
@@ -14,18 +14,18 @@ typedef struct {
int
refNum
;
int
steps
;
int
rsetId
;
int64_t
rid
;
int64_t
*
rid
;
void
**
p
;
}
SRefSpace
;
void
iterateRefs
(
int
rsetId
)
{
int
count
=
0
;
void
*
p
=
taosIterateRef
(
rsetId
,
NULL
);
void
*
p
=
taosIterateRef
(
rsetId
,
0
);
while
(
p
)
{
// process P
count
++
;
p
=
taosIterateRef
(
rsetId
,
p
);
p
=
taosIterateRef
(
rsetId
,
(
int64_t
)
p
);
}
printf
(
" %d "
,
count
);
...
...
@@ -34,7 +34,6 @@ void iterateRefs(int rsetId) {
void
*
addRef
(
void
*
param
)
{
SRefSpace
*
pSpace
=
(
SRefSpace
*
)
param
;
int
id
;
int64_t
rid
;
for
(
int
i
=
0
;
i
<
pSpace
->
steps
;
++
i
)
{
printf
(
"a"
);
...
...
@@ -51,8 +50,7 @@ void *addRef(void *param) {
void
*
removeRef
(
void
*
param
)
{
SRefSpace
*
pSpace
=
(
SRefSpace
*
)
param
;
int
id
;
int64_t
rid
;
int
id
,
code
;
for
(
int
i
=
0
;
i
<
pSpace
->
steps
;
++
i
)
{
printf
(
"d"
);
...
...
@@ -71,16 +69,15 @@ void *removeRef(void *param) {
void
*
acquireRelease
(
void
*
param
)
{
SRefSpace
*
pSpace
=
(
SRefSpace
*
)
param
;
int
id
;
int64_t
rid
;
for
(
int
i
=
0
;
i
<
pSpace
->
steps
;
++
i
)
{
printf
(
"a"
);
id
=
random
()
%
pSpace
->
refNum
;
void
*
p
=
taosAcquireRef
(
pSpace
->
rsetId
,
pSpace
->
p
[
id
]);
void
*
p
=
taosAcquireRef
(
pSpace
->
rsetId
,
(
int64_t
)
pSpace
->
p
[
id
]);
if
(
p
)
{
usleep
(
id
%
5
+
1
);
taosReleaseRef
(
pSpace
->
rsetId
,
pSpace
->
p
[
id
]);
taosReleaseRef
(
pSpace
->
rsetId
,
(
int64_t
)
pSpace
->
p
[
id
]);
}
}
...
...
@@ -103,6 +100,7 @@ void *openRefSpace(void *param) {
}
pSpace
->
p
=
(
void
**
)
calloc
(
sizeof
(
void
*
),
pSpace
->
refNum
);
pSpace
->
rid
=
calloc
(
pSpace
->
refNum
,
sizeof
(
int64_t
));
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
...
...
tests/script/sh/prepare_udf.sh
浏览文件 @
f96ad1f4
...
...
@@ -5,6 +5,7 @@ echo -n "" > /tmp/empty
dd
if
=
/dev/zero
bs
=
3584
of
=
/tmp/big
count
=
1
rm
-rf
/tmp/sum_double.so /tmp/add_one.so
touch
/tmp/normal
gcc
-g
-O0
-fPIC
-shared
sh/sum_double.c
-o
/tmp/sum_double.so
gcc
-g
-O0
-fPIC
-shared
sh/add_one.c
-o
/tmp/add_one.so
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录