more
This commit is contained in:
parent
cc7640321b
commit
4ed2af9e97
|
@ -150,6 +150,7 @@ int32_t tTABLEIDCmprFn(const void *p1, const void *p2);
|
|||
int32_t tsdbKeyCmprFn(const void *p1, const void *p2);
|
||||
|
||||
// SDelIdx
|
||||
int32_t tDelIdxClear(SDelIdx *pDelIdx);
|
||||
int32_t tDelIdxPutItem(SDelIdx *pDelIdx, SDelIdxItem *pItem);
|
||||
int32_t tDelIdxGetItemByIdx(SDelIdx *pDelIdx, SDelIdxItem *pItem, int32_t idx);
|
||||
int32_t tDelIdxGetItem(SDelIdx *pDelIdx, SDelIdxItem *pItem, TABLEID id);
|
||||
|
|
|
@ -265,6 +265,8 @@ static int32_t tsdbCommitDelEnd(SCommitter *pCommitter) {
|
|||
if (code) goto _err;
|
||||
}
|
||||
|
||||
tDelIdxClear(&pCommitter->delIdxNew);
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
|
@ -300,7 +302,7 @@ static int32_t tsdbCommitDel(SCommitter *pCommitter) {
|
|||
}
|
||||
|
||||
_exit:
|
||||
tsdbDebug("vgId:%d commit del data done, nDel:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nDel);
|
||||
tsdbDebug("vgId:%d commit del done, nDel:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nDel);
|
||||
return code;
|
||||
|
||||
_err:
|
||||
|
|
|
@ -107,6 +107,9 @@ int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb
|
|||
goto _err;
|
||||
}
|
||||
|
||||
pDelFWriter->pFile->size = TSDB_FHDR_SIZE;
|
||||
pDelFWriter->pFile->offset = 0;
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
|
@ -188,7 +191,6 @@ int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SDelIdx *pDelIdx, uint8_t **ppBuf)
|
|||
|
||||
// prepare
|
||||
pDelIdx->delimiter = TSDB_FILE_DLMT;
|
||||
// pDelIdx->nOffset = (todo)
|
||||
|
||||
// alloc
|
||||
if (!ppBuf) ppBuf = &pBuf;
|
||||
|
@ -219,7 +221,7 @@ int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SDelIdx *pDelIdx, uint8_t **ppBuf)
|
|||
return code;
|
||||
|
||||
_err:
|
||||
tsdbError("vgId:%d failed to write del idx since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
||||
tsdbError("vgId:%d write del idx failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
||||
tsdbFree(pBuf);
|
||||
return code;
|
||||
}
|
||||
|
@ -379,9 +381,12 @@ _err:
|
|||
|
||||
int32_t tsdbReadDelIdx(SDelFReader *pReader, SDelIdx *pDelIdx, uint8_t **ppBuf) {
|
||||
int32_t code = 0;
|
||||
int32_t n;
|
||||
int64_t offset = pReader->pFile->offset;
|
||||
int64_t size = pReader->pFile->size - offset;
|
||||
|
||||
ASSERT(ppBuf && *ppBuf);
|
||||
|
||||
// seek
|
||||
if (taosLSeekFile(pReader->pReadH, offset, SEEK_SET) < 0) {
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -407,10 +412,9 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SDelIdx *pDelIdx, uint8_t **ppBuf)
|
|||
}
|
||||
|
||||
// decode
|
||||
int32_t n = tGetDelIdx(*ppBuf, pDelIdx);
|
||||
n = tGetDelIdx(*ppBuf, pDelIdx);
|
||||
ASSERT(n == size - sizeof(TSCKSUM));
|
||||
ASSERT(pDelIdx->delimiter == TSDB_FILE_DLMT);
|
||||
// ASSERT(pDelIdx->nOffset > 0 && pDelIdx->nData > 0);
|
||||
|
||||
return code;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "tsdb.h"
|
||||
|
||||
// SOffset =======================================================================
|
||||
#define TSDB_OFFSET_I32 ((uint8_t)0)
|
||||
#define TSDB_OFFSET_I16 ((uint8_t)1)
|
||||
#define TSDB_OFFSET_I8 ((uint8_t)2)
|
||||
|
@ -234,6 +235,13 @@ static FORCE_INLINE int32_t tGetDelIdxItem(uint8_t *p, SDelIdxItem *pDelIdxItem)
|
|||
}
|
||||
|
||||
// SDelIdx ======================================================
|
||||
int32_t tDelIdxClear(SDelIdx *pDelIdx) {
|
||||
int32_t code = 0;
|
||||
tdbFree(pDelIdx->offset.pOffset);
|
||||
tdbFree(pDelIdx->pData);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tDelIdxPutItem(SDelIdx *pDelIdx, SDelIdxItem *pItem) {
|
||||
int32_t code = 0;
|
||||
uint32_t offset = pDelIdx->nData;
|
||||
|
|
Loading…
Reference in New Issue