Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9888d086
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
9888d086
编写于
5月 19, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: avoid invalid read/write
上级
20e90670
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
25 deletion
+28
-25
source/libs/index/src/indexFst.c
source/libs/index/src/indexFst.c
+13
-13
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+3
-3
source/libs/index/src/indexUtil.c
source/libs/index/src/indexUtil.c
+10
-7
source/libs/index/test/fstTest.cc
source/libs/index/test/fstTest.cc
+2
-2
未找到文件。
source/libs/index/src/indexFst.c
浏览文件 @
9888d086
...
...
@@ -99,7 +99,7 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes* nodes, FstSlice bs, Output
if
(
fstSliceIsEmpty
(
s
))
{
return
;
}
size_t
sz
=
taosArrayGetSize
(
nodes
->
stack
)
-
1
;
int32_t
sz
=
taosArrayGetSize
(
nodes
->
stack
)
-
1
;
FstBuilderNodeUnfinished
*
un
=
taosArrayGet
(
nodes
->
stack
,
sz
);
assert
(
un
->
last
==
NULL
);
...
...
@@ -130,11 +130,11 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes* nodes, FstSlice bs, Output
uint64_t
fstUnFinishedNodesFindCommPrefix
(
FstUnFinishedNodes
*
node
,
FstSlice
bs
)
{
FstSlice
*
s
=
&
bs
;
size_t
ssz
=
taosArrayGetSize
(
node
->
stack
);
// stack size
int32_t
ssz
=
taosArrayGetSize
(
node
->
stack
);
// stack size
uint64_t
count
=
0
;
int32_t
lsz
;
// data len
uint8_t
*
data
=
fstSliceData
(
s
,
&
lsz
);
for
(
size
_t
i
=
0
;
i
<
ssz
&&
i
<
lsz
;
i
++
)
{
for
(
int32
_t
i
=
0
;
i
<
ssz
&&
i
<
lsz
;
i
++
)
{
FstBuilderNodeUnfinished
*
un
=
taosArrayGet
(
node
->
stack
,
i
);
if
(
un
->
last
->
inp
==
data
[
i
])
{
count
++
;
...
...
@@ -147,8 +147,8 @@ uint64_t fstUnFinishedNodesFindCommPrefix(FstUnFinishedNodes* node, FstSlice bs)
uint64_t
fstUnFinishedNodesFindCommPrefixAndSetOutput
(
FstUnFinishedNodes
*
node
,
FstSlice
bs
,
Output
in
,
Output
*
out
)
{
FstSlice
*
s
=
&
bs
;
size
_t
lsz
=
(
size_t
)(
s
->
end
-
s
->
start
+
1
);
// data len
size
_t
ssz
=
taosArrayGetSize
(
node
->
stack
);
// stack size
int32
_t
lsz
=
(
size_t
)(
s
->
end
-
s
->
start
+
1
);
// data len
int32
_t
ssz
=
taosArrayGetSize
(
node
->
stack
);
// stack size
*
out
=
in
;
uint64_t
i
=
0
;
for
(
i
=
0
;
i
<
lsz
&&
i
<
ssz
;
i
++
)
{
...
...
@@ -245,7 +245,7 @@ void fstStateCompileForOneTrans(FstCountingWriter* w, CompiledAddr addr, FstTran
return
;
}
void
fstStateCompileForAnyTrans
(
FstCountingWriter
*
w
,
CompiledAddr
addr
,
FstBuilderNode
*
node
)
{
size
_t
sz
=
taosArrayGetSize
(
node
->
trans
);
int32
_t
sz
=
taosArrayGetSize
(
node
->
trans
);
assert
(
sz
<=
256
);
uint8_t
tSize
=
0
;
...
...
@@ -253,7 +253,7 @@ void fstStateCompileForAnyTrans(FstCountingWriter* w, CompiledAddr addr, FstBuil
// finalOutput.is_zero()
bool
anyOuts
=
(
node
->
finalOutput
!=
0
);
for
(
size
_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32
_t
i
=
0
;
i
<
sz
;
i
++
)
{
FstTransition
*
t
=
taosArrayGet
(
node
->
trans
,
i
);
tSize
=
TMAX
(
tSize
,
packDeltaSize
(
addr
,
t
->
addr
));
oSize
=
TMAX
(
oSize
,
packSize
(
t
->
out
));
...
...
@@ -301,7 +301,7 @@ void fstStateCompileForAnyTrans(FstCountingWriter* w, CompiledAddr addr, FstBuil
/// for (uint8_t i = 0; i < 256; i++) {
// index[i] = 255;
///}
for
(
size
_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32
_t
i
=
0
;
i
<
sz
;
i
++
)
{
FstTransition
*
t
=
taosArrayGet
(
node
->
trans
,
i
);
index
[
t
->
inp
]
=
i
;
// fstPackDeltaIn(w, addr, t->addr, tSize);
...
...
@@ -731,7 +731,7 @@ bool fstNodeFindInput(FstNode* node, uint8_t b, uint64_t* res) {
}
bool
fstNodeCompile
(
FstNode
*
node
,
void
*
w
,
CompiledAddr
lastAddr
,
CompiledAddr
addr
,
FstBuilderNode
*
builderNode
)
{
size
_t
sz
=
taosArrayGetSize
(
builderNode
->
trans
);
int32
_t
sz
=
taosArrayGetSize
(
builderNode
->
trans
);
assert
(
sz
<
256
);
if
(
sz
==
0
&&
builderNode
->
isFinal
&&
builderNode
->
finalOutput
==
0
)
{
return
true
;
...
...
@@ -959,8 +959,8 @@ void fstBuilderNodeUnfinishedAddOutputPrefix(FstBuilderNodeUnfinished* unNode, O
if
(
FST_BUILDER_NODE_IS_FINAL
(
unNode
->
node
))
{
unNode
->
node
->
finalOutput
+=
out
;
}
size
_t
sz
=
taosArrayGetSize
(
unNode
->
node
->
trans
);
for
(
size
_t
i
=
0
;
i
<
sz
;
i
++
)
{
int32
_t
sz
=
taosArrayGetSize
(
unNode
->
node
->
trans
);
for
(
int32
_t
i
=
0
;
i
<
sz
;
i
++
)
{
FstTransition
*
trn
=
taosArrayGet
(
unNode
->
node
->
trans
,
i
);
trn
->
out
+=
out
;
}
...
...
@@ -1077,7 +1077,7 @@ bool fstGet(Fst* fst, FstSlice* b, Output* out) {
tOut
=
tOut
+
FST_NODE_FINAL_OUTPUT
(
root
);
}
for
(
size
_t
i
=
0
;
i
<
taosArrayGetSize
(
nodes
);
i
++
)
{
for
(
int32
_t
i
=
0
;
i
<
taosArrayGetSize
(
nodes
);
i
++
)
{
FstNode
**
node
=
(
FstNode
**
)
taosArrayGet
(
nodes
,
i
);
fstNodeDestroy
(
*
node
);
}
...
...
@@ -1352,7 +1352,7 @@ StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallb
StreamState
s2
=
{.
node
=
nextNode
,
.
trans
=
0
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
nextState
};
taosArrayPush
(
sws
->
stack
,
&
s2
);
size_t
isz
=
taosArrayGetSize
(
sws
->
inp
);
int32_t
isz
=
taosArrayGetSize
(
sws
->
inp
);
uint8_t
*
buf
=
(
uint8_t
*
)
taosMemoryMalloc
(
isz
*
sizeof
(
uint8_t
));
for
(
uint32_t
i
=
0
;
i
<
isz
;
i
++
)
{
buf
[
i
]
=
*
(
uint8_t
*
)
taosArrayGet
(
sws
->
inp
,
i
);
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
9888d086
...
...
@@ -116,7 +116,7 @@ TFileCache* tfileCacheCreate(const char* path) {
continue
;
}
TFileHeader
*
header
=
&
reader
->
header
;
ICacheKey
key
=
{.
suid
=
header
->
suid
,
.
colName
=
header
->
colName
,
.
nColName
=
strlen
(
header
->
colName
)};
ICacheKey
key
=
{.
suid
=
header
->
suid
,
.
colName
=
header
->
colName
,
.
nColName
=
(
int32_t
)
strlen
(
header
->
colName
)};
char
buf
[
128
]
=
{
0
};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
...
...
@@ -230,7 +230,7 @@ static int32_t tfSearchTerm(void* reader, SIndexTerm* tem, SIdxTempResult* tr) {
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, found table info in tindex, time cost: %"
PRIu64
"us"
,
tem
->
suid
,
tem
->
colName
,
tem
->
colVal
,
cost
);
ret
=
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
offset
,
tr
->
total
);
ret
=
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
(
int32_t
)
offset
,
tr
->
total
);
cost
=
taosGetTimestampUs
()
-
et
;
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, load all table info, time cost: %"
PRIu64
"us"
,
tem
->
suid
,
tem
->
colName
,
tem
->
colVal
,
cost
);
...
...
@@ -890,7 +890,7 @@ static int tfileWriteFooter(TFileWriter* write) {
char
buf
[
sizeof
(
tfileMagicNumber
)
+
1
]
=
{
0
};
void
*
pBuf
=
(
void
*
)
buf
;
taosEncodeFixedU64
((
void
**
)(
void
*
)
&
pBuf
,
tfileMagicNumber
);
int
nwrite
=
write
->
ctx
->
write
(
write
->
ctx
,
buf
,
strlen
(
buf
));
int
nwrite
=
write
->
ctx
->
write
(
write
->
ctx
,
buf
,
(
int32_t
)
strlen
(
buf
));
indexInfo
(
"tfile write footer size: %d"
,
write
->
ctx
->
size
(
write
->
ctx
));
assert
(
nwrite
==
sizeof
(
tfileMagicNumber
));
...
...
source/libs/index/src/indexUtil.c
浏览文件 @
9888d086
...
...
@@ -37,14 +37,14 @@ static int iBinarySearch(SArray *arr, int s, int e, uint64_t k) {
}
void
iIntersection
(
SArray
*
inters
,
SArray
*
final
)
{
int32_t
sz
=
taosArrayGetSize
(
inters
);
int32_t
sz
=
(
int32_t
)
taosArrayGetSize
(
inters
);
if
(
sz
<=
0
)
{
return
;
}
MergeIndex
*
mi
=
taosMemoryCalloc
(
sz
,
sizeof
(
MergeIndex
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SArray
*
t
=
taosArrayGetP
(
inters
,
i
);
mi
[
i
].
len
=
taosArrayGetSize
(
t
);
mi
[
i
].
len
=
(
int32_t
)
taosArrayGetSize
(
t
);
mi
[
i
].
idx
=
0
;
}
...
...
@@ -70,7 +70,7 @@ void iIntersection(SArray *inters, SArray *final) {
taosMemoryFreeClear
(
mi
);
}
void
iUnion
(
SArray
*
inters
,
SArray
*
final
)
{
int32_t
sz
=
taosArrayGetSize
(
inters
);
int32_t
sz
=
(
int32_t
)
taosArrayGetSize
(
inters
);
if
(
sz
<=
0
)
{
return
;
}
...
...
@@ -82,7 +82,7 @@ void iUnion(SArray *inters, SArray *final) {
MergeIndex
*
mi
=
taosMemoryCalloc
(
sz
,
sizeof
(
MergeIndex
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SArray
*
t
=
taosArrayGetP
(
inters
,
i
);
mi
[
i
].
len
=
taosArrayGetSize
(
t
);
mi
[
i
].
len
=
(
int32_t
)
taosArrayGetSize
(
t
);
mi
[
i
].
idx
=
0
;
}
while
(
1
)
{
...
...
@@ -117,8 +117,8 @@ void iUnion(SArray *inters, SArray *final) {
}
void
iExcept
(
SArray
*
total
,
SArray
*
except
)
{
int32_t
tsz
=
taosArrayGetSize
(
total
);
int32_t
esz
=
taosArrayGetSize
(
except
);
int32_t
tsz
=
(
int32_t
)
taosArrayGetSize
(
total
);
int32_t
esz
=
(
int32_t
)
taosArrayGetSize
(
except
);
if
(
esz
==
0
||
tsz
==
0
)
{
return
;
}
...
...
@@ -141,7 +141,10 @@ int uidCompare(const void *a, const void *b) {
// add more version compare
uint64_t
u1
=
*
(
uint64_t
*
)
a
;
uint64_t
u2
=
*
(
uint64_t
*
)
b
;
return
u1
-
u2
;
if
(
u1
==
u2
)
{
return
0
;
}
return
u1
<
u2
?
-
1
:
1
;
}
int
verdataCompare
(
const
void
*
a
,
const
void
*
b
)
{
SIdxVerdata
*
va
=
(
SIdxVerdata
*
)
a
;
...
...
source/libs/index/test/fstTest.cc
浏览文件 @
9888d086
...
...
@@ -48,7 +48,7 @@ class FstWriter {
class
FstReadMemory
{
public:
FstReadMemory
(
size
_t
size
,
const
std
::
string
&
fileName
=
"/tmp/tindex.tindex"
)
{
FstReadMemory
(
int32
_t
size
,
const
std
::
string
&
fileName
=
"/tmp/tindex.tindex"
)
{
_wc
=
writerCtxCreate
(
TFile
,
fileName
.
c_str
(),
true
,
64
*
1024
);
_w
=
fstCountingWriterCreate
(
_wc
);
_size
=
size
;
...
...
@@ -152,7 +152,7 @@ class FstReadMemory {
Fst
*
_fst
;
FstSlice
_s
;
WriterCtx
*
_wc
;
size_t
_size
;
int32_t
_size
;
};
#define L 100
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录