adjust more
This commit is contained in:
parent
77f27b6269
commit
43c84c977a
|
@ -540,7 +540,6 @@ struct SHeadFile {
|
||||||
int64_t commitID;
|
int64_t commitID;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
int64_t loffset;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SDataFile {
|
struct SDataFile {
|
||||||
|
@ -555,6 +554,7 @@ struct SLastFile {
|
||||||
|
|
||||||
int64_t commitID;
|
int64_t commitID;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
|
int64_t offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSmaFile {
|
struct SSmaFile {
|
||||||
|
|
|
@ -466,9 +466,9 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
if (pRSet) {
|
if (pRSet) {
|
||||||
wSet.diskId = pRSet->diskId;
|
wSet.diskId = pRSet->diskId;
|
||||||
wSet.fid = pCommitter->commitFid;
|
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;
|
fData = *pRSet->pDataF;
|
||||||
fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0};
|
fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
|
||||||
fSma = *pRSet->pSmaF;
|
fSma = *pRSet->pSmaF;
|
||||||
} else {
|
} else {
|
||||||
SDiskID did = {0};
|
SDiskID did = {0};
|
||||||
|
@ -479,9 +479,9 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
||||||
|
|
||||||
wSet.diskId = did;
|
wSet.diskId = did;
|
||||||
wSet.fid = pCommitter->commitFid;
|
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};
|
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};
|
fSma = (SSmaFile){.commitID = pCommitter->commitID, .size = 0};
|
||||||
}
|
}
|
||||||
code = tsdbDataFWriterOpen(&pCommitter->dWriter.pWriter, pTsdb, &wSet);
|
code = tsdbDataFWriterOpen(&pCommitter->dWriter.pWriter, pTsdb, &wSet);
|
||||||
|
|
|
@ -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->commitID);
|
||||||
n += tPutI64v(p ? p + n : p, pHeadFile->size);
|
n += tPutI64v(p ? p + n : p, pHeadFile->size);
|
||||||
n += tPutI64v(p ? p + n : p, pHeadFile->offset);
|
n += tPutI64v(p ? p + n : p, pHeadFile->offset);
|
||||||
n += tPutI64v(p ? p + n : p, pHeadFile->loffset);
|
|
||||||
|
|
||||||
return n;
|
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->commitID);
|
||||||
n += tGetI64v(p + n, &pHeadFile->size);
|
n += tGetI64v(p + n, &pHeadFile->size);
|
||||||
n += tGetI64v(p + n, &pHeadFile->offset);
|
n += tGetI64v(p + n, &pHeadFile->offset);
|
||||||
n += tGetI64v(p + n, &pHeadFile->loffset);
|
|
||||||
|
|
||||||
return n;
|
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->commitID);
|
||||||
n += tPutI64v(p ? p + n : p, pLastFile->size);
|
n += tPutI64v(p ? p + n : p, pLastFile->size);
|
||||||
|
n += tPutI64v(p ? p + n : p, pLastFile->offset);
|
||||||
|
|
||||||
return n;
|
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->commitID);
|
||||||
n += tGetI64v(p + n, &pLastFile->size);
|
n += tGetI64v(p + n, &pLastFile->size);
|
||||||
|
n += tGetI64v(p + n, &pLastFile->offset);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,7 +502,7 @@ _err:
|
||||||
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
|
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int64_t offset = pReader->pSet->pHeadF->offset;
|
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;
|
int64_t n;
|
||||||
uint32_t delimiter;
|
uint32_t delimiter;
|
||||||
|
|
||||||
|
@ -564,8 +564,8 @@ _err:
|
||||||
|
|
||||||
int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) {
|
int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int64_t offset = pReader->pSet->pHeadF->loffset;
|
int64_t offset = pReader->pSet->pLastF->offset;
|
||||||
int64_t size = pReader->pSet->pHeadF->size - offset;
|
int64_t size = pReader->pSet->pLastF->size - offset;
|
||||||
int64_t n;
|
int64_t n;
|
||||||
uint32_t delimiter;
|
uint32_t delimiter;
|
||||||
|
|
||||||
|
@ -579,13 +579,13 @@ int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
// seek
|
// seek
|
||||||
if (taosLSeekFile(pReader->pHeadFD, offset, SEEK_SET) < 0) {
|
if (taosLSeekFile(pReader->pLastFD, offset, SEEK_SET) < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read
|
// read
|
||||||
n = taosReadFile(pReader->pHeadFD, pReader->pBuf1, size);
|
n = taosReadFile(pReader->pLastFD, pReader->pBuf1, size);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
|
@ -1292,13 +1292,13 @@ _err:
|
||||||
|
|
||||||
int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) {
|
int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SHeadFile *pHeadFile = &pWriter->fHead;
|
SLastFile *pLastFile = &pWriter->fLast;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
int64_t n;
|
int64_t n;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (taosArrayGetSize(aBlockL) == 0) {
|
if (taosArrayGetSize(aBlockL) == 0) {
|
||||||
pHeadFile->loffset = pHeadFile->size;
|
pLastFile->offset = pLastFile->size;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1324,19 +1324,19 @@ int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) {
|
||||||
ASSERT(n + sizeof(TSCKSUM) == size);
|
ASSERT(n + sizeof(TSCKSUM) == size);
|
||||||
|
|
||||||
// write
|
// write
|
||||||
n = taosWriteFile(pWriter->pHeadFD, pWriter->pBuf1, size);
|
n = taosWriteFile(pWriter->pLastFD, pWriter->pBuf1, size);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
pHeadFile->loffset = pHeadFile->size;
|
pLastFile->offset = pLastFile->size;
|
||||||
pHeadFile->size += size;
|
pLastFile->size += size;
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
tsdbTrace("vgId:%d tsdb write blockl, loffset:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode),
|
tsdbTrace("vgId:%d tsdb write blockl, loffset:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode),
|
||||||
pHeadFile->loffset, size);
|
pLastFile->offset, size);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
|
|
Loading…
Reference in New Issue