Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a12bb2db
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看板
提交
a12bb2db
编写于
3月 07, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add UT
上级
744f6768
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
9 deletion
+36
-9
source/libs/index/src/index.c
source/libs/index/src/index.c
+8
-0
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+8
-1
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+17
-7
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+3
-1
未找到文件。
source/libs/index/src/index.c
浏览文件 @
a12bb2db
...
...
@@ -341,6 +341,8 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
// TODO: iterator mem and tidex
STermValueType
s
=
kTypeValue
;
int64_t
st
=
taosGetTimestampUs
();
SIdxTempResult
*
tr
=
sIdxTempResultCreate
();
if
(
0
==
indexCacheSearch
(
cache
,
query
,
tr
,
&
s
))
{
if
(
s
==
kTypeDeletion
)
{
...
...
@@ -348,17 +350,23 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
// coloum already drop by other oper, no need to query tindex
return
0
;
}
else
{
st
=
taosGetTimestampUs
();
if
(
0
!=
indexTFileSearch
(
sIdx
->
tindex
,
query
,
tr
))
{
indexError
(
"corrupt at index(TFile) col:%s val: %s"
,
term
->
colName
,
term
->
colVal
);
goto
END
;
}
int64_t
tfCost
=
taosGetTimestampUs
()
-
st
;
indexInfo
(
"tfile search cost: %"
PRIu64
"us"
,
tfCost
);
}
}
else
{
indexError
(
"corrupt at index(cache) col:%s val: %s"
,
term
->
colName
,
term
->
colVal
);
goto
END
;
}
int64_t
cost
=
taosGetTimestampUs
()
-
st
;
indexInfo
(
"search cost: %"
PRIu64
"us"
,
cost
);
sIdxTempResultMergeTo
(
*
result
,
tr
);
sIdxTempResultDestroy
(
tr
);
return
0
;
END:
...
...
source/libs/index/src/index_cache.c
浏览文件 @
a12bb2db
...
...
@@ -276,14 +276,19 @@ static int indexQueryMem(MemTable* mem, CacheTerm* ct, EIndexQueryType qtype, SI
}
else
if
(
c
->
operaType
==
DEL_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
added
,
tr
->
deled
,
c
->
uid
)
}
}
else
{
break
;
}
}
}
else
if
(
qtype
==
QUERY_PREFIX
)
{
}
else
if
(
qtype
==
QUERY_SUFFIX
)
{
}
else
if
(
qtype
==
QUERY_RANGE
)
}
}
tSkipListDestroyIter
(
iter
);
return
0
;
}
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
SIdxTempResult
*
result
,
STermValueType
*
s
)
{
int64_t
st
=
taosGetTimestampUs
();
if
(
cache
==
NULL
)
{
return
0
;
}
...
...
@@ -312,12 +317,14 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SIdxTempResult* result
// continue search in imm
ret
=
indexQueryMem
(
imm
,
&
ct
,
qtype
,
result
,
s
);
}
if
(
hasJson
)
{
tfree
(
p
);
}
indexMemUnRef
(
mem
);
indexMemUnRef
(
imm
);
indexInfo
(
"cache search, time cost %"
PRIu64
"us"
,
taosGetTimestampUs
()
-
st
);
return
ret
;
}
...
...
source/libs/index/src/index_tfile.c
浏览文件 @
a12bb2db
...
...
@@ -189,8 +189,8 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SIdxTempResul
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
EIndexQueryType
qtype
=
query
->
qType
;
SArray
*
result
=
taosArrayInit
(
16
,
sizeof
(
uint64_t
));
int
ret
=
-
1
;
//
SArray* result = taosArrayInit(16, sizeof(uint64_t));
int
ret
=
-
1
;
// refactor to callback later
if
(
qtype
==
QUERY_TERM
)
{
uint64_t
offset
;
...
...
@@ -200,11 +200,18 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SIdxTempResul
p
=
indexPackJsonData
(
term
);
sz
=
strlen
(
p
);
}
int64_t
st
=
taosGetTimestampUs
();
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
if
(
fstGet
(
reader
->
fst
,
&
key
,
&
offset
))
{
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, found table info in tindex"
,
term
->
suid
,
term
->
colName
,
term
->
colVal
);
ret
=
tfileReaderLoadTableIds
(
reader
,
offset
,
result
);
int64_t
et
=
taosGetTimestampUs
();
int64_t
cost
=
et
-
st
;
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, found table info in tindex, time cost: %"
PRIu64
"us"
,
term
->
suid
,
term
->
colName
,
term
->
colVal
,
cost
);
ret
=
tfileReaderLoadTableIds
(
reader
,
offset
,
tr
->
total
);
cost
=
taosGetTimestampUs
()
-
et
;
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, load all table info, time cost: %"
PRIu64
"us"
,
term
->
suid
,
term
->
colName
,
term
->
colVal
,
cost
);
}
else
{
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, not found table info in tindex"
,
term
->
suid
,
term
->
colName
,
term
->
colVal
);
...
...
@@ -225,8 +232,8 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SIdxTempResul
}
tfileReaderUnRef
(
reader
);
taosArrayAddAll
(
tr
->
total
,
result
);
taosArrayDestroy
(
result
);
//
taosArrayAddAll(tr->total, result);
//
taosArrayDestroy(result);
return
ret
;
}
...
...
@@ -391,6 +398,7 @@ int indexTFileSearch(void* tfile, SIndexTermQuery* query, SIdxTempResult* result
return
ret
;
}
int64_t
st
=
taosGetTimestampUs
();
IndexTFile
*
pTfile
=
tfile
;
SIndexTerm
*
term
=
query
->
term
;
...
...
@@ -399,6 +407,8 @@ int indexTFileSearch(void* tfile, SIndexTermQuery* query, SIdxTempResult* result
if
(
reader
==
NULL
)
{
return
0
;
}
int64_t
cost
=
taosGetTimestampUs
()
-
st
;
indexInfo
(
"index tfile stage 1 cost: %"
PRId64
""
,
cost
);
return
tfileReaderSearch
(
reader
,
query
,
result
);
}
...
...
source/libs/index/test/indexTests.cc
浏览文件 @
a12bb2db
...
...
@@ -768,7 +768,7 @@ class IndexObj {
int64_t
s
=
taosGetTimestampUs
();
if
(
Search
(
mq
,
result
)
==
0
)
{
int64_t
e
=
taosGetTimestampUs
();
std
::
cout
<<
"search one successfully and time cost:"
<<
e
-
s
<<
"
\t
query col:"
<<
colName
std
::
cout
<<
"search one successfully and time cost:"
<<
e
-
s
<<
"
us
\t
query col:"
<<
colName
<<
"
\t
val: "
<<
colVal
<<
"
\t
size:"
<<
taosArrayGetSize
(
result
)
<<
std
::
endl
;
}
else
{
}
...
...
@@ -1106,8 +1106,10 @@ TEST_F(IndexEnv2, testIndex_del) {
}
index
->
Del
(
"tag10"
,
"Hello"
,
12
);
index
->
Del
(
"tag10"
,
"Hello"
,
11
);
EXPECT_EQ
(
98
,
index
->
SearchOne
(
"tag10"
,
"Hello"
));
index
->
WriteMultiMillonData
(
"tag10"
,
"xxxxxxxxxxxxxx"
,
100
*
10000
);
index
->
Del
(
"tag10"
,
"Hello"
,
17
);
EXPECT_EQ
(
97
,
index
->
SearchOne
(
"tag10"
,
"Hello"
));
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录