Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2da90213
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看板
未验证
提交
2da90213
编写于
3月 17, 2022
作者:
H
Haojun Liao
提交者:
GitHub
3月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10792 from taosdata/feature/db_ser
[td-13039] refactor.
上级
ad0cdac4
a77239c1
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
75 addition
and
66 deletion
+75
-66
include/common/tcommon.h
include/common/tcommon.h
+10
-62
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+65
-4
未找到文件。
include/common/tcommon.h
浏览文件 @
2da90213
...
...
@@ -62,18 +62,17 @@ typedef struct SDataBlockInfo {
union
{
int64_t
uid
;
int64_t
blockId
;};
}
SDataBlockInfo
;
typedef
struct
SConstantItem
{
SColumnInfo
info
;
int32_t
startRow
;
// run-length-encoding to save the space for multiple rows
int32_t
endRow
;
SVariant
value
;
}
SConstantItem
;
//
typedef struct SConstantItem {
//
SColumnInfo info;
//
int32_t startRow; // run-length-encoding to save the space for multiple rows
//
int32_t endRow;
//
SVariant value;
//
} SConstantItem;
// info.numOfCols = taosArrayGetSize(pDataBlock) + taosArrayGetSize(pConstantList);
typedef
struct
SSDataBlock
{
SColumnDataAgg
*
pBlockAgg
;
SArray
*
pDataBlock
;
// SArray<SColumnInfoData>
SArray
*
pConstantList
;
// SArray<SConstantItem>, it is a constant/tags value of the corresponding result value.
SDataBlockInfo
info
;
}
SSDataBlock
;
...
...
@@ -95,66 +94,15 @@ typedef struct SColumnInfoData {
};
}
SColumnInfoData
;
static
FORCE_INLINE
int32_t
tEncodeDataBlock
(
void
**
buf
,
const
SSDataBlock
*
pBlock
)
{
int64_t
tbUid
=
pBlock
->
info
.
uid
;
int16_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
int16_t
hasVarCol
=
pBlock
->
info
.
hasVarCol
;
int32_t
rows
=
pBlock
->
info
.
rows
;
int32_t
sz
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
tbUid
);
tlen
+=
taosEncodeFixedI16
(
buf
,
numOfCols
);
tlen
+=
taosEncodeFixedI16
(
buf
,
hasVarCol
);
tlen
+=
taosEncodeFixedI32
(
buf
,
rows
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SColumnInfoData
*
pColData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pColData
->
info
.
colId
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pColData
->
info
.
type
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pColData
->
info
.
bytes
);
int32_t
colSz
=
rows
*
pColData
->
info
.
bytes
;
tlen
+=
taosEncodeBinary
(
buf
,
pColData
->
pData
,
colSz
);
}
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeDataBlock
(
const
void
*
buf
,
SSDataBlock
*
pBlock
)
{
int32_t
sz
;
buf
=
taosDecodeFixedI64
(
buf
,
&
pBlock
->
info
.
uid
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pBlock
->
info
.
numOfCols
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pBlock
->
info
.
hasVarCol
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pBlock
->
info
.
rows
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pBlock
->
pDataBlock
=
taosArrayInit
(
sz
,
sizeof
(
SColumnInfoData
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SColumnInfoData
data
=
{
0
};
buf
=
taosDecodeFixedI16
(
buf
,
&
data
.
info
.
colId
);
buf
=
taosDecodeFixedI16
(
buf
,
&
data
.
info
.
type
);
buf
=
taosDecodeFixedI32
(
buf
,
&
data
.
info
.
bytes
);
int32_t
colSz
=
pBlock
->
info
.
rows
*
data
.
info
.
bytes
;
buf
=
taosDecodeBinary
(
buf
,
(
void
**
)
&
data
.
pData
,
colSz
);
taosArrayPush
(
pBlock
->
pDataBlock
,
&
data
);
}
return
(
void
*
)
buf
;
}
void
*
blockDataDestroy
(
SSDataBlock
*
pBlock
);
int32_t
tEncodeDataBlock
(
void
**
buf
,
const
SSDataBlock
*
pBlock
);
void
*
tDecodeDataBlock
(
const
void
*
buf
,
SSDataBlock
*
pBlock
);
static
FORCE_INLINE
void
tDeleteSSDataBlock
(
SSDataBlock
*
pBlock
)
{
if
(
pBlock
==
NULL
)
{
return
;
}
// int32_t numOfOutput = pBlock->info.numOfCols;
int32_t
sz
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
sz
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
tfree
(
pColInfoData
->
pData
);
}
taosArrayDestroy
(
pBlock
->
pDataBlock
);
tfree
(
pBlock
->
pBlockAgg
);
// tfree(pBlock);
blockDataDestroy
(
pBlock
);
}
static
FORCE_INLINE
int32_t
tEncodeSMqPollRsp
(
void
**
buf
,
const
SMqPollRsp
*
pRsp
)
{
...
...
source/common/src/tdatablock.c
浏览文件 @
2da90213
...
...
@@ -240,10 +240,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, co
}
size_t
blockDataGetNumOfCols
(
const
SSDataBlock
*
pBlock
)
{
ASSERT
(
pBlock
);
size_t
constantCols
=
(
pBlock
->
pConstantList
!=
NULL
)
?
taosArrayGetSize
(
pBlock
->
pConstantList
)
:
0
;
ASSERT
(
pBlock
->
info
.
numOfCols
==
taosArrayGetSize
(
pBlock
->
pDataBlock
)
+
constantCols
);
ASSERT
(
pBlock
&&
pBlock
->
info
.
numOfCols
==
taosArrayGetSize
(
pBlock
->
pDataBlock
));
return
pBlock
->
info
.
numOfCols
;
}
...
...
@@ -1166,3 +1163,67 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
size_t
blockDataGetCapacityInRow
(
const
SSDataBlock
*
pBlock
,
size_t
pageSize
)
{
return
pageSize
/
(
blockDataGetSerialRowSize
(
pBlock
)
+
blockDataGetSerialMetaSize
(
pBlock
));
}
int32_t
tEncodeDataBlock
(
void
**
buf
,
const
SSDataBlock
*
pBlock
)
{
int64_t
tbUid
=
pBlock
->
info
.
uid
;
int16_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
int16_t
hasVarCol
=
pBlock
->
info
.
hasVarCol
;
int32_t
rows
=
pBlock
->
info
.
rows
;
int32_t
sz
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
tbUid
);
tlen
+=
taosEncodeFixedI16
(
buf
,
numOfCols
);
tlen
+=
taosEncodeFixedI16
(
buf
,
hasVarCol
);
tlen
+=
taosEncodeFixedI32
(
buf
,
rows
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SColumnInfoData
*
pColData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pColData
->
info
.
colId
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pColData
->
info
.
type
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pColData
->
info
.
bytes
);
if
(
IS_VAR_DATA_TYPE
(
pColData
->
info
.
type
))
{
tlen
+=
taosEncodeBinary
(
buf
,
pColData
->
varmeta
.
offset
,
sizeof
(
int32_t
)
*
rows
);
}
else
{
tlen
+=
taosEncodeBinary
(
buf
,
pColData
->
nullbitmap
,
BitmapLen
(
rows
));
}
int32_t
len
=
colDataGetLength
(
pColData
,
rows
);
taosEncodeFixedI32
(
buf
,
len
);
tlen
+=
taosEncodeBinary
(
buf
,
pColData
->
pData
,
len
);
}
return
tlen
;
}
void
*
tDecodeDataBlock
(
const
void
*
buf
,
SSDataBlock
*
pBlock
)
{
int32_t
sz
;
buf
=
taosDecodeFixedI64
(
buf
,
&
pBlock
->
info
.
uid
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pBlock
->
info
.
numOfCols
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pBlock
->
info
.
hasVarCol
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pBlock
->
info
.
rows
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pBlock
->
pDataBlock
=
taosArrayInit
(
sz
,
sizeof
(
SColumnInfoData
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SColumnInfoData
data
=
{
0
};
buf
=
taosDecodeFixedI16
(
buf
,
&
data
.
info
.
colId
);
buf
=
taosDecodeFixedI16
(
buf
,
&
data
.
info
.
type
);
buf
=
taosDecodeFixedI32
(
buf
,
&
data
.
info
.
bytes
);
if
(
IS_VAR_DATA_TYPE
(
data
.
info
.
type
))
{
buf
=
taosDecodeBinary
(
buf
,
(
void
**
)
&
data
.
varmeta
.
offset
,
pBlock
->
info
.
rows
*
sizeof
(
int32_t
));
data
.
varmeta
.
length
=
pBlock
->
info
.
rows
*
sizeof
(
int32_t
);
data
.
varmeta
.
allocLen
=
data
.
varmeta
.
length
;
}
else
{
buf
=
taosDecodeBinary
(
buf
,
(
void
**
)
&
data
.
nullbitmap
,
BitmapLen
(
pBlock
->
info
.
rows
));
}
int32_t
len
=
0
;
buf
=
taosDecodeFixedI32
(
buf
,
&
len
);
buf
=
taosDecodeBinary
(
buf
,
(
void
**
)
&
data
.
pData
,
len
);
taosArrayPush
(
pBlock
->
pDataBlock
,
&
data
);
}
return
(
void
*
)
buf
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录