Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
26f2d342
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
26f2d342
编写于
5月 02, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(index): add prefix query
上级
ee5b67a9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
220 addition
and
111 deletion
+220
-111
include/libs/index/index.h
include/libs/index/index.h
+3
-1
source/libs/executor/src/indexoperator.c
source/libs/executor/src/indexoperator.c
+29
-20
source/libs/index/src/index.c
source/libs/index/src/index.c
+7
-43
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+29
-0
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+152
-47
未找到文件。
include/libs/index/index.h
浏览文件 @
26f2d342
...
...
@@ -17,6 +17,7 @@
#define _TD_INDEX_H_
#include "os.h"
#include "taoserror.h"
#include "tarray.h"
#ifdef __cplusplus
...
...
@@ -41,7 +42,8 @@ typedef enum {
UPDATE_VALUE
,
// update index column value
ADD_INDEX
,
// add index on specify column
DROP_INDEX
,
// drop existed index
DROP_SATBLE
// drop stable
DROP_SATBLE
,
// drop stable
DEFAULT
// query
}
SIndexOperOnColumn
;
typedef
enum
{
MUST
=
0
,
SHOULD
=
1
,
NOT
=
2
}
EIndexOperatorType
;
...
...
source/libs/executor/src/indexoperator.c
浏览文件 @
26f2d342
...
...
@@ -55,11 +55,11 @@ typedef struct SIFParam {
SArray
*
result
;
char
*
condValue
;
uint8_t
colValType
;
col_id_t
colId
;
int64_t
suid
;
// add later
char
dbName
[
TSDB_DB_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
int64_t
suid
;
// add later
char
dbName
[
TSDB_DB_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
}
SIFParam
;
typedef
int32_t
(
*
sif_func_t
)(
SIFParam
*
left
,
SIFParam
*
rigth
,
SIFParam
*
output
);
...
...
@@ -145,10 +145,11 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
SColumnNode
*
cn
=
(
SColumnNode
*
)
node
;
/*only support tag column*/
SIF_ERR_RET
(
sifValidateColumn
(
cn
));
param
->
colId
=
cn
->
colId
;
param
->
colValType
=
cn
->
node
.
resType
.
type
;
memcpy
(
param
->
dbName
,
cn
->
dbName
,
sizeof
(
cn
->
dbName
));
memcpy
(
param
->
colName
,
cn
->
colName
,
sizeof
(
cn
->
colName
));
break
;
}
case
QUERY_NODE_NODE_LIST
:
{
...
...
@@ -231,61 +232,68 @@ static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *outpu
qError
(
"index-filter not support buildin function"
);
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
static
int32_t
sifIndex
(
SIFParam
*
left
,
SIFParam
*
right
,
int8_t
operType
,
SIFParam
*
output
)
{
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
return
TSDB_CODE_SUCCESS
;
static
int32_t
sifDoIndex
(
SIFParam
*
left
,
SIFParam
*
right
,
int8_t
operType
,
SIFParam
*
output
)
{
SIndexTerm
*
tm
=
indexTermCreate
(
left
->
suid
,
DEFAULT
,
left
->
colValType
,
left
->
colName
,
strlen
(
left
->
colName
),
right
->
condValue
,
strlen
(
right
->
condValue
));
if
(
tm
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
SIndexMultiTermQuery
*
mtm
=
indexMultiTermQueryCreate
(
MUST
);
indexMultiTermQueryAdd
(
mtm
,
tm
,
QUERY_TERM
);
return
indexSearch
(
NULL
,
mtm
,
output
->
result
);
}
static
int32_t
sifLessThanFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_LOWER_THAN
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifLessEqualFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_LOWER_EQUAL
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifGreaterThanFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_GREATER_THAN
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifGreaterEqualFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_GREATER_EQUAL
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifEqualFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_EQUAL
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifNotEqualFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_NOT_EQUAL
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifInFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_IN
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifNotInFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_NOT_IN
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifLikeFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_LIKE
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifNotLikeFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_NOT_LIKE
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifMatchFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_MATCH
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifNotMatchFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_NMATCH
;
return
sifIndex
(
left
,
right
,
id
,
output
);
return
sif
Do
Index
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifDefaultFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
// add more except
...
...
@@ -460,6 +468,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
qError
(
"index-filter failed to taosHashInit"
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
nodesWalkExprPostOrder
(
pNode
,
sifCalcWalker
,
&
ctx
);
SIF_ERR_RET
(
ctx
.
code
);
...
...
source/libs/index/src/index.c
浏览文件 @
26f2d342
...
...
@@ -175,55 +175,19 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
return
0
;
}
int
indexSearch
(
SIndex
*
index
,
SIndexMultiTermQuery
*
multiQuerys
,
SArray
*
result
)
{
#ifdef USE_LUCENE
EIndexOperatorType
opera
=
multiQuerys
->
opera
;
int
nQuery
=
taosArrayGetSize
(
multiQuerys
->
query
);
char
**
fields
=
taosMemoryMalloc
(
sizeof
(
char
*
)
*
nQuery
);
char
**
keys
=
taosMemoryMalloc
(
sizeof
(
char
*
)
*
nQuery
);
int
*
types
=
taosMemoryMalloc
(
sizeof
(
int
)
*
nQuery
);
for
(
int
i
=
0
;
i
<
nQuery
;
i
++
)
{
SIndexTermQuery
*
p
=
taosArrayGet
(
multiQuerys
->
query
,
i
);
SIndexTerm
*
term
=
p
->
field_value
;
fields
[
i
]
=
taosMemoryCalloc
(
1
,
term
->
nKey
+
1
);
keys
[
i
]
=
taosMemoryCalloc
(
1
,
term
->
nVal
+
1
);
memcpy
(
fields
[
i
],
term
->
key
,
term
->
nKey
);
memcpy
(
keys
[
i
],
term
->
val
,
term
->
nVal
);
types
[
i
]
=
(
int
)(
p
->
type
);
}
int
*
tResult
=
NULL
;
int
tsz
=
0
;
index_multi_search
(
index
->
index
,
(
const
char
**
)
fields
,
(
const
char
**
)
keys
,
types
,
nQuery
,
opera
,
&
tResult
,
&
tsz
);
for
(
int
i
=
0
;
i
<
tsz
;
i
++
)
{
taosArrayPush
(
result
,
&
tResult
[
i
]);
}
for
(
int
i
=
0
;
i
<
nQuery
;
i
++
)
{
taosMemoryFree
(
fields
[
i
]);
taosMemoryFree
(
keys
[
i
]);
}
taosMemoryFree
(
fields
);
taosMemoryFree
(
keys
);
taosMemoryFree
(
types
);
#endif
#ifdef USE_INVERTED_INDEX
EIndexOperatorType
opera
=
multiQuerys
->
opera
;
// relation of querys
SArray
*
i
nterResu
lts
=
taosArrayInit
(
4
,
POINTER_BYTES
);
SArray
*
i
Rs
lts
=
taosArrayInit
(
4
,
POINTER_BYTES
);
int
nQuery
=
taosArrayGetSize
(
multiQuerys
->
query
);
for
(
size_t
i
=
0
;
i
<
nQuery
;
i
++
)
{
SIndexTermQuery
*
q
T
erm
=
taosArrayGet
(
multiQuerys
->
query
,
i
);
SArray
*
t
Resu
lt
=
NULL
;
indexTermSearch
(
index
,
q
Term
,
&
tResu
lt
);
taosArrayPush
(
i
nterResults
,
(
void
*
)
&
tResu
lt
);
SIndexTermQuery
*
q
t
erm
=
taosArrayGet
(
multiQuerys
->
query
,
i
);
SArray
*
t
rs
lt
=
NULL
;
indexTermSearch
(
index
,
q
term
,
&
trs
lt
);
taosArrayPush
(
i
Rslts
,
(
void
*
)
&
trs
lt
);
}
indexMergeFinalResults
(
i
nterResu
lts
,
opera
,
result
);
indexInterResultsDestroy
(
i
nterResu
lts
);
indexMergeFinalResults
(
i
Rs
lts
,
opera
,
result
);
indexInterResultsDestroy
(
i
Rs
lts
);
#endif
return
0
;
...
...
source/libs/index/src/indexCache.c
浏览文件 @
26f2d342
...
...
@@ -34,9 +34,38 @@ static char* indexCacheTermGet(const void* pData);
static
MemTable
*
indexInternalCacheCreate
(
int8_t
type
);
static
int32_t
cacheSearchTerm
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchPrefix
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchSuffix
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRegex
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRange
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
(
*
cacheSearch
[])(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
=
{
cacheSearchTerm
,
cacheSearchPrefix
,
cacheSearchSuffix
,
cacheSearchRegex
,
cacheSearchRange
};
static
void
doMergeWork
(
SSchedMsg
*
msg
);
static
bool
indexCacheIteratorNext
(
Iterate
*
itera
);
static
int32_t
cacheSearchTerm
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
static
int32_t
cacheSearchPrefix
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
static
int32_t
cacheSearchSuffix
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
static
int32_t
cacheSearchRegex
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
static
int32_t
cacheSearchRange
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
}
static
IterateValue
*
indexCacheIteratorGetValue
(
Iterate
*
iter
);
IndexCache
*
indexCacheCreate
(
SIndex
*
idx
,
uint64_t
suid
,
const
char
*
colName
,
int8_t
type
)
{
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
26f2d342
...
...
@@ -57,6 +57,17 @@ static int tfileCompare(const void* a, const void* b);
static
int
tfileParseFileName
(
const
char
*
filename
,
uint64_t
*
suid
,
char
*
col
,
int
*
version
);
static
void
tfileGenFileName
(
char
*
filename
,
uint64_t
suid
,
const
char
*
col
,
int
version
);
static
void
tfileGenFileFullName
(
char
*
fullname
,
const
char
*
path
,
uint64_t
suid
,
const
char
*
col
,
int32_t
version
);
/*
* search from tfile
*/
static
int32_t
tfSearchTerm
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
);
static
int32_t
tfSearchPrefix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
);
static
int32_t
tfSearchSuffix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
);
static
int32_t
tfSearchRegex
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
);
static
int32_t
tfSearchRange
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
);
static
int32_t
(
*
tfSearch
[])(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
=
{
tfSearchTerm
,
tfSearchPrefix
,
tfSearchSuffix
,
tfSearchRegex
,
tfSearchRange
};
TFileCache
*
tfileCacheCreate
(
const
char
*
path
)
{
TFileCache
*
tcache
=
taosMemoryCalloc
(
1
,
sizeof
(
TFileCache
));
...
...
@@ -183,59 +194,153 @@ void tfileReaderDestroy(TFileReader* reader) {
writerCtxDestroy
(
reader
->
ctx
,
reader
->
remove
);
taosMemoryFree
(
reader
);
}
static
int32_t
tfSearchTerm
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
int
ret
=
0
;
char
*
p
=
tem
->
colVal
;
uint64_t
sz
=
tem
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
tem
);
sz
=
strlen
(
p
);
}
int64_t
st
=
taosGetTimestampUs
();
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
uint64_t
offset
;
if
(
fstGet
(((
TFileReader
*
)
reader
)
->
fst
,
&
key
,
&
offset
))
{
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"
,
tem
->
suid
,
tem
->
colName
,
tem
->
colVal
,
cost
);
ret
=
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
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
);
}
if
(
hasJson
)
{
taosMemoryFree
(
p
);
}
fstSliceDestroy
(
&
key
);
return
0
;
}
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SIdxTempResult
*
tr
)
{
SIndexTerm
*
term
=
query
->
term
;
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
EIndexQueryType
qtype
=
query
->
qType
;
static
int32_t
tfSearchPrefix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
char
*
p
=
tem
->
colVal
;
uint64_t
sz
=
tem
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
tem
);
sz
=
strlen
(
p
);
}
// SArray* result = taosArrayInit(16, sizeof(uint64_t));
int
ret
=
-
1
;
// refactor to callback later
if
(
qtype
==
QUERY_TERM
)
{
uint64_t
offset
;
char
*
p
=
term
->
colVal
;
uint64_t
sz
=
term
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
term
);
sz
=
strlen
(
p
);
}
int64_t
st
=
taosGetTimestampUs
();
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
if
(
fstGet
(
reader
->
fst
,
&
key
,
&
offset
))
{
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
);
}
fstSliceDestroy
(
&
key
);
if
(
hasJson
)
{
taosMemoryFree
(
p
);
SArray
*
offsets
=
taosArrayInit
(
16
,
sizeof
(
uint64_t
));
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
p
,
AUTOMATION_PREFIX
);
FstStreamBuilder
*
sb
=
fstSearch
(((
TFileReader
*
)
reader
)
->
fst
,
ctx
);
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithStateResult
*
rt
=
NULL
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
taosArrayPush
(
offsets
,
&
(
rt
->
out
.
out
));
swsResultDestroy
(
rt
);
}
streamWithStateDestroy
(
st
);
fstStreamBuilderDestroy
(
sb
);
int32_t
ret
=
0
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
offsets
);
i
++
)
{
uint64_t
offset
=
*
(
uint64_t
*
)
taosArrayGet
(
offsets
,
i
);
ret
=
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
offset
,
tr
->
total
);
if
(
ret
!=
0
)
{
indexError
(
"failed to find target tablelist"
);
return
TSDB_CODE_TDB_FILE_CORRUPTED
;
}
}
else
if
(
qtype
==
QUERY_PREFIX
)
{
// handle later
//
}
else
if
(
qtype
==
QUERY_SUFFIX
)
{
// handle later
}
else
if
(
qtype
==
QUERY_REGEX
)
{
// handle later
}
else
if
(
qtype
==
QUERY_RANGE
)
{
// handle later
}
tfileReaderUnRef
(
reader
);
if
(
hasJson
)
{
taosMemoryFree
(
p
);
}
return
0
;
}
static
int32_t
tfSearchSuffix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
// taosArrayAddAll(tr->total, result);
// taosArrayDestroy(result);
int
ret
=
0
;
char
*
p
=
tem
->
colVal
;
uint64_t
sz
=
tem
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
tem
);
sz
=
strlen
(
p
);
}
int64_t
st
=
taosGetTimestampUs
();
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
/*impl later*/
if
(
hasJson
)
{
taosMemoryFree
(
p
);
}
fstSliceDestroy
(
&
key
);
return
0
;
}
static
int32_t
tfSearchRegex
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
int
ret
=
0
;
char
*
p
=
tem
->
colVal
;
uint64_t
sz
=
tem
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
tem
);
sz
=
strlen
(
p
);
}
int64_t
st
=
taosGetTimestampUs
();
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
/*impl later*/
if
(
hasJson
)
{
taosMemoryFree
(
p
);
}
fstSliceDestroy
(
&
key
);
return
0
;
}
static
int32_t
tfSearchRange
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
int
ret
=
0
;
char
*
p
=
tem
->
colVal
;
uint64_t
sz
=
tem
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
tem
);
sz
=
strlen
(
p
);
}
int64_t
st
=
taosGetTimestampUs
();
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
// uint64_t offset;
// if (fstGet(((TFileReader*)reader)->fst, &key, &offset)) {
// 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",
// tem->suid, tem->colName, tem->colVal, cost);
// ret = tfileReaderLoadTableIds((TFileReader*)reader, 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);
//}
if
(
hasJson
)
{
taosMemoryFree
(
p
);
}
fstSliceDestroy
(
&
key
);
return
0
;
}
return
ret
;
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SIdxTempResult
*
tr
)
{
SIndexTerm
*
term
=
query
->
term
;
EIndexQueryType
qtype
=
query
->
qType
;
if
(
qtype
>=
sizeof
(
tfSearch
)
/
sizeof
(
tfSearch
[
0
]))
{
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, not found table info in tindex"
,
term
->
suid
,
term
->
colName
,
term
->
colVal
);
return
-
1
;
}
else
{
return
tfSearch
[
qtype
](
reader
,
term
,
tr
);
}
tfileReaderUnRef
(
reader
);
return
0
;
}
TFileWriter
*
tfileWriterOpen
(
char
*
path
,
uint64_t
suid
,
int32_t
version
,
const
char
*
colName
,
uint8_t
colType
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录