Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d5c57b68
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看板
提交
d5c57b68
编写于
8月 03, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some warnings
上级
362fb3d3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
16 addition
and
17 deletion
+16
-17
src/util/src/hash.c
src/util/src/hash.c
+7
-7
src/util/src/talgo.c
src/util/src/talgo.c
+3
-3
src/util/src/tarray.c
src/util/src/tarray.c
+3
-3
src/util/src/tbuffer.c
src/util/src/tbuffer.c
+0
-1
src/util/src/tcache.c
src/util/src/tcache.c
+3
-3
未找到文件。
src/util/src/hash.c
浏览文件 @
d5c57b68
...
@@ -81,7 +81,7 @@ static FORCE_INLINE void __lock_destroy(void *lock) {
...
@@ -81,7 +81,7 @@ static FORCE_INLINE void __lock_destroy(void *lock) {
static
FORCE_INLINE
int32_t
taosHashCapacity
(
int32_t
length
)
{
static
FORCE_INLINE
int32_t
taosHashCapacity
(
int32_t
length
)
{
int32_t
len
=
MIN
(
length
,
HASH_MAX_CAPACITY
);
int32_t
len
=
MIN
(
length
,
HASH_MAX_CAPACITY
);
u
int32_t
i
=
4
;
int32_t
i
=
4
;
while
(
i
<
len
)
i
=
(
i
<<
1u
);
while
(
i
<
len
)
i
=
(
i
<<
1u
);
return
i
;
return
i
;
}
}
...
@@ -176,7 +176,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool threadsafe) {
...
@@ -176,7 +176,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool threadsafe) {
}
}
// the max slots is not defined by user
// the max slots is not defined by user
pHashObj
->
capacity
=
taosHashCapacity
(
capacity
);
pHashObj
->
capacity
=
taosHashCapacity
(
(
int32_t
)
capacity
);
assert
((
pHashObj
->
capacity
&
(
pHashObj
->
capacity
-
1
))
==
0
);
assert
((
pHashObj
->
capacity
&
(
pHashObj
->
capacity
-
1
))
==
0
);
pHashObj
->
hashFp
=
fn
;
pHashObj
->
hashFp
=
fn
;
...
@@ -219,7 +219,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
...
@@ -219,7 +219,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
__wr_lock
(
pHashObj
->
lock
);
__wr_lock
(
pHashObj
->
lock
);
uint32_t
hashVal
=
0
;
uint32_t
hashVal
=
0
;
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
keyLen
,
&
hashVal
);
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
(
uint32_t
)
keyLen
,
&
hashVal
);
if
(
pNode
==
NULL
)
{
// no data in hash table with the specified key, add it into hash table
if
(
pNode
==
NULL
)
{
// no data in hash table with the specified key, add it into hash table
taosHashTableResize
(
pHashObj
);
taosHashTableResize
(
pHashObj
);
...
@@ -261,7 +261,7 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) {
...
@@ -261,7 +261,7 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) {
__rd_lock
(
pHashObj
->
lock
);
__rd_lock
(
pHashObj
->
lock
);
uint32_t
hashVal
=
0
;
uint32_t
hashVal
=
0
;
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
keyLen
,
&
hashVal
);
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
(
int32_t
)
keyLen
,
&
hashVal
);
__unlock
(
pHashObj
->
lock
);
__unlock
(
pHashObj
->
lock
);
...
@@ -278,7 +278,7 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
...
@@ -278,7 +278,7 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
__wr_lock
(
pHashObj
->
lock
);
__wr_lock
(
pHashObj
->
lock
);
uint32_t
val
=
0
;
uint32_t
val
=
0
;
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
keyLen
,
&
val
);
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
(
uint32_t
)
keyLen
,
&
val
);
if
(
pNode
==
NULL
)
{
if
(
pNode
==
NULL
)
{
__unlock
(
pHashObj
->
lock
);
__unlock
(
pHashObj
->
lock
);
return
;
return
;
...
@@ -460,7 +460,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
...
@@ -460,7 +460,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
SHashNode
*
pNode
=
NULL
;
SHashNode
*
pNode
=
NULL
;
SHashNode
*
pNext
=
NULL
;
SHashNode
*
pNext
=
NULL
;
int32_t
newSize
=
pHashObj
->
capacity
<<
1u
;
int32_t
newSize
=
(
int32_t
)(
pHashObj
->
capacity
)
<<
1u
;
if
(
newSize
>
HASH_MAX_CAPACITY
)
{
if
(
newSize
>
HASH_MAX_CAPACITY
)
{
// uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
// uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
// pHashObj->capacity, HASH_MAX_CAPACITY);
// pHashObj->capacity, HASH_MAX_CAPACITY);
...
@@ -539,7 +539,7 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
...
@@ -539,7 +539,7 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
pNewNode
->
key
=
pNewNode
->
data
+
dsize
;
pNewNode
->
key
=
pNewNode
->
data
+
dsize
;
memcpy
(
pNewNode
->
key
,
key
,
keyLen
);
memcpy
(
pNewNode
->
key
,
key
,
keyLen
);
pNewNode
->
keyLen
=
keyLen
;
pNewNode
->
keyLen
=
(
uint32_t
)
keyLen
;
pNewNode
->
hashVal
=
hashVal
;
pNewNode
->
hashVal
=
hashVal
;
return
pNewNode
;
return
pNewNode
;
...
...
src/util/src/talgo.c
浏览文件 @
d5c57b68
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
} while (0);
} while (0);
static
void
median
(
void
*
src
,
size_t
size
,
size_t
s
,
size_t
e
,
const
void
*
param
,
__ext_compar_fn_t
comparFn
,
void
*
buf
)
{
static
void
median
(
void
*
src
,
size_t
size
,
size_t
s
,
size_t
e
,
const
void
*
param
,
__ext_compar_fn_t
comparFn
,
void
*
buf
)
{
int32_t
mid
=
((
e
-
s
)
>>
1u
)
+
s
;
int32_t
mid
=
((
int32_t
)(
e
-
s
)
>>
1u
)
+
(
int32_t
)
s
;
if
(
comparFn
(
elePtrAt
(
src
,
size
,
mid
),
elePtrAt
(
src
,
size
,
s
),
param
)
==
1
)
{
if
(
comparFn
(
elePtrAt
(
src
,
size
,
mid
),
elePtrAt
(
src
,
size
,
s
),
param
)
==
1
)
{
doswap
(
elePtrAt
(
src
,
size
,
mid
),
elePtrAt
(
src
,
size
,
s
),
size
,
buf
);
doswap
(
elePtrAt
(
src
,
size
,
mid
),
elePtrAt
(
src
,
size
,
s
),
size
,
buf
);
...
@@ -152,14 +152,14 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const
...
@@ -152,14 +152,14 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const
void
taosqsort
(
void
*
src
,
size_t
numOfElem
,
size_t
size
,
const
void
*
param
,
__ext_compar_fn_t
comparFn
)
{
void
taosqsort
(
void
*
src
,
size_t
numOfElem
,
size_t
size
,
const
void
*
param
,
__ext_compar_fn_t
comparFn
)
{
char
*
buf
=
calloc
(
1
,
size
);
// prepare the swap buffer
char
*
buf
=
calloc
(
1
,
size
);
// prepare the swap buffer
tqsortImpl
(
src
,
0
,
numOfElem
-
1
,
size
,
param
,
comparFn
,
buf
);
tqsortImpl
(
src
,
0
,
(
int32_t
)
numOfElem
-
1
,
(
int32_t
)
size
,
param
,
comparFn
,
buf
);
taosTFree
(
buf
);
taosTFree
(
buf
);
}
}
void
*
taosbsearch
(
const
void
*
key
,
const
void
*
base
,
size_t
nmemb
,
size_t
size
,
__compar_fn_t
compar
,
int
flags
)
{
void
*
taosbsearch
(
const
void
*
key
,
const
void
*
base
,
size_t
nmemb
,
size_t
size
,
__compar_fn_t
compar
,
int
flags
)
{
// TODO: need to check the correctness of this function
// TODO: need to check the correctness of this function
int
l
=
0
;
int
l
=
0
;
int
r
=
nmemb
;
int
r
=
(
int
)
nmemb
;
int
idx
=
0
;
int
idx
=
0
;
int
comparison
;
int
comparison
;
...
...
src/util/src/tarray.c
浏览文件 @
d5c57b68
...
@@ -120,8 +120,8 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
...
@@ -120,8 +120,8 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
void
*
dst
=
TARRAY_GET_ELEM
(
pArray
,
index
);
void
*
dst
=
TARRAY_GET_ELEM
(
pArray
,
index
);
int32_t
remain
=
pArray
->
size
-
index
;
int32_t
remain
=
(
int32_t
)(
pArray
->
size
-
index
)
;
memmove
(
dst
+
pArray
->
elemSize
,
dst
,
pArray
->
elemSize
*
remain
);
memmove
(
(
char
*
)
dst
+
pArray
->
elemSize
,
(
char
*
)
dst
,
pArray
->
elemSize
*
remain
);
memcpy
(
dst
,
pData
,
pArray
->
elemSize
);
memcpy
(
dst
,
pData
,
pArray
->
elemSize
);
pArray
->
size
+=
1
;
pArray
->
size
+=
1
;
...
@@ -138,7 +138,7 @@ void taosArrayRemove(SArray* pArray, size_t index) {
...
@@ -138,7 +138,7 @@ void taosArrayRemove(SArray* pArray, size_t index) {
}
}
size_t
remain
=
pArray
->
size
-
index
-
1
;
size_t
remain
=
pArray
->
size
-
index
-
1
;
memmove
(
pArray
->
pData
+
index
*
pArray
->
elemSize
,
pArray
->
pData
+
(
index
+
1
)
*
pArray
->
elemSize
,
remain
*
pArray
->
elemSize
);
memmove
(
(
char
*
)
pArray
->
pData
+
index
*
pArray
->
elemSize
,
(
char
*
)
pArray
->
pData
+
(
index
+
1
)
*
pArray
->
elemSize
,
remain
*
pArray
->
elemSize
);
pArray
->
size
-=
1
;
pArray
->
size
-=
1
;
}
}
...
...
src/util/src/tbuffer.c
浏览文件 @
d5c57b68
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
#include <stdlib.h>
#include <stdlib.h>
#include <memory.h>
#include <memory.h>
#include <assert.h>
#include <assert.h>
#include <arpa/inet.h>
#include "tbuffer.h"
#include "tbuffer.h"
#include "exception.h"
#include "exception.h"
#include <taoserror.h>
#include <taoserror.h>
...
...
src/util/src/tcache.c
浏览文件 @
d5c57b68
...
@@ -292,7 +292,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
...
@@ -292,7 +292,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
uError
(
"cache:%s, key:%p, failed to added into cache, out of memory"
,
pCacheObj
->
name
,
key
);
uError
(
"cache:%s, key:%p, failed to added into cache, out of memory"
,
pCacheObj
->
name
,
key
);
}
}
}
else
{
// old data exists, update the node
}
else
{
// old data exists, update the node
pNode
=
taosUpdateCacheImpl
(
pCacheObj
,
pOld
,
key
,
keyLen
,
pData
,
dataSize
,
duration
*
1000L
);
pNode
=
taosUpdateCacheImpl
(
pCacheObj
,
pOld
,
key
,
(
int32_t
)
keyLen
,
pData
,
(
uint32_t
)
dataSize
,
duration
*
1000L
);
uDebug
(
"cache:%s, key:%p, %p exist in cache, updated old:%p"
,
pCacheObj
->
name
,
key
,
pNode
->
data
,
pOld
);
uDebug
(
"cache:%s, key:%p, %p exist in cache, updated old:%p"
,
pCacheObj
->
name
,
key
,
pNode
->
data
,
pOld
);
}
}
...
@@ -509,7 +509,7 @@ SCacheDataNode *taosCreateCacheNode(const char *key, size_t keyLen, const char *
...
@@ -509,7 +509,7 @@ SCacheDataNode *taosCreateCacheNode(const char *key, size_t keyLen, const char *
memcpy
(
pNewNode
->
data
,
pData
,
size
);
memcpy
(
pNewNode
->
data
,
pData
,
size
);
pNewNode
->
key
=
(
char
*
)
pNewNode
+
sizeof
(
SCacheDataNode
)
+
size
;
pNewNode
->
key
=
(
char
*
)
pNewNode
+
sizeof
(
SCacheDataNode
)
+
size
;
pNewNode
->
keySize
=
keyLen
;
pNewNode
->
keySize
=
(
uint16_t
)
keyLen
;
memcpy
(
pNewNode
->
key
,
key
,
keyLen
);
memcpy
(
pNewNode
->
key
,
key
,
keyLen
);
...
@@ -645,7 +645,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
...
@@ -645,7 +645,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
while
(
taosHashIterNext
(
pIter
))
{
while
(
taosHashIterNext
(
pIter
))
{
SCacheDataNode
*
pNode
=
*
(
SCacheDataNode
**
)
taosHashIterGet
(
pIter
);
SCacheDataNode
*
pNode
=
*
(
SCacheDataNode
**
)
taosHashIterGet
(
pIter
);
if
(
pNode
->
expireTime
<
time
&&
T_REF_VAL_GET
(
pNode
)
<=
0
)
{
if
(
pNode
->
expireTime
<
(
uint64_t
)
time
&&
T_REF_VAL_GET
(
pNode
)
<=
0
)
{
taosCacheReleaseNode
(
pCacheObj
,
pNode
);
taosCacheReleaseNode
(
pCacheObj
,
pNode
);
continue
;
continue
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录