Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN产品汪
TDengine
提交
d0e32fbd
T
TDengine
项目概览
CSDN产品汪
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d0e32fbd
编写于
3月 06, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add more code
上级
7d66dbc4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
105 addition
and
57 deletion
+105
-57
src/vnode/common/inc/dataformat.h
src/vnode/common/inc/dataformat.h
+27
-21
src/vnode/common/inc/key.h
src/vnode/common/inc/key.h
+0
-10
src/vnode/common/inc/list.h
src/vnode/common/inc/list.h
+0
-20
src/vnode/common/src/dataformat.c
src/vnode/common/src/dataformat.c
+78
-6
未找到文件。
src/vnode/common/inc/dataformat.h
浏览文件 @
d0e32fbd
...
...
@@ -12,7 +12,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if
!defined(_TD_DATA_FORMAT_H_)
#if
ndef _TD_DATA_FORMAT_H_
#define _TD_DATA_FORMAT_H_
#include <stdint.h>
...
...
@@ -24,14 +24,26 @@ extern "C" {
#endif
// ----------------- Data row structure
/* A data row, the format
of it
is like below:
/* A data row, the format is like below:
* +---------+---------------------------------+
* | int32_t | |
* +---------+---------------------------------+
* | len |
data
|
* | len |
row
|
* +---------+---------------------------------+
* len: the length including sizeof(row) + sizeof(len)
* row: actual row data encoding
*/
typedef
char
*
SDataRow
;
typedef
void
*
SDataRow
;
#define dataRowLen(r) (*(int32_t *)(r))
#define dataRowTuple(r) ((char *)(r) + sizeof(int32_t))
#define dataRowSetLen(r, l) (dataRowLen(r) = (l))
#define dataRowIdx(r, i) ((char *)(r) + i)
SDataRow
tdNewDataRow
(
int32_t
bytes
);
SDataRow
tdNewDdataFromSchema
(
SSchema
*
pSchema
);
void
tdFreeDataRow
(
SDataRow
row
);
int32_t
tdAppendColVal
(
SDataRow
row
,
void
*
value
,
SColumn
*
pCol
,
int32_t
suffixOffset
);
/* Data rows definition, the format of it is like below:
* +---------+---------+-----------------------+--------+-----------------------+
...
...
@@ -40,7 +52,7 @@ typedef char* SDataRow;
* | len | nrows | SDataRow | .... | SDataRow |
* +---------+---------+-----------------------+--------+-----------------------+
*/
typedef
char
*
SDataRows
;
typedef
void
*
SDataRows
;
/* Data column definition
* +---------+---------+-----------------------+
...
...
@@ -49,7 +61,7 @@ typedef char * SDataRows;
* | len | npoints | data |
* +---------+---------+-----------------------+
*/
typedef
char
*
SDataCol
;
typedef
char
*
SDataCol
;
/* Data columns definition
* +---------+---------+-----------------------+--------+-----------------------+
...
...
@@ -58,24 +70,24 @@ typedef char * SDataCol;
* | len | npoints | SDataCol | .... | SDataCol |
* +---------+---------+-----------------------+--------+-----------------------+
*/
typedef
char
*
SDataCols
;
typedef
char
*
SDataCols
;
typedef
struct
{
int32_t
rowCounter
;
int32_t
totalRows
;
SDataRow
row
;
int32_t
rowCounter
;
int32_t
totalRows
;
SDataRow
row
;
}
SDataRowsIter
;
// ----------------- Data column structure
// ---- operation on SDataRow;
#define TD_DATA_ROW_HEADER_SIZE
sizeof(int32_t)
#define TD_DATA_ROW_HEADER_SIZE sizeof(int32_t)
#define TD_DATAROW_LEN(pDataRow) (*(int32_t *)(pDataRow))
#define TD_DATAROW_DATA(pDataRow) ((pDataRow) + sizeof(int32_t))
SDataRow
tdSDataRowDup
(
SDataRow
rdata
);
void
tdSDataRowCpy
(
SDataRow
src
,
void
*
dst
);
void
tdFreeSDataRow
(
SDataRow
rdata
);
void
tdSDataRowCpy
(
SDataRow
src
,
void
*
dst
);
void
tdFreeSDataRow
(
SDataRow
rdata
);
// ---- operation on SDataRows
#define TD_DATAROWS_LEN(pDataRows) (*(int32_t *)(pDataRows))
...
...
@@ -91,18 +103,12 @@ void tdFreeSDataRow(SDataRow rdata);
#define TD_DATACOLS_NPOINTS(pDataCols) (*(int32_t *)(pDataCols + sizeof(int32_t)))
// ---- operation on SDataRowIter
int32_t
tdInitSDataRowsIter
(
SDataRows
rows
,
SDataRowsIter
*
pIter
);
void
tdInitSDataRowsIter
(
SDataRows
rows
,
SDataRowsIter
*
pIter
);
int32_t
tdRdataIterEnd
(
SDataRowsIter
*
pIter
);
void
tdRdataIterNext
(
SDataRowsIter
*
pIter
);
// ----
/**
* Get the maximum
*/
int32_t
tdGetMaxDataRowSize
(
SSchema
*
pSchema
);
#ifdef __cplusplus
}
#endif
#endif // _TD_DATA_FORMAT_H_
#endif
// _TD_DATA_FORMAT_H_
src/vnode/common/inc/key.h
已删除
100644 → 0
浏览文件 @
7d66dbc4
#if !defined(_TD_KEY_H_)
#define _TD_KEY_H_
typedef
struct
{
}
key
;
#endif // _TD_KEY_H_
src/vnode/common/inc/list.h
已删除
100644 → 0
浏览文件 @
7d66dbc4
#if !defined(_TD_LIST_H_)
#define _TD_LIST_H_
#include <stdint.h>
typedef
enum
{
TD_LIST_ORDERED
,
TD_LIST_UNORDERED
}
TLIST_TYPE
;
typedef
int32_t
(
*
comparefn
(
void
*
key1
,
void
*
key2
));
struct
_list_type
{
TLIST_TYPE
type
;
};
typedef
struct
_list_node
{
}
SListNode
;
typedef
struct
_list
{
}
SList
;
#endif // _TD_LIST_H_
src/vnode/common/src/dataformat.c
浏览文件 @
d0e32fbd
...
...
@@ -2,7 +2,82 @@
#include "dataformat.h"
int32_t
tdGetMaxDataRowSize
(
SSchema
*
pSchema
)
{
static
int32_t
tdGetMaxDataRowSize
(
SSchema
*
pSchema
);
/**
* Create a data row with maximum row length bytes.
*
* NOTE: THE AAPLICATION SHOULD MAKE SURE BYTES IS LARGE ENOUGH TO
* HOLD THE WHOE ROW.
*
* @param bytes max bytes a row can take
* @return SDataRow object for success
* NULL for failure
*/
SDataRow
tdNewDataRow
(
int32_t
bytes
)
{
int32_t
size
=
sizeof
(
int32_t
)
+
bytes
;
SDataRow
row
=
malloc
(
size
);
if
(
row
==
NULL
)
return
NULL
;
dataRowSetLen
(
row
,
sizeof
(
int32_t
));
return
row
;
}
SDataRow
tdNewDdataFromSchema
(
SSchema
*
pSchema
)
{
int32_t
bytes
=
tdGetMaxDataRowSize
(
pSchema
);
return
tdNewDataRow
(
bytes
);
}
/**
* Free the SDataRow object
*/
void
tdFreeDataRow
(
SDataRow
row
)
{
if
(
row
)
free
(
row
);
}
/**
* Append a column value to a SDataRow object.
* NOTE: THE APPLICATION SHOULD MAKE SURE VALID PARAMETERS. THE FUNCTION ASSUMES
* THE ROW OBJECT HAS ENOUGH SPACE TO HOLD THE VALUE.
*
* @param row the row to append value to
* @param value value pointer to append
* @param pSchema schema
* @param colIdx column index
*
* @return 0 for success and -1 for failure
*/
int32_t
tdAppendColVal
(
SDataRow
row
,
void
*
value
,
SColumn
*
pCol
,
int32_t
suffixOffset
)
{
int32_t
offset
;
switch
(
pCol
->
type
)
{
case
TD_DATATYPE_BOOL
:
case
TD_DATATYPE_TINYINT
:
case
TD_DATATYPE_SMALLINT
:
case
TD_DATATYPE_INT
:
case
TD_DATATYPE_BIGINT
:
case
TD_DATATYPE_FLOAT
:
case
TD_DATATYPE_DOUBLE
:
memcpy
(
dataRowIdx
(
row
,
pCol
->
offset
+
sizeof
(
int32_t
)),
value
,
rowDataLen
[
pCol
->
type
]);
if
(
dataRowLen
(
row
)
>
suffixOffset
+
sizeof
(
int32_t
))
dataRowSetLen
(
row
,
dataRowLen
(
row
)
+
rowDataLen
[
pCol
->
type
]);
break
;
case
TD_DATATYPE_VARCHAR
:
offset
=
dataRowLen
(
row
)
>
suffixOffset
?
dataRowLen
(
row
)
:
suffixOffset
;
memcpy
(
dataRowIdx
(
row
,
pCol
->
offset
+
sizeof
(
int32_t
)),
(
void
*
)(
&
offset
),
sizeof
(
offset
));
case
TD_DATATYPE_NCHAR
:
case
TD_DATATYPE_BINARY
:
break
;
default:
return
-
1
;
}
return
0
;
}
static
int32_t
tdGetMaxDataRowSize
(
SSchema
*
pSchema
)
{
int32_t
nbytes
=
0
;
for
(
int32_t
i
=
0
;
i
<
TD_SCHEMA_NCOLS
(
pSchema
);
i
++
)
{
...
...
@@ -37,7 +112,7 @@ void tdFreeSDataRow(SDataRow rdata) {
free
(
rdata
);
}
int32_t
tdInitSDataRowsIter
(
SDataRows
rows
,
SDataRowsIter
*
pIter
)
{
void
tdInitSDataRowsIter
(
SDataRows
rows
,
SDataRowsIter
*
pIter
)
{
pIter
->
totalRows
=
TD_DATAROWS_ROWS
(
rows
);
pIter
->
rowCounter
=
1
;
pIter
->
row
=
TD_DATAROWS_DATA
(
rows
);
...
...
@@ -48,10 +123,7 @@ void tdRdataIterNext(SDataRowsIter *pIter) {
pIter
->
row
=
pIter
->
row
+
TD_DATAROW_LEN
(
pIter
->
row
);
}
int32_t
tdRdataIterEnd
(
SDataRowsIter
*
pIter
)
{
return
pIter
->
rowCounter
>=
pIter
->
totalRows
;
}
int32_t
tdRdataIterEnd
(
SDataRowsIter
*
pIter
)
{
return
pIter
->
rowCounter
>=
pIter
->
totalRows
;
}
/**
* Copy it
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录