提交 6211f281 编写于 作者: H Hongze Cheng

more work

上级 996ded19
......@@ -42,7 +42,9 @@ int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema *
void tTSchemaDestroy(STSchema *pTSchema);
// 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
#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))
// 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;
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;
}
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;
if (IS_VAR_DATA_TYPE(type)) {
......@@ -421,7 +421,7 @@ int32_t tTSRowNew(STSRowBuilder *pBuilder, SArray *pArray, STSchema *pTSchema, S
_set_none:
if ((flags & 0xf0) == 0) {
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)) {
*(VarDataOffsetT *)(pf + pTColumn->offset) = 0;
} else {
......@@ -434,7 +434,7 @@ int32_t tTSRowNew(STSRowBuilder *pBuilder, SArray *pArray, STSchema *pTSchema, S
_set_null:
if ((flags & 0xf0) == 0) {
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)) {
*(VarDataOffsetT *)(pf + pTColumn->offset) = 0;
} else {
......@@ -1109,9 +1109,9 @@ _err:
#if 1 // ===================================================================================================================
static void dataColSetNEleNull(SDataCol *pCol, int nEle);
int tdAllocMemForCol(SDataCol *pCol, int maxPoints) {
int spaceNeeded = pCol->bytes * maxPoints;
if (IS_VAR_DATA_TYPE(pCol->type)) {
spaceNeeded += sizeof(VarDataOffsetT) * maxPoints;
int spaceNeeded = pCol->bytes * maxPoints;
if (IS_VAR_DATA_TYPE(pCol->type)) {
spaceNeeded += sizeof(VarDataOffsetT) * maxPoints;
}
#ifdef TD_SUPPORT_BITMAP
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 tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
typedef struct TSDBROW TSDBROW;
typedef struct TSDBKEY TSDBKEY;
typedef struct TABLEID TABLEID;
typedef struct SDelOp SDelOp;
typedef struct SDelDataItem SDelDataItem;
typedef struct SDelData SDelData;
typedef struct SDelIdxItem SDelIdxItem;
typedef struct SDelIdx SDelIdx;
typedef struct STbData STbData;
typedef struct SMemTable SMemTable;
typedef struct STbDataIter STbDataIter;
typedef struct SMergeInfo SMergeInfo;
typedef struct STable STable;
typedef struct SOffset SOffset;
typedef struct SMapData SMapData;
typedef struct SVDataCols SVDataCols;
typedef struct TSDBROW TSDBROW;
typedef struct TSDBKEY TSDBKEY;
typedef struct TABLEID TABLEID;
typedef struct SDelOp SDelOp;
typedef struct SDelDataItem SDelDataItem;
typedef struct SDelData SDelData;
typedef struct SDelIdxItem SDelIdxItem;
typedef struct SDelIdx SDelIdx;
typedef struct STbData STbData;
typedef struct SMemTable SMemTable;
typedef struct STbDataIter STbDataIter;
typedef struct SMergeInfo SMergeInfo;
typedef struct STable STable;
typedef struct SOffset SOffset;
typedef struct SMapData SMapData;
typedef struct SColData SColData;
typedef struct SColDataBlock SColDataBlock;
// tsdbMemTable ==============================================================================================
......@@ -270,8 +271,16 @@ int tsdbLockRepo(STsdb *pTsdb);
int tsdbUnlockRepo(STsdb *pTsdb);
struct TSDBROW {
int64_t version;
STSRow *pTSRow;
union {
struct {
int64_t version;
STSRow *pTSRow;
};
struct {
SColDataBlock *pColDataBlock;
int32_t iRow;
};
};
};
struct SBlockIdxItem {
......@@ -449,8 +458,19 @@ struct SMapData {
uint8_t *pData;
};
struct SVDataCols {
int64_t *aVersion;
struct SColData {
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
......
......@@ -40,8 +40,8 @@ struct SCommitter {
SBlockIdx *pBlockIdx;
SMapData oBlock;
SMapData nBlock;
SColDataBatch oBatch;
SColDataBatch nBatch;
SColDataBlock oColDataBlock;
SColDataBlock nColDataBlock;
/* commit del */
SDelFReader *pDelFReader;
SDelFWriter *pDelFWriter;
......
......@@ -726,4 +726,41 @@ int32_t tsdbKeyFid(TSKEY key, int32_t minutes, int8_t precision) {
}
}
// SColDataBlock ======================================================
\ No newline at end of file
// 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;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册