more code
This commit is contained in:
parent
a36be0a0ab
commit
3f4b4b5235
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tsdbFS.h"
|
||||||
|
#include "tsdbSttFReaderWriter.h"
|
||||||
|
|
||||||
|
#ifndef _TSDB_COMMIT_H_
|
||||||
|
#define _TSDB_COMMIT_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TSDB_COMMIT_H_*/
|
|
@ -23,7 +23,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct STFileSet STFileSet;
|
typedef struct STFileSet STFileSet;
|
||||||
typedef struct SFileOp SFileOp;
|
typedef struct STFileOp STFileOp;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_FOP_NONE = 0,
|
TSDB_FOP_NONE = 0,
|
||||||
|
@ -37,10 +37,10 @@ int32_t tsdbFileSetToJson(const STFileSet *fset, cJSON *json);
|
||||||
int32_t tsdbFileSetFromJson(const cJSON *json, STFileSet *fset);
|
int32_t tsdbFileSetFromJson(const cJSON *json, STFileSet *fset);
|
||||||
|
|
||||||
int32_t tsdbFileSetCreate(int32_t fid, STFileSet **ppSet);
|
int32_t tsdbFileSetCreate(int32_t fid, STFileSet **ppSet);
|
||||||
int32_t tsdbFileSetEdit(STFileSet *pSet, SFileOp *pOp);
|
int32_t tsdbFileSetEdit(STFileSet *pSet, STFileOp *pOp);
|
||||||
int32_t tsdbEditFileSet(STFileSet *pFileSet, const SFileOp *pOp);
|
int32_t tsdbEditFileSet(STFileSet *pFileSet, const STFileOp *pOp);
|
||||||
|
|
||||||
struct SFileOp {
|
struct STFileOp {
|
||||||
tsdb_fop_t op;
|
tsdb_fop_t op;
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
STFile oState; // old file state
|
STFile oState; // old file state
|
||||||
|
|
|
@ -47,7 +47,7 @@ typedef struct SSttFileWriter SSttFileWriter;
|
||||||
typedef struct SSttFileWriterConfig SSttFileWriterConfig;
|
typedef struct SSttFileWriterConfig SSttFileWriterConfig;
|
||||||
|
|
||||||
int32_t tsdbSttFWriterOpen(const SSttFileWriterConfig *config, SSttFileWriter **ppWriter);
|
int32_t tsdbSttFWriterOpen(const SSttFileWriterConfig *config, SSttFileWriter **ppWriter);
|
||||||
int32_t tsdbSttFWriterClose(SSttFileWriter **ppWriter, int8_t abort, struct SFileOp *op);
|
int32_t tsdbSttFWriterClose(SSttFileWriter **ppWriter, int8_t abort, struct STFileOp *op);
|
||||||
int32_t tsdbSttFWriteTSData(SSttFileWriter *pWriter, TABLEID *tbid, TSDBROW *pRow);
|
int32_t tsdbSttFWriteTSData(SSttFileWriter *pWriter, TABLEID *tbid, TSDBROW *pRow);
|
||||||
int32_t tsdbSttFWriteDLData(SSttFileWriter *pWriter, TABLEID *tbid, SDelData *pDelData);
|
int32_t tsdbSttFWriteDLData(SSttFileWriter *pWriter, TABLEID *tbid, SDelData *pDelData);
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,12 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dev.h"
|
#include "inc/tsdbCommit.h"
|
||||||
|
|
||||||
// extern dependencies
|
// extern dependencies
|
||||||
typedef struct {
|
typedef struct {
|
||||||
STsdb *pTsdb;
|
STsdb *pTsdb;
|
||||||
|
|
||||||
// config
|
// config
|
||||||
int32_t minutes;
|
int32_t minutes;
|
||||||
int8_t precision;
|
int8_t precision;
|
||||||
|
@ -25,7 +26,10 @@ typedef struct {
|
||||||
int32_t maxRow;
|
int32_t maxRow;
|
||||||
int8_t cmprAlg;
|
int8_t cmprAlg;
|
||||||
int8_t sttTrigger;
|
int8_t sttTrigger;
|
||||||
SArray *aTbDataP;
|
|
||||||
|
SArray *aTbDataP; // SArray<STbData *>
|
||||||
|
SArray *aFileOp; // SArray<STFileOp>
|
||||||
|
|
||||||
// context
|
// context
|
||||||
TSKEY nextKey;
|
TSKEY nextKey;
|
||||||
int32_t fid;
|
int32_t fid;
|
||||||
|
@ -33,8 +37,8 @@ typedef struct {
|
||||||
TSKEY minKey;
|
TSKEY minKey;
|
||||||
TSKEY maxKey;
|
TSKEY maxKey;
|
||||||
STFileSet *pFileSet;
|
STFileSet *pFileSet;
|
||||||
|
|
||||||
// writer
|
// writer
|
||||||
SArray *aFileOp;
|
|
||||||
SSttFileWriter *pWriter;
|
SSttFileWriter *pWriter;
|
||||||
} SCommitter;
|
} SCommitter;
|
||||||
|
|
||||||
|
@ -243,7 +247,7 @@ static int32_t end_commit_file_set(SCommitter *pCommitter) {
|
||||||
|
|
||||||
if (pCommitter->pWriter == NULL) return 0;
|
if (pCommitter->pWriter == NULL) return 0;
|
||||||
|
|
||||||
struct SFileOp *pFileOp = taosArrayReserve(pCommitter->aFileOp, 1);
|
struct STFileOp *pFileOp = taosArrayReserve(pCommitter->aFileOp, 1);
|
||||||
if (pFileOp == NULL) {
|
if (pFileOp == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
@ -319,17 +323,14 @@ static int32_t open_committer(STsdb *pTsdb, SCommitInfo *pInfo, SCommitter *pCom
|
||||||
pCommitter->minRow = pInfo->info.config.tsdbCfg.minRows;
|
pCommitter->minRow = pInfo->info.config.tsdbCfg.minRows;
|
||||||
pCommitter->maxRow = pInfo->info.config.tsdbCfg.maxRows;
|
pCommitter->maxRow = pInfo->info.config.tsdbCfg.maxRows;
|
||||||
pCommitter->cmprAlg = pInfo->info.config.tsdbCfg.compression;
|
pCommitter->cmprAlg = pInfo->info.config.tsdbCfg.compression;
|
||||||
pCommitter->sttTrigger = 7; // TODO
|
pCommitter->sttTrigger = 2; // TODO
|
||||||
|
|
||||||
pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
|
pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
|
||||||
if (pCommitter->aTbDataP == NULL) {
|
pCommitter->aFileOp = taosArrayInit(16, sizeof(STFileOp));
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
if (pCommitter->aTbDataP == NULL || pCommitter->aFileOp == NULL) {
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
taosArrayDestroy(pCommitter->aTbDataP);
|
||||||
}
|
taosArrayDestroy(pCommitter->aFileOp);
|
||||||
pCommitter->aFileOp = taosArrayInit(16, sizeof(struct SFileOp));
|
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||||
if (pCommitter->aFileOp == NULL) {
|
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start loop
|
// start loop
|
||||||
|
@ -337,17 +338,9 @@ static int32_t open_committer(STsdb *pTsdb, SCommitInfo *pInfo, SCommitter *pCom
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError( //
|
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
"vgId:%d %s failed at line %d since %s", //
|
|
||||||
TD_VID(pTsdb->pVnode), //
|
|
||||||
__func__, //
|
|
||||||
lino, //
|
|
||||||
tstrerror(code));
|
|
||||||
} else {
|
} else {
|
||||||
tsdbDebug( //
|
tsdbDebug("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
|
||||||
"vgId:%d %s done", //
|
|
||||||
TD_VID(pTsdb->pVnode), //
|
|
||||||
__func__);
|
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -425,16 +418,9 @@ int32_t tsdbCommitBegin(STsdb *pTsdb, SCommitInfo *pInfo) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", //
|
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
TD_VID(pTsdb->pVnode), //
|
|
||||||
__func__, //
|
|
||||||
lino, //
|
|
||||||
tstrerror(code));
|
|
||||||
} else {
|
} else {
|
||||||
tsdbInfo("vgId:%d %s done, nRow:%" PRId64 " nDel:%" PRId64, //
|
tsdbInfo("vgId:%d %s done, nRow:%" PRId64 " nDel:%" PRId64, TD_VID(pTsdb->pVnode), __func__, pMem->nRow,
|
||||||
TD_VID(pTsdb->pVnode), //
|
|
||||||
__func__, //
|
|
||||||
pMem->nRow, //
|
|
||||||
pMem->nDel);
|
pMem->nDel);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -440,7 +440,7 @@ static int32_t edit_fs(STFileSystem *pFS, const SArray *aFileOp) {
|
||||||
// TODO: copy current state to new state
|
// TODO: copy current state to new state
|
||||||
|
|
||||||
for (int32_t iop = 0; iop < taosArrayGetSize(aFileOp); iop++) {
|
for (int32_t iop = 0; iop < taosArrayGetSize(aFileOp); iop++) {
|
||||||
struct SFileOp *pOp = taosArrayGet(aFileOp, iop);
|
struct STFileOp *pOp = taosArrayGet(aFileOp, iop);
|
||||||
|
|
||||||
struct STFileSet tmpSet = {.fid = pOp->fid};
|
struct STFileSet tmpSet = {.fid = pOp->fid};
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFileSetEdit(struct STFileSet *pSet, struct SFileOp *pOp) {
|
int32_t tsdbFileSetEdit(struct STFileSet *pSet, struct STFileOp *pOp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
// TODO
|
// TODO
|
||||||
return code;
|
return code;
|
||||||
|
@ -126,7 +126,7 @@ int32_t tsdbFileSetFromJson(const cJSON *json, STFileSet *fset) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbEditFileSet(struct STFileSet *pFileSet, const struct SFileOp *pOp) {
|
int32_t tsdbEditFileSet(struct STFileSet *pFileSet, const struct STFileOp *pOp) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
ASSERTS(0, "TODO: Not implemented yet");
|
ASSERTS(0, "TODO: Not implemented yet");
|
||||||
// TODO
|
// TODO
|
||||||
|
|
|
@ -30,7 +30,7 @@ typedef struct {
|
||||||
SSttFileWriter *pSttFWriter;
|
SSttFileWriter *pSttFWriter;
|
||||||
SDataFileWriter *pDataFWriter;
|
SDataFileWriter *pDataFWriter;
|
||||||
|
|
||||||
SArray *aFileOp; // SArray<struct SFileOp>
|
SArray *aFileOp; // SArray<struct STFileOp>
|
||||||
} SMerger;
|
} SMerger;
|
||||||
|
|
||||||
static int32_t tsdbFileSystemShouldMerge(STsdb *pTsdb) {
|
static int32_t tsdbFileSystemShouldMerge(STsdb *pTsdb) {
|
||||||
|
|
|
@ -549,7 +549,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbSttFWriterClose(SSttFileWriter **ppWriter, int8_t abort, struct SFileOp *op) {
|
int32_t tsdbSttFWriterClose(SSttFileWriter **ppWriter, int8_t abort, struct STFileOp *op) {
|
||||||
int32_t vgId = TD_VID(ppWriter[0]->config.pTsdb->pVnode);
|
int32_t vgId = TD_VID(ppWriter[0]->config.pTsdb->pVnode);
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
|
|
Loading…
Reference in New Issue