more
This commit is contained in:
parent
ded484b5cd
commit
c36491c19c
|
@ -6,16 +6,35 @@
|
||||||
#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
|
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_KEY_RANGE_AT_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