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) {
static
FORCE_INLINE
int32_t
taosHashCapacity
(
int32_t
length
)
{
int32_t
len
=
MIN
(
length
,
HASH_MAX_CAPACITY
);
u
int32_t
i
=
4
;
int32_t
i
=
4
;
while
(
i
<
len
)
i
=
(
i
<<
1u
);
return
i
;
}
...
...
@@ -176,7 +176,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool threadsafe) {
}
// 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
);
pHashObj
->
hashFp
=
fn
;
...
...
@@ -219,7 +219,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
__wr_lock
(
pHashObj
->
lock
);
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
taosHashTableResize
(
pHashObj
);
...
...
@@ -261,7 +261,7 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen) {
__rd_lock
(
pHashObj
->
lock
);
uint32_t
hashVal
=
0
;
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
keyLen
,
&
hashVal
);
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
(
int32_t
)
keyLen
,
&
hashVal
);
__unlock
(
pHashObj
->
lock
);
...
...
@@ -278,7 +278,7 @@ void taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
__wr_lock
(
pHashObj
->
lock
);
uint32_t
val
=
0
;
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
keyLen
,
&
val
);
SHashNode
*
pNode
=
doGetNodeFromHashTable
(
pHashObj
,
key
,
(
uint32_t
)
keyLen
,
&
val
);
if
(
pNode
==
NULL
)
{
__unlock
(
pHashObj
->
lock
);
return
;
...
...
@@ -460,7 +460,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
SHashNode
*
pNode
=
NULL
;
SHashNode
*
pNext
=
NULL
;
int32_t
newSize
=
pHashObj
->
capacity
<<
1u
;
int32_t
newSize
=
(
int32_t
)(
pHashObj
->
capacity
)
<<
1u
;
if
(
newSize
>
HASH_MAX_CAPACITY
)
{
// uDebug("current capacity:%d, maximum capacity:%d, no resize applied due to limitation is reached",
// pHashObj->capacity, HASH_MAX_CAPACITY);
...
...
@@ -539,7 +539,7 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
pNewNode
->
key
=
pNewNode
->
data
+
dsize
;
memcpy
(
pNewNode
->
key
,
key
,
keyLen
);
pNewNode
->
keyLen
=
keyLen
;
pNewNode
->
keyLen
=
(
uint32_t
)
keyLen
;
pNewNode
->
hashVal
=
hashVal
;
return
pNewNode
;
...
...
src/util/src/talgo.c
浏览文件 @
d5c57b68
...
...
@@ -24,7 +24,7 @@
} 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
)
{
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
)
{
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
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
tqsortImpl
(
src
,
0
,
numOfElem
-
1
,
size
,
param
,
comparFn
,
buf
);
tqsortImpl
(
src
,
0
,
(
int32_t
)
numOfElem
-
1
,
(
int32_t
)
size
,
param
,
comparFn
,
buf
);
taosTFree
(
buf
);
}
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
int
l
=
0
;
int
r
=
nmemb
;
int
r
=
(
int
)
nmemb
;
int
idx
=
0
;
int
comparison
;
...
...
src/util/src/tarray.c
浏览文件 @
d5c57b68
...
...
@@ -120,8 +120,8 @@ void* taosArrayInsert(SArray* pArray, size_t index, void* pData) {
void
*
dst
=
TARRAY_GET_ELEM
(
pArray
,
index
);
int32_t
remain
=
pArray
->
size
-
index
;
memmove
(
dst
+
pArray
->
elemSize
,
dst
,
pArray
->
elemSize
*
remain
);
int32_t
remain
=
(
int32_t
)(
pArray
->
size
-
index
)
;
memmove
(
(
char
*
)
dst
+
pArray
->
elemSize
,
(
char
*
)
dst
,
pArray
->
elemSize
*
remain
);
memcpy
(
dst
,
pData
,
pArray
->
elemSize
);
pArray
->
size
+=
1
;
...
...
@@ -138,7 +138,7 @@ void taosArrayRemove(SArray* pArray, size_t index) {
}
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
;
}
...
...
src/util/src/tbuffer.c
浏览文件 @
d5c57b68
...
...
@@ -17,7 +17,6 @@
#include <stdlib.h>
#include <memory.h>
#include <assert.h>
#include <arpa/inet.h>
#include "tbuffer.h"
#include "exception.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
uError
(
"cache:%s, key:%p, failed to added into cache, out of memory"
,
pCacheObj
->
name
,
key
);
}
}
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
);
}
...
...
@@ -509,7 +509,7 @@ SCacheDataNode *taosCreateCacheNode(const char *key, size_t keyLen, const char *
memcpy
(
pNewNode
->
data
,
pData
,
size
);
pNewNode
->
key
=
(
char
*
)
pNewNode
+
sizeof
(
SCacheDataNode
)
+
size
;
pNewNode
->
keySize
=
keyLen
;
pNewNode
->
keySize
=
(
uint16_t
)
keyLen
;
memcpy
(
pNewNode
->
key
,
key
,
keyLen
);
...
...
@@ -645,7 +645,7 @@ static void doCacheRefresh(SCacheObj* pCacheObj, int64_t time, __cache_free_fn_t
while
(
taosHashIterNext
(
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
);
continue
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录