Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e9a1e863
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e9a1e863
编写于
5月 14, 2022
作者:
H
Hongze Cheng
提交者:
GitHub
5月 14, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12464 from taosdata/feat--tag-index
feat: tag index
上级
d3e722fc
f3eaca04
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
100 addition
and
30 deletion
+100
-30
source/common/src/ttypes.c
source/common/src/ttypes.c
+2
-1
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+4
-2
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+25
-23
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+68
-3
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-1
未找到文件。
source/common/src/ttypes.c
浏览文件 @
e9a1e863
...
...
@@ -402,7 +402,8 @@ tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX] = {
{
TSDB_DATA_TYPE_UINT
,
12
,
INT_BYTES
,
"INT UNSIGNED"
,
0
,
UINT32_MAX
,
tsCompressInt
,
tsDecompressInt
,
getStatics_u32
},
{
TSDB_DATA_TYPE_UBIGINT
,
15
,
LONG_BYTES
,
"BIGINT UNSIGNED"
,
0
,
UINT64_MAX
,
tsCompressBigint
,
tsDecompressBigint
,
getStatics_u64
},
{
TSDB_DATA_TYPE_JSON
,
4
,
TSDB_MAX_JSON_TAG_LEN
,
"JSON"
,
0
,
0
,
tsCompressString
,
tsDecompressString
,
getStatics_nchr
},
{
TSDB_DATA_TYPE_JSON
,
4
,
TSDB_MAX_JSON_TAG_LEN
,
"JSON"
,
0
,
0
,
tsCompressString
,
tsDecompressString
,
getStatics_nchr
},
};
char
tTokenTypeSwitcher
[
13
]
=
{
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
e9a1e863
...
...
@@ -96,8 +96,10 @@ typedef struct {
#pragma pack(push, 1)
typedef
struct
{
tb_uid_t
suid
;
int16_t
cid
;
char
data
[];
int32_t
cid
;
uint8_t
isNull
:
1
;
uint8_t
type
:
7
;
uint8_t
data
[];
// val + uid
}
STagIdxKey
;
#pragma pack(pop)
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
e9a1e863
...
...
@@ -227,8 +227,7 @@ static int ctbIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
static
int
tagIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
STagIdxKey
*
pTagIdxKey1
=
(
STagIdxKey
*
)
pKey1
;
STagIdxKey
*
pTagIdxKey2
=
(
STagIdxKey
*
)
pKey2
;
int8_t
*
p1
,
*
p2
;
int8_t
type
;
tb_uid_t
uid1
,
uid2
;
int
c
;
// compare suid
...
...
@@ -245,31 +244,34 @@ static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
return
-
1
;
}
// compare value
p1
=
pTagIdxKey1
->
data
;
p2
=
pTagIdxKey2
->
data
;
ASSERT
(
p1
[
0
]
==
p2
[
0
]);
type
=
p1
[
0
];
ASSERT
(
pTagIdxKey1
->
type
==
pTagIdxKey2
->
type
);
p1
++
;
p2
++
;
c
=
doCompare
(
p1
,
p2
,
type
,
0
);
if
(
c
)
return
c
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
p1
=
p1
+
varDataTLen
(
p1
);
p2
=
p2
+
varDataTLen
(
p2
);
}
else
{
p1
=
p1
+
tDataTypes
[
type
].
bytes
;
p2
=
p2
+
tDataTypes
[
type
].
bytes
;
// check NULL, NULL is always the smallest
if
(
pTagIdxKey1
->
isNull
&&
!
pTagIdxKey2
->
isNull
)
{
return
-
1
;
}
else
if
(
!
pTagIdxKey1
->
isNull
&&
pTagIdxKey2
->
isNull
)
{
return
1
;
}
else
if
(
!
pTagIdxKey1
->
isNull
&&
!
pTagIdxKey2
->
isNull
)
{
// all not NULL, compr tag vals
c
=
doCompare
(
pTagIdxKey1
->
data
,
pTagIdxKey2
->
data
,
pTagIdxKey1
->
type
,
0
);
if
(
c
)
return
c
;
if
(
IS_VAR_DATA_TYPE
(
pTagIdxKey1
->
type
))
{
uid1
=
*
(
tb_uid_t
*
)(
pTagIdxKey1
->
data
+
varDataTLen
(
pTagIdxKey1
->
data
));
uid2
=
*
(
tb_uid_t
*
)(
pTagIdxKey2
->
data
+
varDataTLen
(
pTagIdxKey2
->
data
));
}
else
{
uid1
=
*
(
tb_uid_t
*
)(
pTagIdxKey1
->
data
+
tDataTypes
[
pTagIdxKey1
->
type
].
bytes
);
uid2
=
*
(
tb_uid_t
*
)(
pTagIdxKey2
->
data
+
tDataTypes
[
pTagIdxKey2
->
type
].
bytes
);
}
}
// compare suid
if
(
*
(
tb_uid_t
*
)
p1
>
*
(
tb_uid_t
*
)
p2
)
{
return
1
;
}
else
if
(
*
(
tb_uid_t
*
)
p1
<
*
(
tb_uid_t
*
)
p2
)
{
// compare uid
if
(
uid1
<
uid2
)
{
return
-
1
;
}
else
if
(
uid1
>
uid2
)
{
return
1
;
}
else
{
return
0
;
}
return
0
;
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
e9a1e863
...
...
@@ -22,7 +22,7 @@ static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME);
static
int
metaUpdateTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateCtbIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
p
ME
);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
p
CtbEntry
);
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
SMetaEntry
me
=
{
0
};
...
...
@@ -389,8 +389,73 @@ static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
return
tdbDbInsert
(
pMeta
->
pCtbIdx
,
&
ctbIdxKey
,
sizeof
(
ctbIdxKey
),
NULL
,
0
,
&
pMeta
->
txn
);
}
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
// TODO
static
int
metaCreateTagIdxKey
(
tb_uid_t
suid
,
int32_t
cid
,
const
void
*
pTagData
,
int8_t
type
,
tb_uid_t
uid
,
STagIdxKey
**
ppTagIdxKey
,
int32_t
*
nTagIdxKey
)
{
int32_t
nTagData
=
0
;
if
(
pTagData
)
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
nTagData
=
varDataTLen
(
pTagData
);
}
else
{
nTagData
=
tDataTypes
[
type
].
bytes
;
}
}
*
nTagIdxKey
=
sizeof
(
STagIdxKey
)
+
nTagData
+
sizeof
(
tb_uid_t
);
*
ppTagIdxKey
=
(
STagIdxKey
*
)
taosMemoryMalloc
(
*
nTagIdxKey
);
if
(
*
ppTagIdxKey
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
(
*
ppTagIdxKey
)
->
suid
=
suid
;
(
*
ppTagIdxKey
)
->
cid
=
cid
;
(
*
ppTagIdxKey
)
->
isNull
=
(
pTagData
==
NULL
)
?
1
:
0
;
(
*
ppTagIdxKey
)
->
type
=
type
;
if
(
nTagData
)
memcpy
((
*
ppTagIdxKey
)
->
data
,
pTagData
,
nTagData
);
*
(
tb_uid_t
*
)((
*
ppTagIdxKey
)
->
data
+
nTagData
)
=
uid
;
return
0
;
}
static
void
metaDestroyTagIdxKey
(
STagIdxKey
*
pTagIdxKey
)
{
if
(
pTagIdxKey
)
taosMemoryFree
(
pTagIdxKey
);
}
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
)
{
void
*
pData
=
NULL
;
int
nData
=
0
;
STbDbKey
tbDbKey
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
STagIdxKey
*
pTagIdxKey
=
NULL
;
int32_t
nTagIdxKey
;
const
SSchema
*
pTagColumn
;
// = &stbEntry.stbEntry.schema.pSchema[0];
const
void
*
pTagData
=
NULL
;
//
SDecoder
dc
=
{
0
};
// get super table
tdbDbGet
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
);
tbDbKey
.
uid
=
pCtbEntry
->
ctbEntry
.
suid
;
tbDbKey
.
version
=
*
(
int64_t
*
)
pData
;
tdbDbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pData
,
&
nData
);
tDecoderInit
(
&
dc
,
pData
,
nData
);
metaDecodeEntry
(
&
dc
,
&
stbEntry
);
pTagColumn
=
&
stbEntry
.
stbEntry
.
schemaTag
.
pSchema
[
0
];
pTagData
=
tdGetKVRowValOfCol
((
const
SKVRow
)
pCtbEntry
->
ctbEntry
.
pTags
,
pTagColumn
->
colId
);
// update tag index
if
(
metaCreateTagIdxKey
(
pCtbEntry
->
ctbEntry
.
suid
,
pTagColumn
->
colId
,
pTagData
,
pTagColumn
->
type
,
pCtbEntry
->
uid
,
&
pTagIdxKey
,
&
nTagIdxKey
)
<
0
)
{
return
-
1
;
}
tdbDbInsert
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
NULL
,
0
,
&
pMeta
->
txn
);
metaDestroyTagIdxKey
(
pTagIdxKey
);
tDecoderClear
(
&
dc
);
tdbFree
(
pData
);
return
0
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e9a1e863
...
...
@@ -3844,7 +3844,7 @@ static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SS
if
(
pVal
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_NULL
)
{
// todo
}
else
{
tdAddColToKVRow
(
pBuilder
,
pSchema
->
colId
,
&
(
pVal
->
datum
.
p
),
tdAddColToKVRow
(
pBuilder
,
pSchema
->
colId
,
nodesGetValueFromNode
(
pVal
),
IS_VAR_DATA_TYPE
(
pSchema
->
type
)
?
varDataTLen
(
pVal
->
datum
.
p
)
:
TYPE_BYTES
[
pSchema
->
type
]);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录