finish more code
This commit is contained in:
parent
5b83fcc1fc
commit
2cfdf7bf62
|
@ -89,12 +89,12 @@ void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
|||
void tRowDestroy(SRow *pRow);
|
||||
void tRowSort(SArray *aRowP);
|
||||
int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag);
|
||||
int32_t tRowAppendToColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData);
|
||||
|
||||
// SRowIter ================================
|
||||
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
|
||||
void tRowIterClose(SRowIter **ppIter);
|
||||
SColVal *tRowIterNext(SRowIter *pIter);
|
||||
int32_t tRowAppendToColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData);
|
||||
|
||||
// STag ================================
|
||||
int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag);
|
||||
|
|
|
@ -117,7 +117,8 @@ static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) {
|
|||
void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
||||
int32_t tsdbRowCmprFn(const void *p1, const void *p2);
|
||||
// STSDBRowIter
|
||||
void tsdbRowIterInit(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema);
|
||||
int32_t tsdbRowIterOpen(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema);
|
||||
void tsdbRowClose(STSDBRowIter *pIter);
|
||||
SColVal *tsdbRowIterNext(STSDBRowIter *pIter);
|
||||
// SRowMerger
|
||||
int32_t tsdbRowMergerInit2(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRow, STSchema *pTSchema);
|
||||
|
@ -571,10 +572,14 @@ struct SDFileSet {
|
|||
};
|
||||
|
||||
struct STSDBRowIter {
|
||||
TSDBROW *pRow;
|
||||
STSchema *pTSchema;
|
||||
SColVal colVal;
|
||||
int32_t i;
|
||||
TSDBROW *pRow;
|
||||
union {
|
||||
SRowIter *pIter;
|
||||
struct {
|
||||
int32_t iColData;
|
||||
SColVal cv;
|
||||
};
|
||||
};
|
||||
};
|
||||
struct SRowMerger {
|
||||
STSchema *pTSchema;
|
||||
|
|
|
@ -596,7 +596,7 @@ int32_t tDiskDataAddRow(SDiskDataBuilder *pBuilder, TSDBROW *pRow, STSchema *pTS
|
|||
if (pBuilder->bi.maxKey < kRow.ts) pBuilder->bi.maxKey = kRow.ts;
|
||||
|
||||
STSDBRowIter iter = {0};
|
||||
tsdbRowIterInit(&iter, pRow, pTSchema);
|
||||
tsdbRowIterOpen(&iter, pRow, pTSchema);
|
||||
|
||||
SColVal *pColVal = tsdbRowIterNext(&iter);
|
||||
for (int32_t iBuilder = 0; iBuilder < pBuilder->nBuilder; iBuilder++) {
|
||||
|
|
|
@ -594,42 +594,50 @@ int32_t tsdbRowCmprFn(const void *p1, const void *p2) {
|
|||
}
|
||||
|
||||
// STSDBRowIter ======================================================
|
||||
void tsdbRowIterInit(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema) {
|
||||
int32_t tsdbRowIterOpen(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema) {
|
||||
int32_t code = 0;
|
||||
|
||||
pIter->pRow = pRow;
|
||||
if (pRow->type == TSDBROW_ROW_FMT) {
|
||||
ASSERT(pTSchema);
|
||||
pIter->pTSchema = pTSchema;
|
||||
pIter->i = 1;
|
||||
code = tRowIterOpen(pRow->pTSRow, pTSchema, &pIter->pIter);
|
||||
if (code) goto _exit;
|
||||
} else if (pRow->type == TSDBROW_COL_FMT) {
|
||||
pIter->pTSchema = NULL;
|
||||
pIter->i = 0;
|
||||
pIter->iColData = 0;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
void tsdbRowClose(STSDBRowIter *pIter) {
|
||||
if (pIter->pRow->type == TSDBROW_ROW_FMT) {
|
||||
tRowIterClose(&pIter->pIter);
|
||||
}
|
||||
}
|
||||
|
||||
SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
|
||||
if (pIter->pRow->type == TSDBROW_ROW_FMT) {
|
||||
if (pIter->i < pIter->pTSchema->numOfCols) {
|
||||
tRowGet(pIter->pRow->pTSRow, pIter->pTSchema, pIter->i, &pIter->colVal);
|
||||
pIter->i++;
|
||||
|
||||
return &pIter->colVal;
|
||||
}
|
||||
return tRowIterNext(pIter->pIter);
|
||||
} else if (pIter->pRow->type == TSDBROW_COL_FMT) {
|
||||
if (pIter->i < pIter->pRow->pBlockData->nColData) {
|
||||
SColData *pColData = tBlockDataGetColDataByIdx(pIter->pRow->pBlockData, pIter->i);
|
||||
if (pIter->iColData == 0) {
|
||||
pIter->cv = COL_VAL_VALUE(PRIMARYKEY_TIMESTAMP_COL_ID, TSDB_DATA_TYPE_TIMESTAMP,
|
||||
(SValue){.val = pIter->pRow->pBlockData->aTSKEY[pIter->pRow->iRow]});
|
||||
++pIter->iColData;
|
||||
return &pIter->cv;
|
||||
}
|
||||
|
||||
tColDataGetValue(pColData, pIter->pRow->iRow, &pIter->colVal);
|
||||
pIter->i++;
|
||||
|
||||
return &pIter->colVal;
|
||||
if (pIter->iColData < pIter->pRow->pBlockData->nColData) {
|
||||
tColDataGetValue(&pIter->pRow->pBlockData->aColData[pIter->iColData], pIter->pRow->iRow, &pIter->cv);
|
||||
++pIter->iColData;
|
||||
return &pIter->cv;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// SRowMerger ======================================================
|
||||
|
|
Loading…
Reference in New Issue