Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
a3af16e8
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看板
提交
a3af16e8
编写于
4月 05, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-98] suppress compiler warnings.
上级
d88df895
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
97 addition
and
126 deletion
+97
-126
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+0
-1
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+0
-2
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+3
-3
src/client/src/tscSql.c
src/client/src/tscSql.c
+13
-13
src/client/src/tscSub.c
src/client/src/tscSub.c
+3
-3
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+0
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-2
src/query/tests/astTest.cpp
src/query/tests/astTest.cpp
+3
-0
src/query/tests/tsBufTest.cpp
src/query/tests/tsBufTest.cpp
+12
-12
src/query/tests/unitTest.cpp
src/query/tests/unitTest.cpp
+3
-0
src/util/inc/tcache.h
src/util/inc/tcache.h
+1
-1
src/util/src/tcache.c
src/util/src/tcache.c
+4
-4
src/util/tests/cacheTest.cpp
src/util/tests/cacheTest.cpp
+15
-15
src/util/tests/skiplistTest.cpp
src/util/tests/skiplistTest.cpp
+3
-3
src/vnode/tsdb/src/tsdbRead.c
src/vnode/tsdb/src/tsdbRead.c
+15
-15
tests/examples/c/demo.c
tests/examples/c/demo.c
+20
-51
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
a3af16e8
...
...
@@ -468,7 +468,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo);
extern
void
*
pVnodeConn
;
extern
void
*
pTscMgmtConn
;
extern
void
*
tscCacheHandle
;
extern
int32_t
globalCode
;
extern
int
slaveIndex
;
extern
void
*
tscTmr
;
extern
void
*
tscQhandle
;
...
...
src/client/src/tscAsync.c
浏览文件 @
a3af16e8
...
...
@@ -200,7 +200,6 @@ void taos_fetch_rows_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, int), voi
SSqlObj
*
pSql
=
(
SSqlObj
*
)
taosa
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
tscError
(
"sql object is NULL"
);
// globalCode = TSDB_CODE_DISCONNECTED;
tscQueueAsyncError
(
fp
,
param
,
TSDB_CODE_DISCONNECTED
);
return
;
}
...
...
@@ -232,7 +231,6 @@ void taos_fetch_row_a(TAOS_RES *taosa, void (*fp)(void *, TAOS_RES *, TAOS_ROW),
SSqlObj
*
pSql
=
(
SSqlObj
*
)
taosa
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
tscError
(
"sql object is NULL"
);
// globalCode = TSDB_CODE_DISCONNECTED;
tscQueueAsyncError
(
fp
,
param
,
TSDB_CODE_DISCONNECTED
);
return
;
}
...
...
src/client/src/tscPrepare.c
浏览文件 @
a3af16e8
...
...
@@ -467,14 +467,14 @@ static int insertStmtExecute(STscStmt* stmt) {
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
tscError
(
"connection disconnected"
);
return
NULL
;
}
STscStmt
*
pStmt
=
calloc
(
1
,
sizeof
(
STscStmt
));
if
(
pStmt
==
NULL
)
{
globalCode
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
tscError
(
"failed to allocate memory for statement"
);
return
NULL
;
}
...
...
@@ -482,7 +482,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
SSqlObj
*
pSql
=
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pSql
==
NULL
)
{
free
(
pStmt
);
globalCode
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
tscError
(
"failed to allocate memory for statement"
);
return
NULL
;
}
...
...
src/client/src/tscSql.c
浏览文件 @
a3af16e8
...
...
@@ -57,17 +57,17 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
taos_init
();
if
(
!
validUserName
(
user
))
{
globalCode
=
TSDB_CODE_INVALID_ACCT
;
terrno
=
TSDB_CODE_INVALID_ACCT
;
return
NULL
;
}
if
(
!
validPassword
(
pass
))
{
globalCode
=
TSDB_CODE_INVALID_PASS
;
terrno
=
TSDB_CODE_INVALID_PASS
;
return
NULL
;
}
if
(
tscInitRpc
(
user
,
pass
)
!=
0
)
{
globalCode
=
TSDB_CODE_NETWORK_UNAVAIL
;
terrno
=
TSDB_CODE_NETWORK_UNAVAIL
;
return
NULL
;
}
...
...
@@ -92,7 +92,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
STscObj
*
pObj
=
(
STscObj
*
)
calloc
(
1
,
sizeof
(
STscObj
));
if
(
NULL
==
pObj
)
{
globalCode
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
NULL
;
}
...
...
@@ -107,7 +107,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
/* db name is too long */
if
(
len
>
TSDB_DB_NAME_LEN
)
{
free
(
pObj
);
globalCode
=
TSDB_CODE_INVALID_DB
;
terrno
=
TSDB_CODE_INVALID_DB
;
return
NULL
;
}
...
...
@@ -122,7 +122,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
SSqlObj
*
pSql
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
NULL
==
pSql
)
{
globalCode
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
free
(
pObj
);
return
NULL
;
}
...
...
@@ -140,7 +140,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
pSql
->
cmd
.
command
=
TSDB_SQL_CONNECT
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
&
pSql
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
globalCode
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
free
(
pSql
);
free
(
pObj
);
return
NULL
;
...
...
@@ -303,7 +303,7 @@ int taos_query(TAOS *taos, const char *sqlstr) {
TAOS_RES
*
taos_use_result
(
TAOS
*
taos
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
return
NULL
;
}
...
...
@@ -662,7 +662,7 @@ static void waitForRetrieveRsp(void *param, TAOS_RES *tres, int numOfRows) {
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
res
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
return
NULL
;
}
...
...
@@ -694,7 +694,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
int
nRows
=
0
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
*
rows
=
NULL
;
return
0
;
}
...
...
@@ -733,7 +733,7 @@ int taos_select_db(TAOS *taos, const char *db) {
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
return
TSDB_CODE_DISCONNECTED
;
}
...
...
@@ -1011,7 +1011,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
return
TSDB_CODE_DISCONNECTED
;
}
...
...
@@ -1143,7 +1143,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
return
TSDB_CODE_DISCONNECTED
;
}
...
...
src/client/src/tscSub.c
浏览文件 @
a3af16e8
...
...
@@ -99,14 +99,14 @@ void tscUpdateSubscriptionProgress(void* sub, int64_t uid, TSKEY ts) {
static
SSub
*
tscCreateSubscription
(
STscObj
*
pObj
,
const
char
*
topic
,
const
char
*
sql
)
{
SSub
*
pSub
=
calloc
(
1
,
sizeof
(
SSub
));
if
(
pSub
==
NULL
)
{
globalCode
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
tscError
(
"failed to allocate memory for subscription"
);
return
NULL
;
}
SSqlObj
*
pSql
=
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pSql
==
NULL
)
{
globalCode
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
tscError
(
"failed to allocate SSqlObj for subscription"
);
goto
failed
;
}
...
...
@@ -309,7 +309,7 @@ void tscSaveSubscriptionProgress(void* sub) {
TAOS_SUB
*
taos_subscribe
(
TAOS
*
taos
,
int
restart
,
const
char
*
topic
,
const
char
*
sql
,
TAOS_SUBSCRIBE_CALLBACK
fp
,
void
*
param
,
int
interval
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
tscError
(
"connection disconnected"
);
return
NULL
;
}
...
...
src/client/src/tscSystem.c
浏览文件 @
a3af16e8
...
...
@@ -33,7 +33,6 @@ void * pVMeterConn;
void
*
pTscMgmtConn
;
void
*
pSlaveConn
;
void
*
tscCacheHandle
;
int32_t
globalCode
=
0
;
int
slaveIndex
;
void
*
tscTmr
;
void
*
tscQhandle
;
...
...
src/client/src/tscUtil.c
浏览文件 @
a3af16e8
...
...
@@ -819,7 +819,7 @@ void tscCloseTscObj(STscObj* pObj) {
pObj
->
signature
=
NULL
;
SSqlObj
*
pSql
=
pObj
->
pSql
;
if
(
pSql
)
{
globalCode
=
pSql
->
res
.
code
;
terrno
=
pSql
->
res
.
code
;
}
taosTmrStopA
(
&
(
pObj
->
pTimer
));
...
...
@@ -2153,7 +2153,7 @@ int16_t tscGetJoinTagColIndexByUid(STagCond* pTagCond, uint64_t uid) {
bool
tscIsUpdateQuery
(
STscObj
*
pObj
)
{
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
{
globalCode
=
TSDB_CODE_DISCONNECTED
;
terrno
=
TSDB_CODE_DISCONNECTED
;
return
TSDB_CODE_DISCONNECTED
;
}
...
...
src/query/tests/astTest.cpp
浏览文件 @
a3af16e8
...
...
@@ -9,6 +9,9 @@
#include "tsdb.h"
#include "tskiplist.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
typedef
struct
ResultObj
{
int32_t
numOfResult
;
char
*
resultName
[
64
];
...
...
src/query/tests/tsBufTest.cpp
浏览文件 @
a3af16e8
...
...
@@ -158,7 +158,7 @@ void loadDataTest() {
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
int64_t
*
list
=
createTsList
(
num
,
start
,
step
);
tsBufAppend
(
pTSBuf
,
j
,
i
,
(
const
char
*
)
list
,
num
*
sizeof
(
int64_t
));
printf
(
"%d - %
lld
\n
"
,
i
,
list
[
0
]);
printf
(
"%d - %
"
PRIu64
"
\n
"
,
i
,
list
[
0
]);
free
(
list
);
start
+=
step
*
num
;
...
...
@@ -195,7 +195,7 @@ void loadDataTest() {
tsBufResetPos
(
pNewBuf
);
int64_t
s
=
taosGetTimestampUs
();
printf
(
"start:%
lld
\n
"
,
s
);
printf
(
"start:%
"
PRIu64
"
\n
"
,
s
);
int32_t
x
=
0
;
while
(
tsBufNextPos
(
pNewBuf
))
{
...
...
@@ -204,11 +204,11 @@ void loadDataTest() {
break
;
}
// printf("%d-%
lld-%lld
\n", elem.vnode, elem.tag, elem.ts);
// printf("%d-%
" PRIu64 "-%" PRIu64 "
\n", elem.vnode, elem.tag, elem.ts);
}
int64_t
e
=
taosGetTimestampUs
();
printf
(
"end:%
lld, elapsed:%lld
, total obj:%d
\n
"
,
e
,
e
-
s
,
x
);
printf
(
"end:%
"
PRIu64
", elapsed:%"
PRIu64
"
, total obj:%d
\n
"
,
e
,
e
-
s
,
x
);
}
void
randomIncTsTest
()
{}
...
...
@@ -229,14 +229,14 @@ void TSTraverse() {
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
int64_t
*
list
=
createTsList
(
num
,
start
,
step
);
tsBufAppend
(
pTSBuf
,
j
,
i
,
(
const
char
*
)
list
,
num
*
sizeof
(
int64_t
));
printf
(
"%d - %d - %
lld, %lld
\n
"
,
j
,
i
,
list
[
0
],
list
[
num
-
1
]);
printf
(
"%d - %d - %
"
PRIu64
", %"
PRIu64
"
\n
"
,
j
,
i
,
list
[
0
],
list
[
num
-
1
]);
free
(
list
);
start
+=
step
*
num
;
list
=
createTsList
(
num
,
start
,
step
);
tsBufAppend
(
pTSBuf
,
j
,
i
,
(
const
char
*
)
list
,
num
*
sizeof
(
int64_t
));
printf
(
"%d - %d - %
lld, %lld
\n
"
,
j
,
i
,
list
[
0
],
list
[
num
-
1
]);
printf
(
"%d - %d - %
"
PRIu64
", %"
PRIu64
"
\n
"
,
j
,
i
,
list
[
0
],
list
[
num
-
1
]);
free
(
list
);
start
+=
step
*
num
;
...
...
@@ -250,7 +250,7 @@ void TSTraverse() {
////////////////////////////////////////////////////////////////////////////////////////
// reverse traverse
int64_t
s
=
taosGetTimestampUs
();
printf
(
"start:%
lld
\n
"
,
s
);
printf
(
"start:%
"
PRIu64
"
\n
"
,
s
);
pTSBuf
->
cur
.
order
=
TSQL_SO_DESC
;
...
...
@@ -258,7 +258,7 @@ void TSTraverse() {
int32_t
x
=
0
;
while
(
tsBufNextPos
(
pTSBuf
))
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
// printf("%d-%
lld-%lld
\n", elem.vnode, elem.tag, elem.ts);
// printf("%d-%
" PRIu64 "-%" PRIu64 "
\n", elem.vnode, elem.tag, elem.ts);
}
// specify the data block with vnode and tags value
...
...
@@ -273,7 +273,7 @@ void TSTraverse() {
int32_t
totalOutput
=
10
;
while
(
1
)
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
printf
(
"%d-%
lld-%lld
\n
"
,
elem
.
vnode
,
elem
.
tag
,
elem
.
ts
);
printf
(
"%d-%
"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
,
elem
.
ts
);
if
(
!
tsBufNextPos
(
pTSBuf
))
{
break
;
...
...
@@ -303,7 +303,7 @@ void TSTraverse() {
// complete forwards traverse
while
(
tsBufNextPos
(
pTSBuf
))
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
// printf("%d-%
lld-%lld
\n", elem.vnode, elem.tag, elem.ts);
// printf("%d-%
" PRIu64 "-%" PRIu64 "
\n", elem.vnode, elem.tag, elem.ts);
}
// specify the data block with vnode and tags value
...
...
@@ -318,7 +318,7 @@ void TSTraverse() {
totalOutput
=
10
;
while
(
1
)
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
printf
(
"%d-%
lld-%lld
\n
"
,
elem
.
vnode
,
elem
.
tag
,
elem
.
ts
);
printf
(
"%d-%
"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
,
elem
.
ts
);
if
(
!
tsBufNextPos
(
pTSBuf
))
{
break
;
...
...
@@ -429,7 +429,7 @@ void mergeIdenticalVnodeBufferTest() {
STSElem
elem
=
tsBufGetElem
(
pTSBuf1
);
EXPECT_EQ
(
elem
.
vnode
,
12
);
printf
(
"%d-%
lld-%lld
\n
"
,
elem
.
vnode
,
elem
.
tag
,
elem
.
ts
);
printf
(
"%d-%
"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
,
elem
.
ts
);
}
tsBufDestory
(
pTSBuf1
);
...
...
src/query/tests/unitTest.cpp
浏览文件 @
a3af16e8
...
...
@@ -11,6 +11,9 @@
#include "tvariant.h"
#include "ttokendef.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
namespace
{
int32_t
testValidateName
(
char
*
name
)
{
SSQLToken
token
=
{
0
};
...
...
src/util/inc/tcache.h
浏览文件 @
a3af16e8
...
...
@@ -98,7 +98,7 @@ SCacheObj *taosCacheInit(void *tmrCtrl, int64_t refreshTimeInSeconds);
* @param keepTime survival time in second
* @return cached element
*/
void
*
taosCachePut
(
SCacheObj
*
pCacheObj
,
c
har
*
key
,
void
*
pData
,
size_t
dataSize
,
int
keepTimeInSeconds
);
void
*
taosCachePut
(
SCacheObj
*
pCacheObj
,
c
onst
char
*
key
,
const
void
*
pData
,
size_t
dataSize
,
int
keepTimeInSeconds
);
/**
* get data from cache
...
...
src/util/src/tcache.c
浏览文件 @
a3af16e8
...
...
@@ -233,8 +233,8 @@ static FORCE_INLINE void taosCacheMoveToTrash(SCacheObj *pCacheObj, SCacheDataNo
* @param dataSize
* @return
*/
static
SCacheDataNode
*
taosUpdateCacheImpl
(
SCacheObj
*
pCacheObj
,
SCacheDataNode
*
pNode
,
char
*
key
,
int32_t
keyLen
,
void
*
pData
,
uint32_t
dataSize
,
uint64_t
duration
)
{
static
SCacheDataNode
*
taosUpdateCacheImpl
(
SCacheObj
*
pCacheObj
,
SCacheDataNode
*
pNode
,
c
onst
c
har
*
key
,
int32_t
keyLen
,
const
void
*
pData
,
uint32_t
dataSize
,
uint64_t
duration
)
{
SCacheDataNode
*
pNewNode
=
NULL
;
// only a node is not referenced by any other object, in-place update it
...
...
@@ -288,7 +288,7 @@ static SCacheDataNode *taosUpdateCacheImpl(SCacheObj *pCacheObj, SCacheDataNode
* @param pNode
* @return
*/
static
FORCE_INLINE
SCacheDataNode
*
taosAddToCacheImpl
(
SCacheObj
*
pCacheObj
,
char
*
key
,
size_t
keyLen
,
const
void
*
pData
,
static
FORCE_INLINE
SCacheDataNode
*
taosAddToCacheImpl
(
SCacheObj
*
pCacheObj
,
c
onst
c
har
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dataSize
,
uint64_t
duration
)
{
SCacheDataNode
*
pNode
=
taosCreateHashNode
(
key
,
keyLen
,
pData
,
dataSize
,
duration
);
if
(
pNode
==
NULL
)
{
...
...
@@ -401,7 +401,7 @@ SCacheObj *taosCacheInit(void *tmrCtrl, int64_t refreshTime) {
return
pCacheObj
;
}
void
*
taosCachePut
(
SCacheObj
*
pCacheObj
,
c
har
*
key
,
void
*
pData
,
size_t
dataSize
,
int
duration
)
{
void
*
taosCachePut
(
SCacheObj
*
pCacheObj
,
c
onst
char
*
key
,
const
void
*
pData
,
size_t
dataSize
,
int
duration
)
{
SCacheDataNode
*
pNode
;
if
(
pCacheObj
==
NULL
||
pCacheObj
->
pHashTable
==
NULL
)
{
...
...
src/util/tests/cacheTest.cpp
浏览文件 @
a3af16e8
...
...
@@ -22,15 +22,15 @@ TEST(testCase, client_cache_test) {
void
*
tscTmr
=
taosTmrInit
(
tsMaxMgmtConnections
*
2
,
200
,
6000
,
"TSC"
);
SCacheObj
*
tscCacheHandle
=
taosCacheInit
(
tscTmr
,
REFRESH_TIME_IN_SEC
);
char
*
key1
=
"test1"
;
char
*
data1
=
"test11"
;
c
onst
c
har
*
key1
=
"test1"
;
char
data1
[]
=
"test11"
;
char
*
cachedObj
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key1
,
data1
,
strlen
(
data1
),
1
);
sleep
(
REFRESH_TIME_IN_SEC
+
1
);
printf
(
"obj is still valid: %s
\n
"
,
cachedObj
);
char
*
data2
=
"test22"
;
char
data2
[]
=
"test22"
;
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj
,
false
);
/* the object is cleared by cache clean operation */
...
...
@@ -43,8 +43,8 @@ TEST(testCase, client_cache_test) {
getchar
();
char
*
key3
=
"test2"
;
char
*
data3
=
"kkkkkkk"
;
c
onst
c
har
*
key3
=
"test2"
;
c
onst
c
har
*
data3
=
"kkkkkkk"
;
char
*
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key3
,
data3
,
strlen
(
data3
),
1
);
printf
(
"%s
\n
"
,
cachedObj2
);
...
...
@@ -55,11 +55,11 @@ TEST(testCase, client_cache_test) {
char
*
d
=
(
char
*
)
taosCacheAcquireByName
(
tscCacheHandle
,
key3
);
// assert(d == NULL);
char
*
key5
=
"test5"
;
char
*
data5
=
"data5kkkkk"
;
char
key5
[]
=
"test5"
;
char
data5
[]
=
"data5kkkkk"
;
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
data5
,
strlen
(
data5
),
20
);
char
*
data6
=
"new Data after updated"
;
c
onst
c
har
*
data6
=
"new Data after updated"
;
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj2
,
false
);
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
data6
,
strlen
(
data6
),
20
);
...
...
@@ -67,7 +67,7 @@ TEST(testCase, client_cache_test) {
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj2
,
true
);
char
*
data7
=
"add call update procedure"
;
c
onst
c
har
*
data7
=
"add call update procedure"
;
cachedObj2
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key5
,
data7
,
strlen
(
data7
),
20
);
printf
(
"%s
\n
=======================================
\n\n
"
,
cachedObj2
);
...
...
@@ -76,8 +76,8 @@ TEST(testCase, client_cache_test) {
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cachedObj2
,
true
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
cc
,
false
);
char
*
data8
=
"ttft"
;
char
*
key6
=
"key6"
;
c
onst
c
har
*
data8
=
"ttft"
;
c
onst
c
har
*
key6
=
"key6"
;
char
*
ft
=
(
char
*
)
taosCachePut
(
tscCacheHandle
,
key6
,
data8
,
strlen
(
data8
),
20
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
ft
,
false
);
...
...
@@ -86,7 +86,7 @@ TEST(testCase, client_cache_test) {
* 140ns
*/
uint64_t
startTime
=
taosGetTimestampUs
();
printf
(
"Cache Performance Test
\n
start time:%
lld
\n
"
,
startTime
);
printf
(
"Cache Performance Test
\n
start time:%
"
PRIu64
"
\n
"
,
startTime
);
for
(
int32_t
i
=
0
;
i
<
1000
;
++
i
)
{
char
*
dd
=
(
char
*
)
taosCacheAcquireByName
(
tscCacheHandle
,
key6
);
if
(
dd
!=
NULL
)
{
...
...
@@ -101,7 +101,7 @@ TEST(testCase, client_cache_test) {
uint64_t
endTime
=
taosGetTimestampUs
();
int64_t
el
=
endTime
-
startTime
;
printf
(
"End of Test, %
lld
\n
Total Elapsed Time:%lld
us.avg:%f us
\n
"
,
endTime
,
el
,
el
/
1000.0
);
printf
(
"End of Test, %
"
PRIu64
"
\n
Total Elapsed Time:%"
PRIu64
"
us.avg:%f us
\n
"
,
endTime
,
el
,
el
/
1000.0
);
taosCacheCleanup
(
tscCacheHandle
);
}
...
...
@@ -125,7 +125,7 @@ TEST(testCase, cache_resize_test) {
}
uint64_t
endTime
=
taosGetTimestampUs
();
printf
(
"add %d object cost:%
lld
us, avg:%f us
\n
"
,
num
,
endTime
-
startTime
,
(
endTime
-
startTime
)
/
(
double
)
num
);
printf
(
"add %d object cost:%
"
PRIu64
"
us, avg:%f us
\n
"
,
num
,
endTime
-
startTime
,
(
endTime
-
startTime
)
/
(
double
)
num
);
startTime
=
taosGetTimestampUs
();
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
...
...
@@ -134,7 +134,7 @@ TEST(testCase, cache_resize_test) {
assert
(
k
!=
0
);
}
endTime
=
taosGetTimestampUs
();
printf
(
"retrieve %d object cost:%
lld
us,avg:%f
\n
"
,
num
,
endTime
-
startTime
,
(
endTime
-
startTime
)
/
(
double
)
num
);
printf
(
"retrieve %d object cost:%
"
PRIu64
"
us,avg:%f
\n
"
,
num
,
endTime
-
startTime
,
(
endTime
-
startTime
)
/
(
double
)
num
);
taosCacheCleanup
(
pCache
);
taosMsleep
(
20000
);
...
...
src/util/tests/skiplistTest.cpp
浏览文件 @
a3af16e8
...
...
@@ -175,7 +175,7 @@ void stringKeySkiplistTest() {
}
int64_t
e
=
taosGetTimestampUs
();
printf
(
"elapsed time:%
lld
us to insert %d data, avg:%f us
\n
"
,
(
e
-
s
),
total
,
(
double
)(
e
-
s
)
/
total
);
printf
(
"elapsed time:%
"
PRIu64
"
us to insert %d data, avg:%f us
\n
"
,
(
e
-
s
),
total
,
(
double
)(
e
-
s
)
/
total
);
printf
(
"level two------------------
\n
"
);
tSkipListPrint
(
pSkipList
,
1
);
...
...
@@ -237,13 +237,13 @@ void skiplistPerformanceTest() {
int64_t
cur
=
taosGetTimestampMs
();
int64_t
elapsed
=
cur
-
prev
;
printf
(
"add %d, elapsed time: %
lld
ms, avg elapsed:%f ms, total:%d
\n
"
,
100000
,
elapsed
,
elapsed
/
100000.0
,
i
);
printf
(
"add %d, elapsed time: %
"
PRIu64
"
ms, avg elapsed:%f ms, total:%d
\n
"
,
100000
,
elapsed
,
elapsed
/
100000.0
,
i
);
prev
=
cur
;
}
}
int64_t
e
=
taosGetTimestampMs
();
printf
(
"total:%
lld
ms, avg:%f
\n
"
,
e
-
s
,
(
e
-
s
)
/
(
double
)
size
);
printf
(
"total:%
"
PRIu64
"
ms, avg:%f
\n
"
,
e
-
s
,
(
e
-
s
)
/
(
double
)
size
);
printf
(
"max level of skiplist:%d, actually level:%d
\n
"
,
pSkipList
->
maxLevel
,
pSkipList
->
level
);
assert
(
tSkipListGetSize
(
pSkipList
)
==
size
);
...
...
src/vnode/tsdb/src/tsdbRead.c
浏览文件 @
a3af16e8
...
...
@@ -1053,7 +1053,7 @@ typedef struct SSyntaxTreeFilterSupporter {
* convert the result pointer to STabObj instead of tSkipListNode
* @param pRes
*/
static
void
tansformQueryResult
(
SArray
*
pRes
)
{
static
UNUSED_FUNC
void
tansformQueryResult
(
SArray
*
pRes
)
{
if
(
pRes
==
NULL
||
taosArrayGetSize
(
pRes
)
==
0
)
{
return
;
}
...
...
@@ -1305,10 +1305,10 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) {
}
static
int32_t
doQueryTableList
(
STable
*
pSTable
,
SArray
*
pRes
,
const
char
*
pCond
)
{
STColumn
*
stcol
=
schemaColAt
(
pSTable
->
tagSchema
,
0
);
//
STColumn* stcol = schemaColAt(pSTable->tagSchema, 0);
tExprNode
*
pExpr
=
NULL
;
tSQLBinaryExprFromString
(
&
pExpr
,
stcol
,
schemaNCols
(
pSTable
->
tagSchema
),
(
char
*
)
pCond
,
strlen
(
pCond
));
//
tSQLBinaryExprFromString(&pExpr, stcol, schemaNCols(pSTable->tagSchema), (char*) pCond, strlen(pCond));
// failed to build expression, no result, return immediately
if
(
pExpr
==
NULL
)
{
...
...
@@ -1319,18 +1319,18 @@ static int32_t doQueryTableList(STable* pSTable, SArray* pRes, const char* pCond
}
// query according to the binary expression
SSyntaxTreeFilterSupporter
s
=
{.
pTagSchema
=
stcol
,
.
numOfTags
=
schemaNCols
(
pSTable
->
tagSchema
)};
SBinaryFilterSupp
supp
=
{
.
fp
=
(
__result_filter_fn_t
)
tSkipListNodeFilterCallback
,
.
setupInfoFn
=
(
__do_filter_suppl_fn_t
)
filterPrepare
,
.
pExtInfo
=
&
s
};
tSQLBinaryExprTraverse
(
pExpr
,
pSTable
->
pIndex
,
pRes
,
&
supp
);
tExprTreeDestroy
(
&
pExpr
,
tSQLListTraverseDestroyInfo
);
tansformQueryResult
(
pRes
);
//
SSyntaxTreeFilterSupporter s = {.pTagSchema = stcol, .numOfTags = schemaNCols(pSTable->tagSchema)};
//
//
SBinaryFilterSupp supp = {
//
.fp = (__result_filter_fn_t)tSkipListNodeFilterCallback,
//
.setupInfoFn = (__do_filter_suppl_fn_t)filterPrepare,
//
.pExtInfo = &s
//
};
//
//
tSQLBinaryExprTraverse(pExpr, pSTable->pIndex, pRes, &supp);
//
tExprTreeDestroy(&pExpr, tSQLListTraverseDestroyInfo);
//
//
tansformQueryResult(pRes);
return
TSDB_CODE_SUCCESS
;
}
...
...
tests/examples/c/demo.c
浏览文件 @
a3af16e8
...
...
@@ -24,44 +24,20 @@
void
taosMsleep
(
int
mseconds
);
static
int32_t
doQuery
(
TAOS
*
taos
,
const
char
*
sql
)
{
int32_t
code
=
taos_query
(
taos
,
sql
);
if
(
code
!=
0
)
{
printf
(
"failed to execute query, reason:%s
\n
"
,
taos_errstr
(
taos
));
return
-
1
;
}
TAOS_RES
*
res
=
taos_use_result
(
taos
);
TAOS_ROW
row
=
NULL
;
char
buf
[
512
]
=
{
0
};
int32_t
numOfFields
=
taos_num_fields
(
res
);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
res
);
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
taos_print_row
(
buf
,
row
,
pFields
,
numOfFields
);
printf
(
"%s
\n
"
,
buf
);
memset
(
buf
,
0
,
512
);
}
taos_free_result
(
res
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
TAOS
*
taos
;
char
qstr
[
1024
];
TAOS_RES
*
result
;
// connect to server
if
(
argc
<
2
)
{
printf
(
"please input server-ip
\n
"
);
return
0
;
}
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"~/sec/cfg"
);
// init TAOS
taos_init
();
taos
=
taos_connect
(
argv
[
1
],
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to server, reason:%s
\n
"
,
taos_errstr
(
taos
));
...
...
@@ -69,20 +45,6 @@ int main(int argc, char *argv[]) {
}
printf
(
"success to connect to server
\n
"
);
doQuery
(
taos
,
"create database if not exists test"
);
doQuery
(
taos
,
"use test"
);
doQuery
(
taos
,
"create table if not exists tm0 (ts timestamp, k int);"
);
doQuery
(
taos
,
"insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);"
);
doQuery
(
taos
,
"select * from tm0;"
);
// doQuery(taos, "insert into tm01 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);");
// doQuery(taos, "insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);");
// doQuery(taos, "insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);");
// doQuery(taos, "insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);");
taos_close
(
taos
);
getchar
();
return
0
;
taos_query
(
taos
,
"drop database demo"
);
if
(
taos_query
(
taos
,
"create database demo"
)
!=
0
)
{
...
...
@@ -90,19 +52,19 @@ int main(int argc, char *argv[]) {
exit
(
1
);
}
printf
(
"success to create database
\n
"
);
taos_query
(
taos
,
"use demo"
);
// create table
if
(
taos_query
(
taos
,
"create table m1 (ts timestamp, speed int)"
)
!=
0
)
{
printf
(
"failed to create table, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
printf
(
"success to create table
\n
"
);
// sleep for one second to make sure table is created on data node
// taosMsleep(1000);
// insert 10 records
int
i
=
0
;
for
(
i
=
0
;
i
<
10
;
++
i
)
{
...
...
@@ -113,28 +75,35 @@ int main(int argc, char *argv[]) {
//sleep(1);
}
printf
(
"success to insert rows, total %d rows
\n
"
,
i
);
// query the records
sprintf
(
qstr
,
"SELECT * FROM m1"
);
if
(
taos_query
(
taos
,
qstr
)
!=
0
)
{
printf
(
"failed to select, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
printf
(
"failed to get result, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
//
TAOS_ROW row;
TAOS_ROW
row
;
int
rows
=
0
;
int
num_fields
=
taos_field_count
(
taos
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
char
temp
[
256
];
printf
(
"select * from table, result:
\n
"
);
// fetch the records row by row
while
((
row
=
taos_fetch_row
(
result
)))
{
rows
++
;
taos_print_row
(
temp
,
row
,
fields
,
num_fields
);
printf
(
"%s
\n
"
,
temp
);
}
taos_free_result
(
result
);
printf
(
"====demo end====
\n\n
"
);
return
getchar
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录