TD-34
This commit is contained in:
parent
cfa6e5469b
commit
5808cc499c
|
@ -56,6 +56,7 @@ int tdListAppend(SList *list, void *data);
|
|||
SListNode *tdListPopHead(SList *list);
|
||||
SListNode *tdListPopTail(SList *list);
|
||||
SListNode *tdListPopNode(SList *list, SListNode *node);
|
||||
void tdListMove(SList *src, SList *dst);
|
||||
|
||||
void tdListNodeGetData(SList *list, SListNode *node, void *target);
|
||||
void tdListInitIter(SList *list, SListIter *pIter, TD_LIST_DIRECTION_T direction);
|
||||
|
|
|
@ -135,6 +135,16 @@ SListNode *tdListPopNode(SList *list, SListNode *node) {
|
|||
return node;
|
||||
}
|
||||
|
||||
// Move all node elements from src to dst, the dst is assumed as an empty list
|
||||
void tdListMove(SList *src, SList *dst) {
|
||||
// assert(dst->eleSize == src->eleSize);
|
||||
dst->numOfEles = src->numOfEles;
|
||||
dst->head = src->head;
|
||||
dst->tail = src->tail;
|
||||
src->numOfEles = 0;
|
||||
src->head = src->tail = NULL;
|
||||
}
|
||||
|
||||
void tdListNodeGetData(SList *list, SListNode *node, void *target) { memcpy(target, node->data, list->eleSize); }
|
||||
|
||||
void tdListInitIter(SList *list, SListIter *pIter, TD_LIST_DIRECTION_T direction) {
|
||||
|
|
|
@ -308,9 +308,23 @@ int32_t tsdbTriggerCommit(tsdb_repo_t *repo) {
|
|||
if (pthread_mutex_lock(&(pRepo->mutex)) < 0) return -1;
|
||||
if (pRepo->commit) return 0;
|
||||
pRepo->commit = 1;
|
||||
// Loop to move pData to iData
|
||||
for (int i = 0; i < pRepo->config.maxTables; i++) {
|
||||
STable *pTable = pRepo->tsdbMeta->tables[i];
|
||||
if (pTable != NULL) {
|
||||
void *pData = pTable->content.pData;
|
||||
pTable->content.pData = NULL;
|
||||
pTable->iData = pData;
|
||||
}
|
||||
}
|
||||
// Loop to move mem to imem
|
||||
tdListMove(pRepo->tsdbCache->mem, pRepo->tsdbCache->imem);
|
||||
|
||||
pthread_create(&(pRepo->commitThread), NULL, tsdbCommitToFile, (void *)repo);
|
||||
pthread_mutex_unlock(&(pRepo->mutex));
|
||||
|
||||
pthread_join(pRepo->commitThread, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -692,7 +706,20 @@ static int32_t tsdbInsertDataToTable(tsdb_repo_t *repo, SSubmitBlk *pBlock) {
|
|||
}
|
||||
|
||||
static void *tsdbCommitToFile(void *arg) {
|
||||
STsdbRepo *pRepo = (STsdbRepo *)arg;
|
||||
// TODO
|
||||
STsdbRepo *pRepo = (STsdbRepo *)arg;
|
||||
STsdbMeta *pMeta = pRepo->tsdbMeta;
|
||||
for (int i = 0; i < pRepo->config.maxTables; i++) {
|
||||
STable *pTable = pMeta->tables[i];
|
||||
if (pTable == NULL) continue;
|
||||
SSkipListIterator *pIter = tSkipListCreateIter(pTable->iData);
|
||||
while (tSkipListIterNext(pIter)) {
|
||||
SSkipListNode *node = tSkipListIterGet(pIter);
|
||||
SDataRow row = SL_GET_NODE_DATA(node);
|
||||
int k = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -101,7 +101,8 @@ TEST(TsdbTest, createRepo) {
|
|||
|
||||
tsdbInsertData(pRepo, pMsg);
|
||||
|
||||
int k = 0;
|
||||
tsdbTriggerCommit(pRepo);
|
||||
|
||||
}
|
||||
|
||||
TEST(TsdbTest, openRepo) {
|
||||
|
|
Loading…
Reference in New Issue