Merge branch '2.0' of https://github.com/taosdata/TDengine into 2.0
This commit is contained in:
commit
473586ef77
|
@ -1,12 +1,14 @@
|
|||
#if !defined(_TD_CACHE_H_)
|
||||
#define _TD_CACHE_H_
|
||||
|
||||
#define TD_MIN_CACHE_BLOCK_SIZE 1024*1024 /* 1M */
|
||||
#define TD_MAX_CACHE_BLOCK_SIZE 64*1024*1024 /* 64M */
|
||||
|
||||
typedef void cache_pool_t;
|
||||
|
||||
typedef struct SCacheBlock
|
||||
{
|
||||
SCacheBlock *next;
|
||||
SCacheBlock *prev;
|
||||
int32_t blockId;
|
||||
char data[];
|
||||
} SCacheBlock;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "tstring.h"
|
||||
#include "type.h"
|
||||
|
||||
typedef struct _scolumn {
|
||||
|
@ -15,4 +16,25 @@ typedef struct SSchema {
|
|||
SColumn *columns;
|
||||
} SSchema;
|
||||
|
||||
// Column with version
|
||||
typedef struct {
|
||||
td_datatype_t type;
|
||||
int32_t colId;
|
||||
int32_t bytes;
|
||||
} SVColumn;
|
||||
|
||||
// Schema with version
|
||||
typedef struct {
|
||||
int32_t version; // Schema with version
|
||||
int32_t numOfCols;
|
||||
int32_t columnId;
|
||||
SVColumn *columns;
|
||||
} SVSchema;
|
||||
|
||||
int32_t tdAddColumnToSchema(tstring_t pSchema, SColumn col);
|
||||
|
||||
td_datatype_t tdGetTypeOfCol(SSchema *pSchema, int32_t col);
|
||||
int32_t tdGetLengthOfCol(SSchema *pSchema, int32_t col);
|
||||
|
||||
|
||||
#endif // _TD_SCHEMA_H_
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "schema.h"
|
||||
|
||||
/* The row data should in the form of
|
||||
*/
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
// 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,24 @@
|
|||
/* A dynamic string library
|
||||
*/
|
||||
#if !defined(_TD_TSTRING_H_)
|
||||
#define _TD_TSTRING_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef char* tstring_t;
|
||||
|
||||
// The string header
|
||||
typedef struct {
|
||||
int32_t strLen; // Allocated data space
|
||||
int32_t avail; // Available space
|
||||
char data[];
|
||||
} STStrHdr;
|
||||
|
||||
// Get the data length of the string
|
||||
#define TSTRLEN(pstr) ((STStrHdr *)pstr)->strLen
|
||||
// Get the available space
|
||||
#define TSTRAVAIL(pstr) ((STStrHdr *)pstr)->avail
|
||||
// Get the real allocated string length
|
||||
#define TSTRRLEN(pstr) ((STStrHdr *)pstr)->strLen + sizeof(STStrHdr)
|
||||
|
||||
#endif // _TD_TSTRING_H_
|
|
@ -4,11 +4,19 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "cache.h"
|
||||
#include "dlist.h"
|
||||
|
||||
typedef struct {
|
||||
int64_t blockId;
|
||||
SCacheBlock *pBlock
|
||||
} STSDBCacheBlock;
|
||||
|
||||
// Use a doublely linked list to implement this
|
||||
typedef struct STSDBCache {
|
||||
int64_t blockId; // A block ID counter
|
||||
SCacheBlock *blockList;
|
||||
SDList *cacheList;
|
||||
} STSDBCache;
|
||||
|
||||
STSDBCache *tsdbCreateCache();
|
||||
|
||||
#endif // _TD_TSDBCACHE_H_
|
||||
|
|
Loading…
Reference in New Issue