more work
This commit is contained in:
parent
996ded1944
commit
6211f28102
|
@ -42,7 +42,9 @@ int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema *
|
||||||
void tTSchemaDestroy(STSchema *pTSchema);
|
void tTSchemaDestroy(STSchema *pTSchema);
|
||||||
|
|
||||||
// SValue
|
// SValue
|
||||||
int tValueCmprFn(const SValue *pValue1, const SValue *pValue2, int8_t type);
|
int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type);
|
||||||
|
int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type);
|
||||||
|
int tValueCmprFn(const SValue *pValue1, const SValue *pValue2, int8_t type);
|
||||||
|
|
||||||
// STSRow2
|
// STSRow2
|
||||||
#define COL_VAL_NONE(CID) ((SColVal){.cid = (CID), .isNone = 1})
|
#define COL_VAL_NONE(CID) ((SColVal){.cid = (CID), .isNone = 1})
|
||||||
|
|
|
@ -37,7 +37,7 @@ typedef struct {
|
||||||
#define GET_BIT2(p, i) (((p)[(i) / 4] >> ((i) % 4)) & ((uint8_t)3))
|
#define GET_BIT2(p, i) (((p)[(i) / 4] >> ((i) % 4)) & ((uint8_t)3))
|
||||||
|
|
||||||
// SValue
|
// SValue
|
||||||
static FORCE_INLINE int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type) {
|
int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
@ -88,7 +88,7 @@ static FORCE_INLINE int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type) {
|
int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type) {
|
||||||
int32_t n = 0;
|
int32_t n = 0;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
@ -421,7 +421,7 @@ int32_t tTSRowNew(STSRowBuilder *pBuilder, SArray *pArray, STSchema *pTSchema, S
|
||||||
_set_none:
|
_set_none:
|
||||||
if ((flags & 0xf0) == 0) {
|
if ((flags & 0xf0) == 0) {
|
||||||
setBitMap(pb, 0, iColumn - 1, flags);
|
setBitMap(pb, 0, iColumn - 1, flags);
|
||||||
if (flags & TSROW_HAS_VAL) { // set 0
|
if (flags & TSROW_HAS_VAL) { // set 0
|
||||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||||
*(VarDataOffsetT *)(pf + pTColumn->offset) = 0;
|
*(VarDataOffsetT *)(pf + pTColumn->offset) = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -434,7 +434,7 @@ int32_t tTSRowNew(STSRowBuilder *pBuilder, SArray *pArray, STSchema *pTSchema, S
|
||||||
_set_null:
|
_set_null:
|
||||||
if ((flags & 0xf0) == 0) {
|
if ((flags & 0xf0) == 0) {
|
||||||
setBitMap(pb, 1, iColumn - 1, flags);
|
setBitMap(pb, 1, iColumn - 1, flags);
|
||||||
if (flags & TSROW_HAS_VAL) { // set 0
|
if (flags & TSROW_HAS_VAL) { // set 0
|
||||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||||
*(VarDataOffsetT *)(pf + pTColumn->offset) = 0;
|
*(VarDataOffsetT *)(pf + pTColumn->offset) = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1109,9 +1109,9 @@ _err:
|
||||||
#if 1 // ===================================================================================================================
|
#if 1 // ===================================================================================================================
|
||||||
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
|
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
|
||||||
int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
|
||||||
int spaceNeeded = pCol->bytes * maxPoints;
|
int spaceNeeded = pCol->bytes * maxPoints;
|
||||||
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
spaceNeeded += sizeof(VarDataOffsetT) * maxPoints;
|
spaceNeeded += sizeof(VarDataOffsetT) * maxPoints;
|
||||||
}
|
}
|
||||||
#ifdef TD_SUPPORT_BITMAP
|
#ifdef TD_SUPPORT_BITMAP
|
||||||
int32_t nBitmapBytes = (int32_t)TD_BITMAP_BYTES(maxPoints);
|
int32_t nBitmapBytes = (int32_t)TD_BITMAP_BYTES(maxPoints);
|
||||||
|
|
|
@ -31,22 +31,23 @@ 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 SDelDataItem SDelDataItem;
|
||||||
typedef struct SDelData SDelData;
|
typedef struct SDelData SDelData;
|
||||||
typedef struct SDelIdxItem SDelIdxItem;
|
typedef struct SDelIdxItem SDelIdxItem;
|
||||||
typedef struct SDelIdx SDelIdx;
|
typedef struct SDelIdx SDelIdx;
|
||||||
typedef struct STbData STbData;
|
typedef struct STbData STbData;
|
||||||
typedef struct SMemTable SMemTable;
|
typedef struct SMemTable SMemTable;
|
||||||
typedef struct STbDataIter STbDataIter;
|
typedef struct STbDataIter STbDataIter;
|
||||||
typedef struct SMergeInfo SMergeInfo;
|
typedef struct SMergeInfo SMergeInfo;
|
||||||
typedef struct STable STable;
|
typedef struct STable STable;
|
||||||
typedef struct SOffset SOffset;
|
typedef struct SOffset SOffset;
|
||||||
typedef struct SMapData SMapData;
|
typedef struct SMapData SMapData;
|
||||||
typedef struct SVDataCols SVDataCols;
|
typedef struct SColData SColData;
|
||||||
|
typedef struct SColDataBlock SColDataBlock;
|
||||||
|
|
||||||
// tsdbMemTable ==============================================================================================
|
// tsdbMemTable ==============================================================================================
|
||||||
|
|
||||||
|
@ -270,8 +271,16 @@ int tsdbLockRepo(STsdb *pTsdb);
|
||||||
int tsdbUnlockRepo(STsdb *pTsdb);
|
int tsdbUnlockRepo(STsdb *pTsdb);
|
||||||
|
|
||||||
struct TSDBROW {
|
struct TSDBROW {
|
||||||
int64_t version;
|
union {
|
||||||
STSRow *pTSRow;
|
struct {
|
||||||
|
int64_t version;
|
||||||
|
STSRow *pTSRow;
|
||||||
|
};
|
||||||
|
struct {
|
||||||
|
SColDataBlock *pColDataBlock;
|
||||||
|
int32_t iRow;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SBlockIdxItem {
|
struct SBlockIdxItem {
|
||||||
|
@ -449,8 +458,19 @@ struct SMapData {
|
||||||
uint8_t *pData;
|
uint8_t *pData;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SVDataCols {
|
struct SColData {
|
||||||
int64_t *aVersion;
|
int16_t cid;
|
||||||
|
uint8_t flags;
|
||||||
|
uint32_t nData;
|
||||||
|
uint8_t *pData;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SColDataBlock {
|
||||||
|
int32_t nRow;
|
||||||
|
int64_t *aVersion;
|
||||||
|
TSKEY *aTSKey;
|
||||||
|
int32_t nColData;
|
||||||
|
SColData *aColData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -40,8 +40,8 @@ struct SCommitter {
|
||||||
SBlockIdx *pBlockIdx;
|
SBlockIdx *pBlockIdx;
|
||||||
SMapData oBlock;
|
SMapData oBlock;
|
||||||
SMapData nBlock;
|
SMapData nBlock;
|
||||||
SColDataBatch oBatch;
|
SColDataBlock oColDataBlock;
|
||||||
SColDataBatch nBatch;
|
SColDataBlock nColDataBlock;
|
||||||
/* commit del */
|
/* commit del */
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader;
|
||||||
SDelFWriter *pDelFWriter;
|
SDelFWriter *pDelFWriter;
|
||||||
|
|
|
@ -726,4 +726,41 @@ int32_t tsdbKeyFid(TSKEY key, int32_t minutes, int8_t precision) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SColDataBlock ======================================================
|
// TSDBROW ======================================================
|
||||||
|
void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// SColDataBlock ======================================================
|
||||||
|
int32_t tsdbColDataBlockAppend(SColDataBlock *pColDataBlock, TSDBROW *pRow, STSchema *pTSchema) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t nRow = pColDataBlock->nRow;
|
||||||
|
STColumn *pTColumn;
|
||||||
|
SColData *pColData;
|
||||||
|
SColVal colVal;
|
||||||
|
|
||||||
|
pColDataBlock->nRow++;
|
||||||
|
|
||||||
|
// version
|
||||||
|
pColDataBlock->aVersion[nRow] = pRow->version; // TODO
|
||||||
|
|
||||||
|
// ts
|
||||||
|
pColDataBlock->aTSKey[nRow] = pRow->pTSRow->ts; // TODO
|
||||||
|
|
||||||
|
// other rows
|
||||||
|
for (int32_t iCol = 1; iCol < pTSchema->numOfCols; iCol++) {
|
||||||
|
pTColumn = &pTSchema->columns[iCol];
|
||||||
|
|
||||||
|
tsdbRowGetColVal(pRow, pTSchema, iCol, &colVal);
|
||||||
|
|
||||||
|
if (colVal.isNone) {
|
||||||
|
// TODO
|
||||||
|
} else if (colVal.isNull) {
|
||||||
|
// TODO
|
||||||
|
} else {
|
||||||
|
pColData->nData += tPutValue(pColData->pData + pColData->nData, &colVal.value, pTColumn->type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
|
}
|
Loading…
Reference in New Issue