adjust more

This commit is contained in:
Hongze Cheng 2022-08-16 01:45:37 +00:00
parent 77f27b6269
commit 43c84c977a
4 changed files with 18 additions and 18 deletions

View File

@ -540,7 +540,6 @@ struct SHeadFile {
int64_t commitID;
int64_t size;
int64_t offset;
int64_t loffset;
};
struct SDataFile {
@ -555,6 +554,7 @@ struct SLastFile {
int64_t commitID;
int64_t size;
int64_t offset;
};
struct SSmaFile {

View File

@ -466,9 +466,9 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
if (pRSet) {
wSet.diskId = pRSet->diskId;
wSet.fid = pCommitter->commitFid;
fHead = (SHeadFile){.commitID = pCommitter->commitID, .offset = 0, .size = 0, .loffset = 0};
fHead = (SHeadFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
fData = *pRSet->pDataF;
fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0};
fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
fSma = *pRSet->pSmaF;
} else {
SDiskID did = {0};
@ -479,9 +479,9 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
wSet.diskId = did;
wSet.fid = pCommitter->commitFid;
fHead = (SHeadFile){.commitID = pCommitter->commitID, .offset = 0, .size = 0, .loffset = 0};
fHead = (SHeadFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
fData = (SDataFile){.commitID = pCommitter->commitID, .size = 0};
fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0};
fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
fSma = (SSmaFile){.commitID = pCommitter->commitID, .size = 0};
}
code = tsdbDataFWriterOpen(&pCommitter->dWriter.pWriter, pTsdb, &wSet);

View File

@ -21,7 +21,6 @@ int32_t tPutHeadFile(uint8_t *p, SHeadFile *pHeadFile) {
n += tPutI64v(p ? p + n : p, pHeadFile->commitID);
n += tPutI64v(p ? p + n : p, pHeadFile->size);
n += tPutI64v(p ? p + n : p, pHeadFile->offset);
n += tPutI64v(p ? p + n : p, pHeadFile->loffset);
return n;
}
@ -32,7 +31,6 @@ static int32_t tGetHeadFile(uint8_t *p, SHeadFile *pHeadFile) {
n += tGetI64v(p + n, &pHeadFile->commitID);
n += tGetI64v(p + n, &pHeadFile->size);
n += tGetI64v(p + n, &pHeadFile->offset);
n += tGetI64v(p + n, &pHeadFile->loffset);
return n;
}
@ -60,6 +58,7 @@ int32_t tPutLastFile(uint8_t *p, SLastFile *pLastFile) {
n += tPutI64v(p ? p + n : p, pLastFile->commitID);
n += tPutI64v(p ? p + n : p, pLastFile->size);
n += tPutI64v(p ? p + n : p, pLastFile->offset);
return n;
}
@ -69,6 +68,7 @@ static int32_t tGetLastFile(uint8_t *p, SLastFile *pLastFile) {
n += tGetI64v(p + n, &pLastFile->commitID);
n += tGetI64v(p + n, &pLastFile->size);
n += tGetI64v(p + n, &pLastFile->offset);
return n;
}

View File

@ -502,7 +502,7 @@ _err:
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
int32_t code = 0;
int64_t offset = pReader->pSet->pHeadF->offset;
int64_t size = pReader->pSet->pHeadF->loffset - offset;
int64_t size = pReader->pSet->pHeadF->size - offset;
int64_t n;
uint32_t delimiter;
@ -564,8 +564,8 @@ _err:
int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) {
int32_t code = 0;
int64_t offset = pReader->pSet->pHeadF->loffset;
int64_t size = pReader->pSet->pHeadF->size - offset;
int64_t offset = pReader->pSet->pLastF->offset;
int64_t size = pReader->pSet->pLastF->size - offset;
int64_t n;
uint32_t delimiter;
@ -579,13 +579,13 @@ int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) {
if (code) goto _err;
// seek
if (taosLSeekFile(pReader->pHeadFD, offset, SEEK_SET) < 0) {
if (taosLSeekFile(pReader->pLastFD, offset, SEEK_SET) < 0) {
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
}
// read
n = taosReadFile(pReader->pHeadFD, pReader->pBuf1, size);
n = taosReadFile(pReader->pLastFD, pReader->pBuf1, size);
if (n < 0) {
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
@ -1292,13 +1292,13 @@ _err:
int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) {
int32_t code = 0;
SHeadFile *pHeadFile = &pWriter->fHead;
SLastFile *pLastFile = &pWriter->fLast;
int64_t size;
int64_t n;
// check
if (taosArrayGetSize(aBlockL) == 0) {
pHeadFile->loffset = pHeadFile->size;
pLastFile->offset = pLastFile->size;
goto _exit;
}
@ -1324,19 +1324,19 @@ int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) {
ASSERT(n + sizeof(TSCKSUM) == size);
// write
n = taosWriteFile(pWriter->pHeadFD, pWriter->pBuf1, size);
n = taosWriteFile(pWriter->pLastFD, pWriter->pBuf1, size);
if (n < 0) {
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
}
// update
pHeadFile->loffset = pHeadFile->size;
pHeadFile->size += size;
pLastFile->offset = pLastFile->size;
pLastFile->size += size;
_exit:
tsdbTrace("vgId:%d tsdb write blockl, loffset:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode),
pHeadFile->loffset, size);
pLastFile->offset, size);
return code;
_err: