提交 d2185b7e 编写于 作者: H Hongze Cheng

more code

上级 8233a5bc
......@@ -112,6 +112,8 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
goto LABEL; \
}
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#ifdef __cplusplus
}
#endif
......
......@@ -15,44 +15,42 @@
#include "dev.h"
int32_t tDelBlockCreate(SDelBlock *pDelBlock) {
memset(pDelBlock, 0, sizeof(SDelBlock));
for (int32_t i = 0; i < 5; ++i) {
tColDataInit(&pDelBlock->aColData[i], i + 1, TSDB_DATA_TYPE_BIGINT, 0);
int32_t tDelBlockCreate(SDelBlock *pDelBlock, int32_t capacity) {
int32_t code;
memset(pDelBlock, 0, sizeof(*pDelBlock));
pDelBlock->capacity = capacity;
for (int32_t i = 0; i < ARRAY_SIZE(pDelBlock->aData); ++i) {
if ((code = tRealloc((uint8_t **)&pDelBlock->aData[i], sizeof(int64_t) * capacity))) {
for (i--; i >= 0; --i) tFree(pDelBlock->aData[i]);
return code;
}
}
return 0;
}
int32_t tDelBlockDestroy(SDelBlock *pDelBlock) {
for (int32_t i = 0; i < 5; ++i) {
tColDataDestroy(&pDelBlock->aColData[i]);
for (int32_t i = 0; i < ARRAY_SIZE(pDelBlock->aData); ++i) {
tFree(pDelBlock->aData[i]);
}
return 0;
}
int32_t tDelBlockClear(SDelBlock *pDelBlock) {
for (int32_t i = 0; i < 5; ++i) {
tColDataClear(&pDelBlock->aColData[i]);
}
pDelBlock->nRow = 0;
return 0;
}
int32_t tDelBlockAppend(SDelBlock *pDelBlock, const TABLEID *tbid, const SDelData *pDelData) {
int32_t code = 0;
SColVal cv;
// TODO
code = tColDataAppendValue(&pDelBlock->aColData[0], &cv);
code = tColDataAppendValue(&pDelBlock->aColData[1], &cv);
code = tColDataAppendValue(&pDelBlock->aColData[2], &cv);
code = tColDataAppendValue(&pDelBlock->aColData[3], &cv);
code = tColDataAppendValue(&pDelBlock->aColData[4], &cv);
return code;
ASSERT(pDelBlock->nRow < pDelBlock->capacity);
pDelBlock->aData[0][pDelBlock->nRow] = tbid->suid;
pDelBlock->aData[1][pDelBlock->nRow] = tbid->uid;
pDelBlock->aData[2][pDelBlock->nRow] = pDelData->version;
pDelBlock->aData[3][pDelBlock->nRow] = pDelData->sKey;
pDelBlock->aData[4][pDelBlock->nRow] = pDelData->eKey;
pDelBlock->nRow++;
return 0;
}
int32_t tsdbUpdateSkmTb(STsdb *pTsdb, const TABLEID *tbid, SSkmInfo *pSkmTb) {
......
......@@ -27,7 +27,7 @@ typedef struct SDelBlock SDelBlock;
typedef struct SDelBlk SDelBlk;
/* Exposed APIs */
int32_t tDelBlockCreate(SDelBlock *pDelBlock);
int32_t tDelBlockCreate(SDelBlock *pDelBlock, int32_t capacity);
int32_t tDelBlockDestroy(SDelBlock *pDelBlock);
int32_t tDelBlockClear(SDelBlock *pDelBlock);
int32_t tDelBlockAppend(SDelBlock *pDelBlock, const TABLEID *tbid, const SDelData *pDelData);
......@@ -36,8 +36,11 @@ int32_t tsdbUpdateSkmTb(STsdb *pTsdb, const TABLEID *tbid, SSkmInfo *pSkmTb);
int32_t tsdbUpdateSkmRow(STsdb *pTsdb, const TABLEID *tbid, int32_t sver, SSkmInfo *pSkmRow);
/* Exposed Structs */
// <suid, uid, version, skey, ekey>
struct SDelBlock {
SColData aColData[5]; // <suid, uid, version, skey, ekey>
int32_t capacity;
int32_t nRow;
int64_t *aData[5]; // [suid, uid, version, skey, ekey
};
struct SDelBlk {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册