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

more code

上级 44258669
......@@ -47,6 +47,7 @@ typedef void (*TArray2Cb)(void *);
#define TARRAY2_GET_PTR(a, i) ((a)->data + i)
#define TARRAY2_FIRST(a) ((a)->data[0])
#define TARRAY2_LAST(a) ((a)->data[(a)->size - 1])
#define TARRAY2_DATA_LEN(a) ((a)->size * sizeof(typeof((a)->data[0])))
static FORCE_INLINE int32_t tarray2_make_room( //
void *arg, // array
......@@ -114,9 +115,9 @@ static FORCE_INLINE int32_t tarray2_make_room( //
__ret; \
})
#define TARRAY2_INSERT_P(a, idx, ep) TARRAY2_INSERT(a, idx, *(ep))
#define TARRAY2_APPEND(a, e) TARRAY2_INSERT(a, (a)->size, e)
#define TARRAY2_APPEND_P(a, ep) TARRAY2_APPEND(a, *(ep))
#define TARRAY2_INSERT_PTR(a, idx, ep) TARRAY2_INSERT(a, idx, *(ep))
#define TARRAY2_APPEND(a, e) TARRAY2_INSERT(a, (a)->size, e)
#define TARRAY2_APPEND_PTR(a, ep) TARRAY2_APPEND(a, *(ep))
// return (TYPE *)
#define TARRAY2_SEARCH(a, ep, cmp, flag) \
......
......@@ -23,7 +23,10 @@
extern "C" {
#endif
typedef struct SFDataPtr SFDataPtr;
typedef struct SFDataPtr {
int64_t offset;
int64_t size;
} SFDataPtr;
extern int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **ppFD);
extern void tsdbCloseFile(STsdbFD **ppFD);
......@@ -31,11 +34,6 @@ extern int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, const uint8_t *pBuf,
extern int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size);
extern int32_t tsdbFsyncFile(STsdbFD *pFD);
struct SFDataPtr {
int64_t offset;
int64_t size;
};
#ifdef __cplusplus
}
#endif
......
......@@ -38,11 +38,11 @@ typedef union {
typedef union {
TARRAY2(int64_t) aData[5];
struct {
TARRAY2(int64_t) aSuid[1];
TARRAY2(int64_t) aUid[1];
TARRAY2(int64_t) aVer[1];
TARRAY2(int64_t) aSkey[1];
TARRAY2(int64_t) aEkey[1];
TARRAY2(int64_t) suid[1];
TARRAY2(int64_t) uid[1];
TARRAY2(int64_t) version[1];
TARRAY2(int64_t) skey[1];
TARRAY2(int64_t) ekey[1];
};
} SDelBlock;
......@@ -55,7 +55,7 @@ typedef struct SDelBlk {
SFDataPtr dp;
} SDelBlk;
#define DEL_BLOCK_SIZE(db) TARRAY2_SIZE((db)->aSuid)
#define DEL_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid)
int32_t tDelBlockInit(SDelBlock *delBlock);
int32_t tDelBlockFree(SDelBlock *delBlock);
......@@ -97,11 +97,12 @@ typedef union {
typedef struct STbStatisBlk {
int32_t numRec;
int32_t size[9];
TABLEID minTid;
TABLEID maxTid;
int64_t minVer;
int64_t maxVer;
SFDataPtr dp;
SFDataPtr dp[1];
} STbStatisBlk;
#define STATIS_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid)
......@@ -110,8 +111,6 @@ int32_t tStatisBlockInit(STbStatisBlock *statisBlock);
int32_t tStatisBlockFree(STbStatisBlock *statisBlock);
int32_t tStatisBlockClear(STbStatisBlock *statisBlock);
int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *statisRecord);
int32_t tStatisBlockEncode(STbStatisBlock *statisBlock, void *buf, int32_t size);
int32_t tStatisBlockDecode(const void *buf, STbStatisBlock *statisBlock);
// other apis
int32_t tsdbUpdateSkmTb(STsdb *pTsdb, const TABLEID *tbid, SSkmInfo *pSkmTb);
......
......@@ -305,7 +305,7 @@ static int32_t tsdbSttFileDoWriteTSDataBlock(SSttFileWriter *writer) {
}
tBlockDataClear(writer->bData);
code = TARRAY2_APPEND_P(writer->sttBlkArray, sttBlk);
code = TARRAY2_APPEND_PTR(writer->sttBlkArray, sttBlk);
TSDB_CHECK_CODE(code, lino, _exit);
_exit:
......@@ -326,31 +326,31 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) {
.numRec = STATIS_BLOCK_SIZE(writer->sData),
.minTid = {.suid = TARRAY2_FIRST(writer->sData->suid), .uid = TARRAY2_FIRST(writer->sData->uid)},
.maxTid = {.suid = TARRAY2_LAST(writer->sData->suid), .uid = TARRAY2_LAST(writer->sData->uid)},
// .minVer = TARRAY2_FIRST(writer->sData->aVer),
// .maxVer = TARRAY2_FIRST(writer->sData->aVer),
.minVer = TARRAY2_FIRST(writer->sData->minVer),
.maxVer = TARRAY2_FIRST(writer->sData->maxVer),
}};
// statisBlk->minVer = statisBlk->maxVer = statisBlk->maxVer = writer->sData->aData[2][0];
// for (int32_t iRow = 1; iRow < writer->sData->nRow; iRow++) {
// if (statisBlk->minVer > writer->sData->aData[2][iRow]) statisBlk->minVer = writer->sData->aData[2][iRow];
// if (statisBlk->maxVer < writer->sData->aData[2][iRow]) statisBlk->maxVer = writer->sData->aData[2][iRow];
// }
for (int32_t i = 1; i < STATIS_BLOCK_SIZE(writer->sData); i++) {
statisBlk->minVer = TMIN(statisBlk->minVer, TARRAY2_GET(writer->sData->minVer, i));
statisBlk->maxVer = TMAX(statisBlk->maxVer, TARRAY2_GET(writer->sData->maxVer, i));
}
// statisBlk->dp.offset = writer->file->size;
// statisBlk->dp.size = 0;
statisBlk->dp->offset = writer->file->size;
statisBlk->dp->size = 0;
// // TODO: add compression here
// int64_t tsize = sizeof(int64_t) * writer->sData->nRow;
// for (int32_t i = 0; i < ARRAY_SIZE(writer->sData->aData); i++) {
// code = tsdbWriteFile(writer->fd, writer->file->size, (const uint8_t *)writer->sData->aData[i], tsize);
// TSDB_CHECK_CODE(code, lino, _exit);
for (int32_t i = 0; i < ARRAY_SIZE(writer->sData->aData); i++) {
int32_t size;
code = tsdbCmprData((uint8_t *)TARRAY2_DATA(&writer->sData->aData[i]), TARRAY2_DATA_LEN(&writer->sData->aData[i]),
TSDB_DATA_TYPE_BIGINT, TWO_STAGE_COMP, &writer->config->aBuf[0], 0, &size,
&writer->config->aBuf[1]);
TSDB_CHECK_CODE(code, lino, _exit);
statisBlk->size[i] = size;
statisBlk->dp->size += size;
}
// statisBlk->dp.size += tsize;
// writer->file->size += tsize;
// }
tStatisBlockClear(writer->sData);
code = TARRAY2_APPEND_P(writer->statisBlkArray, statisBlk);
code = TARRAY2_APPEND_PTR(writer->statisBlkArray, statisBlk);
TSDB_CHECK_CODE(code, lino, _exit);
_exit:
......@@ -394,7 +394,7 @@ static int32_t tsdbSttFileDoWriteDelBlock(SSttFileWriter *writer) {
}
tDelBlockDestroy(writer->dData);
code = TARRAY2_APPEND_P(writer->delBlkArray, delBlk);
code = TARRAY2_APPEND_PTR(writer->delBlkArray, delBlk);
TSDB_CHECK_CODE(code, lino, _exit);
_exit:
......@@ -723,13 +723,13 @@ int32_t tsdbSttFWriteTSDataBlock(SSttFileWriter *writer, SBlockData *bdata) {
int32_t code = 0;
int32_t lino = 0;
SRowInfo rowInfo;
rowInfo.suid = bdata->suid;
SRowInfo row[1];
row->suid = bdata->suid;
for (int32_t i = 0; i < bdata->nRow; i++) {
rowInfo.uid = bdata->uid ? bdata->uid : bdata->aUid[i];
rowInfo.row = tsdbRowFromBlockData(bdata, i);
row->uid = bdata->uid ? bdata->uid : bdata->aUid[i];
row->row = tsdbRowFromBlockData(bdata, i);
code = tsdbSttFWriteTSData(writer, &rowInfo);
code = tsdbSttFWriteTSData(writer, row);
TSDB_CHECK_CODE(code, lino, _exit);
}
......
......@@ -85,16 +85,6 @@ int32_t tStatisBlockPut(STbStatisBlock *statisBlock, const STbStatisRecord *stat
return 0;
}
int32_t tStatisBlockEncode(STbStatisBlock *statisBlock, void *buf, int32_t size) {
// TODO
return 0;
}
int32_t tStatisBlockDecode(const void *buf, STbStatisBlock *statisBlock) {
// TODO
return 0;
}
// other apis ----------
int32_t tsdbUpdateSkmTb(STsdb *pTsdb, const TABLEID *tbid, SSkmInfo *pSkmTb) {
if (tbid->suid) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册