Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0b0253f2
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看板
提交
0b0253f2
编写于
5月 28, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: support tag filter
上级
6acbe7e7
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
189 addition
and
178 deletion
+189
-178
source/libs/index/inc/indexCache.h
source/libs/index/inc/indexCache.h
+1
-1
source/libs/index/inc/indexTfile.h
source/libs/index/inc/indexTfile.h
+2
-2
source/libs/index/inc/indexUtil.h
source/libs/index/inc/indexUtil.h
+14
-9
source/libs/index/src/index.c
source/libs/index/src/index.c
+15
-15
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+52
-54
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+47
-47
source/libs/index/src/indexUtil.c
source/libs/index/src/indexUtil.c
+39
-41
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+6
-6
source/libs/index/test/utilUT.cc
source/libs/index/test/utilUT.cc
+13
-3
未找到文件。
source/libs/index/inc/indexCache.h
浏览文件 @
0b0253f2
...
...
@@ -74,7 +74,7 @@ void indexCacheIteratorDestroy(Iterate* iiter);
int
indexCachePut
(
void
*
cache
,
SIndexTerm
*
term
,
uint64_t
uid
);
// int indexCacheGet(void *cache, uint64_t *rst);
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
void
indexCacheRef
(
IndexCache
*
cache
);
void
indexCacheUnRef
(
IndexCache
*
cache
);
...
...
source/libs/index/inc/indexTfile.h
浏览文件 @
0b0253f2
...
...
@@ -105,7 +105,7 @@ TFileReader* tfileGetReaderByCol(IndexTFile* tf, uint64_t suid, char* colName);
TFileReader
*
tfileReaderOpen
(
char
*
path
,
uint64_t
suid
,
int64_t
version
,
const
char
*
colName
);
TFileReader
*
tfileReaderCreate
(
WriterCtx
*
ctx
);
void
tfileReaderDestroy
(
TFileReader
*
reader
);
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SIdxT
empResu
lt
*
tr
);
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SIdxT
Rs
lt
*
tr
);
void
tfileReaderRef
(
TFileReader
*
reader
);
void
tfileReaderUnRef
(
TFileReader
*
reader
);
...
...
@@ -120,7 +120,7 @@ int tfileWriterFinish(TFileWriter* tw);
IndexTFile
*
indexTFileCreate
(
const
char
*
path
);
void
indexTFileDestroy
(
IndexTFile
*
tfile
);
int
indexTFilePut
(
void
*
tfile
,
SIndexTerm
*
term
,
uint64_t
uid
);
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SIdxT
empResu
lt
*
tr
);
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SIdxT
Rs
lt
*
tr
);
Iterate
*
tfileIteratorCreate
(
TFileReader
*
reader
);
void
tfileIteratorDestroy
(
Iterate
*
iterator
);
...
...
source/libs/index/inc/indexUtil.h
浏览文件 @
0b0253f2
...
...
@@ -66,7 +66,7 @@ extern "C" {
* [1, 4, 5]
* output:[4, 5]
*/
void
iIntersection
(
SArray
*
in
terResults
,
SArray
*
finalResul
t
);
void
iIntersection
(
SArray
*
in
,
SArray
*
ou
t
);
/* multi sorted result union
* input: [1, 2, 4, 5]
...
...
@@ -74,7 +74,7 @@ void iIntersection(SArray *interResults, SArray *finalResult);
* [1, 4, 5]
* output:[1, 2, 3, 4, 5]
*/
void
iUnion
(
SArray
*
in
terResults
,
SArray
*
finalResul
t
);
void
iUnion
(
SArray
*
in
,
SArray
*
ou
t
);
/* see example
* total: [1, 2, 4, 5, 7, 8]
...
...
@@ -92,19 +92,24 @@ typedef struct {
uint64_t
data
;
}
SIdxVerdata
;
/*
* index temp result
*
*/
typedef
struct
{
SArray
*
total
;
SArray
*
added
;
SArray
*
deled
;
}
SIdxTempResult
;
SArray
*
add
;
SArray
*
del
;
}
SIdxTRslt
;
SIdxTRslt
*
idxTRsltCreate
();
SIdxTempResult
*
idxTempResultCreate
(
);
void
idxTRsltClear
(
SIdxTRslt
*
tr
);
void
idxT
empResultClear
(
SIdxTempResu
lt
*
tr
);
void
idxT
RsltDestroy
(
SIdxTRs
lt
*
tr
);
void
idxT
empResultDestroy
(
SIdxTempResult
*
tr
);
void
idxT
RsltMergeTo
(
SIdxTRslt
*
tr
,
SArray
*
out
);
void
idxTempResultMergeTo
(
SIdxTempResult
*
tr
,
SArray
*
result
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/index/src/index.c
浏览文件 @
0b0253f2
...
...
@@ -29,7 +29,7 @@
#include "lucene++/Lucene_c.h"
#endif
#define INDEX_NUM_OF_THREADS
1
#define INDEX_NUM_OF_THREADS
5
#define INDEX_QUEUE_SIZE 200
#define INDEX_DATA_BOOL_NULL 0x02
...
...
@@ -85,7 +85,7 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oTyp
static
int
indexGenTFile
(
SIndex
*
index
,
IndexCache
*
cache
,
SArray
*
batch
);
// merge cache and tfile by opera type
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
icache
,
IterateValue
*
iTfv
,
SIdxT
empResu
lt
*
helper
);
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
icache
,
IterateValue
*
iTfv
,
SIdxT
Rs
lt
*
helper
);
// static int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
...
...
@@ -343,7 +343,7 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
int64_t
st
=
taosGetTimestampUs
();
SIdxT
empResult
*
tr
=
idxTempResu
ltCreate
();
SIdxT
Rslt
*
tr
=
idxTRs
ltCreate
();
if
(
0
==
indexCacheSearch
(
cache
,
query
,
tr
,
&
s
))
{
if
(
s
==
kTypeDeletion
)
{
indexInfo
(
"col: %s already drop by"
,
term
->
colName
);
...
...
@@ -365,12 +365,12 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
int64_t
cost
=
taosGetTimestampUs
()
-
st
;
indexInfo
(
"search cost: %"
PRIu64
"us"
,
cost
);
idxT
empResu
ltMergeTo
(
tr
,
*
result
);
idxT
Rs
ltMergeTo
(
tr
,
*
result
);
idxT
empResu
ltDestroy
(
tr
);
idxT
Rs
ltDestroy
(
tr
);
return
0
;
END:
idxT
empResu
ltDestroy
(
tr
);
idxT
Rs
ltDestroy
(
tr
);
return
-
1
;
}
static
void
indexInterResultsDestroy
(
SArray
*
results
)
{
...
...
@@ -406,18 +406,18 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oType
return
0
;
}
static
void
indexMayMergeTempToFinalResult
(
SArray
*
result
,
TFileValue
*
tfv
,
SIdxT
empResu
lt
*
tr
)
{
static
void
indexMayMergeTempToFinalResult
(
SArray
*
result
,
TFileValue
*
tfv
,
SIdxT
Rs
lt
*
tr
)
{
int32_t
sz
=
taosArrayGetSize
(
result
);
if
(
sz
>
0
)
{
TFileValue
*
lv
=
taosArrayGetP
(
result
,
sz
-
1
);
if
(
tfv
!=
NULL
&&
strcmp
(
lv
->
colVal
,
tfv
->
colVal
)
!=
0
)
{
idxT
empResu
ltMergeTo
(
tr
,
lv
->
tableId
);
idxT
empResu
ltClear
(
tr
);
idxT
Rs
ltMergeTo
(
tr
,
lv
->
tableId
);
idxT
Rs
ltClear
(
tr
);
taosArrayPush
(
result
,
&
tfv
);
}
else
if
(
tfv
==
NULL
)
{
// handle last iterator
idxT
empResu
ltMergeTo
(
tr
,
lv
->
tableId
);
idxT
Rs
ltMergeTo
(
tr
,
lv
->
tableId
);
}
else
{
// temp result saved in help
tfileValueDestroy
(
tfv
);
...
...
@@ -426,7 +426,7 @@ static void indexMayMergeTempToFinalResult(SArray* result, TFileValue* tfv, SIdx
taosArrayPush
(
result
,
&
tfv
);
}
}
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
cv
,
IterateValue
*
tv
,
SIdxT
empResu
lt
*
tr
)
{
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
cv
,
IterateValue
*
tv
,
SIdxT
Rs
lt
*
tr
)
{
char
*
colVal
=
(
cv
!=
NULL
)
?
cv
->
colVal
:
tv
->
colVal
;
TFileValue
*
tfv
=
tfileValueCreate
(
colVal
);
...
...
@@ -436,9 +436,9 @@ static void indexMergeCacheAndTFile(SArray* result, IterateValue* cv, IterateVal
uint64_t
id
=
*
(
uint64_t
*
)
taosArrayGet
(
cv
->
val
,
0
);
uint32_t
ver
=
cv
->
ver
;
if
(
cv
->
type
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
del
ed
,
tr
->
adde
d
,
id
)
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
ad
d
,
id
)
}
else
if
(
cv
->
type
==
DEL_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
add
ed
,
tr
->
deled
,
id
)
INDEX_MERGE_ADD_DEL
(
tr
->
add
,
tr
->
del
,
id
)
}
}
if
(
tv
!=
NULL
)
{
...
...
@@ -491,7 +491,7 @@ int indexFlushCacheToTFile(SIndex* sIdx, void* cache) {
bool
cn
=
cacheIter
?
cacheIter
->
next
(
cacheIter
)
:
false
;
bool
tn
=
tfileIter
?
tfileIter
->
next
(
tfileIter
)
:
false
;
SIdxT
empResult
*
tr
=
idxTempResu
ltCreate
();
SIdxT
Rslt
*
tr
=
idxTRs
ltCreate
();
while
(
cn
==
true
||
tn
==
true
)
{
IterateValue
*
cv
=
(
cn
==
true
)
?
cacheIter
->
getValue
(
cacheIter
)
:
NULL
;
IterateValue
*
tv
=
(
tn
==
true
)
?
tfileIter
->
getValue
(
tfileIter
)
:
NULL
;
...
...
@@ -517,7 +517,7 @@ int indexFlushCacheToTFile(SIndex* sIdx, void* cache) {
}
}
indexMayMergeTempToFinalResult
(
result
,
NULL
,
tr
);
idxT
empResu
ltDestroy
(
tr
);
idxT
Rs
ltDestroy
(
tr
);
int
ret
=
indexGenTFile
(
sIdx
,
pCache
,
result
);
indexDestroyFinalResult
(
result
);
...
...
source/libs/index/src/indexCache.c
浏览文件 @
0b0253f2
...
...
@@ -36,32 +36,31 @@ static char* indexCacheTermGet(const void* pData);
static
MemTable
*
indexInternalCacheCreate
(
int8_t
type
);
static
int32_t
cacheSearchTerm
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchPrefix
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchSuffix
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRegex
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchLessThan
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchLessEqual
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterThan
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterEqual
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRange
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchTerm
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchPrefix
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchSuffix
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRegex
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchLessThan
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchLessEqual
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterThan
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterEqual
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRange
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
);
/*comm func of compare, used in (LE/LT/GE/GT compare)*/
static
int32_t
cacheSearchCompareFunc
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
,
RangeType
type
);
static
int32_t
cacheSearchTerm_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchPrefix_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchSuffix_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRegex_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchLessThan_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchLessEqual_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterThan_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterEqual_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRange_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchCompareFunc_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTempResult
*
tr
,
STermValueType
*
s
,
static
int32_t
cacheSearchCompareFunc
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
,
RangeType
type
);
static
int32_t
cacheSearchTerm_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchPrefix_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchSuffix_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRegex_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchLessThan_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchLessEqual_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterThan_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterEqual_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRange_JSON
(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxTRslt
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchCompareFunc_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
,
RangeType
type
);
static
int32_t
(
*
cacheSearch
[][
QUERY_MAX
])(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
=
{
static
int32_t
(
*
cacheSearch
[][
QUERY_MAX
])(
void
*
cache
,
SIndexTerm
*
ct
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
=
{
{
cacheSearchTerm
,
cacheSearchPrefix
,
cacheSearchSuffix
,
cacheSearchRegex
,
cacheSearchLessThan
,
cacheSearchLessEqual
,
cacheSearchGreaterThan
,
cacheSearchGreaterEqual
,
cacheSearchRange
},
{
cacheSearchTerm_JSON
,
cacheSearchPrefix_JSON
,
cacheSearchSuffix_JSON
,
cacheSearchRegex_JSON
,
...
...
@@ -71,7 +70,7 @@ static int32_t (*cacheSearch[][QUERY_MAX])(void* cache, SIndexTerm* ct, SIdxTemp
static
void
doMergeWork
(
SSchedMsg
*
msg
);
static
bool
indexCacheIteratorNext
(
Iterate
*
itera
);
static
int32_t
cacheSearchTerm
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchTerm
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
if
(
cache
==
NULL
)
{
return
0
;
}
...
...
@@ -93,11 +92,11 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTempResult* tr
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
if
(
0
==
strcmp
(
c
->
colVal
,
pCt
->
colVal
))
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
del
ed
,
tr
->
adde
d
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
ad
d
,
c
->
uid
)
// taosArrayPush(result, &c->uid);
*
s
=
kTypeValue
;
}
else
if
(
c
->
operaType
==
DEL_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
add
ed
,
tr
->
deled
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
add
,
tr
->
del
,
c
->
uid
)
}
}
else
{
break
;
...
...
@@ -108,20 +107,19 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTempResult* tr
tSkipListDestroyIter
(
iter
);
return
0
;
}
static
int32_t
cacheSearchPrefix
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchPrefix
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
static
int32_t
cacheSearchSuffix
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchSuffix
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
static
int32_t
cacheSearchRegex
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchRegex
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
static
int32_t
cacheSearchCompareFunc
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTempResult
*
tr
,
STermValueType
*
s
,
RangeType
type
)
{
static
int32_t
cacheSearchCompareFunc
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
,
RangeType
type
)
{
if
(
cache
==
NULL
)
{
return
0
;
}
...
...
@@ -148,11 +146,11 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTempRes
TExeCond
cond
=
cmpFn
(
c
->
colVal
,
pCt
->
colVal
,
pCt
->
colType
);
if
(
cond
==
MATCH
)
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
del
ed
,
tr
->
adde
d
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
ad
d
,
c
->
uid
)
// taosArrayPush(result, &c->uid);
*
s
=
kTypeValue
;
}
else
if
(
c
->
operaType
==
DEL_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
add
ed
,
tr
->
deled
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
add
,
tr
->
del
,
c
->
uid
)
}
}
else
if
(
cond
==
CONTINUE
)
{
continue
;
...
...
@@ -164,20 +162,20 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTempRes
tSkipListDestroyIter
(
iter
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchLessThan
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchLessThan
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc
(
cache
,
term
,
tr
,
s
,
LT
);
}
static
int32_t
cacheSearchLessEqual
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchLessEqual
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc
(
cache
,
term
,
tr
,
s
,
LE
);
}
static
int32_t
cacheSearchGreaterThan
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchGreaterThan
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc
(
cache
,
term
,
tr
,
s
,
GT
);
}
static
int32_t
cacheSearchGreaterEqual
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchGreaterEqual
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc
(
cache
,
term
,
tr
,
s
,
GE
);
}
static
int32_t
cacheSearchTerm_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchTerm_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
if
(
cache
==
NULL
)
{
return
0
;
}
...
...
@@ -205,11 +203,11 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTempResul
if
(
0
==
strcmp
(
c
->
colVal
,
pCt
->
colVal
))
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
del
ed
,
tr
->
adde
d
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
ad
d
,
c
->
uid
)
// taosArrayPush(result, &c->uid);
*
s
=
kTypeValue
;
}
else
if
(
c
->
operaType
==
DEL_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
add
ed
,
tr
->
deled
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
add
,
tr
->
del
,
c
->
uid
)
}
}
else
{
break
;
...
...
@@ -223,32 +221,32 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTempResul
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchPrefix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchPrefix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchSuffix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchSuffix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchRegex_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchRegex_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchLessThan_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchLessThan_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
LT
);
}
static
int32_t
cacheSearchLessEqual_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchLessEqual_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
LE
);
}
static
int32_t
cacheSearchGreaterThan_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchGreaterThan_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
GT
);
}
static
int32_t
cacheSearchGreaterEqual_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchGreaterEqual_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
GE
);
}
static
int32_t
cacheSearchRange_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchRange_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchCompareFunc_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
,
static
int32_t
cacheSearchCompareFunc_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
,
RangeType
type
)
{
if
(
cache
==
NULL
)
{
return
0
;
...
...
@@ -290,11 +288,11 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTe
TExeCond
cond
=
cmpFn
(
p
+
skip
,
term
->
colVal
,
dType
);
if
(
cond
==
MATCH
)
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
del
ed
,
tr
->
adde
d
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
ad
d
,
c
->
uid
)
// taosArrayPush(result, &c->uid);
*
s
=
kTypeValue
;
}
else
if
(
c
->
operaType
==
DEL_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
add
ed
,
tr
->
deled
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
add
,
tr
->
del
,
c
->
uid
)
}
}
else
if
(
cond
==
CONTINUE
)
{
continue
;
...
...
@@ -310,7 +308,7 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTe
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchRange
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchRange
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
...
...
@@ -569,7 +567,7 @@ int indexCacheDel(void* cache, const char* fieldValue, int32_t fvlen, uint64_t u
return
0
;
}
static
int32_t
indexQueryMem
(
MemTable
*
mem
,
SIndexTermQuery
*
query
,
SIdxT
empResu
lt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
indexQueryMem
(
MemTable
*
mem
,
SIndexTermQuery
*
query
,
SIdxT
Rs
lt
*
tr
,
STermValueType
*
s
)
{
if
(
mem
==
NULL
)
{
return
0
;
}
...
...
@@ -583,7 +581,7 @@ static int32_t indexQueryMem(MemTable* mem, SIndexTermQuery* query, SIdxTempResu
return
cacheSearch
[
0
][
qtype
](
mem
,
term
,
tr
,
s
);
}
}
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
SIdxT
empResu
lt
*
result
,
STermValueType
*
s
)
{
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
SIdxT
Rs
lt
*
result
,
STermValueType
*
s
)
{
int64_t
st
=
taosGetTimestampUs
();
if
(
cache
==
NULL
)
{
return
0
;
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
0b0253f2
...
...
@@ -60,31 +60,31 @@ static void tfileGenFileFullName(char* fullname, const char* path, uint64_t s
/*
* search from tfile
*/
static
int32_t
tfSearchTerm
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchPrefix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchSuffix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchRegex
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchLessThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchLessEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchGreaterThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchGreaterEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchRange
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchCompareFunc
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
,
RangeType
ctype
);
static
int32_t
tfSearchTerm_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchPrefix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchSuffix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchRegex_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchLessThan_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchLessEqual_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchGreaterThan_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchGreaterEqual_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchRange_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
);
static
int32_t
tfSearchCompareFunc_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
,
RangeType
ctype
);
static
int32_t
(
*
tfSearch
[][
QUERY_MAX
])(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
=
{
static
int32_t
tfSearchTerm
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchPrefix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchSuffix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchRegex
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchLessThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchLessEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchGreaterThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchGreaterEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchRange
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchCompareFunc
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
,
RangeType
ctype
);
static
int32_t
tfSearchTerm_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchPrefix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchSuffix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchRegex_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchLessThan_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchLessEqual_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchGreaterThan_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchGreaterEqual_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchRange_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
);
static
int32_t
tfSearchCompareFunc_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
,
RangeType
ctype
);
static
int32_t
(
*
tfSearch
[][
QUERY_MAX
])(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
=
{
{
tfSearchTerm
,
tfSearchPrefix
,
tfSearchSuffix
,
tfSearchRegex
,
tfSearchLessThan
,
tfSearchLessEqual
,
tfSearchGreaterThan
,
tfSearchGreaterEqual
,
tfSearchRange
},
{
tfSearchTerm_JSON
,
tfSearchPrefix_JSON
,
tfSearchSuffix_JSON
,
tfSearchRegex_JSON
,
tfSearchLessThan_JSON
,
...
...
@@ -220,7 +220,7 @@ void tfileReaderDestroy(TFileReader* reader) {
taosMemoryFree
(
reader
);
}
static
int32_t
tfSearchTerm
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchTerm
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
int
ret
=
0
;
char
*
p
=
tem
->
colVal
;
uint64_t
sz
=
tem
->
nColVal
;
...
...
@@ -243,7 +243,7 @@ static int32_t tfSearchTerm(void* reader, SIndexTerm* tem, SIdxTempResult* tr) {
return
0
;
}
static
int32_t
tfSearchPrefix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchPrefix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
char
*
p
=
tem
->
colVal
;
uint64_t
sz
=
tem
->
nColVal
;
...
...
@@ -279,7 +279,7 @@ static int32_t tfSearchPrefix(void* reader, SIndexTerm* tem, SIdxTempResult* tr)
}
return
0
;
}
static
int32_t
tfSearchSuffix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchSuffix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
int
ret
=
0
;
...
...
@@ -298,7 +298,7 @@ static int32_t tfSearchSuffix(void* reader, SIndexTerm* tem, SIdxTempResult* tr)
fstSliceDestroy
(
&
key
);
return
0
;
}
static
int32_t
tfSearchRegex
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchRegex
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
int
ret
=
0
;
...
...
@@ -319,7 +319,7 @@ static int32_t tfSearchRegex(void* reader, SIndexTerm* tem, SIdxTempResult* tr)
return
0
;
}
static
int32_t
tfSearchCompareFunc
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
,
RangeType
type
)
{
static
int32_t
tfSearchCompareFunc
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
,
RangeType
type
)
{
int
ret
=
0
;
char
*
p
=
tem
->
colVal
;
int
skip
=
0
;
...
...
@@ -358,19 +358,19 @@ static int32_t tfSearchCompareFunc(void* reader, SIndexTerm* tem, SIdxTempResult
fstStreamBuilderDestroy
(
sb
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tfSearchLessThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchLessThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
return
tfSearchCompareFunc
(
reader
,
tem
,
tr
,
LT
);
}
static
int32_t
tfSearchLessEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchLessEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
return
tfSearchCompareFunc
(
reader
,
tem
,
tr
,
LE
);
}
static
int32_t
tfSearchGreaterThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchGreaterThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
return
tfSearchCompareFunc
(
reader
,
tem
,
tr
,
GT
);
}
static
int32_t
tfSearchGreaterEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchGreaterEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
return
tfSearchCompareFunc
(
reader
,
tem
,
tr
,
GE
);
}
static
int32_t
tfSearchRange
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchRange
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
int
ret
=
0
;
char
*
p
=
tem
->
colVal
;
...
...
@@ -399,7 +399,7 @@ static int32_t tfSearchRange(void* reader, SIndexTerm* tem, SIdxTempResult* tr)
fstSliceDestroy
(
&
key
);
return
0
;
}
static
int32_t
tfSearchTerm_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchTerm_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
int
ret
=
0
;
char
*
p
=
indexPackJsonData
(
tem
);
int
sz
=
strlen
(
p
);
...
...
@@ -424,36 +424,36 @@ static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTempResult*
// deprecate api
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tfSearchPrefix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchPrefix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tfSearchSuffix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchSuffix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tfSearchRegex_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchRegex_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tfSearchLessThan_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchLessThan_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
return
tfSearchCompareFunc_JSON
(
reader
,
tem
,
tr
,
LT
);
}
static
int32_t
tfSearchLessEqual_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchLessEqual_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
return
tfSearchCompareFunc_JSON
(
reader
,
tem
,
tr
,
LE
);
}
static
int32_t
tfSearchGreaterThan_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchGreaterThan_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
return
tfSearchCompareFunc_JSON
(
reader
,
tem
,
tr
,
GT
);
}
static
int32_t
tfSearchGreaterEqual_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchGreaterEqual_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
return
tfSearchCompareFunc_JSON
(
reader
,
tem
,
tr
,
GE
);
}
static
int32_t
tfSearchRange_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
)
{
static
int32_t
tfSearchRange_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tfSearchCompareFunc_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
empResu
lt
*
tr
,
RangeType
ctype
)
{
static
int32_t
tfSearchCompareFunc_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxT
Rs
lt
*
tr
,
RangeType
ctype
)
{
int
ret
=
0
;
int
skip
=
0
;
...
...
@@ -501,7 +501,7 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTempR
fstStreamBuilderDestroy
(
sb
);
return
TSDB_CODE_SUCCESS
;
}
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SIdxT
empResu
lt
*
tr
)
{
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SIdxT
Rs
lt
*
tr
)
{
SIndexTerm
*
term
=
query
->
term
;
EIndexQueryType
qtype
=
query
->
qType
;
int
ret
=
0
;
...
...
@@ -673,7 +673,7 @@ void indexTFileDestroy(IndexTFile* tfile) {
taosMemoryFree
(
tfile
);
}
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SIdxT
empResu
lt
*
result
)
{
int
indexTFileSearch
(
void
*
tfile
,
SIndexTermQuery
*
query
,
SIdxT
Rs
lt
*
result
)
{
int
ret
=
-
1
;
if
(
tfile
==
NULL
)
{
return
ret
;
...
...
source/libs/index/src/indexUtil.c
浏览文件 @
0b0253f2
...
...
@@ -36,24 +36,24 @@ static int iBinarySearch(SArray *arr, int s, int e, uint64_t k) {
return
s
;
}
void
iIntersection
(
SArray
*
in
ters
,
SArray
*
final
)
{
int32_t
sz
=
(
int32_t
)
taosArrayGetSize
(
in
ters
);
void
iIntersection
(
SArray
*
in
,
SArray
*
out
)
{
int32_t
sz
=
(
int32_t
)
taosArrayGetSize
(
in
);
if
(
sz
<=
0
)
{
return
;
}
MergeIndex
*
mi
=
taosMemoryCalloc
(
sz
,
sizeof
(
MergeIndex
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SArray
*
t
=
taosArrayGetP
(
in
ters
,
i
);
SArray
*
t
=
taosArrayGetP
(
in
,
i
);
mi
[
i
].
len
=
(
int32_t
)
taosArrayGetSize
(
t
);
mi
[
i
].
idx
=
0
;
}
SArray
*
base
=
taosArrayGetP
(
in
ters
,
0
);
SArray
*
base
=
taosArrayGetP
(
in
,
0
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
base
);
i
++
)
{
uint64_t
tgt
=
*
(
uint64_t
*
)
taosArrayGet
(
base
,
i
);
bool
has
=
true
;
for
(
int
j
=
1
;
j
<
taosArrayGetSize
(
in
ters
);
j
++
)
{
SArray
*
oth
=
taosArrayGetP
(
in
ters
,
j
);
for
(
int
j
=
1
;
j
<
taosArrayGetSize
(
in
);
j
++
)
{
SArray
*
oth
=
taosArrayGetP
(
in
,
j
);
int
mid
=
iBinarySearch
(
oth
,
mi
[
j
].
idx
,
mi
[
j
].
len
-
1
,
tgt
);
if
(
mid
>=
0
&&
mid
<
mi
[
j
].
len
)
{
uint64_t
val
=
*
(
uint64_t
*
)
taosArrayGet
(
oth
,
mid
);
...
...
@@ -64,24 +64,24 @@ void iIntersection(SArray *inters, SArray *final) {
}
}
if
(
has
==
true
)
{
taosArrayPush
(
final
,
&
tgt
);
taosArrayPush
(
out
,
&
tgt
);
}
}
taosMemoryFreeClear
(
mi
);
}
void
iUnion
(
SArray
*
in
ters
,
SArray
*
final
)
{
int32_t
sz
=
(
int32_t
)
taosArrayGetSize
(
in
ters
);
void
iUnion
(
SArray
*
in
,
SArray
*
out
)
{
int32_t
sz
=
(
int32_t
)
taosArrayGetSize
(
in
);
if
(
sz
<=
0
)
{
return
;
}
if
(
sz
==
1
)
{
taosArrayAddAll
(
final
,
taosArrayGetP
(
inters
,
0
));
taosArrayAddAll
(
out
,
taosArrayGetP
(
in
,
0
));
return
;
}
MergeIndex
*
mi
=
taosMemoryCalloc
(
sz
,
sizeof
(
MergeIndex
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SArray
*
t
=
taosArrayGetP
(
in
ters
,
i
);
SArray
*
t
=
taosArrayGetP
(
in
,
i
);
mi
[
i
].
len
=
(
int32_t
)
taosArrayGetSize
(
t
);
mi
[
i
].
idx
=
0
;
}
...
...
@@ -90,7 +90,7 @@ void iUnion(SArray *inters, SArray *final) {
int
mIdx
=
-
1
;
for
(
int
j
=
0
;
j
<
sz
;
j
++
)
{
SArray
*
t
=
taosArrayGetP
(
in
ters
,
j
);
SArray
*
t
=
taosArrayGetP
(
in
,
j
);
if
(
mi
[
j
].
idx
>=
mi
[
j
].
len
)
{
continue
;
}
...
...
@@ -102,13 +102,13 @@ void iUnion(SArray *inters, SArray *final) {
}
if
(
mIdx
!=
-
1
)
{
mi
[
mIdx
].
idx
++
;
if
(
taosArrayGetSize
(
final
)
>
0
)
{
uint64_t
lVal
=
*
(
uint64_t
*
)
taosArrayGetLast
(
final
);
if
(
taosArrayGetSize
(
out
)
>
0
)
{
uint64_t
lVal
=
*
(
uint64_t
*
)
taosArrayGetLast
(
out
);
if
(
lVal
==
mVal
)
{
continue
;
}
}
taosArrayPush
(
final
,
&
mVal
);
taosArrayPush
(
out
,
&
mVal
);
}
else
{
break
;
}
...
...
@@ -158,46 +158,44 @@ int verdataCompare(const void *a, const void *b) {
return
cmp
;
}
SIdxT
empResult
*
idxTempResu
ltCreate
()
{
SIdxT
empResult
*
tr
=
taosMemoryCalloc
(
1
,
sizeof
(
SIdxTempResu
lt
));
SIdxT
Rslt
*
idxTRs
ltCreate
()
{
SIdxT
Rslt
*
tr
=
taosMemoryCalloc
(
1
,
sizeof
(
SIdxTRs
lt
));
tr
->
total
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
tr
->
add
ed
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
tr
->
del
ed
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
tr
->
add
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
tr
->
del
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
return
tr
;
}
void
idxT
empResultClear
(
SIdxTempResu
lt
*
tr
)
{
void
idxT
RsltClear
(
SIdxTRs
lt
*
tr
)
{
if
(
tr
==
NULL
)
{
return
;
}
taosArrayClear
(
tr
->
total
);
taosArrayClear
(
tr
->
add
ed
);
taosArrayClear
(
tr
->
del
ed
);
taosArrayClear
(
tr
->
add
);
taosArrayClear
(
tr
->
del
);
}
void
idxT
empResultDestroy
(
SIdxTempResu
lt
*
tr
)
{
void
idxT
RsltDestroy
(
SIdxTRs
lt
*
tr
)
{
if
(
tr
==
NULL
)
{
return
;
}
taosArrayDestroy
(
tr
->
total
);
taosArrayDestroy
(
tr
->
add
ed
);
taosArrayDestroy
(
tr
->
del
ed
);
taosArrayDestroy
(
tr
->
add
);
taosArrayDestroy
(
tr
->
del
);
}
void
idxT
empResultMergeTo
(
SIdxTempResu
lt
*
tr
,
SArray
*
result
)
{
void
idxT
RsltMergeTo
(
SIdxTRs
lt
*
tr
,
SArray
*
result
)
{
taosArraySort
(
tr
->
total
,
uidCompare
);
taosArraySort
(
tr
->
added
,
uidCompare
);
taosArraySort
(
tr
->
deled
,
uidCompare
);
SArray
*
arrs
=
taosArrayInit
(
2
,
sizeof
(
void
*
));
taosArrayPush
(
arrs
,
&
tr
->
total
);
taosArrayPush
(
arrs
,
&
tr
->
added
);
iUnion
(
arrs
,
result
);
taosArrayDestroy
(
arrs
);
indexError
(
"tmp result: total: %d, added: %d, del: %d"
,
(
int
)
taosArrayGetSize
(
tr
->
total
),
(
int
)
taosArrayGetSize
(
tr
->
added
),
(
int
)
taosArrayGetSize
(
tr
->
deled
));
if
(
taosArrayGetSize
(
tr
->
added
)
!=
0
&&
taosArrayGetSize
(
result
)
==
0
)
{
indexError
(
"except result: %d"
,
(
int
)(
taosArrayGetSize
(
result
)));
taosArraySort
(
tr
->
add
,
uidCompare
);
taosArraySort
(
tr
->
del
,
uidCompare
);
if
(
taosArrayGetSize
(
tr
->
total
)
==
0
||
taosArrayGetSize
(
tr
->
add
)
==
0
)
{
SArray
*
t
=
taosArrayGetSize
(
tr
->
total
)
==
0
?
tr
->
add
:
tr
->
total
;
taosArrayAddAll
(
result
,
t
);
}
else
{
SArray
*
arrs
=
taosArrayInit
(
2
,
sizeof
(
void
*
));
taosArrayPush
(
arrs
,
&
tr
->
total
);
taosArrayPush
(
arrs
,
&
tr
->
add
);
iUnion
(
arrs
,
result
);
taosArrayDestroy
(
arrs
);
}
iExcept
(
result
,
tr
->
del
ed
);
iExcept
(
result
,
tr
->
del
);
}
source/libs/index/test/indexTests.cc
浏览文件 @
0b0253f2
...
...
@@ -411,12 +411,12 @@ class TFileObj {
//
//
}
SIdxT
empResult
*
tr
=
idxTempResu
ltCreate
();
SIdxT
Rslt
*
tr
=
idxTRs
ltCreate
();
int
ret
=
tfileReaderSearch
(
reader_
,
query
,
tr
);
idxT
empResu
ltMergeTo
(
tr
,
result
);
idxT
empResu
ltDestroy
(
tr
);
idxT
Rs
ltMergeTo
(
tr
,
result
);
idxT
Rs
ltDestroy
(
tr
);
return
ret
;
}
~
TFileObj
()
{
...
...
@@ -531,11 +531,11 @@ class CacheObj {
indexCacheDebug
(
cache
);
}
int
Get
(
SIndexTermQuery
*
query
,
int16_t
colId
,
int32_t
version
,
SArray
*
result
,
STermValueType
*
s
)
{
SIdxT
empResult
*
tr
=
idxTempResu
ltCreate
();
SIdxT
Rslt
*
tr
=
idxTRs
ltCreate
();
int
ret
=
indexCacheSearch
(
cache
,
query
,
tr
,
s
);
idxT
empResu
ltMergeTo
(
tr
,
result
);
idxT
empResu
ltDestroy
(
tr
);
idxT
Rs
ltMergeTo
(
tr
,
result
);
idxT
Rs
ltDestroy
(
tr
);
if
(
ret
!=
0
)
{
std
::
cout
<<
"failed to get from cache:"
<<
ret
<<
std
::
endl
;
...
...
source/libs/index/test/utilUT.cc
浏览文件 @
0b0253f2
...
...
@@ -338,12 +338,22 @@ TEST_F(UtilEnv, testFill) {
}
}
TEST_F
(
UtilEnv
,
TempResult
)
{
SIdxT
empResult
*
relt
=
idxTempResu
ltCreate
();
SIdxT
Rslt
*
relt
=
idxTRs
ltCreate
();
SArray
*
f
=
taosArrayInit
(
0
,
sizeof
(
uint64_t
));
uint64_t
val
=
UINT64_MAX
-
1
;
taosArrayPush
(
relt
->
added
,
&
val
);
idxTempResultMergeTo
(
relt
,
f
);
taosArrayPush
(
relt
->
add
,
&
val
);
idxTRsltMergeTo
(
relt
,
f
);
EXPECT_EQ
(
taosArrayGetSize
(
f
),
1
);
}
TEST_F
(
UtilEnv
,
TempResultExcept
)
{
SIdxTRslt
*
relt
=
idxTRsltCreate
();
SArray
*
f
=
taosArrayInit
(
0
,
sizeof
(
uint64_t
));
uint64_t
val
=
UINT64_MAX
;
taosArrayPush
(
relt
->
add
,
&
val
);
idxTRsltMergeTo
(
relt
,
f
);
EXPECT_EQ
(
taosArrayGetSize
(
f
),
1
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录