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
|
||||
|
||||
typedef struct STFileSet STFileSet;
|
||||
typedef struct SFileOp SFileOp;
|
||||
typedef struct STFileOp STFileOp;
|
||||
|
||||
typedef enum {
|
||||
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 tsdbFileSetCreate(int32_t fid, STFileSet **ppSet);
|
||||
int32_t tsdbFileSetEdit(STFileSet *pSet, SFileOp *pOp);
|
||||
int32_t tsdbEditFileSet(STFileSet *pFileSet, const SFileOp *pOp);
|
||||
int32_t tsdbFileSetEdit(STFileSet *pSet, STFileOp *pOp);
|
||||
int32_t tsdbEditFileSet(STFileSet *pFileSet, const STFileOp *pOp);
|
||||
|
||||
struct SFileOp {
|
||||
struct STFileOp {
|
||||
tsdb_fop_t op;
|
||||
int32_t fid;
|
||||
STFile oState; // old file state
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef struct SSttFileWriter SSttFileWriter;
|
|||
typedef struct SSttFileWriterConfig SSttFileWriterConfig;
|
||||
|
||||
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 tsdbSttFWriteDLData(SSttFileWriter *pWriter, TABLEID *tbid, SDelData *pDelData);
|
||||
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dev.h"
|
||||
#include "inc/tsdbCommit.h"
|
||||
|
||||
// extern dependencies
|
||||
typedef struct {
|
||||
STsdb *pTsdb;
|
||||
|
||||
// config
|
||||
int32_t minutes;
|
||||
int8_t precision;
|
||||
|
@ -25,7 +26,10 @@ typedef struct {
|
|||
int32_t maxRow;
|
||||
int8_t cmprAlg;
|
||||
int8_t sttTrigger;
|
||||
SArray *aTbDataP;
|
||||
|
||||
SArray *aTbDataP; // SArray<STbData *>
|
||||
SArray *aFileOp; // SArray<STFileOp>
|
||||
|
||||
// context
|
||||
TSKEY nextKey;
|
||||
int32_t fid;
|
||||
|
@ -33,8 +37,8 @@ typedef struct {
|
|||
TSKEY minKey;
|
||||
TSKEY maxKey;
|
||||
STFileSet *pFileSet;
|
||||
|
||||
// writer
|
||||
SArray *aFileOp;
|
||||
SSttFileWriter *pWriter;
|
||||
} SCommitter;
|
||||
|
||||
|
@ -243,7 +247,7 @@ static int32_t end_commit_file_set(SCommitter *pCommitter) {
|
|||
|
||||
if (pCommitter->pWriter == NULL) return 0;
|
||||
|
||||
struct SFileOp *pFileOp = taosArrayReserve(pCommitter->aFileOp, 1);
|
||||
struct STFileOp *pFileOp = taosArrayReserve(pCommitter->aFileOp, 1);
|
||||
if (pFileOp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
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->maxRow = pInfo->info.config.tsdbCfg.maxRows;
|
||||
pCommitter->cmprAlg = pInfo->info.config.tsdbCfg.compression;
|
||||
pCommitter->sttTrigger = 7; // TODO
|
||||
pCommitter->sttTrigger = 2; // TODO
|
||||
|
||||
pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
|
||||
if (pCommitter->aTbDataP == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
}
|
||||
pCommitter->aFileOp = taosArrayInit(16, sizeof(struct SFileOp));
|
||||
if (pCommitter->aFileOp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
pCommitter->aFileOp = taosArrayInit(16, sizeof(STFileOp));
|
||||
if (pCommitter->aTbDataP == NULL || pCommitter->aFileOp == NULL) {
|
||||
taosArrayDestroy(pCommitter->aTbDataP);
|
||||
taosArrayDestroy(pCommitter->aFileOp);
|
||||
TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit);
|
||||
}
|
||||
|
||||
// start loop
|
||||
|
@ -337,17 +338,9 @@ static int32_t open_committer(STsdb *pTsdb, SCommitInfo *pInfo, SCommitter *pCom
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError( //
|
||||
"vgId:%d %s failed at line %d since %s", //
|
||||
TD_VID(pTsdb->pVnode), //
|
||||
__func__, //
|
||||
lino, //
|
||||
tstrerror(code));
|
||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
} else {
|
||||
tsdbDebug( //
|
||||
"vgId:%d %s done", //
|
||||
TD_VID(pTsdb->pVnode), //
|
||||
__func__);
|
||||
tsdbDebug("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -425,16 +418,9 @@ int32_t tsdbCommitBegin(STsdb *pTsdb, SCommitInfo *pInfo) {
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d %s failed at line %d since %s", //
|
||||
TD_VID(pTsdb->pVnode), //
|
||||
__func__, //
|
||||
lino, //
|
||||
tstrerror(code));
|
||||
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
} else {
|
||||
tsdbInfo("vgId:%d %s done, nRow:%" PRId64 " nDel:%" PRId64, //
|
||||
TD_VID(pTsdb->pVnode), //
|
||||
__func__, //
|
||||
pMem->nRow, //
|
||||
tsdbInfo("vgId:%d %s done, nRow:%" PRId64 " nDel:%" PRId64, TD_VID(pTsdb->pVnode), __func__, pMem->nRow,
|
||||
pMem->nDel);
|
||||
}
|
||||
return code;
|
||||
|
|
|
@ -440,7 +440,7 @@ static int32_t edit_fs(STFileSystem *pFS, const SArray *aFileOp) {
|
|||
// TODO: copy current state to new state
|
||||
|
||||
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};
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t tsdbFileSetEdit(struct STFileSet *pSet, struct SFileOp *pOp) {
|
||||
int32_t tsdbFileSetEdit(struct STFileSet *pSet, struct STFileOp *pOp) {
|
||||
int32_t code = 0;
|
||||
// TODO
|
||||
return code;
|
||||
|
@ -126,7 +126,7 @@ int32_t tsdbFileSetFromJson(const cJSON *json, STFileSet *fset) {
|
|||
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;
|
||||
ASSERTS(0, "TODO: Not implemented yet");
|
||||
// TODO
|
||||
|
|
|
@ -30,7 +30,7 @@ typedef struct {
|
|||
SSttFileWriter *pSttFWriter;
|
||||
SDataFileWriter *pDataFWriter;
|
||||
|
||||
SArray *aFileOp; // SArray<struct SFileOp>
|
||||
SArray *aFileOp; // SArray<struct STFileOp>
|
||||
} SMerger;
|
||||
|
||||
static int32_t tsdbFileSystemShouldMerge(STsdb *pTsdb) {
|
||||
|
|
|
@ -549,7 +549,7 @@ _exit:
|
|||
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 code = 0;
|
||||
int32_t lino;
|
||||
|
|
Loading…
Reference in New Issue