Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5a4b51a9
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5a4b51a9
编写于
6月 25, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix index bug
上级
570b36cb
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
290 addition
and
260 deletion
+290
-260
include/libs/index/index.h
include/libs/index/index.h
+21
-2
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+22
-23
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+66
-69
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+2
-0
source/libs/index/src/index.c
source/libs/index/src/index.c
+51
-2
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+6
-10
source/os/src/osAtomic.c
source/os/src/osAtomic.c
+122
-154
未找到文件。
include/libs/index/index.h
浏览文件 @
5a4b51a9
...
...
@@ -127,7 +127,7 @@ int indexSearch(SIndex* index, SIndexMultiTermQuery* query, SArray* result);
* @parma opt (input, rebuild index opts)
* @return error code
*/
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opt
);
//
int indexRebuild(SIndex* index, SIndexOpts* opt);
/*
* open index
...
...
@@ -185,6 +185,25 @@ SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn operType, uint8_t c
int32_t
nColName
,
const
char
*
colVal
,
int32_t
nColVal
);
void
indexTermDestroy
(
SIndexTerm
*
p
);
/*
* rebuild index
*/
void
indexRebuild
(
SIndexJson
*
idx
,
void
*
iter
);
/*
* check index json status
**/
bool
indexIsRebuild
(
SIndex
*
idx
);
/*
* rebuild index json
*/
void
indexJsonRebuild
(
SIndexJson
*
idx
,
void
*
iter
);
/*
* check index json status
**/
bool
indexJsonIsRebuild
(
SIndexJson
*
idx
);
/*
* init index env
*
...
...
@@ -203,7 +222,7 @@ typedef enum { SFLT_NOT_INDEX, SFLT_COARSE_INDEX, SFLT_ACCURATE_INDEX } SIdxFltS
SIdxFltStatus
idxGetFltStatus
(
SNode
*
pFilterNode
);
int32_t
doFilterTag
(
const
SNode
*
pFilterNode
,
SIndexMetaArg
*
metaArg
,
SArray
*
result
);
int32_t
doFilterTag
(
SNode
*
pFilterNode
,
SIndexMetaArg
*
metaArg
,
SArray
*
result
,
SIdxFltStatus
*
status
);
/*
* destory index env
*
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
5a4b51a9
...
...
@@ -374,22 +374,22 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
int
metaTtlDropTable
(
SMeta
*
pMeta
,
int64_t
ttl
,
SArray
*
tbUids
)
{
metaWLock
(
pMeta
);
int
ret
=
metaTtlSmaller
(
pMeta
,
ttl
,
tbUids
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
metaULock
(
pMeta
);
return
ret
;
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tbUids
);
++
i
)
{
tb_uid_t
*
uid
=
(
tb_uid_t
*
)
taosArrayGet
(
tbUids
,
i
);
metaDropTableByUid
(
pMeta
,
*
uid
,
NULL
);
metaDebug
(
"ttl drop table:%"
PRId64
,
*
uid
);
metaDebug
(
"ttl drop table:%"
PRId64
,
*
uid
);
}
metaULock
(
pMeta
);
return
0
;
}
static
void
metaBuildTtlIdxKey
(
STtlIdxKey
*
ttlKey
,
const
SMetaEntry
*
pME
){
int64_t
ttlDays
;
int64_t
ctime
;
static
void
metaBuildTtlIdxKey
(
STtlIdxKey
*
ttlKey
,
const
SMetaEntry
*
pME
)
{
int64_t
ttlDays
;
int64_t
ctime
;
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
ctime
=
pME
->
ctbEntry
.
ctime
;
ttlDays
=
pME
->
ctbEntry
.
ttlDays
;
...
...
@@ -409,11 +409,10 @@ static void metaBuildTtlIdxKey(STtlIdxKey *ttlKey, const SMetaEntry *pME){
static
int
metaDeleteTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
STtlIdxKey
ttlKey
=
{
0
};
metaBuildTtlIdxKey
(
&
ttlKey
,
pME
);
if
(
ttlKey
.
dtime
==
0
)
return
0
;
if
(
ttlKey
.
dtime
==
0
)
return
0
;
return
tdbTbDelete
(
pMeta
->
pTtlIdx
,
&
ttlKey
,
sizeof
(
ttlKey
),
&
pMeta
->
txn
);
}
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
)
{
void
*
pData
=
NULL
;
int
nData
=
0
;
...
...
@@ -434,7 +433,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
tdbTbDelete
(
pMeta
->
pTbDb
,
&
(
STbDbKey
){.
version
=
version
,
.
uid
=
uid
},
sizeof
(
STbDbKey
),
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pNameIdx
,
e
.
name
,
strlen
(
e
.
name
)
+
1
,
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pMeta
->
txn
);
if
(
e
.
type
!=
TSDB_SUPER_TABLE
)
metaDeleteTtlIdx
(
pMeta
,
&
e
);
if
(
e
.
type
!=
TSDB_SUPER_TABLE
)
metaDeleteTtlIdx
(
pMeta
,
&
e
);
if
(
e
.
type
==
TSDB_CHILD_TABLE
)
{
tdbTbDelete
(
pMeta
->
pCtbIdx
,
&
(
SCtbIdxKey
){.
suid
=
e
.
ctbEntry
.
suid
,
.
uid
=
uid
},
sizeof
(
SCtbIdxKey
),
&
pMeta
->
txn
);
...
...
@@ -757,15 +756,15 @@ _err:
}
static
int
metaUpdateTableOptions
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
void
*
pVal
=
NULL
;
int
nVal
=
0
;
const
void
*
pData
=
NULL
;
int
nData
=
0
;
int
ret
=
0
;
tb_uid_t
uid
;
int64_t
oversion
;
SMetaEntry
entry
=
{
0
};
int
c
=
0
;
void
*
pVal
=
NULL
;
int
nVal
=
0
;
const
void
*
pData
=
NULL
;
int
nData
=
0
;
int
ret
=
0
;
tb_uid_t
uid
;
int64_t
oversion
;
SMetaEntry
entry
=
{
0
};
int
c
=
0
;
// search name index
ret
=
tdbTbGet
(
pMeta
->
pNameIdx
,
pAlterTbReq
->
tbName
,
strlen
(
pAlterTbReq
->
tbName
)
+
1
,
&
pVal
,
&
nVal
);
...
...
@@ -808,22 +807,22 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
metaWLock
(
pMeta
);
// build SMetaEntry
if
(
entry
.
type
==
TSDB_CHILD_TABLE
)
{
if
(
pAlterTbReq
->
updateTTL
)
{
if
(
pAlterTbReq
->
updateTTL
)
{
metaDeleteTtlIdx
(
pMeta
,
&
entry
);
entry
.
ctbEntry
.
ttlDays
=
pAlterTbReq
->
newTTL
;
metaUpdateTtlIdx
(
pMeta
,
&
entry
);
}
if
(
pAlterTbReq
->
newCommentLen
>=
0
)
{
if
(
pAlterTbReq
->
newCommentLen
>=
0
)
{
entry
.
ctbEntry
.
commentLen
=
pAlterTbReq
->
newCommentLen
;
entry
.
ctbEntry
.
comment
=
pAlterTbReq
->
newComment
;
}
}
else
{
if
(
pAlterTbReq
->
updateTTL
)
{
if
(
pAlterTbReq
->
updateTTL
)
{
metaDeleteTtlIdx
(
pMeta
,
&
entry
);
entry
.
ntbEntry
.
ttlDays
=
pAlterTbReq
->
newTTL
;
metaUpdateTtlIdx
(
pMeta
,
&
entry
);
}
if
(
pAlterTbReq
->
newCommentLen
>=
0
)
{
if
(
pAlterTbReq
->
newCommentLen
>=
0
)
{
entry
.
ntbEntry
.
commentLen
=
pAlterTbReq
->
newCommentLen
;
entry
.
ntbEntry
.
comment
=
pAlterTbReq
->
newComment
;
}
...
...
@@ -918,7 +917,7 @@ static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) {
static
int
metaUpdateTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
STtlIdxKey
ttlKey
=
{
0
};
metaBuildTtlIdxKey
(
&
ttlKey
,
pME
);
if
(
ttlKey
.
dtime
==
0
)
return
0
;
if
(
ttlKey
.
dtime
==
0
)
return
0
;
return
tdbTbInsert
(
pMeta
->
pTtlIdx
,
&
ttlKey
,
sizeof
(
ttlKey
),
NULL
,
0
,
&
pMeta
->
txn
);
}
...
...
@@ -976,7 +975,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
SDecoder
dc
=
{
0
};
// get super table
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
)
!=
0
)
{
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
)
!=
0
)
{
return
-
1
;
}
tbDbKey
.
uid
=
pCtbEntry
->
ctbEntry
.
suid
;
...
...
source/libs/executor/src/executil.c
浏览文件 @
5a4b51a9
...
...
@@ -13,10 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "index.h"
#include "function.h"
#include "functionMgt.h"
#include "index.h"
#include "os.h"
#include "tdatablock.h"
#include "thash.h"
#include "tmsg.h"
...
...
@@ -25,45 +25,41 @@
#include "executorimpl.h"
#include "tcompression.h"
void
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
)
{
pResultRowInfo
->
size
=
0
;
void
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
)
{
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
cur
.
pageId
=
-
1
;
}
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
)
{
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
)
{
if
(
pResultRowInfo
==
NULL
)
{
return
;
}
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
// if (pResultRowInfo->pResult[i]) {
// taosMemoryFreeClear(pResultRowInfo->pResult[i]->key);
// }
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
// if (pResultRowInfo->pResult[i]) {
// taosMemoryFreeClear(pResultRowInfo->pResult[i]->key);
// }
}
}
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
// do nothing
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
// do nothing
}
bool
isResultRowClosed
(
SResultRow
*
pRow
)
{
return
(
pRow
->
closed
==
true
);
}
bool
isResultRowClosed
(
SResultRow
*
pRow
)
{
return
(
pRow
->
closed
==
true
);
}
void
closeResultRow
(
SResultRow
*
pResultRow
)
{
pResultRow
->
closed
=
true
;
}
void
closeResultRow
(
SResultRow
*
pResultRow
)
{
pResultRow
->
closed
=
true
;
}
// TODO refactor: use macro
SResultRowEntryInfo
*
getResultEntryInfo
(
const
SResultRow
*
pRow
,
int32_t
index
,
const
int32_t
*
offset
)
{
assert
(
index
>=
0
&&
offset
!=
NULL
);
return
(
SResultRowEntryInfo
*
)((
char
*
)
pRow
->
pEntryInfo
+
offset
[
index
]);
return
(
SResultRowEntryInfo
*
)((
char
*
)
pRow
->
pEntryInfo
+
offset
[
index
]);
}
size_t
getResultRowSize
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
int32_t
rowSize
=
(
numOfOutput
*
sizeof
(
SResultRowEntryInfo
))
+
sizeof
(
SResultRow
);
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
rowSize
+=
pCtx
[
i
].
resDataInfo
.
interBufSize
;
}
...
...
@@ -74,31 +70,29 @@ void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) {
assert
(
pGroupResInfo
!=
NULL
);
taosArrayDestroy
(
pGroupResInfo
->
pRows
);
pGroupResInfo
->
pRows
=
NULL
;
pGroupResInfo
->
index
=
0
;
pGroupResInfo
->
pRows
=
NULL
;
pGroupResInfo
->
index
=
0
;
}
static
int32_t
resultrowComparAsc
(
const
void
*
p1
,
const
void
*
p2
)
{
SResKeyPos
*
pp1
=
*
(
SResKeyPos
**
)
p1
;
SResKeyPos
*
pp2
=
*
(
SResKeyPos
**
)
p2
;
SResKeyPos
*
pp1
=
*
(
SResKeyPos
**
)
p1
;
SResKeyPos
*
pp2
=
*
(
SResKeyPos
**
)
p2
;
if
(
pp1
->
groupId
==
pp2
->
groupId
)
{
int64_t
pts1
=
*
(
int64_t
*
)
pp1
->
key
;
int64_t
pts2
=
*
(
int64_t
*
)
pp2
->
key
;
int64_t
pts1
=
*
(
int64_t
*
)
pp1
->
key
;
int64_t
pts2
=
*
(
int64_t
*
)
pp2
->
key
;
if
(
pts1
==
pts2
)
{
return
0
;
}
else
{
return
pts1
<
pts2
?
-
1
:
1
;
return
pts1
<
pts2
?
-
1
:
1
;
}
}
else
{
return
pp1
->
groupId
<
pp2
->
groupId
?
-
1
:
1
;
return
pp1
->
groupId
<
pp2
->
groupId
?
-
1
:
1
;
}
}
static
int32_t
resultrowComparDesc
(
const
void
*
p1
,
const
void
*
p2
)
{
return
resultrowComparAsc
(
p2
,
p1
);
}
static
int32_t
resultrowComparDesc
(
const
void
*
p1
,
const
void
*
p2
)
{
return
resultrowComparAsc
(
p2
,
p1
);
}
void
initGroupedResultInfo
(
SGroupResInfo
*
pGroupResInfo
,
SHashObj
*
pHashmap
,
int32_t
order
)
{
if
(
pGroupResInfo
->
pRows
!=
NULL
)
{
...
...
@@ -110,20 +104,20 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap, int
pGroupResInfo
->
pRows
=
taosArrayInit
(
10
,
POINTER_BYTES
);
size_t
keyLen
=
0
;
while
((
pData
=
taosHashIterate
(
pHashmap
,
pData
))
!=
NULL
)
{
while
((
pData
=
taosHashIterate
(
pHashmap
,
pData
))
!=
NULL
)
{
void
*
key
=
taosHashGetKey
(
pData
,
&
keyLen
);
SResKeyPos
*
p
=
taosMemoryMalloc
(
keyLen
+
sizeof
(
SResultRowPosition
));
p
->
groupId
=
*
(
uint64_t
*
)
key
;
p
->
pos
=
*
(
SResultRowPosition
*
)
pData
;
p
->
groupId
=
*
(
uint64_t
*
)
key
;
p
->
pos
=
*
(
SResultRowPosition
*
)
pData
;
memcpy
(
p
->
key
,
(
char
*
)
key
+
sizeof
(
uint64_t
),
keyLen
-
sizeof
(
uint64_t
));
taosArrayPush
(
pGroupResInfo
->
pRows
,
&
p
);
}
if
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
)
{
__compar_fn_t
fn
=
(
order
==
TSDB_ORDER_ASC
)
?
resultrowComparAsc
:
resultrowComparDesc
;
__compar_fn_t
fn
=
(
order
==
TSDB_ORDER_ASC
)
?
resultrowComparAsc
:
resultrowComparDesc
;
qsort
(
pGroupResInfo
->
pRows
->
pData
,
taosArrayGetSize
(
pGroupResInfo
->
pRows
),
POINTER_BYTES
,
fn
);
}
...
...
@@ -155,7 +149,7 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo) {
return
0
;
}
return
(
int32_t
)
taosArrayGetSize
(
pGroupResInfo
->
pRows
);
return
(
int32_t
)
taosArrayGetSize
(
pGroupResInfo
->
pRows
);
}
SArray
*
createSortInfo
(
SNodeList
*
pNodeList
)
{
...
...
@@ -189,12 +183,13 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
pBlock
->
info
.
type
=
STREAM_INVALID
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SSlotDescNode
*
pDescNode
=
(
SSlotDescNode
*
)
nodesListGetNode
(
pNode
->
pSlots
,
i
);
// if (!pDescNode->output) { // todo disable it temporarily
// continue;
// }
SSlotDescNode
*
pDescNode
=
(
SSlotDescNode
*
)
nodesListGetNode
(
pNode
->
pSlots
,
i
);
// if (!pDescNode->output) { // todo disable it temporarily
// continue;
// }
SColumnInfoData
idata
=
createColumnInfoData
(
pDescNode
->
dataType
.
type
,
pDescNode
->
dataType
.
bytes
,
pDescNode
->
slotId
);
SColumnInfoData
idata
=
createColumnInfoData
(
pDescNode
->
dataType
.
type
,
pDescNode
->
dataType
.
bytes
,
pDescNode
->
slotId
);
idata
.
info
.
scale
=
pDescNode
->
dataType
.
scale
;
idata
.
info
.
precision
=
pDescNode
->
dataType
.
precision
;
...
...
@@ -206,10 +201,10 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
EDealRes
doTranslateTagExpr
(
SNode
**
pNode
,
void
*
pContext
)
{
SMetaReader
*
mr
=
(
SMetaReader
*
)
pContext
;
if
(
nodeType
(
*
pNode
)
==
QUERY_NODE_COLUMN
)
{
if
(
nodeType
(
*
pNode
)
==
QUERY_NODE_COLUMN
)
{
SColumnNode
*
pSColumnNode
=
*
(
SColumnNode
**
)
pNode
;
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
res
)
{
return
DEAL_RES_ERROR
;
}
...
...
@@ -222,8 +217,8 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) {
const
char
*
p
=
metaGetTableTagVal
(
&
mr
->
me
,
pSColumnNode
->
node
.
resType
.
type
,
&
tagVal
);
if
(
p
==
NULL
)
{
res
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_NULL
;
}
else
if
(
pSColumnNode
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
len
=
((
const
STag
*
)
p
)
->
len
;
}
else
if
(
pSColumnNode
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
len
=
((
const
STag
*
)
p
)
->
len
;
res
->
datum
.
p
=
taosMemoryCalloc
(
len
+
1
,
1
);
memcpy
(
res
->
datum
.
p
,
p
,
len
);
}
else
if
(
IS_VAR_DATA_TYPE
(
pSColumnNode
->
node
.
resType
.
type
))
{
...
...
@@ -235,10 +230,10 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) {
}
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
}
else
if
(
nodeType
(
*
pNode
)
==
QUERY_NODE_FUNCTION
)
{
SFunctionNode
*
pFuncNode
=
*
(
SFunctionNode
**
)
pNode
;
if
(
pFuncNode
->
funcType
==
FUNCTION_TYPE_TBNAME
)
{
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
}
else
if
(
nodeType
(
*
pNode
)
==
QUERY_NODE_FUNCTION
)
{
SFunctionNode
*
pFuncNode
=
*
(
SFunctionNode
**
)
pNode
;
if
(
pFuncNode
->
funcType
==
FUNCTION_TYPE_TBNAME
)
{
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
res
)
{
return
DEAL_RES_ERROR
;
}
...
...
@@ -258,12 +253,12 @@ EDealRes doTranslateTagExpr(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
static
bool
isTableOk
(
STableKeyInfo
*
info
,
SNode
*
pTagCond
,
SMeta
*
metaHandle
)
{
SMetaReader
mr
=
{
0
};
static
bool
isTableOk
(
STableKeyInfo
*
info
,
SNode
*
pTagCond
,
SMeta
*
metaHandle
)
{
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
metaHandle
,
0
);
metaGetTableEntryByUid
(
&
mr
,
info
->
uid
);
SNode
*
pTagCondTmp
=
nodesCloneNode
(
pTagCond
);
SNode
*
pTagCondTmp
=
nodesCloneNode
(
pTagCond
);
nodesRewriteExprPostOrder
(
&
pTagCondTmp
,
doTranslateTagExpr
,
&
mr
);
metaReaderClear
(
&
mr
);
...
...
@@ -276,7 +271,7 @@ static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){
}
ASSERT
(
nodeType
(
pNew
)
==
QUERY_NODE_VALUE
);
SValueNode
*
pValue
=
(
SValueNode
*
)
pNew
;
SValueNode
*
pValue
=
(
SValueNode
*
)
pNew
;
ASSERT
(
pValue
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_BOOL
);
bool
result
=
pValue
->
datum
.
b
;
...
...
@@ -287,12 +282,12 @@ static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){
int32_t
getTableList
(
void
*
metaHandle
,
SScanPhysiNode
*
pScanNode
,
STableListInfo
*
pListInfo
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
pListInfo
->
pTableList
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
if
(
pListInfo
->
pTableList
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
if
(
pListInfo
->
pTableList
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
uint64_t
tableUid
=
pScanNode
->
uid
;
pListInfo
->
suid
=
pScanNode
->
suid
;
SNode
*
pTagCond
=
(
SNode
*
)
pListInfo
->
pTagCond
;
SNode
*
pTagIndexCond
=
(
SNode
*
)
pListInfo
->
pTagIndexCond
;
if
(
pScanNode
->
tableType
==
TSDB_SUPER_TABLE
)
{
...
...
@@ -300,9 +295,12 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
SIndexMetaArg
metaArg
=
{
.
metaEx
=
metaHandle
,
.
idx
=
tsdbGetIdx
(
metaHandle
),
.
ivtIdx
=
tsdbGetIvtIdx
(
metaHandle
),
.
suid
=
tableUid
};
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
uint64_t
));
//code = doFilterTag(pTagIndexCond, &metaArg, res);
code
=
TSDB_CODE_INDEX_REBUILDING
;
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
uint64_t
));
SIdxFltStatus
status
=
SFLT_NOT_INDEX
;
code
=
doFilterTag
(
pTagIndexCond
,
&
metaArg
,
res
,
&
status
);
if
(
code
!=
0
||
status
==
SFLT_NOT_INDEX
)
{
code
=
TSDB_CODE_INDEX_REBUILDING
;
}
if
(
code
==
TSDB_CODE_INDEX_REBUILDING
)
{
code
=
tsdbGetAllTableList
(
metaHandle
,
tableUid
,
pListInfo
->
pTableList
);
}
else
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -323,33 +321,33 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
code
=
tsdbGetAllTableList
(
metaHandle
,
tableUid
,
pListInfo
->
pTableList
);
}
if
(
pTagCond
)
{
if
(
pTagCond
)
{
int32_t
i
=
0
;
while
(
i
<
taosArrayGetSize
(
pListInfo
->
pTableList
))
{
while
(
i
<
taosArrayGetSize
(
pListInfo
->
pTableList
))
{
STableKeyInfo
*
info
=
taosArrayGet
(
pListInfo
->
pTableList
,
i
);
bool
isOk
=
isTableOk
(
info
,
pTagCond
,
metaHandle
);
if
(
!
isOk
)
{
bool
isOk
=
isTableOk
(
info
,
pTagCond
,
metaHandle
);
if
(
!
isOk
)
{
taosArrayRemove
(
pListInfo
->
pTableList
,
i
);
continue
;
}
i
++
;
}
}
}
else
{
// Create one table group.
}
else
{
// Create one table group.
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
tableUid
};
taosArrayPush
(
pListInfo
->
pTableList
,
&
info
);
}
pListInfo
->
pGroupList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
pListInfo
->
pGroupList
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
if
(
pListInfo
->
pGroupList
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
//put into list as default group, remove it if grouping sorting is required later
//
put into list as default group, remove it if grouping sorting is required later
taosArrayPush
(
pListInfo
->
pGroupList
,
&
pListInfo
->
pTableList
);
return
code
;
}
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
)
{
if
(
!
pNodeList
)
{
if
(
!
pNodeList
)
{
return
NULL
;
}
...
...
@@ -378,7 +376,6 @@ SArray* extractPartitionColInfo(SNodeList* pNodeList) {
return
pList
;
}
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
,
SDataBlockDescNode
*
pOutputNodeList
,
int32_t
*
numOfOutputCols
,
int32_t
type
)
{
size_t
numOfCols
=
LIST_LENGTH
(
pNodeList
);
...
...
@@ -394,7 +391,7 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
SColMatchInfo
c
=
{
0
};
c
.
output
=
true
;
c
.
colId
=
pColNode
->
colId
;
c
.
colId
=
pColNode
->
colId
;
c
.
srcSlotId
=
pColNode
->
slotId
;
c
.
matchType
=
type
;
c
.
targetSlotId
=
pNode
->
slotId
;
...
...
@@ -670,8 +667,8 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
}
for
(
int32_t
i
=
1
;
i
<
numOfOutput
;
++
i
)
{
(
*
rowEntryInfoOffset
)[
i
]
=
(
int32_t
)((
*
rowEntryInfoOffset
)[
i
-
1
]
+
sizeof
(
SResultRowEntryInfo
)
+
pFuncCtx
[
i
-
1
].
resDataInfo
.
interBufSize
);
(
*
rowEntryInfoOffset
)[
i
]
=
(
int32_t
)((
*
rowEntryInfoOffset
)[
i
-
1
]
+
sizeof
(
SResultRowEntryInfo
)
+
pFuncCtx
[
i
-
1
].
resDataInfo
.
interBufSize
);
}
setSelectValueColumnInfo
(
pFuncCtx
,
numOfOutput
);
...
...
source/libs/index/inc/indexInt.h
浏览文件 @
5a4b51a9
...
...
@@ -45,6 +45,7 @@ extern "C" {
typedef
enum
{
LT
,
LE
,
GT
,
GE
,
CONTAINS
,
EQ
}
RangeType
;
typedef
enum
{
kTypeValue
,
kTypeDeletion
}
STermValueType
;
typedef
enum
{
kRebuild
,
kFinished
}
SIdxStatus
;
typedef
struct
SIndexStat
{
int32_t
totalAdded
;
//
...
...
@@ -65,6 +66,7 @@ struct SIndex {
char
*
path
;
int8_t
status
;
SIndexStat
stat
;
TdThreadMutex
mtx
;
tsem_t
sem
;
...
...
source/libs/index/src/index.c
浏览文件 @
5a4b51a9
...
...
@@ -39,7 +39,7 @@
#define INDEX_DATA_BIGINT_NULL 0x8000000000000000LL
#define INDEX_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL
#define INDEX_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN
#define INDEX_DATA_FLOAT_NULL 0x7FF00000
// it is an NAN
#define INDEX_DATA_DOUBLE_NULL 0x7FFFFF0000000000LL // an NAN
#define INDEX_DATA_NCHAR_NULL 0xFFFFFFFF
#define INDEX_DATA_BINARY_NULL 0xFF
...
...
@@ -230,7 +230,7 @@ int indexSearch(SIndex* index, SIndexMultiTermQuery* multiQuerys, SArray* result
}
int
indexDelete
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
)
{
return
1
;
}
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opts
)
{
return
0
;
}
//
int indexRebuild(SIndex* index, SIndexOpts* opts) { return 0; }
SIndexOpts
*
indexOptsCreate
()
{
return
NULL
;
}
void
indexOptsDestroy
(
SIndexOpts
*
opts
)
{
return
;
}
...
...
@@ -299,6 +299,7 @@ SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn oper, uint8_t colTy
return
tm
;
}
void
indexTermDestroy
(
SIndexTerm
*
p
)
{
taosMemoryFree
(
p
->
colName
);
taosMemoryFree
(
p
->
colVal
);
...
...
@@ -319,6 +320,54 @@ void indexMultiTermDestroy(SIndexMultiTerm* terms) {
taosArrayDestroy
(
terms
);
}
/*
* rebuild index
*/
static
void
idxSchedRebuildIdx
(
SSchedMsg
*
msg
)
{
// TODO
SIndex
*
idx
=
msg
->
ahandle
;
int8_t
st
=
kFinished
;
atomic_store_8
(
&
idx
->
status
,
st
);
idxReleaseRef
(
idx
->
refId
);
}
void
indexRebuild
(
SIndexJson
*
idx
,
void
*
iter
)
{
// set up rebuild status
int8_t
st
=
kRebuild
;
atomic_store_8
(
&
idx
->
status
,
st
);
// task put into BG thread
SSchedMsg
schedMsg
=
{
0
};
schedMsg
.
fp
=
idxSchedRebuildIdx
;
schedMsg
.
ahandle
=
idx
;
idxAcquireRef
(
idx
->
refId
);
taosScheduleTask
(
indexQhandle
,
&
schedMsg
);
}
/*
* check index json status
**/
bool
indexIsRebuild
(
SIndex
*
idx
)
{
// idx rebuild or not
return
((
SIdxStatus
)
atomic_load_8
(
&
idx
->
status
))
==
kRebuild
?
true
:
false
;
}
/*
* rebuild index
*/
void
indexJsonRebuild
(
SIndexJson
*
idx
,
void
*
iter
)
{
// idx rebuild or not
indexRebuild
(
idx
,
iter
);
}
/*
* check index json status
**/
bool
indexJsonIsRebuild
(
SIndexJson
*
idx
)
{
// load idx rebuild or not
return
((
SIdxStatus
)
atomic_load_8
(
&
idx
->
status
))
==
kRebuild
?
true
:
false
;
}
static
int
idxTermSearch
(
SIndex
*
sIdx
,
SIndexTermQuery
*
query
,
SArray
**
result
)
{
SIndexTerm
*
term
=
query
->
term
;
const
char
*
colName
=
term
->
colName
;
...
...
source/libs/index/src/indexFilter.c
浏览文件 @
5a4b51a9
...
...
@@ -192,7 +192,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
switch
(
nodeType
(
node
))
{
case
QUERY_NODE_VALUE
:
{
SValueNode
*
vn
=
(
SValueNode
*
)
node
;
if
(
vn
->
typeData
==
TSDB_DATA_TYPE_NULL
&&
(
vn
->
literal
==
NULL
||
strlen
(
vn
->
literal
)
==
0
))
{
if
(
vn
->
typeData
==
TSDB_DATA_TYPE_NULL
||
(
vn
->
literal
==
NULL
||
strlen
(
vn
->
literal
)
==
0
))
{
param
->
status
=
SFLT_NOT_INDEX
;
return
0
;
}
...
...
@@ -737,21 +737,20 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) {
SIF_RET
(
code
);
}
int32_t
doFilterTag
(
const
SNode
*
pFilterNode
,
SIndexMetaArg
*
metaArg
,
SArray
*
result
)
{
if
(
pFilterNode
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
int32_t
doFilterTag
(
SNode
*
pFilterNode
,
SIndexMetaArg
*
metaArg
,
SArray
*
result
,
SIdxFltStatus
*
status
)
{
SIdxFltStatus
st
=
idxGetFltStatus
(
pFilterNode
);
if
(
st
==
SFLT_NOT_INDEX
)
{
*
status
=
st
;
return
0
;
}
SFilterInfo
*
filter
=
NULL
;
// todo move to the initialization function
// SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
SArray
*
output
=
taosArrayInit
(
8
,
sizeof
(
uint64_t
));
SIFParam
param
=
{.
arg
=
*
metaArg
,
.
result
=
output
};
SIF_ERR_RET
(
sifCalculate
((
SNode
*
)
pFilterNode
,
&
param
));
taosArrayAddAll
(
result
,
param
.
result
);
// taosArrayAddAll(result, param.result);
sifFreeParam
(
&
param
);
SIF_RET
(
TSDB_CODE_SUCCESS
);
}
...
...
@@ -761,9 +760,6 @@ SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
if
(
pFilterNode
==
NULL
)
{
return
SFLT_NOT_INDEX
;
}
// SFilterInfo *filter = NULL;
// todo move to the initialization function
// SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
SIF_ERR_RET
(
sifGetFltHint
((
SNode
*
)
pFilterNode
,
&
st
));
return
st
;
...
...
source/os/src/osAtomic.c
浏览文件 @
5a4b51a9
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录