more code
This commit is contained in:
parent
eacd2ac234
commit
b6a567f92e
|
@ -260,7 +260,7 @@ static int32_t apply_commit(STFileSystem *fs) {
|
|||
TARRAY2_REMOVE(fsetArray1, i1, tsdbTFileSetRemove);
|
||||
} else if (fset1->fid > fset2->fid) {
|
||||
// create new file set with fid of fset2->fid
|
||||
code = tsdbTFileSetInitEx(fs->tsdb, fset2, &fset1);
|
||||
code = tsdbTFileSetInitDup(fs->tsdb, fset2, &fset1);
|
||||
if (code) return code;
|
||||
code = TARRAY2_SORT_INSERT(fsetArray1, fset1, tsdbTFileSetCmprFn);
|
||||
if (code) return code;
|
||||
|
@ -278,7 +278,7 @@ static int32_t apply_commit(STFileSystem *fs) {
|
|||
TARRAY2_REMOVE(fsetArray1, i1, tsdbTFileSetRemove);
|
||||
} else {
|
||||
// create new file set with fid of fset2->fid
|
||||
code = tsdbTFileSetInitEx(fs->tsdb, fset2, &fset1);
|
||||
code = tsdbTFileSetInitDup(fs->tsdb, fset2, &fset1);
|
||||
if (code) return code;
|
||||
code = TARRAY2_SORT_INSERT(fsetArray1, fset1, tsdbTFileSetCmprFn);
|
||||
if (code) return code;
|
||||
|
@ -383,7 +383,7 @@ static int32_t tsdbFSDupState(STFileSystem *fs) {
|
|||
const STFileSet *fset1;
|
||||
TARRAY2_FOREACH(src, fset1) {
|
||||
STFileSet *fset2;
|
||||
code = tsdbTFileSetInitEx(fs->tsdb, fset1, &fset2);
|
||||
code = tsdbTFileSetInitDup(fs->tsdb, fset1, &fset2);
|
||||
if (code) return code;
|
||||
code = TARRAY2_APPEND(dst, fset2);
|
||||
if (code) return code;
|
||||
|
@ -656,7 +656,7 @@ int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr) {
|
|||
|
||||
taosThreadRwlockRdlock(&fs->tsdb->rwLock);
|
||||
TARRAY2_FOREACH(fs->fSetArr, fset) {
|
||||
code = tsdbTFileSetInitEx(fs->tsdb, fset, &fset1);
|
||||
code = tsdbTFileSetInitDup(fs->tsdb, fset, &fset1);
|
||||
if (code) break;
|
||||
|
||||
code = TARRAY2_APPEND(fsetArr[0], fset1);
|
||||
|
@ -689,7 +689,8 @@ int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr) {
|
|||
|
||||
taosThreadRwlockRdlock(&fs->tsdb->rwLock);
|
||||
TARRAY2_FOREACH(fs->fSetArr, fset) {
|
||||
// TODO: create ref fset of fset1
|
||||
code = tsdbTFileSetInitRef(fs->tsdb, fset, &fset1);
|
||||
if (code) break;
|
||||
|
||||
code = TARRAY2_APPEND(fsetArr[0], fset1);
|
||||
if (code) break;
|
||||
|
@ -697,7 +698,7 @@ int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr) {
|
|||
taosThreadRwlockUnlock(&fs->tsdb->rwLock);
|
||||
|
||||
if (code) {
|
||||
TARRAY2_DESTROY(fsetArr[0], NULL /* TODO */);
|
||||
TARRAY2_DESTROY(fsetArr[0], tsdbTFileSetClear);
|
||||
fsetArr[0] = NULL;
|
||||
}
|
||||
return code;
|
||||
|
@ -705,7 +706,7 @@ int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr) {
|
|||
|
||||
int32_t tsdbFSDestroyRefSnapshot(TFileSetArray **fsetArr) {
|
||||
if (fsetArr[0]) {
|
||||
TARRAY2_DESTROY(fsetArr[0], NULL /* TODO */);
|
||||
TARRAY2_DESTROY(fsetArr[0], tsdbTFileSetClear);
|
||||
fsetArr[0] = NULL;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -48,6 +48,19 @@ static int32_t tsdbSttLvlInitEx(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lvl
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tsdbSttLvlInitRef(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lvl) {
|
||||
int32_t code = tsdbSttLvlInit(lvl1->level, lvl);
|
||||
if (code) return code;
|
||||
|
||||
STFileObj *fobj1;
|
||||
TARRAY2_FOREACH(lvl1->fobjArr, fobj1) {
|
||||
tsdbTFileObjRef(fobj1);
|
||||
code = TARRAY2_APPEND(lvl[0]->fobjArr, fobj1);
|
||||
if (code) return code;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tsdbSttLvlRemoveFObj(void *data) { tsdbTFileObjRemove(*(STFileObj **)data); }
|
||||
static void tsdbSttLvlRemove(SSttLvl **lvl) {
|
||||
TARRAY2_DESTROY(lvl[0]->fobjArr, tsdbSttLvlRemoveFObj);
|
||||
|
@ -405,7 +418,7 @@ int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbTFileSetInitEx(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset) {
|
||||
int32_t tsdbTFileSetInitDup(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset) {
|
||||
int32_t code = tsdbTFileSetInit(fset1->fid, fset);
|
||||
if (code) return code;
|
||||
|
||||
|
@ -435,6 +448,33 @@ int32_t tsdbTFileSetInitEx(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fse
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset) {
|
||||
int32_t code = tsdbTFileSetInit(fset1->fid, fset);
|
||||
if (code) return code;
|
||||
|
||||
for (int32_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) {
|
||||
if (fset1->farr[ftype] == NULL) continue;
|
||||
|
||||
tsdbTFileObjRef(fset1->farr[ftype]);
|
||||
fset[0]->farr[ftype] = fset1->farr[ftype];
|
||||
}
|
||||
|
||||
const SSttLvl *lvl1;
|
||||
TARRAY2_FOREACH(fset1->lvlArr, lvl1) {
|
||||
SSttLvl *lvl;
|
||||
code = tsdbSttLvlInitRef(pTsdb, lvl1, &lvl);
|
||||
if (code) {
|
||||
tsdbTFileSetClear(fset);
|
||||
return code;
|
||||
}
|
||||
|
||||
code = TARRAY2_APPEND(fset[0]->lvlArr, lvl);
|
||||
if (code) return code;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tsdbTFileSetClear(STFileSet **fset) {
|
||||
if (!fset[0]) return 0;
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ typedef enum {
|
|||
|
||||
// init/clear
|
||||
int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset);
|
||||
int32_t tsdbTFileSetInitEx(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset);
|
||||
int32_t tsdbTFileSetInitDup(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset);
|
||||
int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fset);
|
||||
int32_t tsdbTFileSetClear(STFileSet **fset);
|
||||
int32_t tsdbTFileSetRemove(STFileSet **fset);
|
||||
// to/from json
|
||||
|
|
Loading…
Reference in New Issue