more work
This commit is contained in:
parent
7bed78543f
commit
8f3c4e4638
|
@ -31,18 +31,21 @@ extern "C" {
|
||||||
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSDB ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSDB ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
typedef struct TSDBROW TSDBROW;
|
||||||
typedef struct TSDBROW TSDBROW;
|
typedef struct TSDBKEY TSDBKEY;
|
||||||
typedef struct TSDBKEY TSDBKEY;
|
typedef struct TABLEID TABLEID;
|
||||||
typedef struct TABLEID TABLEID;
|
typedef struct SDelOp SDelOp;
|
||||||
typedef struct SDelOp SDelOp;
|
typedef struct SDelDataItem SDelDataItem;
|
||||||
|
typedef struct SDelData SDelData;
|
||||||
|
typedef struct SDelIdxItem SDelIdxItem;
|
||||||
|
typedef struct SDelIdx SDelIdx;
|
||||||
|
typedef struct STbData STbData;
|
||||||
|
typedef struct SMemTable SMemTable;
|
||||||
|
typedef struct STbDataIter STbDataIter;
|
||||||
|
typedef struct SMergeInfo SMergeInfo;
|
||||||
|
typedef struct STable STable;
|
||||||
|
|
||||||
// tsdbMemTable ==============================================================================================
|
// tsdbMemTable ==============================================================================================
|
||||||
typedef struct STbData STbData;
|
|
||||||
typedef struct SMemTable SMemTable;
|
|
||||||
typedef struct STbDataIter STbDataIter;
|
|
||||||
typedef struct SMergeInfo SMergeInfo;
|
|
||||||
typedef struct STable STable;
|
|
||||||
|
|
||||||
// SMemTable
|
// SMemTable
|
||||||
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
|
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
|
||||||
|
@ -75,10 +78,6 @@ int32_t tsdbFSStart(STsdbFS *pFS);
|
||||||
int32_t tsdbFSEnd(STsdbFS *pFS, int8_t rollback);
|
int32_t tsdbFSEnd(STsdbFS *pFS, int8_t rollback);
|
||||||
|
|
||||||
// tsdbReaderWriter.c ==============================================================================================
|
// tsdbReaderWriter.c ==============================================================================================
|
||||||
typedef struct SDelDataItem SDelDataItem;
|
|
||||||
typedef struct SDelData SDelData;
|
|
||||||
typedef struct SDelIdxItem SDelIdxItem;
|
|
||||||
typedef struct SDelIdx SDelIdx;
|
|
||||||
|
|
||||||
// SDataFWriter
|
// SDataFWriter
|
||||||
typedef struct SDataFWriter SDataFWriter;
|
typedef struct SDataFWriter SDataFWriter;
|
||||||
|
@ -149,14 +148,19 @@ void tsdbFree(uint8_t *pBuf);
|
||||||
int32_t tTABLEIDCmprFn(const void *p1, const void *p2);
|
int32_t tTABLEIDCmprFn(const void *p1, const void *p2);
|
||||||
int32_t tsdbKeyCmprFn(const void *p1, const void *p2);
|
int32_t tsdbKeyCmprFn(const void *p1, const void *p2);
|
||||||
|
|
||||||
|
// SDelIdx
|
||||||
|
int32_t tDelIdxGetSize(SDelIdx *pDelIdx);
|
||||||
|
int32_t tDelIdxGetItem(SDelIdx *pDelIdx, int32_t idx, SDelIdxItem *pItem);
|
||||||
int32_t tPutDelIdx(uint8_t *p, SDelIdx *pDelIdx);
|
int32_t tPutDelIdx(uint8_t *p, SDelIdx *pDelIdx);
|
||||||
int32_t tGetDelIdx(uint8_t *p, SDelIdx *pDelIdx);
|
int32_t tGetDelIdx(uint8_t *p, SDelIdx *pDelIdx);
|
||||||
|
|
||||||
|
// SDelData
|
||||||
int32_t tPutDelData(uint8_t *p, SDelData *pDelData);
|
int32_t tPutDelData(uint8_t *p, SDelData *pDelData);
|
||||||
int32_t tGetDelData(uint8_t *p, SDelData *pDelData);
|
int32_t tGetDelData(uint8_t *p, SDelData *pDelData);
|
||||||
|
|
||||||
int32_t tPutDelFileHdr(uint8_t *p, SDelFile *pDelFile);
|
int32_t tPutDelFileHdr(uint8_t *p, SDelFile *pDelFile);
|
||||||
int32_t tGetDelFileHdr(uint8_t *p, SDelFile *pDelFile);
|
int32_t tGetDelFileHdr(uint8_t *p, SDelFile *pDelFile);
|
||||||
|
|
||||||
// structs
|
// structs
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int minFid;
|
int minFid;
|
||||||
|
|
|
@ -210,44 +210,34 @@ static int32_t tsdbCommitDelImpl(SCommitter *pCommitter) {
|
||||||
int32_t iTbData = 0;
|
int32_t iTbData = 0;
|
||||||
int32_t nTbData = taosArrayGetSize(pMemTable->aTbData);
|
int32_t nTbData = taosArrayGetSize(pMemTable->aTbData);
|
||||||
int32_t iDelIdx = 0;
|
int32_t iDelIdx = 0;
|
||||||
int32_t nDelIdx; // TODO
|
int32_t nDelIdx = 0; // TODO
|
||||||
int32_t c;
|
|
||||||
STbData *pTbData = NULL;
|
STbData *pTbData = NULL;
|
||||||
SDelIdx *pDelIdx = NULL;
|
SDelIdx *pDelIdx = NULL;
|
||||||
|
SDelIdx delIdx;
|
||||||
|
|
||||||
|
if (iTbData < nTbData) {
|
||||||
|
pTbData = (STbData *)taosArrayGetP(pMemTable->aTbData, iTbData);
|
||||||
|
}
|
||||||
|
if (iDelIdx < nDelIdx) {
|
||||||
|
// tIMapGet();
|
||||||
|
pDelIdx = &delIdx;
|
||||||
|
}
|
||||||
|
|
||||||
while (iTbData < nTbData || iDelIdx < nDelIdx) {
|
while (iTbData < nTbData || iDelIdx < nDelIdx) {
|
||||||
// if (iTbData < nTbData) {
|
if (pTbData && pDelIdx) {
|
||||||
// pTbData = (STbData *)taosArrayGetP(pMemTable->aTbData, iTbData);
|
} else {
|
||||||
// } else {
|
}
|
||||||
// pTbData = NULL;
|
|
||||||
// }
|
|
||||||
// if (iDelIdx < nDelIdx) {
|
|
||||||
// // pDelIdx = ; // TODO
|
|
||||||
// } else {
|
|
||||||
// pDelIdx = NULL;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (pTbData && pDelIdx) {
|
// start
|
||||||
// c = tTABLEIDCmprFn(pTbData, pDelIdx);
|
// 1. load table del if exist
|
||||||
// if (c == 0) {
|
|
||||||
// iTbData++;
|
|
||||||
// iDelIdx++;
|
|
||||||
// } else if (c < 0) {
|
|
||||||
// iTbData++;
|
|
||||||
// pDelIdx = NULL;
|
|
||||||
// } else {
|
|
||||||
// iDelIdx++;
|
|
||||||
// pTbData = NULL;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (pTbData) {
|
|
||||||
// iTbData++;
|
|
||||||
// } else {
|
|
||||||
// iDelIdx++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TODO: commit with the pTbData and pDelIdx
|
// impl
|
||||||
|
while (1) {
|
||||||
|
// do merge
|
||||||
|
}
|
||||||
|
|
||||||
|
// end
|
||||||
|
// tsdbWriteDelData
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -136,11 +136,45 @@ _err:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbWriteDelData(SDelFWriter *pWriter, SDelData *pDelData, uint8_t **ppBuf, SDelIdxItem *pItem) {
|
int32_t tsdbWriteDelDta(SDelFWriter *pWriter, SDelData *pDelData, uint8_t **ppBuf) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int64_t size;
|
uint8_t *pBuf = NULL;
|
||||||
|
int64_t size;
|
||||||
|
int64_t n;
|
||||||
|
|
||||||
// TODO
|
// prepare
|
||||||
|
|
||||||
|
// alloc
|
||||||
|
if (!ppBuf) ppBuf = &pBuf;
|
||||||
|
size = tPutDelData(NULL, pDelData) + sizeof(TSCKSUM);
|
||||||
|
code = tsdbRealloc(ppBuf, size);
|
||||||
|
if (code) goto _err;
|
||||||
|
|
||||||
|
// build
|
||||||
|
n = tPutDelData(*ppBuf, pDelData);
|
||||||
|
taosCalcChecksumAppend(0, *ppBuf, size);
|
||||||
|
|
||||||
|
ASSERT(n + sizeof(TSCKSUM) == size);
|
||||||
|
|
||||||
|
// write
|
||||||
|
n = taosWriteFile(pWriter->pWriteH, *ppBuf, size);
|
||||||
|
if (n < 0) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(n == size);
|
||||||
|
|
||||||
|
// update
|
||||||
|
pWriter->pFile->offset = pWriter->pFile->size;
|
||||||
|
pWriter->pFile->size += size;
|
||||||
|
|
||||||
|
tsdbFree(pBuf);
|
||||||
|
return code;
|
||||||
|
|
||||||
|
_err:
|
||||||
|
tsdbError("vgId:%d failed to write del data since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
|
||||||
|
tsdbFree(pBuf);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,9 +192,7 @@ int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SDelIdx *pDelIdx, uint8_t **ppBuf)
|
||||||
if (!ppBuf) ppBuf = &pBuf;
|
if (!ppBuf) ppBuf = &pBuf;
|
||||||
size = tPutDelIdx(NULL, pDelIdx) + sizeof(TSCKSUM);
|
size = tPutDelIdx(NULL, pDelIdx) + sizeof(TSCKSUM);
|
||||||
code = tsdbRealloc(ppBuf, size);
|
code = tsdbRealloc(ppBuf, size);
|
||||||
if (code) {
|
if (code) goto _err;
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// build
|
// build
|
||||||
n = tPutDelIdx(*ppBuf, pDelIdx);
|
n = tPutDelIdx(*ppBuf, pDelIdx);
|
||||||
|
@ -291,10 +323,14 @@ int32_t tsdbDelFReaderClose(SDelFReader *pReader) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
if (pReader) {
|
if (pReader) {
|
||||||
taosCloseFile(&pReader->pReadH);
|
if (taosCloseFile(&pReader->pReadH) < 0) {
|
||||||
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,19 @@ int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SDelIdx ======================================================
|
||||||
|
int32_t tDelIdxGetSize(SDelIdx *pDelIdx) {
|
||||||
|
int32_t code = 0;
|
||||||
|
// TODO
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tDelIdxGetItem(SDelIdx *pDelIdx, int32_t idx, SDelIdxItem *pItem) {
|
||||||
|
int32_t code = 0;
|
||||||
|
// TODO
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tPutDelIdx(uint8_t *p, SDelIdx *pDelIdx) {
|
int32_t tPutDelIdx(uint8_t *p, SDelIdx *pDelIdx) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue