Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bb2146cd
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看板
提交
bb2146cd
编写于
5月 30, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(query): do some internal refactor.
上级
70927458
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
120 addition
and
110 deletion
+120
-110
include/common/tdatablock.h
include/common/tdatablock.h
+3
-48
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+20
-20
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+95
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+2
-42
未找到文件。
include/common/tdatablock.h
浏览文件 @
bb2146cd
...
...
@@ -227,6 +227,9 @@ int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
);
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
);
const
char
*
blockCompressDecode
(
SSDataBlock
*
pBlock
,
int32_t
numOfCols
,
int32_t
numOfRows
,
const
char
*
pData
);
void
blockDebugShowData
(
const
SArray
*
dataBlocks
);
int32_t
buildSubmitReqFromDataBlock
(
SSubmitReq
**
pReq
,
const
SArray
*
pDataBlocks
,
STSchema
*
pTSchema
,
int32_t
vgId
,
...
...
@@ -246,54 +249,6 @@ static FORCE_INLINE int32_t blockCompressColData(SColumnInfoData* pColRes, int32
colSize
+
COMP_OVERFLOW_BYTES
,
compressed
,
NULL
,
0
);
}
static
FORCE_INLINE
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
)
{
int32_t
*
actualLen
=
(
int32_t
*
)
data
;
data
+=
sizeof
(
int32_t
);
uint64_t
*
groupId
=
(
uint64_t
*
)
data
;
data
+=
sizeof
(
uint64_t
);
int32_t
*
colSizes
=
(
int32_t
*
)
data
;
data
+=
numOfCols
*
sizeof
(
int32_t
);
*
dataLen
=
(
numOfCols
*
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
)
+
sizeof
(
int32_t
));
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
for
(
int32_t
col
=
0
;
col
<
numOfCols
;
++
col
)
{
SColumnInfoData
*
pColRes
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
col
);
// copy the null bitmap
if
(
IS_VAR_DATA_TYPE
(
pColRes
->
info
.
type
))
{
size_t
metaSize
=
numOfRows
*
sizeof
(
int32_t
);
memcpy
(
data
,
pColRes
->
varmeta
.
offset
,
metaSize
);
data
+=
metaSize
;
(
*
dataLen
)
+=
metaSize
;
}
else
{
int32_t
len
=
BitmapLen
(
numOfRows
);
memcpy
(
data
,
pColRes
->
nullbitmap
,
len
);
data
+=
len
;
(
*
dataLen
)
+=
len
;
}
if
(
needCompress
)
{
colSizes
[
col
]
=
blockCompressColData
(
pColRes
,
numOfRows
,
data
,
needCompress
);
data
+=
colSizes
[
col
];
(
*
dataLen
)
+=
colSizes
[
col
];
}
else
{
colSizes
[
col
]
=
colDataGetLength
(
pColRes
,
numOfRows
);
(
*
dataLen
)
+=
colSizes
[
col
];
memmove
(
data
,
pColRes
->
pData
,
colSizes
[
col
]);
data
+=
colSizes
[
col
];
}
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
}
*
actualLen
=
*
dataLen
;
*
groupId
=
pBlock
->
info
.
groupId
;
}
#ifdef __cplusplus
}
#endif
...
...
source/client/test/clientTests.cpp
浏览文件 @
bb2146cd
...
...
@@ -567,6 +567,7 @@ TEST(testCase, insert_test) {
taos_free_result(pRes);
taos_close(pConn);
}
#endif
TEST
(
testCase
,
projection_query_tables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -625,23 +626,23 @@ TEST(testCase, projection_query_tables) {
printf
(
"start to insert next table
\n
"
);
for(int32_t i = 0; i < 1000000; i += 20) {
char sql[1024] = {0};
sprintf(sql,
"insert into tu2 values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)",
i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7,
i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, i + 14,
i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19);
TAOS_RES* p = taos_query(pConn, sql);
if (taos_errno(p) != 0) {
printf("failed to insert data, reason:%s\n", taos_errstr(p));
}
taos_free_result(p);
}
//
for(int32_t i = 0; i < 1000000; i += 20) {
//
char sql[1024] = {0};
//
sprintf(sql,
//
"insert into tu2 values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
//
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
//
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
//
"(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)",
//
i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7,
//
i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, i + 14,
//
i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19);
//
TAOS_RES* p = taos_query(pConn, sql);
//
if (taos_errno(p) != 0) {
//
printf("failed to insert data, reason:%s\n", taos_errstr(p));
//
}
//
//
taos_free_result(p);
//
}
// pRes = taos_query(pConn, "select * from tu");
// if (taos_errno(pRes) != 0) {
...
...
@@ -663,7 +664,7 @@ TEST(testCase, projection_query_tables) {
// taos_free_result(pRes);
taos_close
(
pConn
);
}
#if 0
TEST(testCase, projection_query_stables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
...
...
@@ -692,8 +693,6 @@ TEST(testCase, projection_query_stables) {
taos_close(pConn);
}
#endif
TEST(testCase, agg_query_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
...
...
@@ -734,5 +733,6 @@ TEST(testCase, agg_query_tables) {
taos_free_result(pRes);
taos_close(pConn);
}
#endif
#pragma GCC diagnostic pop
source/common/src/tdatablock.c
浏览文件 @
bb2146cd
...
...
@@ -1764,3 +1764,98 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
ret
->
length
=
htonl
(
ret
->
length
);
return
ret
;
}
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
)
{
int32_t
*
actualLen
=
(
int32_t
*
)
data
;
data
+=
sizeof
(
int32_t
);
uint64_t
*
groupId
=
(
uint64_t
*
)
data
;
data
+=
sizeof
(
uint64_t
);
int32_t
*
colSizes
=
(
int32_t
*
)
data
;
data
+=
numOfCols
*
sizeof
(
int32_t
);
*
dataLen
=
(
numOfCols
*
sizeof
(
int32_t
)
+
sizeof
(
uint64_t
)
+
sizeof
(
int32_t
));
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
for
(
int32_t
col
=
0
;
col
<
numOfCols
;
++
col
)
{
SColumnInfoData
*
pColRes
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
col
);
// copy the null bitmap
if
(
IS_VAR_DATA_TYPE
(
pColRes
->
info
.
type
))
{
size_t
metaSize
=
numOfRows
*
sizeof
(
int32_t
);
memcpy
(
data
,
pColRes
->
varmeta
.
offset
,
metaSize
);
data
+=
metaSize
;
(
*
dataLen
)
+=
metaSize
;
}
else
{
int32_t
len
=
BitmapLen
(
numOfRows
);
memcpy
(
data
,
pColRes
->
nullbitmap
,
len
);
data
+=
len
;
(
*
dataLen
)
+=
len
;
}
if
(
needCompress
)
{
colSizes
[
col
]
=
blockCompressColData
(
pColRes
,
numOfRows
,
data
,
needCompress
);
data
+=
colSizes
[
col
];
(
*
dataLen
)
+=
colSizes
[
col
];
}
else
{
colSizes
[
col
]
=
colDataGetLength
(
pColRes
,
numOfRows
);
(
*
dataLen
)
+=
colSizes
[
col
];
memmove
(
data
,
pColRes
->
pData
,
colSizes
[
col
]);
data
+=
colSizes
[
col
];
}
colSizes
[
col
]
=
htonl
(
colSizes
[
col
]);
}
*
actualLen
=
*
dataLen
;
*
groupId
=
pBlock
->
info
.
groupId
;
}
const
char
*
blockCompressDecode
(
SSDataBlock
*
pBlock
,
int32_t
numOfCols
,
int32_t
numOfRows
,
const
char
*
pData
)
{
blockDataEnsureCapacity
(
pBlock
,
numOfRows
);
const
char
*
pStart
=
pData
;
int32_t
dataLen
=
*
(
int32_t
*
)
pStart
;
pStart
+=
sizeof
(
int32_t
);
pBlock
->
info
.
groupId
=
*
(
uint64_t
*
)
pStart
;
pStart
+=
sizeof
(
uint64_t
);
int32_t
*
colLen
=
(
int32_t
*
)
pStart
;
pStart
+=
sizeof
(
int32_t
)
*
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
colLen
[
i
]
=
htonl
(
colLen
[
i
]);
ASSERT
(
colLen
[
i
]
>=
0
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
pColInfoData
->
varmeta
.
length
=
colLen
[
i
];
pColInfoData
->
varmeta
.
allocLen
=
colLen
[
i
];
memcpy
(
pColInfoData
->
varmeta
.
offset
,
pStart
,
sizeof
(
int32_t
)
*
numOfRows
);
pStart
+=
sizeof
(
int32_t
)
*
numOfRows
;
if
(
colLen
[
i
]
>
0
)
{
pColInfoData
->
pData
=
taosMemoryMalloc
(
colLen
[
i
]);
}
}
else
{
memcpy
(
pColInfoData
->
nullbitmap
,
pStart
,
BitmapLen
(
numOfRows
));
pStart
+=
BitmapLen
(
numOfRows
);
}
if
(
colLen
[
i
]
>
0
)
{
memcpy
(
pColInfoData
->
pData
,
pStart
,
colLen
[
i
]);
}
// TODO
// setting this flag to true temporarily so aggregate function on stable will
// examine NULL value for non-primary key column
pColInfoData
->
hasNull
=
true
;
pStart
+=
colLen
[
i
];
}
ASSERT
(
pStart
-
pData
==
dataLen
);
return
pStart
;
}
\ No newline at end of file
source/libs/executor/src/executorimpl.c
浏览文件 @
bb2146cd
...
...
@@ -356,8 +356,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
if
(
pResultRowInfo
->
cur
.
pageId
!=
-
1
&&
((
pResult
==
NULL
)
||
(
pResult
->
pageId
!=
pResultRowInfo
->
cur
.
pageId
&&
pResult
->
offset
!=
pResultRowInfo
->
cur
.
offset
)))
{
SResultRowPosition
pos
=
pResultRowInfo
->
cur
;
SFilePage
*
pPage
=
getBufPage
(
pResultBuf
,
pos
.
pageId
);
SFilePage
*
pPage
=
getBufPage
(
pResultBuf
,
pos
.
pageId
);
releaseBufPage
(
pResultBuf
,
pPage
);
}
...
...
@@ -2523,46 +2522,7 @@ int32_t setSDataBlockFromFetchRsp(SSDataBlock* pRes, SLoadRemoteDataInfo* pLoadI
int32_t
compLen
,
int32_t
numOfOutput
,
int64_t
startTs
,
uint64_t
*
total
,
SArray
*
pColList
)
{
if
(
pColList
==
NULL
)
{
// data from other sources
blockDataEnsureCapacity
(
pRes
,
numOfRows
);
int32_t
dataLen
=
*
(
int32_t
*
)
pData
;
pData
+=
sizeof
(
int32_t
);
pRes
->
info
.
groupId
=
*
(
uint64_t
*
)
pData
;
pData
+=
sizeof
(
uint64_t
);
int32_t
*
colLen
=
(
int32_t
*
)
pData
;
char
*
pStart
=
pData
+
sizeof
(
int32_t
)
*
numOfOutput
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
colLen
[
i
]
=
htonl
(
colLen
[
i
]);
ASSERT
(
colLen
[
i
]
>=
0
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pRes
->
pDataBlock
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
pColInfoData
->
varmeta
.
length
=
colLen
[
i
];
pColInfoData
->
varmeta
.
allocLen
=
colLen
[
i
];
memcpy
(
pColInfoData
->
varmeta
.
offset
,
pStart
,
sizeof
(
int32_t
)
*
numOfRows
);
pStart
+=
sizeof
(
int32_t
)
*
numOfRows
;
if
(
colLen
[
i
]
>
0
)
{
pColInfoData
->
pData
=
taosMemoryMalloc
(
colLen
[
i
]);
}
}
else
{
memcpy
(
pColInfoData
->
nullbitmap
,
pStart
,
BitmapLen
(
numOfRows
));
pStart
+=
BitmapLen
(
numOfRows
);
}
if
(
colLen
[
i
]
>
0
)
{
memcpy
(
pColInfoData
->
pData
,
pStart
,
colLen
[
i
]);
}
// TODO setting this flag to true temporarily so aggregate function on stable will
// examine NULL value for non-primary key column
pColInfoData
->
hasNull
=
true
;
pStart
+=
colLen
[
i
];
}
blockCompressDecode
(
pRes
,
numOfOutput
,
numOfRows
,
pData
);
}
else
{
// extract data according to pColList
ASSERT
(
numOfOutput
==
taosArrayGetSize
(
pColList
));
char
*
pStart
=
pData
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录