more progress
This commit is contained in:
parent
0bc5300d03
commit
b1a781cc09
|
@ -34,6 +34,7 @@ typedef struct SValue SValue;
|
||||||
typedef struct SColVal SColVal;
|
typedef struct SColVal SColVal;
|
||||||
typedef struct STSRow2 STSRow2;
|
typedef struct STSRow2 STSRow2;
|
||||||
typedef struct STSRowBuilder STSRowBuilder;
|
typedef struct STSRowBuilder STSRowBuilder;
|
||||||
|
typedef struct SColData SColData;
|
||||||
typedef struct STagVal STagVal;
|
typedef struct STagVal STagVal;
|
||||||
typedef struct STag STag;
|
typedef struct STag STag;
|
||||||
|
|
||||||
|
@ -169,6 +170,12 @@ struct STag {
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
struct SColData {
|
||||||
|
int16_t cid;
|
||||||
|
uint32_t nData;
|
||||||
|
uint8_t *pData;
|
||||||
|
};
|
||||||
|
|
||||||
#if 1 //================================================================================================================================================
|
#if 1 //================================================================================================================================================
|
||||||
// Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap.
|
// Imported since 3.0 and use bitmap to demonstrate None/Null/Norm, while use Null/Norm below 3.0 without of bitmap.
|
||||||
#define TD_SUPPORT_BITMAP
|
#define TD_SUPPORT_BITMAP
|
||||||
|
|
|
@ -34,6 +34,7 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct TSDBROW TSDBROW;
|
typedef struct TSDBROW TSDBROW;
|
||||||
typedef struct TSDBKEY TSDBKEY;
|
typedef struct TSDBKEY TSDBKEY;
|
||||||
|
typedef struct TABLEID TABLEID;
|
||||||
typedef struct SDelOp SDelOp;
|
typedef struct SDelOp SDelOp;
|
||||||
|
|
||||||
static int tsdbKeyCmprFn(const void *p1, const void *p2);
|
static int tsdbKeyCmprFn(const void *p1, const void *p2);
|
||||||
|
@ -883,6 +884,11 @@ struct TSDBKEY {
|
||||||
TSKEY ts;
|
TSKEY ts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TABLEID {
|
||||||
|
tb_uid_t suid;
|
||||||
|
tb_uid_t uid;
|
||||||
|
};
|
||||||
|
|
||||||
struct SDelOp {
|
struct SDelOp {
|
||||||
int64_t version;
|
int64_t version;
|
||||||
TSKEY sKey; // included
|
TSKEY sKey; // included
|
||||||
|
@ -919,6 +925,26 @@ static FORCE_INLINE int tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct SMemSkipListNode SMemSkipListNode;
|
||||||
|
typedef struct SMemSkipList {
|
||||||
|
uint32_t seed;
|
||||||
|
int32_t size;
|
||||||
|
int8_t maxLevel;
|
||||||
|
int8_t level;
|
||||||
|
SMemSkipListNode *pHead;
|
||||||
|
SMemSkipListNode *pTail;
|
||||||
|
} SMemSkipList;
|
||||||
|
|
||||||
|
struct SMemData {
|
||||||
|
tb_uid_t suid;
|
||||||
|
tb_uid_t uid;
|
||||||
|
TSDBKEY minKey;
|
||||||
|
TSDBKEY maxKey;
|
||||||
|
SDelOp *delOpHead;
|
||||||
|
SDelOp *delOpTail;
|
||||||
|
SMemSkipList sl;
|
||||||
|
};
|
||||||
|
|
||||||
struct SMemDataIter {
|
struct SMemDataIter {
|
||||||
SMemData *pMemData;
|
SMemData *pMemData;
|
||||||
TSDBROW row;
|
TSDBROW row;
|
||||||
|
|
|
@ -88,6 +88,30 @@ static int32_t tsdbEndCommit(SCommitH *pCHandle) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbCommitTableData(SCommitH *pCHandle, SMemData *pMemData, SBlockIdx *pBlockIdx) {
|
||||||
|
int32_t code = 0;
|
||||||
|
// TODO
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t tsdbTableIdCmprFn(const void *p1, const void *p2) {
|
||||||
|
TABLEID *pId1 = (TABLEID *)p1;
|
||||||
|
TABLEID *pId2 = (TABLEID *)p2;
|
||||||
|
|
||||||
|
if (pId1->suid < pId2->suid) {
|
||||||
|
return -1;
|
||||||
|
} else if (pId1->suid > pId2->suid) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pId1->uid < pId2->uid) {
|
||||||
|
return -1;
|
||||||
|
} else if (pId1->uid > pId2->uid) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
static int32_t tsdbCommitToFile(SCommitH *pCHandle, int32_t fid) {
|
static int32_t tsdbCommitToFile(SCommitH *pCHandle, int32_t fid) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SMemDataIter iter = {0};
|
SMemDataIter iter = {0};
|
||||||
|
@ -114,6 +138,8 @@ static int32_t tsdbCommitToFile(SCommitH *pCHandle, int32_t fid) {
|
||||||
|
|
||||||
if (!hasData) return code;
|
if (!hasData) return code;
|
||||||
|
|
||||||
|
// create or open the file to commit(todo)
|
||||||
|
|
||||||
// loop to commit each table data
|
// loop to commit each table data
|
||||||
nBlockIdx = 0;
|
nBlockIdx = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -127,7 +153,36 @@ static int32_t tsdbCommitToFile(SCommitH *pCHandle, int32_t fid) {
|
||||||
if (iBlockIdx < nBlockIdx) {
|
if (iBlockIdx < nBlockIdx) {
|
||||||
// pBlockIdx
|
// pBlockIdx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pMemData && pBlockIdx) {
|
||||||
|
int32_t c = tsdbTableIdCmprFn(&(TABLEID){.suid = pMemData->suid, .uid = pMemData->uid},
|
||||||
|
&(TABLEID){.suid = pBlockIdx->suid, .uid = pBlockIdx->uid});
|
||||||
|
if (c == 0) {
|
||||||
|
iMemData++;
|
||||||
|
iBlockIdx++;
|
||||||
|
} else if (c < 0) {
|
||||||
|
pBlockIdx = NULL;
|
||||||
|
iMemData++;
|
||||||
|
} else {
|
||||||
|
pMemData = NULL;
|
||||||
|
iBlockIdx++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (pMemData) {
|
||||||
|
iMemData++;
|
||||||
|
} else {
|
||||||
|
iBlockIdx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tsdbCommitTableData(pCHandle, pMemData, pBlockIdx);
|
||||||
|
if (code) {
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
return code;
|
||||||
}
|
}
|
|
@ -15,33 +15,11 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
typedef struct SMemSkipList SMemSkipList;
|
|
||||||
typedef struct SMemSkipListNode SMemSkipListNode;
|
|
||||||
|
|
||||||
struct SMemSkipListNode {
|
struct SMemSkipListNode {
|
||||||
int8_t level;
|
int8_t level;
|
||||||
SMemSkipListNode *forwards[0];
|
SMemSkipListNode *forwards[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMemSkipList {
|
|
||||||
uint32_t seed;
|
|
||||||
int32_t size;
|
|
||||||
int8_t maxLevel;
|
|
||||||
int8_t level;
|
|
||||||
SMemSkipListNode *pHead;
|
|
||||||
SMemSkipListNode *pTail;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SMemData {
|
|
||||||
tb_uid_t suid;
|
|
||||||
tb_uid_t uid;
|
|
||||||
TSDBKEY minKey;
|
|
||||||
TSDBKEY maxKey;
|
|
||||||
SDelOp *delOpHead;
|
|
||||||
SDelOp *delOpTail;
|
|
||||||
SMemSkipList sl;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
STSchema *pTSchema;
|
STSchema *pTSchema;
|
||||||
|
|
Loading…
Reference in New Issue