Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
af773a37
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看板
提交
af773a37
编写于
2月 17, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '2.0' of
https://github.com/taosdata/TDengine
into 2.0
上级
def046eb
c12fd89c
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
189 addition
and
107 deletion
+189
-107
src/util/inc/tbuffer.h
src/util/inc/tbuffer.h
+73
-41
src/util/src/tbuffer.c
src/util/src/tbuffer.c
+45
-39
src/vnode/CMakeLists.txt
src/vnode/CMakeLists.txt
+6
-3
src/vnode/common/CMakeLists.txt
src/vnode/common/CMakeLists.txt
+8
-0
src/vnode/common/src/schema.c
src/vnode/common/src/schema.c
+1
-1
src/vnode/tsdb/CMakeLists.txt
src/vnode/tsdb/CMakeLists.txt
+9
-0
src/vnode/tsdb/inc/tsdb.h
src/vnode/tsdb/inc/tsdb.h
+24
-2
src/vnode/tsdb/inc/tsdbCache.h
src/vnode/tsdb/inc/tsdbCache.h
+8
-9
src/vnode/tsdb/inc/tsdbFile.h
src/vnode/tsdb/inc/tsdbFile.h
+3
-2
src/vnode/tsdb/inc/tsdbMeta.h
src/vnode/tsdb/inc/tsdbMeta.h
+3
-3
src/vnode/tsdb/src/tsdb.c
src/vnode/tsdb/src/tsdb.c
+5
-4
src/vnode/tsdb/src/tsdbFileStore.c
src/vnode/tsdb/src/tsdbFileStore.c
+1
-1
src/vnode/tsdb/src/tsdbMeta.c
src/vnode/tsdb/src/tsdbMeta.c
+3
-2
未找到文件。
src/util/inc/tbuffer.h
浏览文件 @
af773a37
...
@@ -24,45 +24,78 @@
...
@@ -24,45 +24,78 @@
/*
/*
SBuffer can be used to read or write a buffer, but cannot be used for both
SBuffer can be used to read or write a buffer, but cannot be used for both
read & write at a same time.
read & write at a same time. Below is an example:
Read example:
SBuffer rbuf;
int main(int argc, char** argv) {
if (tbufBeginOperation(&rbuf) != 0) {
//--------------------- write ------------------------
// handling errors
SBuffer wbuf;
}
int32_t code = tbufBeginWrite(&wbuf);
tbufInitRead(&rbuf, data, 1024);
if (code != 0) {
int32_t a = tbufReadInt32(&rbuf);
// handle errors
// other read functions
return 0;
}
Write example:
SBuffer wbuf;
// reserve 1024 bytes for the buffer to improve performance
if (tbufBeginOperation(&wbuf) != 0) {
tbufEnsureCapacity(&wbuf, 1024);
// handling errors
}
// write 5 integers to the buffer
tbufInitWrite(&wbuf, 1024);
for (int i = 0; i < 5; i++) {
tbufWriteInt32(&wbuf, 10);
tbufWriteInt32(&wbuf, i);
// other write functions
}
size_t size = tbufGetSize(&wbuf);
char* data = tbufGetBuffer(&wbuf, true);
// write a string to the buffer
tbufUninitWrite(&wbuf);
tbufWriteString(&wbuf, "this is a string.\n");
// acquire the result and close the write buffer
size_t size = tbufTell(&wbuf);
char* data = tbufGetData(&wbuf, true);
tbufClose(&wbuf, true);
//------------------------ read -----------------------
SBuffer rbuf;
code = tbufBeginRead(&rbuf, data, size);
if (code != 0) {
printf("you will see this message after print out 5 integers and a string.\n");
tbufClose(&rbuf, false);
return 0;
}
// read & print out 5 integers
for (int i = 0; i < 5; i++) {
printf("%d\n", tbufReadInt32(&rbuf));
}
// read & print out a string
printf(tbufReadString(&rbuf, NULL));
// try read another integer, this result in an error as there no this integer
tbufReadInt32(&rbuf);
printf("you should not see this message.\n");
tbufClose(&rbuf, false);
return 0;
}
*/
*/
typedef
struct
{
typedef
struct
{
jmp_buf
jb
;
jmp_buf
jb
;
char
*
buf
;
char
*
data
;
size_t
pos
;
size_t
pos
;
size_t
size
;
size_t
size
;
}
SBuffer
;
}
SBuffer
;
// common functions can be used in both read & write
// common functions can be used in both read & write
#define tbuf
BeginOperation(buf) setjmp((buf)->jb
)
#define tbuf
ThrowError(buf, code) longjmp((buf)->jb, (code)
)
size_t
tbufTell
(
SBuffer
*
buf
);
size_t
tbufTell
(
SBuffer
*
buf
);
size_t
tbufSeekTo
(
SBuffer
*
buf
,
size_t
pos
);
size_t
tbufSeekTo
(
SBuffer
*
buf
,
size_t
pos
);
size_t
tbufSkip
(
SBuffer
*
buf
,
size_t
size
);
size_t
tbufSkip
(
SBuffer
*
buf
,
size_t
size
);
void
tbufClose
(
SBuffer
*
buf
,
bool
keepData
);
// basic read functions
// basic read functions
void
tbufInitRead
(
SBuffer
*
buf
,
void
*
data
,
size_t
size
);
#define tbufBeginRead(buf, data, len) (((buf)->data = (char*)data), ((buf)->pos = 0), ((buf)->size = ((data) == NULL) ? 0 : (len)), setjmp((buf)->jb))
char
*
tbufRead
(
SBuffer
*
buf
,
size_t
size
);
char
*
tbufRead
(
SBuffer
*
buf
,
size_t
size
);
void
tbufReadToBuffer
(
SBuffer
*
buf
,
void
*
dst
,
size_t
size
);
void
tbufReadToBuffer
(
SBuffer
*
buf
,
void
*
dst
,
size_t
size
);
const
char
*
tbufReadString
(
SBuffer
*
buf
,
size_t
*
len
);
const
char
*
tbufReadString
(
SBuffer
*
buf
,
size_t
*
len
);
...
@@ -70,10 +103,9 @@ size_t tbufReadToString(SBuffer* buf, char* dst, size_t size);
...
@@ -70,10 +103,9 @@ size_t tbufReadToString(SBuffer* buf, char* dst, size_t size);
// basic write functions
// basic write functions
void
tbufInitWrite
(
SBuffer
*
buf
,
size_t
size
);
#define tbufBeginWrite(buf) ((buf)->data = NULL, ((buf)->pos = 0), ((buf)->size = 0), setjmp((buf)->jb))
void
tbufEnsureCapacity
(
SBuffer
*
buf
,
size_t
size
);
void
tbufEnsureCapacity
(
SBuffer
*
buf
,
size_t
size
);
char
*
tbufGetResult
(
SBuffer
*
buf
,
bool
takeOver
);
char
*
tbufGetData
(
SBuffer
*
buf
,
bool
takeOver
);
void
tbufUninitWrite
(
SBuffer
*
buf
);
void
tbufWrite
(
SBuffer
*
buf
,
const
void
*
data
,
size_t
size
);
void
tbufWrite
(
SBuffer
*
buf
,
const
void
*
data
,
size_t
size
);
void
tbufWriteAt
(
SBuffer
*
buf
,
size_t
pos
,
const
void
*
data
,
size_t
size
);
void
tbufWriteAt
(
SBuffer
*
buf
,
size_t
pos
,
const
void
*
data
,
size_t
size
);
void
tbufWriteStringLen
(
SBuffer
*
buf
,
const
char
*
str
,
size_t
len
);
void
tbufWriteStringLen
(
SBuffer
*
buf
,
const
char
*
str
,
size_t
len
);
...
@@ -81,24 +113,24 @@ void tbufWriteString(SBuffer* buf, const char* str);
...
@@ -81,24 +113,24 @@ void tbufWriteString(SBuffer* buf, const char* str);
// read & write function for primitive types
// read & write function for primitive types
#ifndef TBUFFER_DEFINE_
OPERA
TION
#ifndef TBUFFER_DEFINE_
FUNC
TION
#define TBUFFER_DEFINE_
OPERA
TION(type, name) \
#define TBUFFER_DEFINE_
FUNC
TION(type, name) \
type tbufRead##name(SBuffer* buf); \
type tbufRead##name(SBuffer* buf); \
void tbufWrite##name(SBuffer* buf, type data); \
void tbufWrite##name(SBuffer* buf, type data); \
void tbufWrite##name##At(SBuffer* buf, size_t pos, type data);
void tbufWrite##name##At(SBuffer* buf, size_t pos, type data);
#endif
#endif
TBUFFER_DEFINE_
OPERA
TION
(
bool
,
Bool
)
TBUFFER_DEFINE_
FUNC
TION
(
bool
,
Bool
)
TBUFFER_DEFINE_
OPERA
TION
(
char
,
Char
)
TBUFFER_DEFINE_
FUNC
TION
(
char
,
Char
)
TBUFFER_DEFINE_
OPERA
TION
(
int8_t
,
Int8
)
TBUFFER_DEFINE_
FUNC
TION
(
int8_t
,
Int8
)
TBUFFER_DEFINE_
OPERA
TION
(
uint8_t
,
Unt8
)
TBUFFER_DEFINE_
FUNC
TION
(
uint8_t
,
Unt8
)
TBUFFER_DEFINE_
OPERA
TION
(
int16_t
,
Int16
)
TBUFFER_DEFINE_
FUNC
TION
(
int16_t
,
Int16
)
TBUFFER_DEFINE_
OPERA
TION
(
uint16_t
,
Uint16
)
TBUFFER_DEFINE_
FUNC
TION
(
uint16_t
,
Uint16
)
TBUFFER_DEFINE_
OPERA
TION
(
int32_t
,
Int32
)
TBUFFER_DEFINE_
FUNC
TION
(
int32_t
,
Int32
)
TBUFFER_DEFINE_
OPERA
TION
(
uint32_t
,
Uint32
)
TBUFFER_DEFINE_
FUNC
TION
(
uint32_t
,
Uint32
)
TBUFFER_DEFINE_
OPERA
TION
(
int64_t
,
Int64
)
TBUFFER_DEFINE_
FUNC
TION
(
int64_t
,
Int64
)
TBUFFER_DEFINE_
OPERA
TION
(
uint64_t
,
Uint64
)
TBUFFER_DEFINE_
FUNC
TION
(
uint64_t
,
Uint64
)
TBUFFER_DEFINE_
OPERA
TION
(
float
,
Float
)
TBUFFER_DEFINE_
FUNC
TION
(
float
,
Float
)
TBUFFER_DEFINE_
OPERA
TION
(
double
,
Double
)
TBUFFER_DEFINE_
FUNC
TION
(
double
,
Double
)
#endif
#endif
\ No newline at end of file
src/util/src/tbuffer.c
浏览文件 @
af773a37
...
@@ -13,7 +13,11 @@
...
@@ -13,7 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#define TBUFFER_DEFINE_OPERATION(type, name) \
#include <stdlib.h>
#include <memory.h>
#include <assert.h>
#define TBUFFER_DEFINE_FUNCTION(type, name) \
type tbufRead##name(SBuffer* buf) { \
type tbufRead##name(SBuffer* buf) { \
type ret; \
type ret; \
tbufReadToBuffer(buf, &ret, sizeof(type)); \
tbufReadToBuffer(buf, &ret, sizeof(type)); \
...
@@ -38,7 +42,8 @@ size_t tbufTell(SBuffer* buf) {
...
@@ -38,7 +42,8 @@ size_t tbufTell(SBuffer* buf) {
size_t
tbufSeekTo
(
SBuffer
*
buf
,
size_t
pos
)
{
size_t
tbufSeekTo
(
SBuffer
*
buf
,
size_t
pos
)
{
if
(
pos
>
buf
->
size
)
{
if
(
pos
>
buf
->
size
)
{
longjmp
(
buf
->
jb
,
1
);
// TODO: update error code, other tbufThrowError need to be changed too
tbufThrowError
(
buf
,
1
);
}
}
size_t
old
=
buf
->
pos
;
size_t
old
=
buf
->
pos
;
buf
->
pos
=
pos
;
buf
->
pos
=
pos
;
...
@@ -49,18 +54,20 @@ size_t tbufSkip(SBuffer* buf, size_t size) {
...
@@ -49,18 +54,20 @@ size_t tbufSkip(SBuffer* buf, size_t size) {
return
tbufSeekTo
(
buf
,
buf
->
pos
+
size
);
return
tbufSeekTo
(
buf
,
buf
->
pos
+
size
);
}
}
////////////////////////////////////////////////////////////////////////////////
void
tbufClose
(
SBuffer
*
buf
,
bool
keepData
)
{
// read functions
if
(
!
keepData
)
{
free
(
buf
->
data
);
void
tbufInitRead
(
SBuffer
*
buf
,
void
*
data
,
size_t
size
)
{
}
buf
->
buf
=
(
char
*
)
data
;
buf
->
data
=
NULL
;
buf
->
pos
=
0
;
buf
->
pos
=
0
;
// empty buffer is not an error, but read an empty buffer is
buf
->
size
=
0
;
buf
->
size
=
(
data
==
NULL
)
?
0
:
size
;
}
}
////////////////////////////////////////////////////////////////////////////////
// read functions
char
*
tbufRead
(
SBuffer
*
buf
,
size_t
size
)
{
char
*
tbufRead
(
SBuffer
*
buf
,
size_t
size
)
{
char
*
ret
=
buf
->
buf
+
buf
->
pos
;
char
*
ret
=
buf
->
data
+
buf
->
pos
;
tbufSkip
(
buf
,
size
);
tbufSkip
(
buf
,
size
);
return
ret
;
return
ret
;
}
}
...
@@ -72,8 +79,8 @@ void tbufReadToBuffer(SBuffer* buf, void* dst, size_t size) {
...
@@ -72,8 +79,8 @@ void tbufReadToBuffer(SBuffer* buf, void* dst, size_t size) {
}
}
const
char
*
tbufReadString
(
SBuffer
*
buf
,
size_t
*
len
)
{
const
char
*
tbufReadString
(
SBuffer
*
buf
,
size_t
*
len
)
{
uint16_t
l
=
tbufReadUint16
();
uint16_t
l
=
tbufReadUint16
(
buf
);
char
*
ret
=
buf
->
buf
+
buf
->
pos
;
char
*
ret
=
buf
->
data
+
buf
->
pos
;
tbufSkip
(
buf
,
l
+
1
);
tbufSkip
(
buf
,
l
+
1
);
ret
[
l
]
=
0
;
// ensure the string end with '\0'
ret
[
l
]
=
0
;
// ensure the string end with '\0'
if
(
len
!=
NULL
)
{
if
(
len
!=
NULL
)
{
...
@@ -83,9 +90,12 @@ const char* tbufReadString(SBuffer* buf, size_t* len) {
...
@@ -83,9 +90,12 @@ const char* tbufReadString(SBuffer* buf, size_t* len) {
}
}
size_t
tbufReadToString
(
SBuffer
*
buf
,
char
*
dst
,
size_t
size
)
{
size_t
tbufReadToString
(
SBuffer
*
buf
,
char
*
dst
,
size_t
size
)
{
assert
(
dst
!=
NULL
);
size_t
len
;
size_t
len
;
const
char
*
str
=
tbufReadString
(
buf
,
&
len
);
const
char
*
str
=
tbufReadString
(
buf
,
&
len
);
if
(
len
>=
size
)
len
=
size
-
1
;
if
(
len
>=
size
)
{
len
=
size
-
1
;
}
memcpy
(
dst
,
str
,
len
);
memcpy
(
dst
,
str
,
len
);
dst
[
len
]
=
0
;
dst
[
len
]
=
0
;
return
len
;
return
len
;
...
@@ -98,57 +108,53 @@ size_t tbufReadToString(SBuffer* buf, char* dst, size_t size) {
...
@@ -98,57 +108,53 @@ size_t tbufReadToString(SBuffer* buf, char* dst, size_t size) {
void
tbufEnsureCapacity
(
SBuffer
*
buf
,
size_t
size
)
{
void
tbufEnsureCapacity
(
SBuffer
*
buf
,
size_t
size
)
{
size
+=
buf
->
pos
;
size
+=
buf
->
pos
;
if
(
size
>
buf
->
size
)
{
if
(
size
>
buf
->
size
)
{
char
*
nbuf
=
NULL
;
size_t
nsize
=
size
+
buf
->
size
;
size_t
nsize
=
size
+
buf
->
size
;
nbuf
=
realloc
(
buf
->
buf
,
nsize
);
char
*
data
=
realloc
(
buf
->
data
,
nsize
);
if
(
nbuf
==
NULL
)
{
if
(
data
==
NULL
)
{
longjmp
(
buf
->
jb
,
2
);
tbufThrowError
(
buf
,
2
);
}
}
buf
->
buf
=
nbuf
;
buf
->
data
=
data
;
buf
->
size
=
nsize
;
buf
->
size
=
nsize
;
}
}
}
}
void
tbufInitWrite
(
SBuffer
*
buf
,
size_t
size
)
{
char
*
tbufGetData
(
SBuffer
*
buf
,
bool
takeOver
)
{
buf
->
buf
=
NULL
;
char
*
ret
=
buf
->
data
;
buf
->
pos
=
0
;
buf
->
size
=
0
;
tbufEnsureCapacity
(
buf
,
size
);
}
char
*
tbufGetResult
(
SBuffer
*
buf
,
bool
takeOver
)
{
char
*
ret
=
buf
->
buf
;
if
(
takeOver
)
{
if
(
takeOver
)
{
buf
->
pos
=
0
;
buf
->
pos
=
0
;
buf
->
size
=
0
;
buf
->
size
=
0
;
buf
->
buf
=
NULL
;
buf
->
data
=
NULL
;
}
}
return
ret
;
return
ret
;
}
}
void
tbufUninitWrite
(
SBuffer
*
buf
)
{
void
tbufEndWrite
(
SBuffer
*
buf
)
{
free
(
buf
->
buf
);
free
(
buf
->
data
);
buf
->
data
=
NULL
;
buf
->
pos
=
0
;
buf
->
size
=
0
;
}
}
void
tbufWrite
(
SBuffer
*
buf
,
const
void
*
data
,
size_t
size
)
{
void
tbufWrite
(
SBuffer
*
buf
,
const
void
*
data
,
size_t
size
)
{
tbufEnsureCapacity
(
size
);
assert
(
data
!=
NULL
);
memcpy
(
buf
->
buf
+
buf
->
pos
,
data
,
size
);
tbufEnsureCapacity
(
buf
,
size
);
memcpy
(
buf
->
data
+
buf
->
pos
,
data
,
size
);
buf
->
pos
+=
size
;
buf
->
pos
+=
size
;
}
}
void
tbufWriteAt
(
SBuffer
*
buf
,
size_t
pos
,
const
void
*
data
,
size_t
size
)
{
void
tbufWriteAt
(
SBuffer
*
buf
,
size_t
pos
,
const
void
*
data
,
size_t
size
)
{
assert
(
data
!=
NULL
);
// this function can only be called to fill the gap on previous writes,
// this function can only be called to fill the gap on previous writes,
// so 'pos + size <= buf->pos' must be true
// so 'pos + size <= buf->pos' must be true
if
(
pos
+
size
>
buf
->
pos
)
{
assert
(
pos
+
size
<=
buf
->
pos
);
longjmp
(
buf
->
jb
,
3
);
memcpy
(
buf
->
data
+
pos
,
data
,
size
);
}
memcpy
(
buf
->
buf
+
pos
,
data
,
size
);
}
}
void
tbufWriteStringLen
(
SBuffer
*
buf
,
const
char
*
str
,
size_t
len
)
{
void
tbufWriteStringLen
(
SBuffer
*
buf
,
const
char
*
str
,
size_t
len
)
{
if
(
len
>
0xffff
)
{
// maximum string length is 65535, if longer string is required
longjmp
(
buf
->
jb
,
4
);
// this function and the corresponding read function need to be
}
// revised.
assert
(
len
<=
0xffff
);
tbufWriteUint16
(
buf
,
(
uint16_t
)
len
);
tbufWriteUint16
(
buf
,
(
uint16_t
)
len
);
tbufWrite
(
buf
,
str
,
len
+
1
);
tbufWrite
(
buf
,
str
,
len
+
1
);
}
}
...
...
src/vnode/CMakeLists.txt
浏览文件 @
af773a37
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
cmake_minimum_required
(
VERSION 2.8
)
PROJECT
(
TDengine
)
ADD_SUBDIRECTORY
(
detail
)
project
(
tsdb
)
\ No newline at end of file
add_subdirectory
(
common
)
add_subdirectory
(
tsdb
)
\ No newline at end of file
src/vnode/common/CMakeLists.txt
0 → 100644
浏览文件 @
af773a37
aux_source_directory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/src SOURCE_LIST
)
list
(
REMOVE_ITEM SOURCE_LIST
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/vnodePeer.c
)
message
(
STATUS
"Common source file
${
SOURCE_LIST
}
"
)
add_library
(
common
${
SOURCE_LIST
}
)
target_include_directories
(
common PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
src/vnode/common/src/schema.c
浏览文件 @
af773a37
...
@@ -51,7 +51,7 @@ SISchema tdConvertSchemaToInline(SSchema *pSchema) {
...
@@ -51,7 +51,7 @@ SISchema tdConvertSchemaToInline(SSchema *pSchema) {
char
*
pName
=
TD_ISCHEMA_COL_NAMES
(
pISchema
);
char
*
pName
=
TD_ISCHEMA_COL_NAMES
(
pISchema
);
for
(
int32_t
i
=
0
;
i
<
totalCols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
totalCols
;
i
++
)
{
SColumn
*
pCol
=
TD_SCHEMA_COLUMN_AT
(
TD_ISCHEMA_SCHEMA
(
pISchema
),
i
);
SColumn
*
pCol
=
TD_SCHEMA_COLUMN_AT
(
TD_ISCHEMA_SCHEMA
(
pISchema
),
i
);
char
*
colName
=
TD_COLUMN_NAME
(
TD_SCHEMA_COLUMN_AT
(
pSchema
,
i
)
,
i
);
char
*
colName
=
TD_COLUMN_NAME
(
TD_SCHEMA_COLUMN_AT
(
pSchema
,
i
));
TD_COLUMN_NAME
(
pCol
)
=
pName
;
TD_COLUMN_NAME
(
pCol
)
=
pName
;
...
...
src/vnode/tsdb/CMakeLists.txt
浏览文件 @
af773a37
aux_source_directory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/src SOURCE_LIST
)
message
(
STATUS
"tsdb source files:
${
SOURCE_LIST
}
"
)
add_library
(
tsdb STATIC
${
SOURCE_LIST
}
)
target_link_libraries
(
tsdb common
)
target_include_directories
(
tsdb PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
\ No newline at end of file
src/vnode/tsdb/inc/tsdb.h
浏览文件 @
af773a37
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include <stdbool.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdint.h>
#include "cache.h"
//
#include "cache.h"
#include "schema.h"
#include "schema.h"
#define TSDB_VERSION_MAJOR 1
#define TSDB_VERSION_MAJOR 1
...
@@ -18,6 +18,21 @@ typedef void tsdb_repo_t; // use void to hide implementation details from ou
...
@@ -18,6 +18,21 @@ typedef void tsdb_repo_t; // use void to hide implementation details from ou
typedef
int32_t
table_id_t
;
// table ID type in this repository
typedef
int32_t
table_id_t
;
// table ID type in this repository
typedef
int16_t
tsdb_id_t
;
// TSDB repository ID
typedef
int16_t
tsdb_id_t
;
// TSDB repository ID
// Submit message
typedef
struct
{
int32_t
numOfTables
;
char
data
[];
}
SSubmitMsg
;
// Submit message for one table
typedef
struct
{
table_id_t
tableId
;
// table ID to insert
int32_t
sversion
;
// data schema version
int32_t
numOfRows
;
// number of rows data
int64_t
uid
;
// table UID to insert
char
data
[];
}
SSubmitBlock
;
// Retention policy.
// Retention policy.
typedef
struct
{
typedef
struct
{
// TODO: Need a more fancy description
// TODO: Need a more fancy description
...
@@ -54,7 +69,7 @@ typedef struct {
...
@@ -54,7 +69,7 @@ typedef struct {
SDataShardPolicy
dataShardPolicy
;
SDataShardPolicy
dataShardPolicy
;
SBlockRowsPolicy
blockRowsPolicy
;
SBlockRowsPolicy
blockRowsPolicy
;
SRetentionPolicy
retentionPlicy
;
// retention configuration
SRetentionPolicy
retentionPlicy
;
// retention configuration
SCachePool
*
cachePool
;
// the cache pool the repository to use
void
*
cachePool
;
// the cache pool the repository to use
}
STSDBCfg
;
}
STSDBCfg
;
// the TSDB repository info
// the TSDB repository info
...
@@ -205,6 +220,9 @@ typedef struct STimeWindow {
...
@@ -205,6 +220,9 @@ typedef struct STimeWindow {
int64_t
ekey
;
int64_t
ekey
;
}
STimeWindow
;
}
STimeWindow
;
typedef
struct
{
}
SColumnFilterInfo
;
// query condition to build vnode iterator
// query condition to build vnode iterator
typedef
struct
STSDBQueryCond
{
typedef
struct
STSDBQueryCond
{
STimeWindow
twindow
;
STimeWindow
twindow
;
...
@@ -237,6 +255,10 @@ typedef struct STableIDList {
...
@@ -237,6 +255,10 @@ typedef struct STableIDList {
int32_t
num
;
int32_t
num
;
}
STableIDList
;
}
STableIDList
;
typedef
struct
{
}
SFields
;
/**
/**
* Get the data block iterator, starting from position according to the query condition
* Get the data block iterator, starting from position according to the query condition
* @param pRepo the TSDB repository to query on
* @param pRepo the TSDB repository to query on
...
...
src/vnode/tsdb/inc/tsdbCache.h
浏览文件 @
af773a37
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdint.h>
#include "cache.h"
//
#include "cache.h"
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16*1024*1024
/* 16M */
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16*1024*1024
/* 16M */
...
@@ -13,22 +13,21 @@ typedef struct {
...
@@ -13,22 +13,21 @@ typedef struct {
int32_t
numOfRows
// numOfRows
int32_t
numOfRows
// numOfRows
}
STableCacheInfo
;
}
STableCacheInfo
;
typedef
struct
{
typedef
struct
_tsdb_cache_block
{
char
*
pData
;
char
*
pData
;
STableCacheInfo
*
pTableInfo
;
STableCacheInfo
*
pTableInfo
;
SCacheB
lock
*
prev
;
struct
_tsdb_cache_b
lock
*
prev
;
SCacheB
lock
*
next
;
struct
_tsdb_cache_b
lock
*
next
;
}
STSDBCacheBlock
;
}
STSDBCacheBlock
;
// Use a doublely linked list to implement this
// Use a doublely linked list to implement this
typedef
struct
STSDBCache
{
typedef
struct
STSDBCache
{
// Number of blocks the cache is allocated
// Number of blocks the cache is allocated
int32_t
numOfBlocks
;
int32_t
numOfBlocks
;
STSDBCacheBlock
*
cacheList
;
STSDBCacheBlock
*
cacheList
;
void
*
current
;
void
*
current
;
}
SCacheHandle
;
}
SCacheHandle
;
// ---- Operation on STSDBCacheBlock
// ---- Operation on STSDBCacheBlock
#define TSDB_CACHE_BLOCK_DATA(pBlock) ((pBlock)->pData)
#define TSDB_CACHE_BLOCK_DATA(pBlock) ((pBlock)->pData)
#define TSDB_CACHE_AVAIL_SPACE(pBlock) ((char *)((pBlock)->pTableInfo) - ((pBlock)->pData))
#define TSDB_CACHE_AVAIL_SPACE(pBlock) ((char *)((pBlock)->pTableInfo) - ((pBlock)->pData))
...
...
src/vnode/tsdb/inc/tsdbFile.h
浏览文件 @
af773a37
#if !defined(_TD_TSDB_FILE_H_)
#if !defined(_TD_TSDB_FILE_H_)
#define _TD_TSDB_FILE_H_
#define _TD_TSDB_FILE_H_
#include "tstring.h"
#include <stdint.h>
// #include "tstring.h"
typedef
int32_t
file_id_t
;
typedef
int32_t
file_id_t
;
...
@@ -24,7 +25,7 @@ typedef struct {
...
@@ -24,7 +25,7 @@ typedef struct {
}
SFileInfo
;
}
SFileInfo
;
typedef
struct
{
typedef
struct
{
tstring_t
fname
;
char
*
fname
;
SFileInfo
fInfo
;
SFileInfo
fInfo
;
}
SFILE
;
}
SFILE
;
...
...
src/vnode/tsdb/inc/tsdbMeta.h
浏览文件 @
af773a37
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include <pthread.h>
#include <pthread.h>
#include "taosdef.h"
//
#include "taosdef.h"
// Initially, there are 4 tables
// Initially, there are 4 tables
#define TSDB_INIT_NUMBER_OF_SUPER_TABLE 4
#define TSDB_INIT_NUMBER_OF_SUPER_TABLE 4
...
@@ -30,7 +30,7 @@ typedef struct STable {
...
@@ -30,7 +30,7 @@ typedef struct STable {
// For TSDB_SUPER_TABLE, it is the schema including tags
// For TSDB_SUPER_TABLE, it is the schema including tags
// For TSDB_NTABLE, it is only the schema, not including tags
// For TSDB_NTABLE, it is only the schema, not including tags
// For TSDB_STABLE, it is NULL
// For TSDB_STABLE, it is NULL
S
V
Schema
*
pSchema
;
SSchema
*
pSchema
;
// Tag value for this table
// Tag value for this table
// For TSDB_SUPER_TABLE and TSDB_NTABLE, it is NULL
// For TSDB_SUPER_TABLE and TSDB_NTABLE, it is NULL
...
@@ -75,7 +75,7 @@ typedef struct {
...
@@ -75,7 +75,7 @@ typedef struct {
#define TSDB_TABLE_CACHE_DATA(pTable) ((pTable)->content.pData)
#define TSDB_TABLE_CACHE_DATA(pTable) ((pTable)->content.pData)
#define TSDB_SUPER_TABLE_INDEX(pTable) ((pTable)->content.pIndex)
#define TSDB_SUPER_TABLE_INDEX(pTable) ((pTable)->content.pIndex)
S
V
Schema
*
tsdbGetTableSchema
(
STable
*
pTable
);
SSchema
*
tsdbGetTableSchema
(
STable
*
pTable
);
// ---- Operation on SMetaHandle
// ---- Operation on SMetaHandle
#define TSDB_NUM_OF_TABLES(pHandle) ((pHandle)->numOfTables)
#define TSDB_NUM_OF_TABLES(pHandle) ((pHandle)->numOfTables)
...
...
src/vnode/tsdb/src/tsdb.c
浏览文件 @
af773a37
...
@@ -2,14 +2,15 @@
...
@@ -2,14 +2,15 @@
#include <stdint.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdlib.h>
#include "taosdef.h"
//
#include "taosdef.h"
// #include "disk.h"
// #include "disk.h"
#include "tsdb.h"
#include "tsdbCache.h"
#include "tsdbCache.h"
#include "tsdbMeta.h"
#include "tsdbMeta.h"
typedef
struct
STSDBRepo
{
typedef
struct
STSDBRepo
{
// TSDB configuration
// TSDB configuration
STSDB
c
fg
*
pCfg
;
STSDB
C
fg
*
pCfg
;
// The meter meta handle of this TSDB repository
// The meter meta handle of this TSDB repository
SMetaHandle
*
pMetaHandle
;
SMetaHandle
*
pMetaHandle
;
...
@@ -18,12 +19,12 @@ typedef struct STSDBRepo {
...
@@ -18,12 +19,12 @@ typedef struct STSDBRepo {
SCacheHandle
*
pCacheHandle
;
SCacheHandle
*
pCacheHandle
;
// Disk tier handle for multi-tier storage
// Disk tier handle for multi-tier storage
SDiskTier
*
pDiskTier
;
void
*
pDiskTier
;
// File Store
// File Store
void
*
pFileStore
;
void
*
pFileStore
;
pthread_mutex
t
_t
tsdbMutex
;
pthread_mutex_t
tsdbMutex
;
}
STSDBRepo
;
}
STSDBRepo
;
...
...
src/vnode/tsdb/src/tsdbFileStore.c
浏览文件 @
af773a37
#include "tsdbFile.h"
#include "tsdbFile.h"
char
*
tsdbGetFileName
(
char
*
dirName
,
char
*
fname
,
TSDB_FILE_TYPE
type
){
char
*
tsdbGetFileName
(
char
*
dirName
,
char
*
fname
,
TSDB_FILE_TYPE
type
){
char
*
suffix
=
tsdbFileSuffix
[
type
];
//
char *suffix = tsdbFileSuffix[type];
// TODO
// TODO
}
}
\ No newline at end of file
src/vnode/tsdb/src/tsdbMeta.c
浏览文件 @
af773a37
#include <stdlib.h>
#include <stdlib.h>
#include "taosdef.h"
// #include "taosdef.h"
#include "tsdb.h"
#include "tsdbMeta.h"
#include "tsdbMeta.h"
SMetaHandle
*
tsdbCreateMetaHandle
(
int32_t
numOfTables
)
{
SMetaHandle
*
tsdbCreateMetaHandle
(
int32_t
numOfTables
)
{
...
@@ -11,7 +12,7 @@ SMetaHandle *tsdbCreateMetaHandle(int32_t numOfTables) {
...
@@ -11,7 +12,7 @@ SMetaHandle *tsdbCreateMetaHandle(int32_t numOfTables) {
pMetahandle
->
numOfTables
=
0
;
pMetahandle
->
numOfTables
=
0
;
pMetahandle
->
numOfSuperTables
=
0
;
pMetahandle
->
numOfSuperTables
=
0
;
pMetahandle
->
pTables
=
calloc
(
sizeof
(
STable
*
)
*
numOfTables
);
pMetahandle
->
pTables
=
calloc
(
sizeof
(
STable
*
)
,
numOfTables
);
if
(
pMetahandle
->
pTables
==
NULL
)
{
if
(
pMetahandle
->
pTables
==
NULL
)
{
free
(
pMetahandle
);
free
(
pMetahandle
);
return
NULL
;
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录