Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
74daf8d1
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
提交
74daf8d1
编写于
5月 04, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/dnode
上级
2f42c2e7
d2c7b8a0
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
484 addition
and
371 deletion
+484
-371
include/libs/index/index.h
include/libs/index/index.h
+7
-5
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+20
-17
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+24
-19
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+2
-2
source/libs/executor/src/indexoperator.c
source/libs/executor/src/indexoperator.c
+52
-20
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+120
-149
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+5
-5
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+3
-2
source/libs/index/src/index.c
source/libs/index/src/index.c
+10
-45
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+56
-27
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+152
-47
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+25
-25
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+8
-8
未找到文件。
include/libs/index/index.h
浏览文件 @
74daf8d1
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#define _TD_INDEX_H_
#define _TD_INDEX_H_
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "tarray.h"
#include "tarray.h"
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -41,11 +42,12 @@ typedef enum {
...
@@ -41,11 +42,12 @@ typedef enum {
UPDATE_VALUE
,
// update index column value
UPDATE_VALUE
,
// update index column value
ADD_INDEX
,
// add index on specify column
ADD_INDEX
,
// add index on specify column
DROP_INDEX
,
// drop existed index
DROP_INDEX
,
// drop existed index
DROP_SATBLE
// drop stable
DROP_SATBLE
,
// drop stable
DEFAULT
// query
}
SIndexOperOnColumn
;
}
SIndexOperOnColumn
;
typedef
enum
{
MUST
=
0
,
SHOULD
=
1
,
NOT
=
2
}
EIndexOperatorType
;
typedef
enum
{
MUST
=
0
,
SHOULD
,
NOT
}
EIndexOperatorType
;
typedef
enum
{
QUERY_TERM
=
0
,
QUERY_PREFIX
=
1
,
QUERY_SUFFIX
=
2
,
QUERY_REGEX
=
3
,
QUERY_RANGE
=
4
}
EIndexQueryType
;
typedef
enum
{
QUERY_TERM
=
0
,
QUERY_PREFIX
,
QUERY_SUFFIX
,
QUERY_REGEX
,
QUERY_RANGE
}
EIndexQueryType
;
/*
/*
* create multi query
* create multi query
...
@@ -166,8 +168,8 @@ void indexOptsDestroy(SIndexOpts* opts);
...
@@ -166,8 +168,8 @@ void indexOptsDestroy(SIndexOpts* opts);
* @param:
* @param:
*/
*/
SIndexTerm
*
indexTermCreate
(
int64_t
suid
,
SIndexOperOnColumn
operType
,
uint8_t
colType
,
const
char
*
colNam
e
,
SIndexTerm
*
indexTermCreate
(
int64_t
suid
,
SIndexOperOnColumn
operType
,
int8_t
qType
,
uint8_t
colTyp
e
,
int32_t
nColName
,
const
char
*
colVal
,
int32_t
nColVal
);
const
char
*
colName
,
int32_t
nColName
,
const
char
*
colVal
,
int32_t
nColVal
);
void
indexTermDestroy
(
SIndexTerm
*
p
);
void
indexTermDestroy
(
SIndexTerm
*
p
);
/*
/*
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
74daf8d1
...
@@ -119,6 +119,17 @@ typedef struct SLimit {
...
@@ -119,6 +119,17 @@ typedef struct SLimit {
int64_t
offset
;
int64_t
offset
;
}
SLimit
;
}
SLimit
;
typedef
struct
SFileBlockLoadRecorder
{
uint64_t
totalRows
;
uint64_t
totalCheckedRows
;
uint32_t
totalBlocks
;
uint32_t
loadBlocks
;
uint32_t
loadBlockStatis
;
uint32_t
skipBlocks
;
uint32_t
filterOutBlocks
;
uint64_t
elapsedTime
;
}
SFileBlockLoadRecorder
;
typedef
struct
STaskCostInfo
{
typedef
struct
STaskCostInfo
{
int64_t
created
;
int64_t
created
;
int64_t
start
;
int64_t
start
;
...
@@ -132,14 +143,10 @@ typedef struct STaskCostInfo {
...
@@ -132,14 +143,10 @@ typedef struct STaskCostInfo {
uint64_t
loadDataInCacheSize
;
uint64_t
loadDataInCacheSize
;
uint64_t
loadDataTime
;
uint64_t
loadDataTime
;
uint64_t
totalRows
;
uint64_t
totalCheckedRows
;
SFileBlockLoadRecorder
*
pRecoder
;
uint32_t
totalBlocks
;
uint32_t
loadBlocks
;
uint32_t
loadBlockStatis
;
uint32_t
skipBlocks
;
uint32_t
filterOutBlocks
;
uint64_t
elapsedTime
;
uint64_t
elapsedTime
;
uint64_t
firstStageMergeTime
;
uint64_t
firstStageMergeTime
;
uint64_t
winInfoSize
;
uint64_t
winInfoSize
;
uint64_t
tableInfoSize
;
uint64_t
tableInfoSize
;
...
@@ -268,7 +275,7 @@ typedef struct SOperatorFpSet {
...
@@ -268,7 +275,7 @@ typedef struct SOperatorFpSet {
typedef
struct
SOperatorInfo
{
typedef
struct
SOperatorInfo
{
uint8_t
operatorType
;
uint8_t
operatorType
;
bool
blocking
Optr
;
// block operator or not
bool
blocking
;
// block operator or not
uint8_t
status
;
// denote if current operator is completed
uint8_t
status
;
// denote if current operator is completed
int32_t
numOfOutput
;
// number of columns of the current operator results
int32_t
numOfOutput
;
// number of columns of the current operator results
char
*
name
;
// name, used to show the query execution plan
char
*
name
;
// name, used to show the query execution plan
...
@@ -333,17 +340,14 @@ typedef struct SScanInfo {
...
@@ -333,17 +340,14 @@ typedef struct SScanInfo {
typedef
struct
STableScanInfo
{
typedef
struct
STableScanInfo
{
void
*
dataReader
;
void
*
dataReader
;
SFileBlockLoadRecorder
readRecorder
;
int32_t
numOfBlocks
;
// extract basic running information.
int32_t
numOfSkipped
;
int32_t
numOfBlockStatis
;
int64_t
numOfRows
;
int64_t
numOfRows
;
int64_t
elapsedTime
;
int64_t
elapsedTime
;
int32_t
prevGroupId
;
// previous table group id
//
int32_t prevGroupId; // previous table group id
SScanInfo
scanInfo
;
SScanInfo
scanInfo
;
int32_t
current
;
int32_t
scanTimes
;
SNode
*
pFilterNode
;
// filter
operator info
SNode
*
pFilterNode
;
// filter
info, which is push down by optimizer
SqlFunctionCtx
*
pCtx
;
//
next
operator query context
SqlFunctionCtx
*
pCtx
;
//
which belongs to the direct upstream operator
operator query context
SResultRowInfo
*
pResultRowInfo
;
SResultRowInfo
*
pResultRowInfo
;
int32_t
*
rowCellInfoOffset
;
int32_t
*
rowCellInfoOffset
;
SExprInfo
*
pExpr
;
SExprInfo
*
pExpr
;
...
@@ -397,7 +401,6 @@ typedef struct SSysTableScanInfo {
...
@@ -397,7 +401,6 @@ typedef struct SSysTableScanInfo {
SArray
*
scanCols
;
// SArray<int16_t> scan column id list
SArray
*
scanCols
;
// SArray<int16_t> scan column id list
SName
name
;
SName
name
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
int32_t
capacity
;
int64_t
numOfBlocks
;
// extract basic running information.
int64_t
numOfBlocks
;
// extract basic running information.
SLoadRemoteDataInfo
loadInfo
;
SLoadRemoteDataInfo
loadInfo
;
}
SSysTableScanInfo
;
}
SSysTableScanInfo
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
74daf8d1
...
@@ -132,6 +132,7 @@ void doSetOperatorCompleted(SOperatorInfo* pOperator) {
...
@@ -132,6 +132,7 @@ void doSetOperatorCompleted(SOperatorInfo* pOperator) {
int32_t
operatorDummyOpenFn
(
SOperatorInfo
*
pOperator
)
{
int32_t
operatorDummyOpenFn
(
SOperatorInfo
*
pOperator
)
{
OPTR_SET_OPENED
(
pOperator
);
OPTR_SET_OPENED
(
pOperator
);
pOperator
->
cost
.
openCost
=
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1592,8 +1593,8 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
...
@@ -1592,8 +1593,8 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
STaskCostInfo
*
pCost
=
&
pTaskInfo
->
cost
;
STaskCostInfo
*
pCost
=
&
pTaskInfo
->
cost
;
pCost
->
totalBlocks
+=
1
;
//
pCost->totalBlocks += 1;
pCost
->
totalRows
+=
pBlock
->
info
.
rows
;
//
pCost->totalRows += pBlock->info.rows;
#if 0
#if 0
// Calculate all time windows that are overlapping or contain current data block.
// Calculate all time windows that are overlapping or contain current data block.
// If current data block is contained by all possible time window, do not load current data block.
// If current data block is contained by all possible time window, do not load current data block.
...
@@ -2411,12 +2412,13 @@ void queryCostStatis(SExecTaskInfo* pTaskInfo) {
...
@@ -2411,12 +2412,13 @@ void queryCostStatis(SExecTaskInfo* pTaskInfo) {
//
//
// calculateOperatorProfResults(pQInfo);
// calculateOperatorProfResults(pQInfo);
qDebug
(
"%s :cost summary: elapsed time:%"
PRId64
" us, first merge:%"
PRId64
SFileBlockLoadRecorder
*
pRecorder
=
pSummary
->
pRecoder
;
" us, total blocks:%d, "
if
(
pSummary
->
pRecoder
!=
NULL
)
{
"load block statis:%d, load data block:%d, total rows:%"
PRId64
", check rows:%"
PRId64
,
qDebug
(
"%s :cost summary: elapsed time:%"
PRId64
" us, first merge:%"
PRId64
" us, total blocks:%d, "
GET_TASKID
(
pTaskInfo
),
pSummary
->
elapsedTime
,
pSummary
->
firstStageMergeTime
,
pSummary
->
totalBlocks
,
"load block statis:%d, load data block:%d, total rows:%"
PRId64
", check rows:%"
PRId64
,
pSummary
->
loadBlockStatis
,
pSummary
->
loadBlocks
,
pSummary
->
totalRows
,
pSummary
->
totalCheckedRows
);
GET_TASKID
(
pTaskInfo
),
pSummary
->
elapsedTime
,
pSummary
->
firstStageMergeTime
,
pRecorder
->
totalBlocks
,
//
pRecorder
->
loadBlockStatis
,
pRecorder
->
loadBlocks
,
pRecorder
->
totalRows
,
pRecorder
->
totalCheckedRows
);
}
// qDebug("QInfo:0x%"PRIx64" :cost summary: winResPool size:%.2f Kb, numOfWin:%"PRId64", tableInfoSize:%.2f Kb,
// qDebug("QInfo:0x%"PRIx64" :cost summary: winResPool size:%.2f Kb, numOfWin:%"PRId64", tableInfoSize:%.2f Kb,
// hashTable:%.2f Kb", pQInfo->qId, pSummary->winInfoSize/1024.0,
// hashTable:%.2f Kb", pQInfo->qId, pSummary->winInfoSize/1024.0,
// pSummary->numOfTimeWindows, pSummary->tableInfoSize/1024.0, pSummary->hashSize/1024.0);
// pSummary->numOfTimeWindows, pSummary->tableInfoSize/1024.0, pSummary->hashSize/1024.0);
...
@@ -3282,7 +3284,7 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock
...
@@ -3282,7 +3284,7 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock
pOperator
->
name
=
"ExchangeOperator"
;
pOperator
->
name
=
"ExchangeOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
;
pOperator
->
blocking
Optr
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfOutput
=
pBlock
->
info
.
numOfCols
;
pOperator
->
numOfOutput
=
pBlock
->
info
.
numOfCols
;
...
@@ -3673,7 +3675,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t
...
@@ -3673,7 +3675,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t
pOperator
->
name
=
"SortedMerge"
;
pOperator
->
name
=
"SortedMerge"
;
// pOperator->operatorType = OP_SortedMerge;
// pOperator->operatorType = OP_SortedMerge;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfOutput
=
num
;
pOperator
->
numOfOutput
=
num
;
...
@@ -3756,7 +3758,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
...
@@ -3756,7 +3758,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
pOperator
->
name
=
"SortOperator"
;
pOperator
->
name
=
"SortOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SORT
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SORT
;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
...
@@ -4419,7 +4421,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -4419,7 +4421,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pOperator
->
name
=
"TableAggregate"
;
pOperator
->
name
=
"TableAggregate"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_AGG
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_AGG
;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
...
@@ -4532,7 +4534,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
...
@@ -4532,7 +4534,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
pOperator
->
name
=
"ProjectOperator"
;
pOperator
->
name
=
"ProjectOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PROJECT
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PROJECT
;
pOperator
->
blocking
Optr
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
...
@@ -4615,7 +4617,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
...
@@ -4615,7 +4617,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
}
}
pOperator
->
name
=
"FillOperator"
;
pOperator
->
name
=
"FillOperator"
;
pOperator
->
blocking
Optr
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_FILL
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_FILL
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
pExpr
=
pExpr
;
...
@@ -4861,15 +4863,19 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4861,15 +4863,19 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pScanPhyNode
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pScanPhyNode
->
node
.
pOutputDataBlockDesc
);
SQueryTableDataCond
cond
=
{
0
};
SQueryTableDataCond
cond
=
{
0
};
int32_t
code
=
initQueryTableDataCond
(
&
cond
,
pTableScanNode
);
int32_t
code
=
initQueryTableDataCond
(
&
cond
,
pTableScanNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
return
NULL
;
}
}
SInterval
interval
=
extractIntervalInfo
(
pTableScanNode
);
SInterval
interval
=
extractIntervalInfo
(
pTableScanNode
);
return
createTableScanOperatorInfo
(
pDataReader
,
&
cond
,
numOfCols
,
pTableScanNode
->
dataRequired
,
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pDataReader
,
&
cond
,
numOfCols
,
pTableScanNode
->
dataRequired
,
pTableScanNode
->
scanSeq
,
pColList
,
pResBlock
,
pScanPhyNode
->
node
.
pConditions
,
pTableScanNode
->
scanSeq
,
pColList
,
pResBlock
,
pScanPhyNode
->
node
.
pConditions
,
&
interval
,
pTableScanNode
->
ratio
,
pTaskInfo
);
&
interval
,
pTableScanNode
->
ratio
,
pTaskInfo
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
type
)
{
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pPhyNode
;
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pPhyNode
;
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pExchange
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pExchange
->
node
.
pOutputDataBlockDesc
);
...
@@ -4877,8 +4883,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4877,8 +4883,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
queryId
,
taskId
);
queryId
,
taskId
);
SArray
*
tableIdList
=
extractTableIdList
(
pTableGroupInfo
);
SArray
*
tableIdList
=
extractTableIdList
(
pTableGroupInfo
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pScanPhyNode
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pScanPhyNode
->
node
.
pOutputDataBlockDesc
);
...
@@ -5628,7 +5633,7 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
...
@@ -5628,7 +5633,7 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
pOperator
->
name
=
"JoinOperator"
;
pOperator
->
name
=
"JoinOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_JOIN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_JOIN
;
pOperator
->
blocking
Optr
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfOutput
=
numOfCols
;
pOperator
->
numOfOutput
=
numOfCols
;
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
74daf8d1
...
@@ -353,7 +353,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -353,7 +353,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
pOperator
->
name
=
"GroupbyAggOperator"
;
pOperator
->
name
=
"GroupbyAggOperator"
;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
// pOperator->operatorType = OP_Groupby;
// pOperator->operatorType = OP_Groupby;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
...
@@ -612,7 +612,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -612,7 +612,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo*
}
}
pOperator
->
name
=
"PartitionOperator"
;
pOperator
->
name
=
"PartitionOperator"
;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PARTITION
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PARTITION
;
pInfo
->
binfo
.
pRes
=
pResultBlock
;
pInfo
->
binfo
.
pRes
=
pResultBlock
;
...
...
source/libs/executor/src/indexoperator.c
浏览文件 @
74daf8d1
...
@@ -55,13 +55,27 @@ typedef struct SIFParam {
...
@@ -55,13 +55,27 @@ typedef struct SIFParam {
SArray
*
result
;
SArray
*
result
;
char
*
condValue
;
char
*
condValue
;
uint8_t
colValType
;
col_id_t
colId
;
col_id_t
colId
;
int64_t
suid
;
// add later
int64_t
suid
;
// add later
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
}
SIFParam
;
}
SIFParam
;
static
int32_t
sifGetFuncFromSql
(
EOperatorType
src
,
EIndexQueryType
*
dst
)
{
if
(
src
==
OP_TYPE_GREATER_THAN
||
src
==
OP_TYPE_GREATER_EQUAL
||
src
==
OP_TYPE_LOWER_THAN
||
src
==
OP_TYPE_LOWER_EQUAL
)
{
*
dst
=
QUERY_RANGE
;
}
else
if
(
src
==
OP_TYPE_EQUAL
)
{
*
dst
=
QUERY_TERM
;
}
else
if
(
src
==
OP_TYPE_LIKE
||
src
==
OP_TYPE_MATCH
||
src
==
OP_TYPE_NMATCH
)
{
*
dst
=
QUERY_REGEX
;
}
else
{
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
return
TSDB_CODE_SUCCESS
;
}
typedef
int32_t
(
*
sif_func_t
)(
SIFParam
*
left
,
SIFParam
*
rigth
,
SIFParam
*
output
);
typedef
int32_t
(
*
sif_func_t
)(
SIFParam
*
left
,
SIFParam
*
rigth
,
SIFParam
*
output
);
// construct tag filter operator later
// construct tag filter operator later
static
void
destroyTagFilterOperatorInfo
(
void
*
param
)
{
static
void
destroyTagFilterOperatorInfo
(
void
*
param
)
{
...
@@ -145,10 +159,11 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
...
@@ -145,10 +159,11 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
SColumnNode
*
cn
=
(
SColumnNode
*
)
node
;
SColumnNode
*
cn
=
(
SColumnNode
*
)
node
;
/*only support tag column*/
/*only support tag column*/
SIF_ERR_RET
(
sifValidateColumn
(
cn
));
SIF_ERR_RET
(
sifValidateColumn
(
cn
));
param
->
colId
=
cn
->
colId
;
param
->
colId
=
cn
->
colId
;
param
->
colValType
=
cn
->
node
.
resType
.
type
;
memcpy
(
param
->
dbName
,
cn
->
dbName
,
sizeof
(
cn
->
dbName
));
memcpy
(
param
->
dbName
,
cn
->
dbName
,
sizeof
(
cn
->
dbName
));
memcpy
(
param
->
colName
,
cn
->
colName
,
sizeof
(
cn
->
colName
));
memcpy
(
param
->
colName
,
cn
->
colName
,
sizeof
(
cn
->
colName
));
break
;
break
;
}
}
case
QUERY_NODE_NODE_LIST
:
{
case
QUERY_NODE_NODE_LIST
:
{
...
@@ -231,61 +246,76 @@ static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *outpu
...
@@ -231,61 +246,76 @@ static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *outpu
qError
(
"index-filter not support buildin function"
);
qError
(
"index-filter not support buildin function"
);
return
TSDB_CODE_QRY_INVALID_INPUT
;
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
}
static
int32_t
sifIndex
(
SIFParam
*
left
,
SIFParam
*
right
,
int8_t
operType
,
SIFParam
*
output
)
{
static
int32_t
sifDoIndex
(
SIFParam
*
left
,
SIFParam
*
right
,
int8_t
operType
,
SIFParam
*
output
)
{
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
tm
=
indexTermCreate
(
left
->
suid
,
DEFAULT
,
operType
,
left
->
colValType
,
left
->
colName
,
return
TSDB_CODE_SUCCESS
;
strlen
(
left
->
colName
),
right
->
condValue
,
strlen
(
right
->
condValue
));
if
(
operType
==
OP_TYPE_LOWER_EQUAL
||
operType
==
OP_TYPE_GREATER_EQUAL
||
operType
==
OP_TYPE_GREATER_THAN
||
operType
==
OP_TYPE_LOWER_THAN
)
{
}
if
(
tm
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
SIndexMultiTermQuery
*
mtm
=
indexMultiTermQueryCreate
(
MUST
);
EIndexQueryType
qtype
=
0
;
SIF_ERR_RET
(
sifGetFuncFromSql
(
operType
,
&
qtype
));
indexMultiTermQueryAdd
(
mtm
,
tm
,
qtype
);
int
ret
=
indexSearch
(
NULL
,
mtm
,
output
->
result
);
indexMultiTermQueryDestroy
(
mtm
);
return
ret
;
}
}
static
int32_t
sifLessThanFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
static
int32_t
sifLessThanFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_LOWER_THAN
;
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
)
{
static
int32_t
sifLessEqualFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_LOWER_EQUAL
;
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
)
{
static
int32_t
sifGreaterThanFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_GREATER_THAN
;
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
)
{
static
int32_t
sifGreaterEqualFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_GREATER_EQUAL
;
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
)
{
static
int32_t
sifEqualFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_EQUAL
;
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
)
{
static
int32_t
sifNotEqualFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_NOT_EQUAL
;
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
)
{
static
int32_t
sifInFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_IN
;
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
)
{
static
int32_t
sifNotInFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_NOT_IN
;
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
)
{
static
int32_t
sifLikeFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_LIKE
;
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
)
{
static
int32_t
sifNotLikeFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_NOT_LIKE
;
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
)
{
static
int32_t
sifMatchFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_MATCH
;
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
)
{
static
int32_t
sifNotMatchFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
int
id
=
OP_TYPE_NMATCH
;
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
)
{
static
int32_t
sifDefaultFunc
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
// add more except
// add more except
...
@@ -460,6 +490,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
...
@@ -460,6 +490,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
qError
(
"index-filter failed to taosHashInit"
);
qError
(
"index-filter failed to taosHashInit"
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
}
nodesWalkExprPostOrder
(
pNode
,
sifCalcWalker
,
&
ctx
);
nodesWalkExprPostOrder
(
pNode
,
sifCalcWalker
,
&
ctx
);
SIF_ERR_RET
(
ctx
.
code
);
SIF_ERR_RET
(
ctx
.
code
);
...
@@ -498,6 +529,7 @@ SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
...
@@ -498,6 +529,7 @@ SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
if
(
pFilterNode
==
NULL
)
{
if
(
pFilterNode
==
NULL
)
{
return
SFLT_NOT_INDEX
;
return
SFLT_NOT_INDEX
;
}
}
// impl later
// impl later
return
SFLT_ACCURATE_INDEX
;
return
SFLT_ACCURATE_INDEX
;
}
}
source/libs/executor/src/scanoperator.c
浏览文件 @
74daf8d1
此差异已折叠。
点击以展开。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
74daf8d1
...
@@ -1078,7 +1078,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -1078,7 +1078,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pOperator
->
name
=
"TimeIntervalAggOperator"
;
pOperator
->
name
=
"TimeIntervalAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
...
@@ -1137,7 +1137,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
...
@@ -1137,7 +1137,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
pOperator
->
name
=
"StreamTimeIntervalAggOperator"
;
pOperator
->
name
=
"StreamTimeIntervalAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
...
@@ -1343,7 +1343,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -1343,7 +1343,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pOperator
->
name
=
"TimeSliceOperator"
;
pOperator
->
name
=
"TimeSliceOperator"
;
// pOperator->operatorType = OP_AllTimeWindow;
// pOperator->operatorType = OP_AllTimeWindow;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfOutput
=
numOfCols
;
pOperator
->
numOfOutput
=
numOfCols
;
...
@@ -1385,7 +1385,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
...
@@ -1385,7 +1385,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
pInfo
->
tsSlotId
=
tsSlotId
;
pInfo
->
tsSlotId
=
tsSlotId
;
pOperator
->
name
=
"StateWindowOperator"
;
pOperator
->
name
=
"StateWindowOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfCols
;
pOperator
->
numOfOutput
=
numOfCols
;
...
@@ -1437,7 +1437,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
...
@@ -1437,7 +1437,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
pInfo
->
reptScan
=
false
;
pInfo
->
reptScan
=
false
;
pOperator
->
name
=
"SessionWindowAggOperator"
;
pOperator
->
name
=
"SessionWindowAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
;
pOperator
->
blocking
Optr
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfOutput
=
numOfCols
;
pOperator
->
numOfOutput
=
numOfCols
;
...
...
source/libs/index/inc/indexInt.h
浏览文件 @
74daf8d1
...
@@ -57,7 +57,7 @@ struct SIndex {
...
@@ -57,7 +57,7 @@ struct SIndex {
char
*
path
;
char
*
path
;
SIndexStat
stat
;
SIndexStat
stat
;
TdThreadMutex
mtx
;
TdThreadMutex
mtx
;
};
};
...
@@ -86,6 +86,7 @@ typedef struct SIndexTerm {
...
@@ -86,6 +86,7 @@ typedef struct SIndexTerm {
int32_t
nColName
;
int32_t
nColName
;
char
*
colVal
;
char
*
colVal
;
int32_t
nColVal
;
int32_t
nColVal
;
int8_t
qType
;
// just use for range
}
SIndexTerm
;
}
SIndexTerm
;
typedef
struct
SIndexTermQuery
{
typedef
struct
SIndexTermQuery
{
...
@@ -165,7 +166,7 @@ int32_t indexSerialCacheKey(ICacheKey* key, char* buf);
...
@@ -165,7 +166,7 @@ int32_t indexSerialCacheKey(ICacheKey* key, char* buf);
} while (0)
} while (0)
#define INDEX_TYPE_CONTAIN_EXTERN_TYPE(ty, exTy) (((ty >> 4) & (exTy)) != 0)
#define INDEX_TYPE_CONTAIN_EXTERN_TYPE(ty, exTy) (((ty >> 4) & (exTy)) != 0)
#define INDEX_TYPE_GET_TYPE(ty) (ty & 0x0F)
#define INDEX_TYPE_GET_TYPE(ty)
(ty & 0x0F)
#define INDEX_TYPE_ADD_EXTERN_TYPE(ty, exTy) \
#define INDEX_TYPE_ADD_EXTERN_TYPE(ty, exTy) \
do { \
do { \
uint8_t oldTy = ty; \
uint8_t oldTy = ty; \
...
...
source/libs/index/src/index.c
浏览文件 @
74daf8d1
...
@@ -175,55 +175,19 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
...
@@ -175,55 +175,19 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
return
0
;
return
0
;
}
}
int
indexSearch
(
SIndex
*
index
,
SIndexMultiTermQuery
*
multiQuerys
,
SArray
*
result
)
{
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
#ifdef USE_INVERTED_INDEX
EIndexOperatorType
opera
=
multiQuerys
->
opera
;
// relation of querys
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
);
int
nQuery
=
taosArrayGetSize
(
multiQuerys
->
query
);
for
(
size_t
i
=
0
;
i
<
nQuery
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
nQuery
;
i
++
)
{
SIndexTermQuery
*
q
T
erm
=
taosArrayGet
(
multiQuerys
->
query
,
i
);
SIndexTermQuery
*
q
t
erm
=
taosArrayGet
(
multiQuerys
->
query
,
i
);
SArray
*
t
Resu
lt
=
NULL
;
SArray
*
t
rs
lt
=
NULL
;
indexTermSearch
(
index
,
q
Term
,
&
tResu
lt
);
indexTermSearch
(
index
,
q
term
,
&
trs
lt
);
taosArrayPush
(
i
nterResults
,
(
void
*
)
&
tResu
lt
);
taosArrayPush
(
i
Rslts
,
(
void
*
)
&
trs
lt
);
}
}
indexMergeFinalResults
(
i
nterResu
lts
,
opera
,
result
);
indexMergeFinalResults
(
i
Rs
lts
,
opera
,
result
);
indexInterResultsDestroy
(
i
nterResu
lts
);
indexInterResultsDestroy
(
i
Rs
lts
);
#endif
#endif
return
0
;
return
0
;
...
@@ -280,8 +244,8 @@ int indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EInde
...
@@ -280,8 +244,8 @@ int indexMultiTermQueryAdd(SIndexMultiTermQuery* pQuery, SIndexTerm* term, EInde
return
0
;
return
0
;
}
}
SIndexTerm
*
indexTermCreate
(
int64_t
suid
,
SIndexOperOnColumn
oper
,
uint8_t
colType
,
const
char
*
colNam
e
,
SIndexTerm
*
indexTermCreate
(
int64_t
suid
,
SIndexOperOnColumn
oper
,
int8_t
queryType
,
uint8_t
colTyp
e
,
int32_t
nColName
,
const
char
*
colVal
,
int32_t
nColVal
)
{
const
char
*
colName
,
int32_t
nColName
,
const
char
*
colVal
,
int32_t
nColVal
)
{
SIndexTerm
*
tm
=
(
SIndexTerm
*
)
taosMemoryCalloc
(
1
,
(
sizeof
(
SIndexTerm
)));
SIndexTerm
*
tm
=
(
SIndexTerm
*
)
taosMemoryCalloc
(
1
,
(
sizeof
(
SIndexTerm
)));
if
(
tm
==
NULL
)
{
if
(
tm
==
NULL
)
{
return
NULL
;
return
NULL
;
...
@@ -298,6 +262,7 @@ SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn oper, uint8_t colTy
...
@@ -298,6 +262,7 @@ SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn oper, uint8_t colTy
tm
->
colVal
=
(
char
*
)
taosMemoryCalloc
(
1
,
nColVal
+
1
);
tm
->
colVal
=
(
char
*
)
taosMemoryCalloc
(
1
,
nColVal
+
1
);
memcpy
(
tm
->
colVal
,
colVal
,
nColVal
);
memcpy
(
tm
->
colVal
,
colVal
,
nColVal
);
tm
->
nColVal
=
nColVal
;
tm
->
nColVal
=
nColVal
;
tm
->
qType
=
queryType
;
return
tm
;
return
tm
;
}
}
...
...
source/libs/index/src/indexCache.c
浏览文件 @
74daf8d1
...
@@ -34,9 +34,64 @@ static char* indexCacheTermGet(const void* pData);
...
@@ -34,9 +34,64 @@ static char* indexCacheTermGet(const void* pData);
static
MemTable
*
indexInternalCacheCreate
(
int8_t
type
);
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
void
doMergeWork
(
SSchedMsg
*
msg
);
static
bool
indexCacheIteratorNext
(
Iterate
*
itera
);
static
bool
indexCacheIteratorNext
(
Iterate
*
itera
);
static
int32_t
cacheSearchTerm
(
void
*
cache
,
CacheTerm
*
ct
,
SIdxTempResult
*
tr
,
STermValueType
*
s
)
{
if
(
cache
==
NULL
)
{
return
0
;
}
MemTable
*
mem
=
cache
;
char
*
key
=
indexCacheTermGet
(
ct
);
SSkipListIterator
*
iter
=
tSkipListCreateIterFromVal
(
mem
->
mem
,
key
,
TSDB_DATA_TYPE_BINARY
,
TSDB_ORDER_ASC
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
if
(
node
==
NULL
)
{
break
;
}
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
if
(
0
==
strcmp
(
c
->
colVal
,
ct
->
colVal
))
{
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
{
break
;
}
}
tSkipListDestroyIter
(
iter
);
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
);
static
IterateValue
*
indexCacheIteratorGetValue
(
Iterate
*
iter
);
IndexCache
*
indexCacheCreate
(
SIndex
*
idx
,
uint64_t
suid
,
const
char
*
colName
,
int8_t
type
)
{
IndexCache
*
indexCacheCreate
(
SIndex
*
idx
,
uint64_t
suid
,
const
char
*
colName
,
int8_t
type
)
{
...
@@ -263,33 +318,7 @@ static int indexQueryMem(MemTable* mem, CacheTerm* ct, EIndexQueryType qtype, SI
...
@@ -263,33 +318,7 @@ static int indexQueryMem(MemTable* mem, CacheTerm* ct, EIndexQueryType qtype, SI
if
(
mem
==
NULL
)
{
if
(
mem
==
NULL
)
{
return
0
;
return
0
;
}
}
char
*
key
=
indexCacheTermGet
(
ct
);
return
cacheSearch
[
qtype
](
mem
,
ct
,
tr
,
s
);
SSkipListIterator
*
iter
=
tSkipListCreateIterFromVal
(
mem
->
mem
,
key
,
TSDB_DATA_TYPE_BINARY
,
TSDB_ORDER_ASC
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
if
(
node
!=
NULL
)
{
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
if
(
qtype
==
QUERY_TERM
)
{
if
(
0
==
strcmp
(
c
->
colVal
,
ct
->
colVal
))
{
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
{
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
)
{
int
indexCacheSearch
(
void
*
cache
,
SIndexTermQuery
*
query
,
SIdxTempResult
*
result
,
STermValueType
*
s
)
{
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
74daf8d1
...
@@ -57,6 +57,17 @@ static int tfileCompare(const void* a, const void* b);
...
@@ -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
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
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
);
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
*
tfileCacheCreate
(
const
char
*
path
)
{
TFileCache
*
tcache
=
taosMemoryCalloc
(
1
,
sizeof
(
TFileCache
));
TFileCache
*
tcache
=
taosMemoryCalloc
(
1
,
sizeof
(
TFileCache
));
...
@@ -183,59 +194,153 @@ void tfileReaderDestroy(TFileReader* reader) {
...
@@ -183,59 +194,153 @@ void tfileReaderDestroy(TFileReader* reader) {
writerCtxDestroy
(
reader
->
ctx
,
reader
->
remove
);
writerCtxDestroy
(
reader
->
ctx
,
reader
->
remove
);
taosMemoryFree
(
reader
);
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
)
{
static
int32_t
tfSearchPrefix
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTempResult
*
tr
)
{
SIndexTerm
*
term
=
query
->
term
;
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
tem
->
colType
,
TSDB_DATA_TYPE_JSON
);
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
char
*
p
=
tem
->
colVal
;
EIndexQueryType
qtype
=
query
->
qType
;
uint64_t
sz
=
tem
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
tem
);
sz
=
strlen
(
p
);
}
// SArray* result = taosArrayInit(16, sizeof(uint64_t));
SArray
*
offsets
=
taosArrayInit
(
16
,
sizeof
(
uint64_t
));
int
ret
=
-
1
;
// refactor to callback later
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
p
,
AUTOMATION_PREFIX
);
if
(
qtype
==
QUERY_TERM
)
{
FstStreamBuilder
*
sb
=
fstSearch
(((
TFileReader
*
)
reader
)
->
fst
,
ctx
);
uint64_t
offset
;
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
char
*
p
=
term
->
colVal
;
StreamWithStateResult
*
rt
=
NULL
;
uint64_t
sz
=
term
->
nColVal
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
if
(
hasJson
)
{
taosArrayPush
(
offsets
,
&
(
rt
->
out
.
out
));
p
=
indexPackJsonData
(
term
);
swsResultDestroy
(
rt
);
sz
=
strlen
(
p
);
}
}
streamWithStateDestroy
(
st
);
int64_t
st
=
taosGetTimestampUs
();
fstStreamBuilderDestroy
(
sb
);
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
if
(
fstGet
(
reader
->
fst
,
&
key
,
&
offset
))
{
int32_t
ret
=
0
;
int64_t
et
=
taosGetTimestampUs
();
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
offsets
);
i
++
)
{
int64_t
cost
=
et
-
st
;
uint64_t
offset
=
*
(
uint64_t
*
)
taosArrayGet
(
offsets
,
i
);
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, found table info in tindex, time cost: %"
PRIu64
"us"
,
ret
=
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
offset
,
tr
->
total
);
term
->
suid
,
term
->
colName
,
term
->
colVal
,
cost
);
if
(
ret
!=
0
)
{
indexError
(
"failed to find target tablelist"
);
ret
=
tfileReaderLoadTableIds
(
reader
,
offset
,
tr
->
total
);
return
TSDB_CODE_TDB_FILE_CORRUPTED
;
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
);
}
}
}
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);
int
ret
=
0
;
// taosArrayDestroy(result);
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
)
{
TFileWriter
*
tfileWriterOpen
(
char
*
path
,
uint64_t
suid
,
int32_t
version
,
const
char
*
colName
,
uint8_t
colType
)
{
...
...
source/libs/index/test/indexTests.cc
浏览文件 @
74daf8d1
...
@@ -483,9 +483,9 @@ TEST_F(IndexTFileEnv, test_tfile_write) {
...
@@ -483,9 +483,9 @@ TEST_F(IndexTFileEnv, test_tfile_write) {
std
::
string
colName
(
"voltage"
);
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"ab"
);
std
::
string
colVal
(
"ab"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexTermQuery
query
=
{
term
,
QUERY_TERM
};
SIndexTermQuery
query
=
{
term
,
QUERY_TERM
};
SArray
*
result
=
(
SArray
*
)
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
SArray
*
result
=
(
SArray
*
)
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
fObj
->
Get
(
&
query
,
result
);
fObj
->
Get
(
&
query
,
result
);
...
@@ -557,7 +557,7 @@ TEST_F(IndexCacheEnv, cache_test) {
...
@@ -557,7 +557,7 @@ TEST_F(IndexCacheEnv, cache_test) {
std
::
string
colName
(
"voltage"
);
std
::
string
colName
(
"voltage"
);
{
{
std
::
string
colVal
(
"v1"
);
std
::
string
colVal
(
"v1"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
indexTermDestroy
(
term
);
indexTermDestroy
(
term
);
...
@@ -565,28 +565,28 @@ TEST_F(IndexCacheEnv, cache_test) {
...
@@ -565,28 +565,28 @@ TEST_F(IndexCacheEnv, cache_test) {
}
}
{
{
std
::
string
colVal
(
"v3"
);
std
::
string
colVal
(
"v3"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
indexTermDestroy
(
term
);
indexTermDestroy
(
term
);
}
}
{
{
std
::
string
colVal
(
"v2"
);
std
::
string
colVal
(
"v2"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
indexTermDestroy
(
term
);
indexTermDestroy
(
term
);
}
}
{
{
std
::
string
colVal
(
"v3"
);
std
::
string
colVal
(
"v3"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
indexTermDestroy
(
term
);
indexTermDestroy
(
term
);
}
}
{
{
std
::
string
colVal
(
"v3"
);
std
::
string
colVal
(
"v3"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
indexTermDestroy
(
term
);
indexTermDestroy
(
term
);
...
@@ -595,14 +595,14 @@ TEST_F(IndexCacheEnv, cache_test) {
...
@@ -595,14 +595,14 @@ TEST_F(IndexCacheEnv, cache_test) {
std
::
cout
<<
"--------first----------"
<<
std
::
endl
;
std
::
cout
<<
"--------first----------"
<<
std
::
endl
;
{
{
std
::
string
colVal
(
"v3"
);
std
::
string
colVal
(
"v3"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
coj
->
Put
(
term
,
othColId
,
version
++
,
suid
++
);
coj
->
Put
(
term
,
othColId
,
version
++
,
suid
++
);
indexTermDestroy
(
term
);
indexTermDestroy
(
term
);
}
}
{
{
std
::
string
colVal
(
"v4"
);
std
::
string
colVal
(
"v4"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
coj
->
Put
(
term
,
othColId
,
version
++
,
suid
++
);
coj
->
Put
(
term
,
othColId
,
version
++
,
suid
++
);
indexTermDestroy
(
term
);
indexTermDestroy
(
term
);
...
@@ -613,7 +613,7 @@ TEST_F(IndexCacheEnv, cache_test) {
...
@@ -613,7 +613,7 @@ TEST_F(IndexCacheEnv, cache_test) {
std
::
string
colVal
(
"v4"
);
std
::
string
colVal
(
"v4"
);
for
(
size_t
i
=
0
;
i
<
10
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
10
;
i
++
)
{
colVal
[
colVal
.
size
()
-
1
]
=
'a'
+
i
;
colVal
[
colVal
.
size
()
-
1
]
=
'a'
+
i
;
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
coj
->
Put
(
term
,
colId
,
version
++
,
suid
++
);
indexTermDestroy
(
term
);
indexTermDestroy
(
term
);
...
@@ -623,9 +623,9 @@ TEST_F(IndexCacheEnv, cache_test) {
...
@@ -623,9 +623,9 @@ TEST_F(IndexCacheEnv, cache_test) {
// begin query
// begin query
{
{
std
::
string
colVal
(
"v3"
);
std
::
string
colVal
(
"v3"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexTermQuery
query
=
{
term
,
QUERY_TERM
};
SIndexTermQuery
query
=
{
term
,
QUERY_TERM
};
SArray
*
ret
=
(
SArray
*
)
taosArrayInit
(
4
,
sizeof
(
suid
));
SArray
*
ret
=
(
SArray
*
)
taosArrayInit
(
4
,
sizeof
(
suid
));
STermValueType
valType
;
STermValueType
valType
;
...
@@ -638,9 +638,9 @@ TEST_F(IndexCacheEnv, cache_test) {
...
@@ -638,9 +638,9 @@ TEST_F(IndexCacheEnv, cache_test) {
}
}
{
{
std
::
string
colVal
(
"v2"
);
std
::
string
colVal
(
"v2"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexTermQuery
query
=
{
term
,
QUERY_TERM
};
SIndexTermQuery
query
=
{
term
,
QUERY_TERM
};
SArray
*
ret
=
(
SArray
*
)
taosArrayInit
(
4
,
sizeof
(
suid
));
SArray
*
ret
=
(
SArray
*
)
taosArrayInit
(
4
,
sizeof
(
suid
));
STermValueType
valType
;
STermValueType
valType
;
...
@@ -670,7 +670,7 @@ class IndexObj {
...
@@ -670,7 +670,7 @@ class IndexObj {
return
ret
;
return
ret
;
}
}
void
Del
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
,
uint64_t
uid
)
{
void
Del
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
,
uint64_t
uid
)
{
SIndexTerm
*
term
=
indexTermCreate
(
0
,
DEL_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
DEL_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
...
@@ -679,7 +679,7 @@ class IndexObj {
...
@@ -679,7 +679,7 @@ class IndexObj {
}
}
int
WriteMillonData
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
=
"Hello world"
,
int
WriteMillonData
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
=
"Hello world"
,
size_t
numOfTable
=
100
*
10000
)
{
size_t
numOfTable
=
100
*
10000
)
{
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
...
@@ -701,7 +701,7 @@ class IndexObj {
...
@@ -701,7 +701,7 @@ class IndexObj {
// opt
// opt
tColVal
[
taosRand
()
%
colValSize
]
=
'a'
+
k
%
26
;
tColVal
[
taosRand
()
%
colValSize
]
=
'a'
+
k
%
26
;
}
}
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
tColVal
.
c_str
(),
tColVal
.
size
());
tColVal
.
c_str
(),
tColVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
...
@@ -737,7 +737,7 @@ class IndexObj {
...
@@ -737,7 +737,7 @@ class IndexObj {
int
SearchOne
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
)
{
int
SearchOne
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
)
{
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
indexMultiTermQueryAdd
(
mq
,
term
,
QUERY_TERM
);
indexMultiTermQueryAdd
(
mq
,
term
,
QUERY_TERM
);
...
@@ -759,7 +759,7 @@ class IndexObj {
...
@@ -759,7 +759,7 @@ class IndexObj {
}
}
int
SearchOneTarget
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
,
uint64_t
val
)
{
int
SearchOneTarget
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
,
uint64_t
val
)
{
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
indexMultiTermQueryAdd
(
mq
,
term
,
QUERY_TERM
);
indexMultiTermQueryAdd
(
mq
,
term
,
QUERY_TERM
);
...
@@ -784,7 +784,7 @@ class IndexObj {
...
@@ -784,7 +784,7 @@ class IndexObj {
void
PutOne
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
)
{
void
PutOne
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
)
{
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
Put
(
terms
,
10
);
Put
(
terms
,
10
);
...
@@ -792,7 +792,7 @@ class IndexObj {
...
@@ -792,7 +792,7 @@ class IndexObj {
}
}
void
PutOneTarge
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
,
uint64_t
val
)
{
void
PutOneTarge
(
const
std
::
string
&
colName
,
const
std
::
string
&
colVal
,
uint64_t
val
)
{
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
Put
(
terms
,
val
);
Put
(
terms
,
val
);
...
@@ -832,7 +832,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
...
@@ -832,7 +832,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
{
{
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
...
@@ -847,7 +847,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
...
@@ -847,7 +847,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
size_t
size
=
200
;
size_t
size
=
200
;
std
::
string
colName
(
"tag1"
),
colVal
(
"hello"
);
std
::
string
colName
(
"tag1"
),
colVal
(
"hello"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
...
@@ -862,7 +862,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
...
@@ -862,7 +862,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
size_t
size
=
200
;
size_t
size
=
200
;
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
indexMultiTermAdd
(
terms
,
term
);
...
@@ -877,7 +877,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
...
@@ -877,7 +877,7 @@ TEST_F(IndexEnv2, testIndexOpen) {
{
{
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
std
::
string
colName
(
"tag1"
),
colVal
(
"Hello"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
0
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
indexMultiTermQueryAdd
(
mq
,
term
,
QUERY_TERM
);
indexMultiTermQueryAdd
(
mq
,
term
,
QUERY_TERM
);
...
...
source/libs/index/test/jsonUT.cc
浏览文件 @
74daf8d1
...
@@ -40,7 +40,7 @@ TEST_F(JsonEnv, testWrite) {
...
@@ -40,7 +40,7 @@ TEST_F(JsonEnv, testWrite) {
{
{
std
::
string
colName
(
"test"
);
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
std
::
string
colVal
(
"ab"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
...
@@ -53,7 +53,7 @@ TEST_F(JsonEnv, testWrite) {
...
@@ -53,7 +53,7 @@ TEST_F(JsonEnv, testWrite) {
{
{
std
::
string
colName
(
"voltage"
);
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"ab1"
);
std
::
string
colVal
(
"ab1"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
...
@@ -66,7 +66,7 @@ TEST_F(JsonEnv, testWrite) {
...
@@ -66,7 +66,7 @@ TEST_F(JsonEnv, testWrite) {
{
{
std
::
string
colName
(
"voltage"
);
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"123"
);
std
::
string
colVal
(
"123"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
...
@@ -81,7 +81,7 @@ TEST_F(JsonEnv, testWrite) {
...
@@ -81,7 +81,7 @@ TEST_F(JsonEnv, testWrite) {
std
::
string
colVal
(
"ab"
);
std
::
string
colVal
(
"ab"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
...
@@ -95,7 +95,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
...
@@ -95,7 +95,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
{
{
std
::
string
colName
(
"test"
);
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
std
::
string
colVal
(
"ab"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
...
@@ -110,7 +110,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
...
@@ -110,7 +110,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
colVal
[
i
%
colVal
.
size
()]
=
'0'
+
i
%
128
;
colVal
[
i
%
colVal
.
size
()]
=
'0'
+
i
%
128
;
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
...
@@ -124,7 +124,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
...
@@ -124,7 +124,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
{
{
std
::
string
colName
(
"voltagefdadfa"
);
std
::
string
colName
(
"voltagefdadfa"
);
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
...
@@ -139,7 +139,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
...
@@ -139,7 +139,7 @@ TEST_F(JsonEnv, testWriteMillonData) {
std
::
string
colVal
(
"ab"
);
std
::
string
colVal
(
"ab"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
0
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录