Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d262ca1b
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看板
提交
d262ca1b
编写于
6月 27, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
trow/STSRow: new ts row from array of colvals
上级
80367eb8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
108 addition
and
1 deletion
+108
-1
include/common/trow.h
include/common/trow.h
+1
-0
source/common/src/trow.c
source/common/src/trow.c
+107
-1
未找到文件。
include/common/trow.h
浏览文件 @
d262ca1b
...
@@ -313,6 +313,7 @@ typedef struct {
...
@@ -313,6 +313,7 @@ typedef struct {
void
tdSTSRowIterReset
(
STSRowIter
*
pIter
,
STSRow
*
pRow
);
void
tdSTSRowIterReset
(
STSRowIter
*
pIter
,
STSRow
*
pRow
);
void
tdSTSRowIterInit
(
STSRowIter
*
pIter
,
STSchema
*
pSchema
);
void
tdSTSRowIterInit
(
STSRowIter
*
pIter
,
STSchema
*
pSchema
);
int32_t
tdSTSRowNew
(
SArray
*
pArray
,
STSchema
*
pTSchema
,
STSRow
**
ppRow
);
bool
tdSTSRowGetVal
(
STSRowIter
*
pIter
,
col_id_t
colId
,
col_type_t
colType
,
SCellVal
*
pVal
);
bool
tdSTSRowGetVal
(
STSRowIter
*
pIter
,
col_id_t
colId
,
col_type_t
colType
,
SCellVal
*
pVal
);
bool
tdGetTpRowDataOfCol
(
STSRowIter
*
pIter
,
col_type_t
colType
,
int32_t
offset
,
SCellVal
*
pVal
);
bool
tdGetTpRowDataOfCol
(
STSRowIter
*
pIter
,
col_type_t
colType
,
int32_t
offset
,
SCellVal
*
pVal
);
bool
tdGetKvRowValOfColEx
(
STSRowIter
*
pIter
,
col_id_t
colId
,
col_type_t
colType
,
col_id_t
*
nIdx
,
SCellVal
*
pVal
);
bool
tdGetKvRowValOfColEx
(
STSRowIter
*
pIter
,
col_id_t
colId
,
col_type_t
colType
,
col_id_t
*
nIdx
,
SCellVal
*
pVal
);
...
...
source/common/src/trow.c
浏览文件 @
d262ca1b
...
@@ -1204,6 +1204,112 @@ static FORCE_INLINE int32_t compareKvRowColId(const void *key1, const void *key2
...
@@ -1204,6 +1204,112 @@ static FORCE_INLINE int32_t compareKvRowColId(const void *key1, const void *key2
}
}
}
}
int32_t
tdSTSRowNew
(
SArray
*
pArray
,
STSchema
*
pTSchema
,
STSRow
**
ppRow
)
{
STColumn
*
pTColumn
;
SColVal
*
pColVal
;
int32_t
nColVal
=
taosArrayGetSize
(
pArray
);
int32_t
varDataLen
=
0
;
int32_t
maxVarDataLen
=
0
;
int32_t
iColVal
=
0
;
void
*
varBuf
=
NULL
;
ASSERT
(
nColVal
>
1
);
for
(
int32_t
iColumn
=
0
;
iColumn
<
pTSchema
->
numOfCols
;
++
iColumn
)
{
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
if
(
iColVal
<
nColVal
)
{
pColVal
=
(
SColVal
*
)
taosArrayGet
(
pArray
,
iColVal
);
}
else
{
pColVal
=
NULL
;
}
if
(
iColumn
==
0
)
{
ASSERT
(
pColVal
->
cid
==
pTColumn
->
colId
);
ASSERT
(
pTColumn
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
ASSERT
(
pTColumn
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
);
}
else
{
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
if
(
pColVal
)
{
varDataLen
+=
(
pColVal
->
value
.
nData
+
sizeof
(
VarDataLenT
));
if
(
maxVarDataLen
<
pColVal
->
value
.
nData
)
{
maxVarDataLen
=
pColVal
->
value
.
nData
;
}
}
else
{
varDataLen
+=
sizeof
(
VarDataLenT
);
if
(
pTColumn
->
type
==
TSDB_DATA_TYPE_VARCHAR
)
{
varDataLen
+=
CHAR_BYTES
;
if
(
maxVarDataLen
<
CHAR_BYTES
)
{
maxVarDataLen
=
CHAR_BYTES
;
}
}
else
{
varDataLen
+=
INT_BYTES
;
if
(
maxVarDataLen
<
INT_BYTES
)
{
maxVarDataLen
=
INT_BYTES
;
}
}
}
}
}
++
iColVal
;
}
*
ppRow
=
(
STSRow
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STSRow
)
+
pTSchema
->
flen
+
varDataLen
+
TD_BITMAP_BYTES
(
pTSchema
->
numOfCols
-
1
));
if
(
!
(
*
ppRow
))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
maxVarDataLen
>
0
)
{
varBuf
=
taosMemoryMalloc
(
maxVarDataLen
+
sizeof
(
VarDataLenT
));
if
(
!
varBuf
)
{
taosMemoryFreeClear
(
*
ppRow
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
SRowBuilder
rb
=
{
0
};
tdSRowInit
(
&
rb
,
pTSchema
->
version
);
tdSRowSetInfo
(
&
rb
,
pTSchema
->
numOfCols
,
pTSchema
->
numOfCols
,
pTSchema
->
flen
);
tdSRowResetBuf
(
&
rb
,
*
ppRow
);
iColVal
=
0
;
for
(
int32_t
iColumn
=
0
;
iColumn
<
pTSchema
->
numOfCols
;
++
iColumn
)
{
pTColumn
=
&
pTSchema
->
columns
[
iColumn
];
TDRowValT
valType
=
TD_VTYPE_NORM
;
const
void
*
val
=
NULL
;
if
(
iColVal
<
nColVal
)
{
pColVal
=
(
SColVal
*
)
taosArrayGet
(
pArray
,
iColVal
);
if
(
pColVal
->
isNone
)
{
valType
=
TD_VTYPE_NONE
;
}
else
if
(
pColVal
->
isNull
)
{
valType
=
TD_VTYPE_NULL
;
}
else
if
(
IS_VAR_DATA_TYPE
(
pTColumn
->
type
))
{
varDataSetLen
(
varBuf
,
pColVal
->
value
.
nData
);
memcpy
(
varDataVal
(
varBuf
),
pColVal
->
value
.
pData
,
pColVal
->
value
.
nData
);
val
=
varBuf
;
}
else
{
val
=
(
const
void
*
)
&
pColVal
->
value
.
i64
;
}
}
else
{
pColVal
=
NULL
;
valType
=
TD_VTYPE_NONE
;
}
tdAppendColValToRow
(
&
rb
,
pTColumn
->
colId
,
pTColumn
->
type
,
valType
,
val
,
true
,
pTColumn
->
offset
,
iColVal
);
++
iColVal
;
}
taosMemoryFreeClear
(
varBuf
);
return
0
;
}
bool
tdSTSRowGetVal
(
STSRowIter
*
pIter
,
col_id_t
colId
,
col_type_t
colType
,
SCellVal
*
pVal
)
{
bool
tdSTSRowGetVal
(
STSRowIter
*
pIter
,
col_id_t
colId
,
col_type_t
colType
,
SCellVal
*
pVal
)
{
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
pVal
->
val
=
&
pIter
->
pRow
->
ts
;
pVal
->
val
=
&
pIter
->
pRow
->
ts
;
...
@@ -1888,4 +1994,4 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
...
@@ -1888,4 +1994,4 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
*
pColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
value
);
*
pColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
value
);
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录