more code
This commit is contained in:
parent
cc0c3771a6
commit
6e23c8cdb3
|
@ -71,7 +71,7 @@ int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData);
|
|||
int32_t tBufferReserve(SBuffer *pBuffer, int64_t nData, void **ppData);
|
||||
|
||||
// STSchema ================================
|
||||
void tTSchemaDestroy(STSchema *pTSchema);
|
||||
void tDestroyTSchema(STSchema *pTSchema);
|
||||
|
||||
// SColVal ================================
|
||||
#define CV_FLAG_VALUE ((int8_t)0x0)
|
||||
|
@ -243,6 +243,8 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version)
|
|||
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t flags, col_id_t colId, col_bytes_t bytes);
|
||||
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
||||
|
||||
STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -709,9 +709,6 @@ _exit:
|
|||
}
|
||||
|
||||
// STSchema ========================================
|
||||
void tTSchemaDestroy(STSchema *pTSchema) {
|
||||
if (pTSchema) taosMemoryFree(pTSchema);
|
||||
}
|
||||
|
||||
// STag ========================================
|
||||
static int tTagValCmprFn(const void *p1, const void *p2) {
|
||||
|
@ -1179,6 +1176,43 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder) {
|
|||
|
||||
#endif
|
||||
|
||||
STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version) {
|
||||
STSchema *pTSchema = taosMemoryCalloc(1, sizeof(STSchema) + sizeof(STColumn) * numOfCols);
|
||||
if (pTSchema == NULL) return NULL;
|
||||
|
||||
pTSchema->numOfCols = numOfCols;
|
||||
pTSchema->version = version;
|
||||
|
||||
// timestamp column
|
||||
ASSERT(aSchema[0].type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
ASSERT(aSchema[0].colId == PRIMARYKEY_TIMESTAMP_COL_ID);
|
||||
pTSchema->columns[0].colId = aSchema[0].colId;
|
||||
pTSchema->columns[0].type = aSchema[0].type;
|
||||
pTSchema->columns[0].flags = aSchema[0].flags;
|
||||
pTSchema->columns[0].bytes = aSchema[0].bytes;
|
||||
pTSchema->columns[0].offset = -1;
|
||||
|
||||
// other columns
|
||||
for (int32_t iCol = 1; iCol < numOfCols; iCol++) {
|
||||
SSchema *pSchema = &aSchema[iCol];
|
||||
STColumn *pTColumn = &pTSchema->columns[iCol];
|
||||
|
||||
pTColumn->colId = pSchema->colId;
|
||||
pTColumn->type = pSchema->type;
|
||||
pTColumn->flags = pSchema->flags;
|
||||
pTColumn->bytes = pSchema->bytes;
|
||||
pTColumn->offset = pTSchema->flen;
|
||||
|
||||
pTSchema->flen += TYPE_BYTES[pTColumn->type];
|
||||
}
|
||||
|
||||
return pTSchema;
|
||||
}
|
||||
|
||||
void tDestroyTSchema(STSchema *pTSchema) {
|
||||
if (pTSchema) taosMemoryFree(pTSchema);
|
||||
}
|
||||
|
||||
// SColData ========================================
|
||||
void tColDataDestroy(void *ph) {
|
||||
SColData *pColData = (SColData *)ph;
|
||||
|
|
|
@ -341,7 +341,7 @@ int32_t tsdbUpdateTableSchema(SMeta *pMeta, int64_t suid, int64_t uid, SSkmInfo
|
|||
|
||||
pSkmInfo->suid = suid;
|
||||
pSkmInfo->uid = uid;
|
||||
tTSchemaDestroy(pSkmInfo->pTSchema);
|
||||
tDestroyTSchema(pSkmInfo->pTSchema);
|
||||
code = metaGetTbTSchemaEx(pMeta, suid, uid, -1, &pSkmInfo->pTSchema);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
|
@ -365,7 +365,7 @@ static int32_t tsdbCommitterUpdateRowSchema(SCommitter *pCommitter, int64_t suid
|
|||
|
||||
pCommitter->skmRow.suid = suid;
|
||||
pCommitter->skmRow.uid = uid;
|
||||
tTSchemaDestroy(pCommitter->skmRow.pTSchema);
|
||||
tDestroyTSchema(pCommitter->skmRow.pTSchema);
|
||||
code = metaGetTbTSchemaEx(pCommitter->pTsdb->pVnode->pMeta, suid, uid, sver, &pCommitter->skmRow.pTSchema);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
|
@ -498,7 +498,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
|||
#if 0
|
||||
ASSERT(pCommitter->minKey <= pCommitter->nextKey && pCommitter->maxKey >= pCommitter->nextKey);
|
||||
#endif
|
||||
|
||||
|
||||
pCommitter->nextKey = TSKEY_MAX;
|
||||
|
||||
// Reader
|
||||
|
@ -623,7 +623,8 @@ int32_t tsdbWriteDataBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SMapDa
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino,
|
||||
tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -666,7 +667,8 @@ int32_t tsdbWriteSttBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SArray
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino,
|
||||
tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -706,7 +708,8 @@ static int32_t tsdbCommitSttBlk(SDataFWriter *pWriter, SDiskDataBuilder *pBuilde
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino,
|
||||
tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -919,8 +922,8 @@ static void tsdbCommitDataEnd(SCommitter *pCommitter) {
|
|||
#else
|
||||
tBlockDataDestroy(&pCommitter->dWriter.bDatal, 1);
|
||||
#endif
|
||||
tTSchemaDestroy(pCommitter->skmTable.pTSchema);
|
||||
tTSchemaDestroy(pCommitter->skmRow.pTSchema);
|
||||
tDestroyTSchema(pCommitter->skmTable.pTSchema);
|
||||
tDestroyTSchema(pCommitter->skmRow.pTSchema);
|
||||
}
|
||||
|
||||
static int32_t tsdbCommitData(SCommitter *pCommitter) {
|
||||
|
|
|
@ -555,7 +555,7 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
|
|||
}
|
||||
|
||||
tBlockDataDestroy(&pReader->bData, 1);
|
||||
tTSchemaDestroy(pReader->skmTable.pTSchema);
|
||||
tDestroyTSchema(pReader->skmTable.pTSchema);
|
||||
|
||||
// del
|
||||
if (pReader->pDelFReader) tsdbDelFReaderClose(&pReader->pDelFReader);
|
||||
|
@ -1416,7 +1416,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
|||
taosArrayDestroy(pWriter->dReader.aBlockIdx);
|
||||
|
||||
tBlockDataDestroy(&pWriter->bData, 1);
|
||||
tTSchemaDestroy(pWriter->skmTable.pTSchema);
|
||||
tDestroyTSchema(pWriter->skmTable.pTSchema);
|
||||
|
||||
for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) {
|
||||
tFree(pWriter->aBuf[iBuf]);
|
||||
|
|
Loading…
Reference in New Issue