more code
This commit is contained in:
parent
4cb4c6388c
commit
9abfe52c4d
|
@ -376,23 +376,16 @@ static void tsdbSttFWriterDoClose(SSttFileWriter *pWriter) {
|
||||||
// TODO: do clear the struct
|
// TODO: do clear the struct
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbSttFWriterOpen(const SSttFileWriterConfig *config, SSttFileWriter **writer) {
|
|
||||||
writer[0] = taosMemoryMalloc(sizeof(*writer[0]));
|
|
||||||
if (writer[0] == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
writer[0]->config = config[0];
|
|
||||||
writer[0]->ctx.opened = false;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t tsdbSttFileDoWriteBloomFilter(SSttFileWriter *writer) {
|
static int32_t tsdbSttFileDoWriteBloomFilter(SSttFileWriter *writer) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbSttFileDoUpdateHeader(SSttFileWriter *writer) {
|
static int32_t tsdbSttFileDoUpdateHeader(SSttFileWriter *writer) {
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, STFileOp *op) {
|
static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, STFileOp *op) {
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
@ -428,8 +421,7 @@ static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, STFileOp *op) {
|
||||||
code = tsdbFsyncFile(writer->fd);
|
code = tsdbFsyncFile(writer->fd);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
code = tsdbCloseFile(&writer->fd);
|
tsdbCloseFile(&writer->fd);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
|
||||||
|
|
||||||
ASSERT(writer->config.file.size > writer->file.size);
|
ASSERT(writer->config.file.size > writer->file.size);
|
||||||
op->optype = writer->config.file.size ? TSDB_FOP_MODIFY : TSDB_FOP_CREATE;
|
op->optype = writer->config.file.size ? TSDB_FOP_MODIFY : TSDB_FOP_CREATE;
|
||||||
|
@ -443,11 +435,34 @@ _exit:
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbSttFWriterCloseAbort(SSttFileWriter *writer) {
|
static int32_t tsdbSttFWriterCloseAbort(SSttFileWriter *writer) {
|
||||||
// TODO
|
char fname[TSDB_FILENAME_LEN];
|
||||||
ASSERT(0);
|
|
||||||
|
tsdbTFileName(writer->config.tsdb, &writer->config.file, fname);
|
||||||
|
if (writer->config.file.size) { // truncate the file to the original size
|
||||||
|
ASSERT(writer->config.file.size <= writer->file.size);
|
||||||
|
if (writer->config.file.size < writer->file.size) {
|
||||||
|
taosFtruncateFile(writer->fd->pFD, writer->config.file.size);
|
||||||
|
tsdbCloseFile(&writer->fd);
|
||||||
|
}
|
||||||
|
} else { // remove the file
|
||||||
|
tsdbCloseFile(&writer->fd);
|
||||||
|
taosRemoveFile(fname);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tsdbSttFWriterOpen(const SSttFileWriterConfig *config, SSttFileWriter **writer) {
|
||||||
|
writer[0] = taosMemoryMalloc(sizeof(*writer[0]));
|
||||||
|
if (writer[0] == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
writer[0]->config = config[0];
|
||||||
|
writer[0]->ctx.opened = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tsdbSttFWriterClose(SSttFileWriter **writer, int8_t abort, STFileOp *op) {
|
int32_t tsdbSttFWriterClose(SSttFileWriter **writer, int8_t abort, STFileOp *op) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
@ -456,11 +471,11 @@ int32_t tsdbSttFWriterClose(SSttFileWriter **writer, int8_t abort, STFileOp *op)
|
||||||
if (!writer[0]->ctx.opened) {
|
if (!writer[0]->ctx.opened) {
|
||||||
op->optype = TSDB_FOP_NONE;
|
op->optype = TSDB_FOP_NONE;
|
||||||
} else {
|
} else {
|
||||||
if (!abort) {
|
if (abort) {
|
||||||
code = tsdbSttFWriterCloseCommit(writer[0], op);
|
code = tsdbSttFWriterCloseAbort(writer[0]);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
} else {
|
} else {
|
||||||
code = tsdbSttFWriterCloseAbort(writer[0]);
|
code = tsdbSttFWriterCloseCommit(writer[0], op);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
tsdbSttFWriterDoClose(writer[0]);
|
tsdbSttFWriterDoClose(writer[0]);
|
||||||
|
|
Loading…
Reference in New Issue