提交 50e61591 编写于 作者: H Hongze Cheng

more work

上级 e29651f0
......@@ -55,6 +55,10 @@ typedef struct SReadH SReadH;
#define TSDB_MAX_SUBBLOCKS 8
#define HAS_NONE ((int8_t)0x1)
#define HAS_NULL ((int8_t)0x2)
#define HAS_VALUE ((int8_t)0x4)
// tsdbMemTable ==============================================================================================
// SMemTable
......@@ -185,6 +189,10 @@ int32_t tPutBlock(uint8_t *p, void *ph);
int32_t tGetBlock(uint8_t *p, void *ph);
int32_t tBlockCmprFn(const void *p1, const void *p2);
// SBlockCol
int32_t tPutBlockCol(uint8_t *p, void *ph);
int32_t tGetBlockCol(uint8_t *p, void *ph);
// SBlockData
#define tsdbBlockDataCreate() ((SBlockData){0})
void tsdbBlockDataClear(SBlockData *pBlockData);
......@@ -306,9 +314,28 @@ struct SBlockIdx {
int64_t size;
};
struct SMapData {
int32_t nItem;
uint8_t flag;
uint8_t *pOfst;
uint32_t nData;
uint8_t *pData;
uint8_t *pBuf;
};
typedef struct {
int16_t cid;
int8_t type;
int8_t flag;
int64_t offset;
int64_t size;
} SBlockCol;
typedef struct {
int64_t offset;
int64_t ksize;
int64_t bsize;
SMapData mBlockCol; // SMapData<SBlockCol>
} SSubBlock;
struct SBlock {
......@@ -317,9 +344,11 @@ struct SBlock {
int8_t last;
int8_t hasDup;
int8_t nSubBlock;
SSubBlock sBlocks[TSDB_MAX_SUBBLOCKS];
SSubBlock aSubBlock[TSDB_MAX_SUBBLOCKS];
};
int a = sizeof(SBlock);
struct SAggrBlkCol {
int16_t colId;
int16_t maxIndex;
......@@ -393,15 +422,6 @@ struct SDelFile {
int64_t offset;
};
struct SMapData {
int32_t nItem;
uint8_t flag;
uint8_t *pOfst;
uint32_t nData;
uint8_t *pData;
uint8_t *pBuf;
};
typedef struct {
int16_t colId;
int16_t maxIndex;
......
......@@ -723,8 +723,48 @@ _err:
int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, uint8_t **ppBuf, SBlockIdx *pBlockIdx,
SBlock *pBlock) {
int32_t code = 0;
// TODO
int32_t code = 0;
SSubBlock *pSubBlock = &pBlock->aSubBlock[pBlock->nSubBlock++];
SBlockCol bCol;
pSubBlock->offset = 0;
pSubBlock->ksize = 0;
pSubBlock->bsize = 0;
tMapDataClear(&pSubBlock->mBlockCol);
// TSDBKEY
// other columns
for (int32_t iCol = 0; iCol < pBlockData->nCol; iCol++) {
SColData *pColData = &pBlockData->aColData[iCol];
ASSERT(pColData->flags);
if (pColData->flags == HAS_NONE) continue;
bCol.cid = pColData->cid;
bCol.type = pColData->type;
bCol.flag = pColData->flags;
if (pColData->flags != HAS_NULL) {
if (pColData->flags != HAS_VALUE) {
// handle bitmap
}
// handle real data
// bCol.offset = ;
// bCol.size = ;
}
code = tMapDataPutItem(&pSubBlock->mBlockCol, &bCol, tPutBlockCol);
if (code) goto _err;
}
return code;
_err:
tsdbError("vgId:%d write block data failed since %s", pWriter->pTsdb, tstrerror(code));
return code;
}
......
......@@ -277,14 +277,14 @@ int32_t tGetBlockIdx(uint8_t *p, void *ph) {
// SBlock ======================================================
int32_t tPutBlock(uint8_t *p, void *ph) {
int32_t n = 0;
ASSERT(0);
SBlock *pBlock = (SBlock *)ph;
// TODO
return n;
}
int32_t tGetBlock(uint8_t *p, void *ph) {
int32_t n = 0;
ASSERT(0);
SBlock *pBlock = (SBlock *)ph;
// TODO
return n;
}
......@@ -303,6 +303,43 @@ int32_t tBlockCmprFn(const void *p1, const void *p2) {
return 0;
}
// SBlockCol ======================================================
int32_t tPutBlockCol(uint8_t *p, void *ph) {
int32_t n = 0;
SBlockCol *pBlockCol = (SBlockCol *)ph;
ASSERT(pBlockCol->flag && (pBlockCol->flag != HAS_NONE));
n += tPutI16v(p ? p + n : p, pBlockCol->cid);
n += tPutI8(p ? p + n : p, pBlockCol->type);
n += tPutI8(p ? p + n : p, pBlockCol->flag);
if (pBlockCol->flag != HAS_NULL) {
n += tPutI64v(p ? p + n : p, pBlockCol->offset);
n += tPutI64v(p ? p + n : p, pBlockCol->size);
}
return n;
}
int32_t tGetBlockCol(uint8_t *p, void *ph) {
int32_t n = 0;
SBlockCol *pBlockCol = (SBlockCol *)ph;
n += tGetI16v(p + n, &pBlockCol->cid);
n += tGetI8(p + n, &pBlockCol->type);
n += tGetI8(p + n, &pBlockCol->flag);
ASSERT(pBlockCol->flag && (pBlockCol->flag != HAS_NONE));
if (pBlockCol->flag != HAS_NULL) {
n += tGetI64v(p + n, &pBlockCol->offset);
n += tGetI64v(p + n, &pBlockCol->size);
}
return n;
}
// SDelIdx ======================================================
int32_t tPutDelIdx(uint8_t *p, void *ph) {
SDelIdx *pDelIdx = (SDelIdx *)ph;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册