Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
97e979f4
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看板
提交
97e979f4
编写于
3月 04, 2020
作者:
H
hzcheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add more
上级
efb4ac0e
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
118 addition
and
24 deletion
+118
-24
src/vnode/common/inc/dataformat.h
src/vnode/common/inc/dataformat.h
+1
-0
src/vnode/common/inc/schema.h
src/vnode/common/inc/schema.h
+1
-0
src/vnode/common/src/dataformat.c
src/vnode/common/src/dataformat.c
+5
-1
src/vnode/common/src/schema.c
src/vnode/common/src/schema.c
+4
-0
src/vnode/tsdb/CMakeLists.txt
src/vnode/tsdb/CMakeLists.txt
+1
-0
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+1
-1
src/vnode/tsdb/inc/tsdbMeta.h
src/vnode/tsdb/inc/tsdbMeta.h
+6
-2
src/vnode/tsdb/src/tsdbMain.c
src/vnode/tsdb/src/tsdbMain.c
+8
-2
src/vnode/tsdb/src/tsdbMeta.c
src/vnode/tsdb/src/tsdbMeta.c
+91
-18
未找到文件。
src/vnode/common/inc/dataformat.h
浏览文件 @
97e979f4
...
...
@@ -68,6 +68,7 @@ typedef char * SDataCols;
#define TD_DATAROW_DATA(pDataRow) ((pDataRow) + sizeof(int32_t))
SDataRow
tdSDataRowDup
(
SDataRow
rdata
);
void
tdFreeSDataRow
(
SDataRow
rdata
);
// ---- operation on SDataRows
#define TD_DATAROWS_LEN(pDataRows) (*(int32_t *)(pDataRows))
...
...
src/vnode/common/inc/schema.h
浏览文件 @
97e979f4
...
...
@@ -68,6 +68,7 @@ SISchema tdConvertSchemaToInline(SSchema *pSchema);
int32_t
tdGetColumnIdxByName
(
SSchema
*
pSchema
,
char
*
colName
);
int32_t
tdGetColumnIdxById
(
SSchema
*
pSchema
,
int32_t
colId
);
SSchema
*
tdDupSchema
(
SSchema
*
pSchema
);
void
tdFreeSchema
(
SSchema
*
pSchema
);
// ---- TODO: operations to modify schema
...
...
src/vnode/common/src/dataformat.c
浏览文件 @
97e979f4
...
...
@@ -31,4 +31,8 @@ int32_t tdGetMaxDataRowSize(SSchema *pSchema) {
return
nbytes
;
}
SDataRow
tdSDataRowDup
(
SDataRow
rdata
)
{
return
NULL
;
}
\ No newline at end of file
SDataRow
tdSDataRowDup
(
SDataRow
rdata
)
{
return
NULL
;
}
void
tdFreeSDataRow
(
SDataRow
rdata
)
{
if
(
rdata
==
NULL
)
return
;
free
(
rdata
);
}
\ No newline at end of file
src/vnode/common/src/schema.c
浏览文件 @
97e979f4
...
...
@@ -13,6 +13,10 @@ const int32_t rowDataLen[] = {
sizeof
(
int32_t
),
// TD_DATATYPE_NCHAR,
sizeof
(
int32_t
)
// TD_DATATYPE_BINARY
};
void
tdFreeSchema
(
SSchema
*
pSchema
)
{
// TODO
return
;
}
static
size_t
tdGetEstimatedISchemaLen
(
SSchema
*
pSchema
)
{
size_t
colNameLen
=
0
;
...
...
src/vnode/tsdb/CMakeLists.txt
浏览文件 @
97e979f4
...
...
@@ -5,6 +5,7 @@ target_link_libraries(tsdb common tutil)
target_include_directories
(
tsdb
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/src/inc"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/src/util/inc"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/src/os/linux/inc"
)
\ No newline at end of file
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
97e979f4
...
...
@@ -182,7 +182,7 @@ int32_t tsdbAlterTable(tsdb_repo_t *repo, STableCfg *pCfg);
*
* @return 0 for success, -1 for failure and the error number is set
*/
int32_t
tsdbDropTable
(
tsdb_repo_t
*
pRepo
,
STableId
t
i
d
);
int32_t
tsdbDropTable
(
tsdb_repo_t
*
pRepo
,
STableId
t
ableI
d
);
/**
* Get the information of a table in the repository
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
97e979f4
...
...
@@ -17,6 +17,7 @@
#include <pthread.h>
#include "tsdb.h"
#include "dataformat.h"
#ifdef __cplusplus
...
...
@@ -34,6 +35,8 @@ typedef enum {
TSDB_STABLE
// table created from super table
}
TSDB_TABLE_TYPE
;
#define IS_CREATE_STABLE(pCfg) ((pCfg)->tagValues != NULL)
typedef
struct
STable
{
STableId
tableId
;
TSDB_TABLE_TYPE
type
;
...
...
@@ -106,9 +109,10 @@ STsdbMeta *tsdbCreateMeta(int32_t maxTables);
int32_t
tsdbFreeMeta
(
STsdbMeta
*
pMeta
);
// Recover the meta handle from the file
STsdbMeta
*
tsdbOpenMeta
Handle
(
char
*
tsdbDir
);
STsdbMeta
*
tsdbOpenMeta
(
char
*
tsdbDir
);
int32_t
tsdbCreateTableImpl
(
STsdbMeta
*
pHandle
,
STableCfg
*
pCfg
);
int32_t
tsdbCreateTableImpl
(
STsdbMeta
*
pMeta
,
STableCfg
*
pCfg
);
int32_t
tsdbDropTableImpl
(
STsdbMeta
*
pMeta
,
STableId
tableId
);
int32_t
tsdbInsertDataImpl
(
STsdbMeta
*
pMeta
,
STableId
tableId
,
char
*
pData
);
...
...
src/vnode/tsdb/src/tsdbMain.c
浏览文件 @
97e979f4
...
...
@@ -244,9 +244,15 @@ int32_t tsdbAlterTable(tsdb_repo_t *pRepo, STableCfg *pCfg) {
return
0
;
}
int32_t
tsdbDropTable
(
tsdb_repo_t
*
pRepo
,
STableId
tid
)
{
return
0
;
}
int32_t
tsdbDropTable
(
tsdb_repo_t
*
repo
,
STableId
tableId
)
{
// TODO
if
(
repo
==
NULL
)
return
-
1
;
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
return
tsdbDropTableImpl
(
pRepo
->
tsdbMeta
,
tableId
);
}
STableInfo
*
tsdbGetTableInfo
(
tsdb_repo_t
*
pRepo
,
STableId
t
i
d
)
{
STableInfo
*
tsdbGetTableInfo
(
tsdb_repo_t
*
pRepo
,
STableId
t
ableI
d
)
{
// TODO
return
NULL
;
}
...
...
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
97e979f4
#include <stdlib.h>
// #include "taosdef.h"
#include "hash.h"
#include "tskiplist.h"
#include "tsdb.h"
#include "taosdef.h"
#include "tsdbMeta.h"
#include "hash.h"
#define TSDB_SUPER_TABLE_SL_LEVEL 5 // TODO: may change here
static
int
tsdbFreeTable
(
STable
*
pTable
);
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
);
static
STable
*
tsdbGetTableByUid
(
int64_t
uid
);
static
int
tsdbAddTable
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
STable
*
tsdbGetTableByUid
(
STsdbMeta
*
pMeta
,
int64_t
uid
);
static
int
tsdbAddTable
ToMeta
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbAddTableIntoMap
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbAddTableIntoIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
static
int
tsdbRemoveTableFromIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
);
STsdbMeta
*
tsdbCreateMeta
(
int32_t
maxTables
)
{
STsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
...
...
@@ -22,6 +24,7 @@ STsdbMeta *tsdbCreateMeta(int32_t maxTables) {
}
pMeta
->
maxTables
=
maxTables
;
pMeta
->
nTables
=
0
;
pMeta
->
stables
=
NULL
;
pMeta
->
tables
=
(
STable
**
)
calloc
(
maxTables
,
sizeof
(
STable
*
));
if
(
pMeta
->
tables
==
NULL
)
{
...
...
@@ -70,23 +73,28 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
}
STable
*
pSTable
=
NULL
;
int
newSuper
=
0
;
if
(
pCfg
->
stableUid
>
0
)
{
// to create a TSDB_STABLE
pSTable
=
tsdbGetTableByUid
(
pCfg
->
stableUid
);
if
(
IS_CREATE_STABLE
(
pCfg
))
{
// to create a TSDB_STABLE, check if super table exists
pSTable
=
tsdbGetTableByUid
(
p
Meta
,
p
Cfg
->
stableUid
);
if
(
pSTable
==
NULL
)
{
// super table not exists, try to create it
newSuper
=
1
;
pSTable
=
(
STable
*
)
calloc
(
1
,
sizeof
(
STable
));
if
(
pSTable
==
NULL
)
return
-
1
;
pSTable
->
tableId
.
uid
=
pCfg
->
stableUid
;
pSTable
->
tableId
.
tid
=
-
1
;
pSTable
->
type
=
TSDB_SUPER_TABLE
;
pSTable
->
createdTime
=
pCfg
->
createdTime
;
// The created time is not required
//
pSTable->createdTime = pCfg->createdTime; // The created time is not required
pSTable
->
stableUid
=
-
1
;
pSTable
->
numOfCols
=
pCfg
->
numOfCols
;
pSTable
->
pSchema
=
tdDupSchema
(
pCfg
->
schema
);
pSTable
->
content
.
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
0
,
8
,
0
,
0
,
NULL
);
// TODO: change here
tsdbAddTable
(
pMeta
,
pSTable
);
pSTable
->
content
.
pIndex
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
TSDB_DATA_TYPE_TIMESTAMP
,
sizeof
(
int64_t
),
1
,
0
,
NULL
);
// Allow duplicate key, no lock
if
(
pSTable
->
content
.
pIndex
==
NULL
)
{
free
(
pSTable
);
return
NULL
;
}
}
else
{
if
(
pSTable
->
type
!=
TSDB_SUPER_TABLE
)
return
NULL
;
}
...
...
@@ -94,12 +102,13 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
STable
*
pTable
=
(
STable
*
)
malloc
(
sizeof
(
STable
));
if
(
pTable
==
NULL
)
{
if
(
newSuper
)
tsdbFreeTable
(
pSTable
);
return
-
1
;
}
pTable
->
tableId
=
pCfg
->
tableId
;
pTable
->
createdTime
=
pCfg
->
createdTime
;
if
(
1
/* */
)
{
// TSDB_STABLE
if
(
IS_CREATE_STABLE
(
pCfg
)
)
{
// TSDB_STABLE
pTable
->
type
=
TSDB_STABLE
;
pTable
->
stableUid
=
pCfg
->
stableUid
;
pTable
->
pTagVal
=
tdSDataRowDup
(
pCfg
->
tagValues
);
...
...
@@ -110,13 +119,14 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
}
pTable
->
content
.
pData
=
tSkipListCreate
(
TSDB_SUPER_TABLE_SL_LEVEL
,
0
,
8
,
0
,
0
,
NULL
);
tsdbAddTable
(
pMeta
,
pTable
);
if
(
newSuper
)
tsdbAddTableToMeta
(
pMeta
,
pSTable
);
tsdbAddTableToMeta
(
pMeta
,
pTable
);
return
0
;
}
STsdbMeta
*
tsdbOpenMeta
Handle
(
char
*
tsdbDir
)
{
// Open meta file for reading
STsdbMeta
*
tsdbOpenMeta
(
char
*
tsdbDir
)
{
//
TODO :
Open meta file for reading
STsdbMeta
*
pMeta
=
(
STsdbMeta
*
)
malloc
(
sizeof
(
STsdbMeta
));
if
(
pMeta
==
NULL
)
{
...
...
@@ -141,14 +151,59 @@ int32_t tsdbInsertDataImpl(STsdbMeta *pMeta, STableId tableId, char *pData) {
return
0
;
}
static
int
tsdbFreeTable
(
STable
*
pTable
)
{
return
0
;
}
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
)
{
return
0
;
}
int32_t
tsdbDropTableImpl
(
STsdbMeta
*
pMeta
,
STableId
tableId
)
{
if
(
pMeta
==
NULL
)
return
-
1
;
static
STable
*
tsdbGetTableByUid
(
int64_t
uid
)
{
return
NULL
;
}
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
tableId
.
uid
);
if
(
pTable
==
NULL
)
return
-
1
;
static
int
tsdbAddTable
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
// TODO: implement drop super table
return
-
1
;
}
else
{
pMeta
->
tables
[
pTable
->
tableId
.
tid
]
=
NULL
;
pMeta
->
nTables
--
;
assert
(
pMeta
->
nTables
>=
0
);
if
(
pTable
->
type
==
TSDB_STABLE
)
{
tsdbRemoveTableFromIndex
(
pMeta
,
pTable
);
}
tsdbFreeTable
(
pTable
);
}
}
static
int
tsdbFreeTable
(
STable
*
pTable
)
{
// TODO: finish this function
if
(
pTable
->
type
==
TSDB_STABLE
)
{
tdFreeSDataRow
(
pTable
->
pTagVal
);
}
else
{
tdFreeSchema
(
pTable
->
pSchema
);
}
// Free content
if
(
TSDB_TABLE_IS_SUPER_TABLE
(
pTable
))
{
tSkipListDestroy
(
pTable
->
content
.
pIndex
);
}
else
{
tSkipListDestroy
(
pTable
->
content
.
pData
);
}
free
(
pTable
);
return
0
;
}
static
int32_t
tsdbCheckTableCfg
(
STableCfg
*
pCfg
)
{
// TODO
return
0
;
}
static
STable
*
tsdbGetTableByUid
(
STsdbMeta
*
pMeta
,
int64_t
uid
)
{
return
(
STable
*
)
taosGetDataFromHashTable
(
pMeta
->
tableMap
,
(
char
*
)(
&
uid
),
sizeof
(
uid
));
}
static
int
tsdbAddTableToMeta
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
// add super table to the linked list
if
(
pMeta
->
stables
==
NULL
)
{
pMeta
->
stables
=
pTable
;
pTable
->
next
=
NULL
;
...
...
@@ -158,20 +213,38 @@ static int tsdbAddTable(STsdbMeta *pMeta, STable *pTable) {
pTable
->
next
=
pTemp
;
}
}
else
{
// add non-super table to the array
pMeta
->
tables
[
pTable
->
tableId
.
tid
]
=
pTable
;
if
(
pTable
->
type
==
TSDB_STABLE
)
{
// add STABLE to the index
tsdbAddTableIntoIndex
(
pMeta
,
pTable
);
}
pMeta
->
nTables
++
;
}
return
tsdbAddTableIntoMap
(
pMeta
,
pTable
);
}
static
int
tsdbRemoveTableFromMeta
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
// TODO
}
static
int
tsdbAddTableIntoMap
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
// TODO: add the table to the map
int64_t
uid
=
pTable
->
tableId
.
uid
;
if
(
taosAddToHashTable
(
pMeta
->
tableMap
,
(
char
*
)(
&
uid
),
sizeof
(
uid
),
(
void
*
)(
&
pTable
),
sizeof
(
pTable
))
<
0
)
{
return
-
1
;
}
return
0
;
}
static
int
tsdbAddTableIntoIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
assert
(
pTable
->
type
==
TSDB_STABLE
);
// TODO
return
0
;
}
static
int
tsdbRemoveTableFromIndex
(
STsdbMeta
*
pMeta
,
STable
*
pTable
)
{
assert
(
pTable
->
type
==
TSDB_STABLE
);
// TODO
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录