create stable/table

This commit is contained in:
factosea 2024-03-08 11:23:11 +08:00
parent 30e52bb71a
commit af9fdcd29d
6 changed files with 35 additions and 5 deletions

View File

@ -78,5 +78,6 @@ bool checkColumnLevel(uint8_t type, char level[TSDB_CL_COMPRESS_OPTION_LEN]);
void setColEncode(uint32_t* compress, uint8_t encode);
void setColCompress(uint32_t* compress, uint16_t compressType);
void setColLevel(uint32_t* compress, uint8_t level);
void setColCompressByOption(uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level);
#endif /*_TD_TCOL_H_*/

View File

@ -675,8 +675,16 @@ static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper
return pDstWrapper;
}
static FORCE_INLINE void tInitDefaultSColCmprWrapperByCols(SColCmprWrapper* pCmpr, int32_t nCols) {
assert(!pCmpr->pColCmpr);
pCmpr->pColCmpr = taosMemoryCalloc(nCols, sizeof(SColCmpr));
pCmpr->nCols = nCols;
}
static FORCE_INLINE void tInitDefaultSColCmprWrapper(SColCmprWrapper* pCmpr, SSchemaWrapper* pSchema) {
pCmpr->nCols = pSchema->nCols;
assert(!pCmpr->pColCmpr);
pCmpr->pColCmpr = taosMemoryCalloc(pCmpr->nCols, sizeof(SColCmpr));
for (int32_t i = 0; i < pCmpr->nCols; i++) {
SColCmpr* pColCmpr = &pCmpr->pColCmpr[i];
SSchema* pColSchema = &pSchema->pSchema[i];

View File

@ -152,11 +152,11 @@ const char* columnCompressStr(uint16_t type) {
uint8_t columnLevelVal(const char* level) {
uint8_t l = TSDB_COLVAL_LEVEL_MEDIUM;
if (0 == strcmp(level, TSDB_COLUMN_LEVEL_HIGH)) {
if (0 == strcmp(level, "h") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_HIGH)) {
l = TSDB_COLVAL_LEVEL_HIGH;
} else if (0 == strcmp(level, TSDB_COLUMN_LEVEL_MEDIUM)) {
} else if (0 == strcmp(level, "m") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_MEDIUM)) {
l = TSDB_COLVAL_LEVEL_MEDIUM;
} else if (0 == strcmp(level, TSDB_COLUMN_LEVEL_LOW)) {
} else if (0 == strcmp(level, "l") || 0 == strcmp(level, TSDB_COLUMN_LEVEL_LOW)) {
l = TSDB_COLVAL_LEVEL_LOW;
}
return l;
@ -228,7 +228,7 @@ bool checkColumnEncode(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]) {
}
bool checkColumnCompress(uint8_t type, char compress[TSDB_CL_COMPRESS_OPTION_LEN]) {
if (0 == strlen(compress)) {
strncpy(compress, getDefaultEncodeStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
strncpy(compress, getDefaultCompressStr(type), TSDB_CL_COMPRESS_OPTION_LEN);
return true;
}
strtolower(compress, compress);
@ -272,3 +272,10 @@ void setColLevel(uint32_t* compress, uint8_t level) {
*compress |= level;
return;
}
void setColCompressByOption(uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level) {
setColEncode(compress, encode);
setColCompress(compress, compressType);
setColLevel(compress, level);
return;
}

View File

@ -7722,6 +7722,9 @@ void tDestroySVCreateTbReq(SVCreateTbReq *pReq, int32_t flags) {
}
}
if (pReq->colCmpr.pColCmpr) taosMemoryFree(pReq->colCmpr.pColCmpr);
pReq->colCmpr.pColCmpr = NULL;
if (pReq->sql != NULL) {
taosMemoryFree(pReq->sql);
}

View File

@ -1125,6 +1125,10 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
goto _OVER;
}
// todo xsdebug
terrno = TSDB_CODE_OPS_NOT_SUPPORT;
goto _OVER;
mInfo("stb:%s, start to create", createReq.name);
if (mndCheckCreateStbReq(&createReq) != 0) {
terrno = TSDB_CODE_INVALID_MSG;

View File

@ -9870,8 +9870,15 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
}
SNode* pCol;
col_id_t index = 0;
tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols);
FOREACH(pCol, pStmt->pCols) {
toSchema((SColumnDefNode*)pCol, index + 1, req.ntb.schemaRow.pSchema + index);
SColumnDefNode* pColDef = (SColumnDefNode*)pCol;
toSchema(pColDef, index + 1, req.ntb.schemaRow.pSchema + index);
if (pColDef->pOptions) {
req.colCmpr.pColCmpr[index].id = index + 1;
setColCompressByOption(&req.colCmpr.pColCmpr[index].alg, columnEncodeVal(pColDef->pOptions->encode),
columnCompressVal(pColDef->pOptions->compress), columnLevelVal(pColDef->pOptions->compressLevel));
}
++index;
}
pBatch->info = *pVgroupInfo;