Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fb7da7e5
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看板
提交
fb7da7e5
编写于
5月 04, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(index): support index filter
上级
5ed7b44b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
91 addition
and
21 deletion
+91
-21
source/libs/index/inc/indexCache.h
source/libs/index/inc/indexCache.h
+0
-1
source/libs/index/inc/indexFst.h
source/libs/index/inc/indexFst.h
+3
-4
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+1
-0
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+52
-8
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+35
-8
未找到文件。
source/libs/index/inc/indexCache.h
浏览文件 @
fb7da7e5
...
...
@@ -56,7 +56,6 @@ typedef struct CacheTerm {
int8_t
colType
;
SIndexOperOnColumn
operaType
;
int8_t
qType
;
// query type
}
CacheTerm
;
//
...
...
source/libs/index/inc/indexFst.h
浏览文件 @
fb7da7e5
...
...
@@ -52,7 +52,6 @@ typedef struct FstRange {
uint64_t
end
;
}
FstRange
;
typedef
enum
{
GE
,
GT
,
LE
,
LT
}
RangeType
;
typedef
enum
{
OneTransNext
,
OneTrans
,
AnyTrans
,
EmptyFinal
}
State
;
typedef
enum
{
Ordered
,
OutOfOrdered
,
DuplicateKey
}
OrderType
;
...
...
@@ -174,9 +173,9 @@ Output fstStateFinalOutput(FstState* state, uint64_t version, FstSlice* date,
uint64_t
fstStateFindInput
(
FstState
*
state
,
FstNode
*
node
,
uint8_t
b
,
bool
*
null
);
#define FST_STATE_ONE_TRNAS_NEXT(node) (node->state.state == OneTransNext)
#define FST_STATE_ONE_TRNAS(node) (node->state.state == OneTrans)
#define FST_STATE_ANY_TRANS(node) (node->state.state == AnyTrans)
#define FST_STATE_EMPTY_FINAL(node) (node->state.state == EmptyFinal)
#define FST_STATE_ONE_TRNAS(node)
(node->state.state == OneTrans)
#define FST_STATE_ANY_TRANS(node)
(node->state.state == AnyTrans)
#define FST_STATE_EMPTY_FINAL(node)
(node->state.state == EmptyFinal)
typedef
struct
FstLastTransition
{
uint8_t
inp
;
...
...
source/libs/index/inc/indexInt.h
浏览文件 @
fb7da7e5
...
...
@@ -34,6 +34,7 @@
extern
"C"
{
#endif
typedef
enum
{
LT
,
LE
,
GT
,
GE
}
RangeType
;
typedef
enum
{
kTypeValue
,
kTypeDeletion
}
STermValueType
;
typedef
struct
SIndexStat
{
...
...
source/libs/index/src/indexCache.c
浏览文件 @
fb7da7e5
...
...
@@ -43,6 +43,20 @@ static int32_t cacheSearchLessEqual(void* cache, CacheTerm* ct, SIdxTempResult*
static
int32_t
cacheSearchGreaterThan
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchGreaterEqual
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
static
int32_t
cacheSearchRange
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
);
/*comm func of compare, used in (LE/LT/GE/GT compare)*/
static
int32_t
cacheSearchCompareFunc
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
,
RangeType
type
);
typedef
enum
{
MATCH
,
CONTINUE
,
BREAK
}
TExeCond
;
typedef
TExeCond
(
*
_cache_range_compare
)(
void
*
a
,
void
*
b
,
int8_t
type
);
static
TExeCond
tCompareLessThan
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
return
MATCH
;
}
static
TExeCond
tCompareLessEqual
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
return
MATCH
;
}
static
TExeCond
tCompareGreaterThan
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
return
MATCH
;
}
static
TExeCond
tCompareGreaterEqual
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
return
MATCH
;
}
static
TExeCond
(
*
rangeCompare
[])(
void
*
a
,
void
*
b
,
int8_t
type
)
=
{
tCompareLessThan
,
tCompareLessEqual
,
tCompareGreaterThan
,
tCompareGreaterEqual
};
static
int32_t
(
*
cacheSearch
[])(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
=
{
cacheSearchTerm
,
cacheSearchPrefix
,
cacheSearchSuffix
,
cacheSearchRegex
,
cacheSearchLessThan
,
...
...
@@ -93,21 +107,51 @@ static int32_t cacheSearchRegex(void* cache, CacheTerm* ct, SIdxTempResult* tr,
// impl later
return
0
;
}
static
int32_t
cacheSearchCompareFunc
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
,
RangeType
type
)
{
if
(
cache
==
NULL
)
{
return
0
;
}
_cache_range_compare
cmpFn
=
rangeCompare
[
type
];
MemTable
*
mem
=
cache
;
char
*
key
=
indexCacheTermGet
(
ct
);
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
mem
->
mem
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
if
(
node
==
NULL
)
{
break
;
}
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
TExeCond
cond
=
cmpFn
(
c
->
colVal
,
ct
->
colVal
,
ct
->
colType
);
if
(
cond
==
MATCH
)
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
deled
,
tr
->
added
,
c
->
uid
)
// taosArrayPush(result, &c->uid);
*
s
=
kTypeValue
;
}
else
if
(
c
->
operaType
==
DEL_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
added
,
tr
->
deled
,
c
->
uid
)
}
}
else
if
(
cond
==
CONTINUE
)
{
}
else
if
(
cond
==
BREAK
)
{
break
;
}
}
tSkipListDestroyIter
(
iter
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchLessThan
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
return
cacheSearchCompareFunc
(
cache
,
ct
,
tr
,
s
,
LT
);
}
static
int32_t
cacheSearchLessEqual
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
return
cacheSearchCompareFunc
(
cache
,
ct
,
tr
,
s
,
LE
);
}
static
int32_t
cacheSearchGreaterThan
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
return
cacheSearchCompareFunc
(
cache
,
ct
,
tr
,
s
,
GT
);
}
static
int32_t
cacheSearchGreaterEqual
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
return
0
;
return
cacheSearchCompareFunc
(
cache
,
ct
,
tr
,
s
,
GE
);
}
static
int32_t
cacheSearchRange
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
// impl later
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
fb7da7e5
...
...
@@ -70,6 +70,8 @@ static int32_t tfSearchGreaterThan(void* reader, SIndexTerm* tem, SIdxTempResult
static
int32_t
tfSearchGreaterEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
);
static
int32_t
tfSearchRange
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
);
static
int32_t
tfSearchCompareFunc
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
,
RangeType
ctype
);
static
int32_t
(
*
tfSearch
[])(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
=
{
tfSearchTerm
,
tfSearchPrefix
,
tfSearchSuffix
,
tfSearchRegex
,
tfSearchLessThan
,
tfSearchLessEqual
,
tfSearchGreaterThan
,
tfSearchGreaterEqual
,
tfSearchRange
};
...
...
@@ -304,21 +306,46 @@ static int32_t tfSearchRegex(void* reader, SIndexTerm* tem, SIdxTempResult* tr)
fstSliceDestroy
(
&
key
);
return
0
;
}
static
int32_t
tfSearchCompareFunc
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
,
RangeType
type
)
{
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
);
}
SArray
*
offsets
=
taosArrayInit
(
16
,
sizeof
(
uint64_t
));
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
p
,
AUTOMATION_ALWAYS
);
FstStreamBuilder
*
sb
=
fstSearch
(((
TFileReader
*
)
reader
)
->
fst
,
ctx
);
FstSlice
h
=
fstSliceCreate
((
uint8_t
*
)
p
,
sz
);
fstStreamBuilderSetRange
(
sb
,
&
h
,
type
);
fstSliceDestroy
(
&
h
);
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithStateResult
*
rt
=
NULL
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
taosArrayPush
(
offsets
,
&
(
rt
->
out
.
out
));
swsResultDestroy
(
rt
);
}
streamWithStateDestroy
(
st
);
fstStreamBuilderDestroy
(
sb
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tfSearchLessThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
// impl later
return
0
;
return
tfSearchCompareFunc
(
reader
,
tem
,
tr
,
LT
);
}
static
int32_t
tfSearchLessEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
// impl later
return
0
;
return
tfSearchCompareFunc
(
reader
,
tem
,
tr
,
LE
);
}
static
int32_t
tfSearchGreaterThan
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
// impl later
return
0
;
return
tfSearchCompareFunc
(
reader
,
tem
,
tr
,
GT
);
}
static
int32_t
tfSearchGreaterEqual
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
// impl later
return
0
;
return
tfSearchCompareFunc
(
reader
,
tem
,
tr
,
GE
);
}
static
int32_t
tfSearchRange
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录