This commit is contained in:
Hongze Cheng 2022-05-06 10:21:55 +00:00
parent 79b70ac287
commit 5ec83cbf11
1 changed files with 17 additions and 8 deletions

View File

@ -39,6 +39,7 @@ struct SMemSkipListNode {
struct SMemSkipList { struct SMemSkipList {
uint32_t seed; uint32_t seed;
int8_t maxLevel;
int8_t level; int8_t level;
int32_t size; int32_t size;
SMemSkipListNode pHead[]; SMemSkipListNode pHead[];
@ -96,11 +97,14 @@ int32_t tsdbMemTableDestroy2(STsdb *pTsdb, SMemTable *pMemTb) {
int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *pSubmitBlk) { int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *pSubmitBlk) {
SMemData *pMemData; SMemData *pMemData;
SVBufPool *pPool = pMemTb->pTsdb->pVnode->inUse; STsdb *pTsdb = pMemTb->pTsdb;
SVnode *pVnode = pTsdb->pVnode;
SVBufPool *pPool = pVnode->inUse;
int32_t hash; int32_t hash;
int32_t tlen; int32_t tlen;
uint8_t buf[16]; uint8_t buf[16];
int32_t rSize; int32_t rlen;
const uint8_t *p;
SMemSkipListNode *pSlNode; SMemSkipListNode *pSlNode;
const STSRow *pTSRow; const STSRow *pTSRow;
@ -126,8 +130,9 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
pMemData->minVer = -1; pMemData->minVer = -1;
pMemData->maxVer = -1; pMemData->maxVer = -1;
pMemData->nRows = 0; pMemData->nRows = 0;
pMemData->sl.level = 0;
pMemData->sl.seed = taosRand(); pMemData->sl.seed = taosRand();
pMemData->sl.maxLevel = pVnode->config.tsdbCfg.slLevel;
pMemData->sl.level = 0;
pMemData->sl.size = 0; pMemData->sl.size = 0;
// add to MemTable // add to MemTable
@ -137,9 +142,13 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
} }
// loop to insert data to skiplist // loop to insert data to skiplist
p = pSubmitBlk->pData;
for (;;) { for (;;) {
rSize = 0; if (p - (uint8_t *)pSubmitBlk->pData >= pSubmitBlk->nData) break;
pTSRow = NULL;
// p = tGetLen(p, &rlen);
pTSRow = (STSRow *)p;
p += rlen;
if (pTSRow == NULL) break; if (pTSRow == NULL) break;
// check the row (todo) // check the row (todo)
@ -148,7 +157,7 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
// insert the row // insert the row
int8_t level = 1; int8_t level = 1;
tlen = 0; // sizeof(int64_t) + tsdbPutLen(rSize) + rSize; tlen = 0; // sizeof(int64_t) + tsdbPutLen(rlen) + rlen;
pSlNode = vnodeBufPoolMalloc(pPool, tlen); pSlNode = vnodeBufPoolMalloc(pPool, tlen);
if (pSlNode == NULL) { if (pSlNode == NULL) {
ASSERT(0); ASSERT(0);
@ -158,9 +167,9 @@ int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *p
return 0; return 0;
} }
static void tsdbEncodeRow(int64_t version, int32_t rSize, const STSRow *pRow) {} static void tsdbEncodeRow(int64_t version, int32_t rlen, const STSRow *pRow) {}
static void tsdbDecodeRow(int64_t *version, int32_t *rSize, const STSRow **ppRow) {} static void tsdbDecodeRow(int64_t *version, int32_t *rlen, const STSRow **ppRow) {}
// SMemData // SMemData