Merge branch '2.0' of https://github.com/taosdata/TDengine into 2.0
This commit is contained in:
commit
403a25b1b1
|
@ -1,28 +0,0 @@
|
||||||
#if !defined(_TD_DATA_H_)
|
|
||||||
#define _TD_DATA_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "schema.h"
|
|
||||||
|
|
||||||
/* The row data should in the form of
|
|
||||||
*/
|
|
||||||
|
|
||||||
// ---- Row data interface
|
|
||||||
typedef struct {
|
|
||||||
int32_t numOfRows;
|
|
||||||
char * data;
|
|
||||||
} SRData;
|
|
||||||
|
|
||||||
// ---- Column data interface
|
|
||||||
typedef struct {
|
|
||||||
int32_t numOfPoints;
|
|
||||||
char * data;
|
|
||||||
} SCData;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32_t numOfCols;
|
|
||||||
SCData **pData;
|
|
||||||
} SCDataBlock;
|
|
||||||
|
|
||||||
#endif // _TD_DATA_H_
|
|
|
@ -1,29 +0,0 @@
|
||||||
// A doubly linked list
|
|
||||||
#if !defined(_TD_DLIST_H_)
|
|
||||||
#define _TD_DLIST_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SListNode *prev;
|
|
||||||
SListNode *next;
|
|
||||||
void * data;
|
|
||||||
} SListNode;
|
|
||||||
|
|
||||||
// Doubly linked list
|
|
||||||
typedef struct {
|
|
||||||
SListNode *head;
|
|
||||||
SListNode *tail;
|
|
||||||
int32_t length;
|
|
||||||
} SDList;
|
|
||||||
|
|
||||||
// ----- Set operation
|
|
||||||
#define TD_GET_DLIST_LENGTH(pDList) (((SDList *)pDList)->length)
|
|
||||||
#define TD_GET_DLIST_HEAD(pDList) (((SDList *)pDList)->head)
|
|
||||||
#define TD_GET_DLIST_TAIL(pDList) (((SDList *)pDList)->tail)
|
|
||||||
|
|
||||||
#define TD_GET_DLIST_NEXT_NODE(pDNode) (((SListNode *)pDNode)->next)
|
|
||||||
#define TD_GET_DLIST_PREV_NODE(pDNode) (((SListNode *)pDNode)->prev)
|
|
||||||
#define TD_GET_DLIST_NODE_DATA(pDNode) (((SListNode *)pDNode)->data)
|
|
||||||
|
|
||||||
#endif // _TD_DLIST_H_
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
#if !defined(_TD_DATA_FORMAT_H_)
|
||||||
|
#define _TD_DATA_FORMAT_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "type.h"
|
||||||
|
#include "schema.h"
|
||||||
|
|
||||||
|
// ----------------- Data row structure
|
||||||
|
|
||||||
|
/* A data row, the format of it is like below:
|
||||||
|
* +---------+---------------------------------+
|
||||||
|
* | int32_t | |
|
||||||
|
* +---------+---------------------------------+
|
||||||
|
* | len | data |
|
||||||
|
* +---------+---------------------------------+
|
||||||
|
*/
|
||||||
|
typedef char* SDataRow;
|
||||||
|
|
||||||
|
/* Data rows definition, the format of it is like below:
|
||||||
|
* +---------+---------+-----------------------+--------+-----------------------+
|
||||||
|
* | int32_t | int32_t | | | |
|
||||||
|
* +---------+---------+-----------------------+--------+-----------------------+
|
||||||
|
* | len | nrows | SDataRow | .... | SDataRow |
|
||||||
|
* +---------+---------+-----------------------+--------+-----------------------+
|
||||||
|
*/
|
||||||
|
typedef char * SDataRows;
|
||||||
|
|
||||||
|
/* Data column definition
|
||||||
|
* +---------+---------+-----------------------+
|
||||||
|
* | int32_t | int32_t | |
|
||||||
|
* +---------+---------+-----------------------+
|
||||||
|
* | len | npoints | data |
|
||||||
|
* +---------+---------+-----------------------+
|
||||||
|
*/
|
||||||
|
typedef char * SDataCol;
|
||||||
|
|
||||||
|
/* Data columns definition
|
||||||
|
* +---------+---------+-----------------------+--------+-----------------------+
|
||||||
|
* | int32_t | int32_t | | | |
|
||||||
|
* +---------+---------+-----------------------+--------+-----------------------+
|
||||||
|
* | len | npoints | SDataCol | .... | SDataCol |
|
||||||
|
* +---------+---------+-----------------------+--------+-----------------------+
|
||||||
|
*/
|
||||||
|
typedef char * SDataCols;
|
||||||
|
|
||||||
|
// ----------------- Data column structure
|
||||||
|
|
||||||
|
// ---- operation on SDataRow;
|
||||||
|
#define TD_DATAROW_LEN(pDataRow) (*(int32_t *)(pDataRow))
|
||||||
|
#define TD_DATAROW_DATA(pDataRow) ((pDataRow) + sizeof(int32_t))
|
||||||
|
|
||||||
|
// ---- operation on SDataRows
|
||||||
|
#define TD_DATAROWS_LEN(pDataRows) (*(int32_t *)(pDataRows))
|
||||||
|
#define TD_DATAROWS_ROWS(pDataRows) (*(int32_t *)(pDataRows + sizeof(int32_t)))
|
||||||
|
#define TD_NEXT_DATAROW(pDataRow) ((pDataRow) + TD_DATAROW_LEN(pDataRow))
|
||||||
|
|
||||||
|
// ---- operation on SDataCol
|
||||||
|
#define TD_DATACOL_LEN(pDataCol) (*(int32_t *)(pDataCol))
|
||||||
|
#define TD_DATACOL_NPOINTS(pDataCol) (*(int32_t *)(pDataCol + sizeof(int32_t)))
|
||||||
|
|
||||||
|
// ---- operation on SDataCols
|
||||||
|
#define TD_DATACOLS_LEN(pDataCols) (*(int32_t *)(pDataCols))
|
||||||
|
#define TD_DATACOLS_NPOINTS(pDataCols) (*(int32_t *)(pDataCols + sizeof(int32_t)))
|
||||||
|
|
||||||
|
#endif // _TD_DATA_FORMAT_H_
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef enum : uint8_t {
|
typedef enum : uint8_t {
|
||||||
TD_DATATYPE_INVLD = 0,
|
TD_DATATYPE_INVLD = 0, // invalid data type
|
||||||
TD_DATATYPE_BOOL,
|
TD_DATATYPE_BOOL,
|
||||||
TD_DATATYPE_TINYINT,
|
TD_DATATYPE_TINYINT,
|
||||||
TD_DATATYPE_SMALLINT,
|
TD_DATATYPE_SMALLINT,
|
|
@ -6,16 +6,36 @@
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "dlist.h"
|
#include "dlist.h"
|
||||||
|
|
||||||
|
#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16*1024*1024 /* 16M */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t blockId;
|
int64_t skey; // start key
|
||||||
SCacheBlock *pBlock
|
int64_t ekey; // end key
|
||||||
|
int32_t numOfRows // numOfRows
|
||||||
|
} STableCacheInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *pData;
|
||||||
|
STableCacheInfo *pTableInfo;
|
||||||
|
SCacheBlock *prev;
|
||||||
|
SCacheBlock *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 {
|
||||||
int64_t blockId; // A block ID counter
|
// Number of blocks the cache is allocated
|
||||||
|
int32_t numOfBlocks;
|
||||||
SDList *cacheList;
|
SDList *cacheList;
|
||||||
} STSDBCache;
|
void * current;
|
||||||
|
} SCacheHandle;
|
||||||
|
|
||||||
|
|
||||||
|
// ---- Operation on STSDBCacheBlock
|
||||||
|
#define TSDB_CACHE_BLOCK_DATA(pBlock) ((pBlock)->pData)
|
||||||
|
#define TSDB_CACHE_AVAIL_SPACE(pBlock) ((char *)((pBlock)->pTableInfo) - ((pBlock)->pData))
|
||||||
|
#define TSDB_TABLE_INFO_OF_CACHE(pBlock, tableId) ((pBlock)->pTableInfo)[tableId]
|
||||||
|
#define TSDB_NEXT_CACHE_BLOCK(pBlock) ((pBlock)->next)
|
||||||
|
#define TSDB_PREV_CACHE_BLOCK(pBlock) ((pBlock)->prev)
|
||||||
|
|
||||||
STSDBCache *tsdbCreateCache();
|
STSDBCache *tsdbCreateCache();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// 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
|
||||||
|
|
||||||
typedef enum : uint8_t {
|
typedef enum {
|
||||||
TSDB_SUPER_TABLE, // super table
|
TSDB_SUPER_TABLE, // super table
|
||||||
TSDB_NTABLE, // table not created from super table
|
TSDB_NTABLE, // table not created from super table
|
||||||
TSDB_STABLE // table created from super table
|
TSDB_STABLE // table created from super table
|
||||||
|
|
|
@ -3,13 +3,21 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "disk.h"
|
#include "disk.h"
|
||||||
#include "cache.h"
|
#include "tsdbMeta.h"
|
||||||
|
#include "tsdbCache.h"
|
||||||
|
|
||||||
typedef struct STSDBRepo
|
typedef struct STSDBRepo
|
||||||
{
|
{
|
||||||
// TSDB configuration
|
// TSDB configuration
|
||||||
STSDBcfg *pCfg;
|
STSDBcfg *pCfg;
|
||||||
|
|
||||||
|
// The meter meta handle of this TSDB repository
|
||||||
|
SMetaHandle *pMetaHandle;
|
||||||
|
|
||||||
|
// The cache Handle
|
||||||
|
SCacheHandle *pCacheHandle;
|
||||||
|
|
||||||
|
|
||||||
/* Disk tier handle for multi-tier storage
|
/* Disk tier handle for multi-tier storage
|
||||||
*
|
*
|
||||||
* The handle is responsible for dealing with object-oriented
|
* The handle is responsible for dealing with object-oriented
|
||||||
|
|
Loading…
Reference in New Issue