diff --git a/src/tsdb/inc/tsdbMain.h b/src/tsdb/inc/tsdbMain.h index 0749fac72c5ae89e5e2183c3e1dd8a6708dbc08f..e6c6f59ff23b1561a31f5771490d7dab85aee30d 100644 --- a/src/tsdb/inc/tsdbMain.h +++ b/src/tsdb/inc/tsdbMain.h @@ -237,19 +237,19 @@ typedef struct { int32_t algorithm : 8; int32_t numOfRows : 24; int32_t len; - int32_t keyLen; // key column length, keyOffset = offset+sizeof(SCompData)+sizeof(SCompCol)*numOfCols + int32_t keyLen; // key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols int16_t numOfSubBlocks; int16_t numOfCols; // not including timestamp column TSKEY keyFirst; TSKEY keyLast; -} SCompBlock; +} SBlock; typedef struct { int32_t delimiter; // For recovery usage int32_t tid; uint64_t uid; - SCompBlock blocks[]; -} SCompInfo; + SBlock blocks[]; +} SBlockInfo; typedef struct { int16_t colId; @@ -263,14 +263,14 @@ typedef struct { int16_t minIndex; int16_t numOfNull; char padding[2]; -} SCompCol; +} SBlockCol; typedef struct { int32_t delimiter; // For recovery usage int32_t numOfCols; // For recovery usage uint64_t uid; // For recovery usage - SCompCol cols[]; -} SCompData; + SBlockCol cols[]; +} SBlockData; typedef enum { TSDB_WRITE_HELPER, TSDB_READ_HELPER } tsdb_rw_helper_t; @@ -305,10 +305,10 @@ typedef struct { void* pWIdx; // For table set usage SHelperTable tableInfo; - SCompInfo* pCompInfo; + SBlockInfo* pCompInfo; bool hasOldLastBlock; // For block set usage - SCompData* pCompData; + SBlockData* pCompData; SDataCols* pDataCols[2]; void* pBuffer; // Buffer to hold the whole data block void* compBuffer; // Buffer for temperary compress/decompress purpose @@ -319,7 +319,7 @@ typedef struct { SFileGroup fGroup; int numOfIdx; SCompIdx* pCompIdx; - SCompInfo* pCompInfo; + SBlockInfo* pCompInfo; void* pBuf; FILE* tLogStream; } STsdbScanHandle; @@ -523,13 +523,13 @@ int tsdbWriteCompIdx(SRWHelper* pHelper); int tsdbLoadCompIdxImpl(SFile* pFile, uint32_t offset, uint32_t len, void* buffer); int tsdbDecodeSCompIdxImpl(void* buffer, uint32_t len, SCompIdx** ppCompIdx, int* numOfIdx); int tsdbLoadCompIdx(SRWHelper* pHelper, void* target); -int tsdbLoadCompInfoImpl(SFile* pFile, SCompIdx* pIdx, SCompInfo** ppCompInfo); +int tsdbLoadCompInfoImpl(SFile* pFile, SCompIdx* pIdx, SBlockInfo** ppCompInfo); int tsdbLoadCompInfo(SRWHelper* pHelper, void* target); -int tsdbLoadCompData(SRWHelper* phelper, SCompBlock* pcompblock, void* target); +int tsdbLoadCompData(SRWHelper* phelper, SBlock* pcompblock, void* target); void tsdbGetDataStatis(SRWHelper* pHelper, SDataStatis* pStatis, int numOfCols); -int tsdbLoadBlockDataCols(SRWHelper* pHelper, SCompBlock* pCompBlock, SCompInfo* pCompInfo, int16_t* colIds, +int tsdbLoadBlockDataCols(SRWHelper* pHelper, SBlock* pCompBlock, SBlockInfo* pCompInfo, int16_t* colIds, int numOfColIds); -int tsdbLoadBlockData(SRWHelper* pHelper, SCompBlock* pCompBlock, SCompInfo* pCompInfo); +int tsdbLoadBlockData(SRWHelper* pHelper, SBlock* pCompBlock, SBlockInfo* pCompInfo); static FORCE_INLINE int compTSKEY(const void* key1, const void* key2) { if (*(TSKEY*)key1 > *(TSKEY*)key2) { diff --git a/src/tsdb/src/tsdbMemTable.c b/src/tsdb/src/tsdbMemTable.c index 5c3d48f6c9156bfeeb01353380040f6309564489..10476fb45631a5a7168d231c06fcfb968a809d92 100644 --- a/src/tsdb/src/tsdbMemTable.c +++ b/src/tsdb/src/tsdbMemTable.c @@ -645,7 +645,7 @@ void tsdbGetFidKeyRange(int daysPerFile, int8_t precision, int fileId, TSKEY *mi // newLast = TSDB_NLAST_FILE_OPENED(pHelper); // if (tsdbLoadCompIdx(pHelper, NULL) < 0) { -// tsdbError("vgId:%d failed to load SCompIdx part since %s", REPO_ID(pRepo), tstrerror(terrno)); +// tsdbError("vgId:%d failed to load SBlockIdx part since %s", REPO_ID(pRepo), tstrerror(terrno)); // goto _err; // } @@ -681,7 +681,7 @@ void tsdbGetFidKeyRange(int daysPerFile, int8_t precision, int fileId, TSKEY *mi // goto _err; // } -// // Write the SCompBlock part +// // Write the SBlock part // if (tsdbWriteCompInfo(pHelper) < 0) { // tsdbError("vgId:%d, failed to write compInfo part since %s", REPO_ID(pRepo), tstrerror(terrno)); // goto _err; diff --git a/src/tsdb/src/tsdbReadUtil.c b/src/tsdb/src/tsdbReadUtil.c new file mode 100644 index 0000000000000000000000000000000000000000..1eb65016b001f39ee5432fc5969f10859d282ef3 --- /dev/null +++ b/src/tsdb/src/tsdbReadUtil.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "tsdbMain.h" + +typedef struct { + SFileGroup fGroup; + TSKEY minKey; + TSKEY maxKey; +} SReadHandle;