more progress
This commit is contained in:
parent
de32cab384
commit
0bc5300d03
|
@ -39,13 +39,21 @@ typedef struct SDelOp SDelOp;
|
||||||
static int tsdbKeyCmprFn(const void *p1, const void *p2);
|
static int tsdbKeyCmprFn(const void *p1, const void *p2);
|
||||||
|
|
||||||
// tsdbMemTable2.c ==============================================================================================
|
// tsdbMemTable2.c ==============================================================================================
|
||||||
typedef struct SMemTable SMemTable;
|
typedef struct SMemTable SMemTable;
|
||||||
|
typedef struct SMemData SMemData;
|
||||||
|
typedef struct SMemDataIter SMemDataIter;
|
||||||
|
|
||||||
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable);
|
int32_t tsdbMemTableCreate2(STsdb *pTsdb, SMemTable **ppMemTable);
|
||||||
void tsdbMemTableDestroy2(SMemTable *pMemTable);
|
void tsdbMemTableDestroy2(SMemTable *pMemTable);
|
||||||
int32_t tsdbInsertTableData2(STsdb *pTsdb, int64_t version, SVSubmitBlk *pSubmitBlk);
|
int32_t tsdbInsertTableData2(STsdb *pTsdb, int64_t version, SVSubmitBlk *pSubmitBlk);
|
||||||
int32_t tsdbDeleteTableData2(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
int32_t tsdbDeleteTableData2(STsdb *pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
||||||
|
|
||||||
|
/* SMemDataIter */
|
||||||
|
void tsdbMemDataIterOpen(SMemDataIter *pIter, TSDBKEY *pKey, int8_t backward);
|
||||||
|
void tsdbMemDataIterClose(SMemDataIter *pIter);
|
||||||
|
void tsdbMemDataIterNext(SMemDataIter *pIter);
|
||||||
|
void tsdbMemDataIterGet(SMemDataIter *pIter, TSDBROW **ppRow);
|
||||||
|
|
||||||
// tsdbCommit2.c ==============================================================================================
|
// tsdbCommit2.c ==============================================================================================
|
||||||
int32_t tsdbBegin2(STsdb *pTsdb);
|
int32_t tsdbBegin2(STsdb *pTsdb);
|
||||||
int32_t tsdbCommit2(STsdb *pTsdb);
|
int32_t tsdbCommit2(STsdb *pTsdb);
|
||||||
|
@ -254,6 +262,7 @@ typedef struct {
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
uint32_t hasLast : 2;
|
uint32_t hasLast : 2;
|
||||||
uint32_t numOfBlocks : 30;
|
uint32_t numOfBlocks : 30;
|
||||||
|
uint64_t suid;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
TSKEY maxKey;
|
TSKEY maxKey;
|
||||||
} SBlockIdx;
|
} SBlockIdx;
|
||||||
|
@ -910,6 +919,11 @@ static FORCE_INLINE int tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SMemDataIter {
|
||||||
|
SMemData *pMemData;
|
||||||
|
TSDBROW row;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -78,7 +78,7 @@ static int32_t tsdbStartCommit(SCommitH *pCHandle, STsdb *pTsdb) {
|
||||||
ASSERT(pTsdb->imem == NULL && pTsdb->mem);
|
ASSERT(pTsdb->imem == NULL && pTsdb->mem);
|
||||||
pTsdb->imem = pTsdb->mem;
|
pTsdb->imem = pTsdb->mem;
|
||||||
pTsdb->mem = NULL;
|
pTsdb->mem = NULL;
|
||||||
|
// TODO
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,16 +89,45 @@ static int32_t tsdbEndCommit(SCommitH *pCHandle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
TSKEY fidSKey;
|
SMemDataIter iter = {0};
|
||||||
TSKEY fidEKey;
|
TSDBROW *pRow = NULL;
|
||||||
|
int8_t hasData = 0;
|
||||||
|
TSKEY fidSKey;
|
||||||
|
TSKEY fidEKey;
|
||||||
|
int32_t iMemData = 0;
|
||||||
|
int32_t nMemData = taosArrayGetSize(pCHandle->pMemTable->aMemData);
|
||||||
|
int32_t iBlockIdx = 0;
|
||||||
|
int32_t nBlockIdx;
|
||||||
|
|
||||||
// check if there are data in the time range
|
// check if there are data in the time range
|
||||||
for (int32_t iMemData = 0; iMemData < taosArrayGetSize(pCHandle->pMemTable->aMemData); iMemData++) {
|
for (; iMemData < nMemData; iMemData++) {
|
||||||
/* code */
|
SMemData *pMemData = (SMemData *)taosArrayGetP(pCHandle->pMemTable->aMemData, iMemData);
|
||||||
|
tsdbMemDataIterOpen(&iter, &(TSDBKEY){.ts = fidSKey, .version = 0}, 0);
|
||||||
|
tsdbMemDataIterGet(&iter, &pRow);
|
||||||
|
|
||||||
|
if (pRow->tsRow.ts >= fidSKey && pRow->tsRow.ts <= fidEKey) {
|
||||||
|
hasData = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// has data, do commit to file
|
if (!hasData) return code;
|
||||||
|
|
||||||
|
// loop to commit each table data
|
||||||
|
nBlockIdx = 0;
|
||||||
|
for (;;) {
|
||||||
|
if (iBlockIdx >= nBlockIdx && iMemData >= nMemData) break;
|
||||||
|
|
||||||
|
SMemData *pMemData = NULL;
|
||||||
|
SBlockIdx *pBlockIdx = NULL;
|
||||||
|
if (iMemData < nMemData) {
|
||||||
|
pMemData = (SMemData *)taosArrayGetP(pCHandle->pMemTable->aMemData, iBlockIdx);
|
||||||
|
}
|
||||||
|
if (iBlockIdx < nBlockIdx) {
|
||||||
|
// pBlockIdx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
|
|
||||||
typedef struct SMemData SMemData;
|
|
||||||
typedef struct SMemSkipList SMemSkipList;
|
typedef struct SMemSkipList SMemSkipList;
|
||||||
typedef struct SMemSkipListNode SMemSkipListNode;
|
typedef struct SMemSkipListNode SMemSkipListNode;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue