Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f0c1950b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f0c1950b
编写于
9月 07, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor code
上级
e5518eb2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
118 addition
and
29 deletion
+118
-29
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+8
-6
source/libs/index/src/index.c
source/libs/index/src/index.c
+7
-7
source/libs/index/src/indexFst.c
source/libs/index/src/indexFst.c
+4
-3
source/libs/index/src/indexFstFile.c
source/libs/index/src/indexFstFile.c
+5
-5
source/libs/index/src/indexFstRegister.c
source/libs/index/src/indexFstRegister.c
+1
-1
source/libs/index/src/indexFstSparse.c
source/libs/index/src/indexFstSparse.c
+5
-5
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+2
-1
source/libs/index/src/indexUtil.c
source/libs/index/src/indexUtil.c
+1
-1
source/libs/index/test/indexBench.cc
source/libs/index/test/indexBench.cc
+85
-0
未找到文件。
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
f0c1950b
...
...
@@ -416,20 +416,22 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq, STableMe
me
.
ctbEntry
.
pTags
=
pReq
->
ctb
.
pTag
;
#ifdef TAG_FILTER_DEBUG
SArray
*
pTagVals
=
NULL
;
int32_t
code
=
tTagToValArray
((
STag
*
)
pReq
->
ctb
.
pTag
,
&
pTagVals
);
SArray
*
pTagVals
=
NULL
;
int32_t
code
=
tTagToValArray
((
STag
*
)
pReq
->
ctb
.
pTag
,
&
pTagVals
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTagVals
);
i
++
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pTagVal
->
type
))
{
char
*
buf
=
taosMemoryCalloc
(
pTagVal
->
nData
+
1
,
1
);
char
*
buf
=
taosMemoryCalloc
(
pTagVal
->
nData
+
1
,
1
);
memcpy
(
buf
,
pTagVal
->
pData
,
pTagVal
->
nData
);
metaDebug
(
"metaTag table:%s varchar index:%d cid:%d type:%d value:%s"
,
pReq
->
name
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
buf
);
metaDebug
(
"metaTag table:%s varchar index:%d cid:%d type:%d value:%s"
,
pReq
->
name
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
buf
);
taosMemoryFree
(
buf
);
}
else
{
double
val
=
0
;
GET_TYPED_DATA
(
val
,
double
,
pTagVal
->
type
,
&
pTagVal
->
i64
);
metaDebug
(
"metaTag table:%s number index:%d cid:%d type:%d value:%f"
,
pReq
->
name
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
val
);
metaDebug
(
"metaTag table:%s number index:%d cid:%d type:%d value:%f"
,
pReq
->
name
,
i
,
pTagVal
->
cid
,
pTagVal
->
type
,
val
);
}
}
#endif
...
...
source/libs/index/src/index.c
浏览文件 @
f0c1950b
...
...
@@ -303,7 +303,7 @@ SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn oper, uint8_t colTy
buf
=
strndup
(
INDEX_DATA_NULL_STR
,
(
int32_t
)
strlen
(
INDEX_DATA_NULL_STR
));
len
=
(
int32_t
)
strlen
(
INDEX_DATA_NULL_STR
);
}
else
{
const
char
*
emptyStr
=
" "
;
static
const
char
*
emptyStr
=
" "
;
buf
=
strndup
(
emptyStr
,
(
int32_t
)
strlen
(
emptyStr
));
len
=
(
int32_t
)
strlen
(
emptyStr
);
}
...
...
@@ -585,6 +585,12 @@ int idxFlushCacheToTFile(SIndex* sIdx, void* cache, bool quit) {
idxTRsltDestroy
(
tr
);
int
ret
=
idxGenTFile
(
sIdx
,
pCache
,
result
);
if
(
ret
!=
0
)
{
indexError
(
"failed to merge, time cost: %"
PRId64
"ms"
,
cost
/
1000
);
}
else
{
int64_t
cost
=
taosGetTimestampUs
()
-
st
;
indexInfo
(
"success to merge , time cost: %"
PRId64
"ms"
,
cost
/
1000
);
}
idxDestroyFinalRslt
(
result
);
idxCacheDestroyImm
(
pCache
);
...
...
@@ -595,12 +601,6 @@ int idxFlushCacheToTFile(SIndex* sIdx, void* cache, bool quit) {
tfileReaderUnRef
(
pReader
);
idxCacheUnRef
(
pCache
);
int64_t
cost
=
taosGetTimestampUs
()
-
st
;
if
(
ret
!=
0
)
{
indexError
(
"failed to merge, time cost: %"
PRId64
"ms"
,
cost
/
1000
);
}
else
{
indexInfo
(
"success to merge , time cost: %"
PRId64
"ms"
,
cost
/
1000
);
}
atomic_store_32
(
&
pCache
->
merging
,
0
);
if
(
quit
)
{
idxPost
(
sIdx
);
...
...
source/libs/index/src/indexFst.c
浏览文件 @
f0c1950b
...
...
@@ -19,11 +19,12 @@
#include "tchecksum.h"
#include "tcoding.h"
static
void
fstPackDeltaIn
(
IdxFstFile
*
wrt
,
CompiledAddr
nodeAddr
,
CompiledAddr
transAddr
,
uint8_t
nBytes
)
{
static
FORCE_INLINE
void
fstPackDeltaIn
(
IdxFstFile
*
wrt
,
CompiledAddr
nodeAddr
,
CompiledAddr
transAddr
,
uint8_t
nBytes
)
{
CompiledAddr
deltaAddr
=
(
transAddr
==
EMPTY_ADDRESS
)
?
EMPTY_ADDRESS
:
nodeAddr
-
transAddr
;
idxFilePackUintIn
(
wrt
,
deltaAddr
,
nBytes
);
}
static
uint8_t
fstPackDetla
(
IdxFstFile
*
wrt
,
CompiledAddr
nodeAddr
,
CompiledAddr
transAddr
)
{
static
FORCE_INLINE
uint8_t
fstPackDetla
(
IdxFstFile
*
wrt
,
CompiledAddr
nodeAddr
,
CompiledAddr
transAddr
)
{
uint8_t
nBytes
=
packDeltaSize
(
nodeAddr
,
transAddr
);
fstPackDeltaIn
(
wrt
,
nodeAddr
,
transAddr
,
nBytes
);
return
nBytes
;
...
...
@@ -39,7 +40,7 @@ FstUnFinishedNodes* fstUnFinishedNodesCreate() {
fstUnFinishedNodesPushEmpty
(
nodes
,
false
);
return
nodes
;
}
static
void
unFinishedNodeDestroyElem
(
void
*
elem
)
{
static
void
FORCE_INLINE
unFinishedNodeDestroyElem
(
void
*
elem
)
{
FstBuilderNodeUnfinished
*
b
=
(
FstBuilderNodeUnfinished
*
)
elem
;
fstBuilderNodeDestroy
(
b
->
node
);
taosMemoryFree
(
b
->
last
);
...
...
source/libs/index/src/indexFstFile.c
浏览文件 @
f0c1950b
...
...
@@ -30,14 +30,14 @@ typedef struct {
static
void
deleteDataBlockFromLRU
(
const
void
*
key
,
size_t
keyLen
,
void
*
value
)
{
taosMemoryFree
(
value
);
}
static
void
idxGenLRUKey
(
char
*
buf
,
const
char
*
path
,
int32_t
blockId
)
{
static
FORCE_INLINE
void
idxGenLRUKey
(
char
*
buf
,
const
char
*
path
,
int32_t
blockId
)
{
char
*
p
=
buf
;
SERIALIZE_STR_VAR_TO_BUF
(
p
,
path
,
strlen
(
path
));
SERIALIZE_VAR_TO_BUF
(
p
,
'_'
,
char
);
idxInt2str
(
blockId
,
p
,
0
);
return
;
}
static
int
idxFileCtxDoWrite
(
IFileCtx
*
ctx
,
uint8_t
*
buf
,
int
len
)
{
static
FORCE_INLINE
int
idxFileCtxDoWrite
(
IFileCtx
*
ctx
,
uint8_t
*
buf
,
int
len
)
{
if
(
ctx
->
type
==
TFILE
)
{
int
nwr
=
taosWriteFile
(
ctx
->
file
.
pFile
,
buf
,
len
);
assert
(
nwr
==
len
);
...
...
@@ -47,7 +47,7 @@ static int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
ctx
->
offset
+=
len
;
return
len
;
}
static
int
idxFileCtxDoRead
(
IFileCtx
*
ctx
,
uint8_t
*
buf
,
int
len
)
{
static
FORCE_INLINE
int
idxFileCtxDoRead
(
IFileCtx
*
ctx
,
uint8_t
*
buf
,
int
len
)
{
int
nRead
=
0
;
if
(
ctx
->
type
==
TFILE
)
{
#ifdef USE_MMAP
...
...
@@ -111,7 +111,7 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
}
while
(
len
>
0
);
return
total
;
}
static
int
idxFileCtxGetSize
(
IFileCtx
*
ctx
)
{
static
FORCE_INLINE
int
idxFileCtxGetSize
(
IFileCtx
*
ctx
)
{
if
(
ctx
->
type
==
TFILE
)
{
int64_t
file_size
=
0
;
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
...
...
@@ -119,7 +119,7 @@ static int idxFileCtxGetSize(IFileCtx* ctx) {
}
return
0
;
}
static
int
idxFileCtxDoFlush
(
IFileCtx
*
ctx
)
{
static
FORCE_INLINE
int
idxFileCtxDoFlush
(
IFileCtx
*
ctx
)
{
if
(
ctx
->
type
==
TFILE
)
{
taosFsyncFile
(
ctx
->
file
.
pFile
);
}
else
{
...
...
source/libs/index/src/indexFstRegister.c
浏览文件 @
f0c1950b
...
...
@@ -16,7 +16,7 @@
#include "indexFstRegistry.h"
#include "os.h"
uint64_t
fstRegistryHash
(
FstRegistry
*
registry
,
FstBuilderNode
*
bNode
)
{
static
FORCE_INLINE
uint64_t
fstRegistryHash
(
FstRegistry
*
registry
,
FstBuilderNode
*
bNode
)
{
// TODO(yihaoDeng): refactor later
const
uint64_t
FNV_PRIME
=
1099511628211
;
uint64_t
h
=
14695981039346656037u
;
...
...
source/libs/index/src/indexFstSparse.c
浏览文件 @
f0c1950b
...
...
@@ -15,7 +15,7 @@
#include "indexFstSparse.h"
static
void
sparSetUtil
(
int32_t
*
buf
,
int32_t
cap
)
{
static
FORCE_INLINE
void
sparSetInitBuf
(
int32_t
*
buf
,
int32_t
cap
)
{
for
(
int32_t
i
=
0
;
i
<
cap
;
i
++
)
{
buf
[
i
]
=
-
1
;
}
...
...
@@ -28,8 +28,8 @@ FstSparseSet *sparSetCreate(int32_t sz) {
ss
->
dense
=
(
int32_t
*
)
taosMemoryMalloc
(
sz
*
sizeof
(
int32_t
));
ss
->
sparse
=
(
int32_t
*
)
taosMemoryMalloc
(
sz
*
sizeof
(
int32_t
));
sparSet
Util
(
ss
->
dense
,
sz
);
sparSet
Util
(
ss
->
sparse
,
sz
);
sparSet
InitBuf
(
ss
->
dense
,
sz
);
sparSet
InitBuf
(
ss
->
sparse
,
sz
);
ss
->
cap
=
sz
;
...
...
@@ -90,7 +90,7 @@ void sparSetClear(FstSparseSet *ss) {
if
(
ss
==
NULL
)
{
return
;
}
sparSet
Util
(
ss
->
dense
,
ss
->
cap
);
sparSet
Util
(
ss
->
sparse
,
ss
->
cap
);
sparSet
InitBuf
(
ss
->
dense
,
ss
->
cap
);
sparSet
InitBuf
(
ss
->
sparse
,
ss
->
cap
);
ss
->
size
=
0
;
}
source/libs/index/src/indexTfile.c
浏览文件 @
f0c1950b
...
...
@@ -1034,7 +1034,8 @@ static void tfileGenFileName(char* filename, uint64_t suid, const char* col, int
sprintf
(
filename
,
"%"
PRIu64
"-%s-%"
PRId64
".tindex"
,
suid
,
col
,
version
);
return
;
}
static
void
tfileGenFileFullName
(
char
*
fullname
,
const
char
*
path
,
uint64_t
suid
,
const
char
*
col
,
int64_t
version
)
{
static
void
FORCE_INLINE
tfileGenFileFullName
(
char
*
fullname
,
const
char
*
path
,
uint64_t
suid
,
const
char
*
col
,
int64_t
version
)
{
char
filename
[
128
]
=
{
0
};
tfileGenFileName
(
filename
,
suid
,
col
,
version
);
sprintf
(
fullname
,
"%s/%s"
,
path
,
filename
);
...
...
source/libs/index/src/indexUtil.c
浏览文件 @
f0c1950b
...
...
@@ -21,7 +21,7 @@ typedef struct MergeIndex {
int
len
;
}
MergeIndex
;
static
int
iBinarySearch
(
SArray
*
arr
,
int
s
,
int
e
,
uint64_t
k
)
{
static
FORCE_INLINE
int
iBinarySearch
(
SArray
*
arr
,
int
s
,
int
e
,
uint64_t
k
)
{
uint64_t
v
;
int32_t
m
;
while
(
s
<=
e
)
{
...
...
source/libs/index/test/indexBench.cc
0 → 100644
浏览文件 @
f0c1950b
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtest/gtest.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <thread>
#include "index.h"
using
namespace
std
;
static
void
initLog
()
{
const
char
*
defaultLogFileNamePrefix
=
"taoslog"
;
const
int32_t
maxLogFileNum
=
10
;
tsAsyncLog
=
0
;
idxDebugFlag
=
143
;
strcpy
(
tsLogDir
,
logDir
.
c_str
());
taosRemoveDir
(
tsLogDir
);
taosMkDir
(
tsLogDir
);
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
struct
WriteBatch
{
SIndexMultiTerm
*
terms
;
};
class
Idx
{
public:
Idx
(
int
_cacheSize
=
1024
*
1024
*
4
,
const
char
*
_path
=
"tindex"
)
{
opts
.
cacheSize
=
_cacheSize
;
path
=
TD_TMP_DIR_PATH
_path
;
}
int
SetUp
(
bool
remove
)
{
initLog
();
if
(
remove
)
taosRemoveDir
(
path
);
int
ret
=
indexJsonOpen
(
&
opts
,
path
,
&
index
);
return
ret
;
}
int
Write
(
WriteBatch
*
batch
)
{
// write batch
return
0
;
}
int
Read
(
const
char
*
json
,
void
*
key
,
int64_t
*
id
)
{
// read batch
return
0
;
}
void
TearDown
()
{
indexJsonClose
(
index
);
}
std
::
string
path
;
SIndexOpts
opts
;
SIndex
*
index
;
};
int
BenchWrite
(
Idx
*
idx
,
int
nCol
,
int
Limit
)
{
return
0
;
}
int
BenchRead
(
Idx
*
idx
)
{
return
0
;
}
int
main
()
{
Idx
*
idx
=
new
Idx
;
if
(
idx
->
SetUp
(
true
)
!=
0
)
{
std
::
cout
<<
"failed to setup index"
<<
std
::
endl
;
return
0
;
}
else
{
std
::
cout
<<
"succ to setup index"
<<
std
::
endl
;
}
BenchWrite
(
idx
,
10000
,
100
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录