Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
b01e8b8d
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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,发现更多精彩内容 >>
提交
b01e8b8d
编写于
3月 25, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-34
上级
1579f285
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
88 addition
and
11 deletion
+88
-11
src/common/inc/dataformat.h
src/common/inc/dataformat.h
+17
-3
src/common/src/dataformat.c
src/common/src/dataformat.c
+46
-5
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+25
-3
未找到文件。
src/common/inc/dataformat.h
浏览文件 @
b01e8b8d
...
...
@@ -105,11 +105,25 @@ SDataRow tdDataRowDup(SDataRow row);
// ----------------- Data column structure
typedef
struct
SDataCol
{
int
64
_t
len
;
char
data
[]
;
int
32
_t
len
;
void
*
pData
;
}
SDataCol
;
void
tdConvertDataRowToCol
(
SDataCol
*
cols
,
STSchema
*
pSchema
,
int
*
iter
);
typedef
struct
{
TSKEY
firstKey
;
TSKEY
lastKey
;
int
numOfPoints
;
int
numOfCols
;
void
*
buf
;
SDataCol
cols
[];
}
SDataCols
;
#define keyCol(cols) (&((cols)->cols[0])) // Key column
SDataCols
*
tdNewDataCols
(
STSchema
*
pSchema
,
int
nRows
);
void
tdFreeDataCols
(
SDataCols
*
pCols
);
void
tdResetDataCols
(
SDataCols
*
pCols
);
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
SDataCols
*
pCols
,
STSchema
*
pSchema
);
#ifdef __cplusplus
}
...
...
src/common/src/dataformat.c
浏览文件 @
b01e8b8d
...
...
@@ -294,14 +294,55 @@ SDataRow tdDataRowDup(SDataRow row) {
return
trow
;
}
void
tdConvertDataRowToCol
(
SDataCol
*
cols
,
STSchema
*
pSchema
,
int
*
iter
)
{
int
row
=
*
iter
;
SDataCols
*
tdNewDataCols
(
STSchema
*
pSchema
,
int
nRows
)
{
int
nCols
=
schemaNCols
(
pSchema
);
SDataCols
*
pInfo
=
(
SDataCols
*
)
calloc
(
1
,
sizeof
(
SDataCols
)
+
sizeof
(
SDataCol
)
*
nCols
);
if
(
pInfo
==
NULL
)
return
NULL
;
pInfo
->
numOfCols
=
nCols
;
pInfo
->
firstKey
=
INT64_MIN
;
pInfo
->
lastKey
=
INT64_MAX
;
pInfo
->
buf
=
malloc
(
tdMaxRowBytesFromSchema
(
pSchema
)
*
nRows
);
if
(
pInfo
->
buf
==
NULL
)
{
free
(
pInfo
);
return
NULL
;
}
for
(
int
i
=
0
;
i
<
schemaNCols
(
pSchema
);
i
++
)
{
// TODO
pInfo
->
cols
[
0
].
pData
=
pInfo
->
buf
;
for
(
int
i
=
1
;
i
<
nCols
;
i
++
)
{
pInfo
->
cols
[
i
].
pData
=
(
char
*
)(
pInfo
->
cols
[
i
-
1
].
pData
)
+
schemaColAt
(
pSchema
,
i
-
1
)
->
bytes
*
nRows
;
}
*
iter
=
row
+
1
;
return
pInfo
;
}
void
tdFreeDataCols
(
SDataCols
*
pCols
)
{
if
(
pCols
)
{
if
(
pCols
->
buf
)
free
(
pCols
->
buf
);
free
(
pCols
);
}
}
void
tdResetDataCols
(
SDataCols
*
pCols
)
{
pCols
->
firstKey
=
INT64_MAX
;
pCols
->
lastKey
=
INT64_MIN
;
pCols
->
numOfPoints
=
0
;
for
(
int
i
=
0
;
i
<
pCols
->
numOfCols
;
i
++
)
{
pCols
->
cols
[
i
].
len
=
0
;
}
}
void
tdAppendDataRowToDataCol
(
SDataRow
row
,
SDataCols
*
pCols
,
STSchema
*
pSchema
)
{
TSKEY
key
=
dataRowKey
(
row
);
if
(
pCols
->
numOfPoints
==
0
)
pCols
->
firstKey
=
key
;
pCols
->
lastKey
=
key
;
for
(
int
i
=
0
;
i
<
pCols
->
numOfCols
;
i
++
)
{
SDataCol
*
pCol
=
pCols
->
cols
+
i
;
memcpy
((
void
*
)((
char
*
)(
pCol
->
pData
)
+
pCol
->
len
),
dataRowAt
(
row
,
colOffset
(
schemaColAt
(
pSchema
,
i
))),
colBytes
(
schemaColAt
(
pSchema
,
i
)));
pCol
->
len
+=
colBytes
(
schemaColAt
(
pSchema
,
i
));
}
}
/**
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
b01e8b8d
...
...
@@ -84,7 +84,7 @@ static int tsdbOpenMetaFile(char *tsdbDir);
static
int32_t
tsdbInsertDataToTable
(
tsdb_repo_t
*
repo
,
SSubmitBlk
*
pBlock
);
static
int32_t
tsdbRestoreCfg
(
STsdbRepo
*
pRepo
,
STsdbCfg
*
pCfg
);
static
int32_t
tsdbGetDataDirName
(
STsdbRepo
*
pRepo
,
char
*
fname
);
static
void
*
tsdbCommit
ToFile
(
void
*
arg
);
static
void
*
tsdbCommit
Data
(
void
*
arg
);
#define TSDB_GET_TABLE_BY_ID(pRepo, sid) (((STSDBRepo *)pRepo)->pTableList)[sid]
#define TSDB_GET_TABLE_BY_NAME(pRepo, name)
...
...
@@ -327,7 +327,7 @@ int32_t tsdbTriggerCommit(tsdb_repo_t *repo) {
pRepo
->
tsdbCache
->
curBlock
=
NULL
;
// TODO: here should set as detached or use join for memory leak
pthread_create
(
&
(
pRepo
->
commitThread
),
NULL
,
tsdbCommit
ToFile
,
(
void
*
)
repo
);
pthread_create
(
&
(
pRepo
->
commitThread
),
NULL
,
tsdbCommit
Data
,
(
void
*
)
repo
);
tsdbUnLockRepo
(
repo
);
return
0
;
...
...
@@ -816,7 +816,7 @@ static SSkipListIterator **tsdbCreateTableIters(STsdbMeta *pMeta, int maxTables)
}
// Commit to file
static
void
*
tsdbCommit
ToFile
(
void
*
arg
)
{
static
void
*
tsdbCommit
Data
(
void
*
arg
)
{
// TODO
printf
(
"Starting to commit....
\n
"
);
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
arg
;
...
...
@@ -894,4 +894,26 @@ static void *tsdbCommitToFile(void *arg) {
tsdbUnLockRepo
(
arg
);
return
NULL
;
}
static
int
tsdbCommitToFile
(
STsdbRepo
*
pRepo
,
SSkipListIterator
**
iters
,
int
fid
)
{
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
STsdbCfg
*
pCfg
=
&
pRepo
->
config
;
TSKEY
minKey
=
0
,
maxKey
=
0
;
tsdbGetKeyRangeOfFileId
(
pCfg
->
daysPerFile
,
pCfg
->
precision
,
fid
,
&
minKey
,
&
maxKey
);
for
(
int
tid
=
0
;
tid
<
pCfg
->
maxTables
;
tid
++
)
{
STable
*
pTable
=
pMeta
->
tables
[
tid
];
SSkipListIterator
*
pIter
=
iters
[
tid
];
if
(
pIter
==
NULL
)
continue
;
// Read data
// while () {
// }
}
return
0
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录