TD-34
This commit is contained in:
parent
5e6ed4b486
commit
d8c7cdf1c9
|
@ -472,7 +472,7 @@ void tSkipListDoInsert(SSkipList *pSkipList, SSkipListNode **forward, int32_t le
|
|||
SL_GET_FORWARD_POINTER(x, i) = pNode;
|
||||
} else {
|
||||
SL_GET_FORWARD_POINTER(pSkipList->pHead, i) = pNode;
|
||||
SL_GET_BACKWARD_POINTER(pSkipList->pHead, i) = (pSkipList->pHead);
|
||||
// SL_GET_BACKWARD_POINTER(pSkipList->pHead, i) = (pSkipList->pHead);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,19 @@ int tsdbOpenFile(SFile *pFile, int oflag);
|
|||
int tsdbCloseFile(SFile *pFile); SFileGroup *tsdbOpenFilesForCommit(STsdbFileH *pFileH, int fid);
|
||||
int tsdbRemoveFileGroup(STsdbFileH *pFile, int fid);
|
||||
|
||||
#define TSDB_FGROUP_ITER_FORWARD 0
|
||||
#define TSDB_FGROUP_ITER_BACKWARD 1
|
||||
typedef struct {
|
||||
int numOfFGroups;
|
||||
SFileGroup *base;
|
||||
SFileGroup *pFileGroup;
|
||||
int direction;
|
||||
} SFileGroupIter;
|
||||
|
||||
void tsdbInitFileGroupIter(STsdbFileH *pFileH, SFileGroupIter *pIter, int direction);
|
||||
void tsdbSeekFileGroupIter(SFileGroupIter *pIter, int fid);
|
||||
SFileGroup *tsdbGetFileGroupNext(SFileGroupIter *pIter);
|
||||
|
||||
typedef struct {
|
||||
int32_t len;
|
||||
int32_t offset;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "tutil.h"
|
||||
#include "tsdbFile.h"
|
||||
|
||||
const char *tsdbFileSuffix[] = {
|
||||
|
@ -133,6 +134,51 @@ int tsdbRemoveFileGroup(STsdbFileH *pFileH, int fid) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tsdbInitFileGroupIter(STsdbFileH *pFileH, SFileGroupIter *pIter, int direction) {
|
||||
pIter->direction = direction;
|
||||
pIter->base = pFileH->fGroup;
|
||||
pIter->numOfFGroups = pFileH->numOfFGroups;
|
||||
if (pFileH->numOfFGroups == 0){
|
||||
pIter->pFileGroup = NULL;
|
||||
} else {
|
||||
if (direction == TSDB_FGROUP_ITER_FORWARD) {
|
||||
pIter->pFileGroup = pFileH->fGroup;
|
||||
} else {
|
||||
pIter->pFileGroup = pFileH->fGroup + pFileH->numOfFGroups - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tsdbSeekFileGroupIter(SFileGroupIter *pIter, int fid) {
|
||||
int flags = (pIter->direction == TSDB_FGROUP_ITER_FORWARD) ? TD_GE : TD_LE;
|
||||
void *ptr = taosbsearch(&fid, pIter->base, sizeof(SFileGroup), pIter->numOfFGroups, compFGroupKey, flags);
|
||||
if (ptr == NULL) {
|
||||
pIter->pFileGroup = NULL;
|
||||
} else {
|
||||
pIter->pFileGroup = (SFileGroup *)ptr;
|
||||
}
|
||||
}
|
||||
|
||||
SFileGroup *tsdbGetFileGroupNext(SFileGroupIter *pIter) {
|
||||
SFileGroup *ret = pIter->pFileGroup;
|
||||
if (ret == NULL) return NULL;
|
||||
|
||||
if (pIter->direction = TSDB_FGROUP_ITER_FORWARD) {
|
||||
if (pIter->pFileGroup + 1 == pIter->base + pIter->numOfFGroups) {
|
||||
pIter->pFileGroup = NULL;
|
||||
} else {
|
||||
pIter->pFileGroup += 1;
|
||||
}
|
||||
} else {
|
||||
if (pIter->pFileGroup - 1 == pIter->base) {
|
||||
pIter->pFileGroup = NULL;
|
||||
} else {
|
||||
pIter->pFileGroup -= 1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tsdbLoadDataBlock(SFile *pFile, SCompBlock *pStartBlock, int numOfBlocks, SDataCols *pCols, SCompData *pCompData) {
|
||||
SCompBlock *pBlock = pStartBlock;
|
||||
for (int i = 0; i < numOfBlocks; i++) {
|
||||
|
|
|
@ -49,8 +49,8 @@ TEST(TsdbTest, DISABLED_tableEncodeDecode) {
|
|||
ASSERT_EQ(memcmp(pTable->schema, tTable->schema, sizeof(STSchema) + sizeof(STColumn) * nCols), 0);
|
||||
}
|
||||
|
||||
TEST(TsdbTest, DISABLED_createRepo) {
|
||||
// TEST(TsdbTest, createRepo) {
|
||||
// TEST(TsdbTest, DISABLED_createRepo) {
|
||||
TEST(TsdbTest, createRepo) {
|
||||
STsdbCfg config;
|
||||
|
||||
// 1. Create a tsdb repository
|
||||
|
|
Loading…
Reference in New Issue