diff --git a/include/common/tcol.h b/include/common/tcol.h index e4a53cb05b..c69bc1621b 100644 --- a/include/common/tcol.h +++ b/include/common/tcol.h @@ -17,10 +17,10 @@ #define _TD_TCOL_H_ #define TSDB_COLUMN_ENCODE_UNKNOWN "Unknown" -#define TSDB_COLUMN_ENCODE_SIMPLE8B "Simple8b" -#define TSDB_COLUMN_ENCODE_XOR "DeltaI" -#define TSDB_COLUMN_ENCODE_RLE "Bit-Packing" -#define TSDB_COLUMN_ENCODE_DELTAD "DeltaD" +#define TSDB_COLUMN_ENCODE_SIMPLE8B "simple8b" +#define TSDB_COLUMN_ENCODE_XOR "delta-i" +#define TSDB_COLUMN_ENCODE_RLE "bit-packing" +#define TSDB_COLUMN_ENCODE_DELTAD "delta-d" #define TSDB_COLUMN_ENCODE_DISABLED "disabled" #define TSDB_COLUMN_COMPRESS_UNKNOWN "Unknown" @@ -41,7 +41,6 @@ #define TSDB_COLVAL_ENCODE_XOR 2 #define TSDB_COLVAL_ENCODE_RLE 3 #define TSDB_COLVAL_ENCODE_DELTAD 4 - #define TSDB_COLVAL_ENCODE_DISABLED 0xff #define TSDB_COLVAL_COMPRESS_NOCHANGE 0 @@ -53,9 +52,9 @@ #define TSDB_COLVAL_COMPRESS_DISABLED 0xff #define TSDB_COLVAL_LEVEL_NOCHANGE 0 -#define TSDB_COLVAL_LEVEL_HIGH 1 +#define TSDB_COLVAL_LEVEL_LOW 1 #define TSDB_COLVAL_LEVEL_MEDIUM 2 -#define TSDB_COLVAL_LEVEL_LOW 3 +#define TSDB_COLVAL_LEVEL_HIGH 3 #define TSDB_COLVAL_LEVEL_DISABLED 0xff #define TSDB_CL_COMMENT_LEN 1025 @@ -87,9 +86,12 @@ bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRES bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]); bool checkColumnLevelOrSetDefault(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); +void setColEncode(uint32_t* compress, uint8_t encode); +void setColCompress(uint32_t* compress, uint16_t compressType); +void setColLevel(uint32_t* compress, uint8_t level); +int8_t setColCompressByOption(uint8_t type, uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level); +int8_t validColCompressLevel(uint8_t type, uint8_t level); +int8_t validColCompress(uint8_t type, uint8_t l2); +int8_t validColEncode(uint8_t type, uint8_t l1); #endif /*_TD_TCOL_H_*/ diff --git a/include/util/tcompression.h b/include/util/tcompression.h index ac2a639a2c..ab98058b87 100644 --- a/include/util/tcompression.h +++ b/include/util/tcompression.h @@ -260,6 +260,7 @@ typedef enum L1Compress { L1_SIMPLE_8B, L1_XOR, L1_RLE, + L1_DELTAD, L1_DISABLED = 0xFF, } EL1CompressFuncType; diff --git a/source/common/src/tcol.c b/source/common/src/tcol.c index a6aceedd53..fb40631286 100644 --- a/source/common/src/tcol.c +++ b/source/common/src/tcol.c @@ -43,17 +43,27 @@ uint8_t getDefaultEncode(uint8_t type) { case TSDB_DATA_TYPE_DOUBLE: return TSDB_COLVAL_ENCODE_DELTAD; case TSDB_DATA_TYPE_VARCHAR: // TSDB_DATA_TYPE_BINARY - return + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_TIMESTAMP: + return TSDB_COLVAL_ENCODE_XOR; case TSDB_DATA_TYPE_NCHAR: + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_UTINYINT: + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_USMALLINT: + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_UINT: + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_UBIGINT: + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_JSON: + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_VARBINARY: + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_DECIMAL: + return TSDB_COLVAL_ENCODE_DELTAD; case TSDB_DATA_TYPE_BLOB: + return TSDB_COLVAL_ENCODE_SIMPLE8B; case TSDB_DATA_TYPE_MEDIUMBLOB: case TSDB_DATA_TYPE_GEOMETRY: case TSDB_DATA_TYPE_MAX: @@ -90,7 +100,6 @@ uint16_t getDefaultCompress(uint8_t type) { case TSDB_DATA_TYPE_GEOMETRY: case TSDB_DATA_TYPE_MAX: return TSDB_COLVAL_COMPRESS_LZ4; - default: return TSDB_COLVAL_COMPRESS_LZ4; } @@ -294,34 +303,75 @@ void setColLevel(uint32_t* compress, uint8_t level) { return; } -void setColCompressByOption(uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level) { +int8_t setColCompressByOption(uint8_t type, uint32_t* compress, uint8_t encode, uint16_t compressType, uint8_t level) { + if (!validColEncode(type, encode)) return 0; setColEncode(compress, encode); + if (compressType == TSDB_COLVAL_COMPRESS_DISABLED) { setColCompress(compress, compressType); setColLevel(compress, TSDB_COLVAL_LEVEL_DISABLED); } else { + if (!validColCompress(type, compressType)) return 0; setColCompress(compress, compressType); + + if (!validColCompressLevel(type, level)) return 0; setColLevel(compress, level); } - return; + return 1; } bool useCompress(uint8_t tableType) { return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType; } -int8_t validColCompressOption(uint8_t type, uint8_t encode, uint8_t compress, uint8_t level) { - if (level < TSDB_COLVAL_LEVEL_HIGH || level > TSDB_COLVAL_LEVEL_LOW) { +int8_t validColCompressLevel(uint8_t type, uint8_t level) { + if (level < TSDB_COLVAL_LEVEL_LOW || level > TSDB_COLVAL_LEVEL_HIGH) { return 0; } + return 1; +} +int8_t validColCompress(uint8_t type, uint8_t l2) { + // if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) { + // if (l2 != TSDB_COLVAL_COMPRESS_TSZ) { + // return 0; + // } + // } + if (l2 <= TSDB_COLVAL_COMPRESS_NOCHANGE || l2 >= TSDB_COLVAL_COMPRESS_DISABLED) { + return TSDB_COLVAL_COMPRESS_DISABLED == l2 ? 1 : 0; + } + return 1; +} + +// +// | --------type----------|----- supported encode ----| +// |tinyint/smallint/int/bigint/utinyint/usmallinit/uint/ubiginint| simple8b | +// | timestamp/bigint/ubigint | delta-i | +// | bool | bit-packing | +// | flout/double | delta-d | +// +int8_t validColEncode(uint8_t type, uint8_t l1) { if (type == TSDB_DATA_TYPE_BOOL) { - } else if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_BIGINT) { + return TSDB_COLVAL_ENCODE_RLE == l1 ? 1 : 0; + } else if (type >= TSDB_DATA_TYPE_TINYINT && type <= TSDB_DATA_TYPE_INT) { + return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 ? 1 : 0; + } else if (type == TSDB_DATA_TYPE_BIGINT) { + return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 || TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0; } else if (type >= TSDB_DATA_TYPE_FLOAT && type <= TSDB_DATA_TYPE_DOUBLE) { - if (compress == TSDB_COLVAL_COMPRESS_TSZ) { + return TSDB_COLVAL_ENCODE_DELTAD == l1 ? 1 : 0; + } else if ((type == TSDB_DATA_TYPE_VARCHAR && type == TSDB_DATA_TYPE_NCHAR) || type == TSDB_DATA_TYPE_JSON || + type == TSDB_DATA_TYPE_VARBINARY) { + if (l1 >= TSDB_COLVAL_ENCODE_NOCHANGE || l1 <= TSDB_COLVAL_ENCODE_DELTAD) { return 1; + } else if (l1 == TSDB_COLVAL_ENCODE_DISABLED) { + return 1; + } else { + return 0; } - } else if (type == TSDB_DATA_TYPE_VARCHAR && type == TSDB_DATA_TYPE_NCHAR) { } else if (type == TSDB_DATA_TYPE_TIMESTAMP) { - } else if (type >= TSDB_DATA_TYPE_USMALLINT || type <= TSDB_DATA_TYPE_UBIGINT) { + return TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0; + } else if (type >= TSDB_DATA_TYPE_USMALLINT || type <= TSDB_DATA_TYPE_UINT) { + return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 ? 1 : 0; + } else if (type == TSDB_DATA_TYPE_UBIGINT) { + return TSDB_COLVAL_ENCODE_SIMPLE8B == l1 || TSDB_COLVAL_ENCODE_XOR == l1 ? 1 : 0; } else if (type == TSDB_DATA_TYPE_JSON || type == TSDB_DATA_TYPE_VARBINARY) { } return 0; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index cd48490dbd..58830e1a76 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -5769,9 +5769,11 @@ static int32_t checkColumnOptions(SNodeList* pList) { FOREACH(pNode, pList) { SColumnDefNode* pCol = (SColumnDefNode*)pNode; if (!pCol->pOptions) return TSDB_CODE_TSC_ENCODE_PARAM_NULL; - if (!checkColumnEncodeOrSetDefault(pCol->type, pCol->pOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - if (!checkColumnCompressOrSetDefault(pCol->type, pCol->pOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - if (!checkColumnLevelOrSetDefault(pCol->type, pCol->pOptions->compressLevel)) + if (!checkColumnEncodeOrSetDefault(pCol->dataType.type, pCol->pOptions->encode)) + return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; + if (!checkColumnCompressOrSetDefault(pCol->dataType.type, pCol->pOptions->compress)) + return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; + if (!checkColumnLevelOrSetDefault(pCol->dataType.type, pCol->pOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; } return TSDB_CODE_SUCCESS; @@ -6614,9 +6616,10 @@ static int32_t buildAlterSuperTableReq(STranslateContext* pCxt, SAlterTableStmt* if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - setColCompressByOption((uint32_t*)&field.bytes, columnEncodeVal(pStmt->pColOptions->encode), - columnCompressVal(pStmt->pColOptions->compress), - columnLevelVal(pStmt->pColOptions->compressLevel)); + int8_t valid = setColCompressByOption( + pStmt->dataType.type, (uint32_t*)&field.bytes, columnEncodeVal(pStmt->pColOptions->encode), + columnCompressVal(pStmt->pColOptions->compress), columnLevelVal(pStmt->pColOptions->compressLevel)); + if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; taosArrayPush(pAlterReq->pFields, &field); break; } @@ -9912,12 +9915,14 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt* tInitDefaultSColCmprWrapperByCols(&req.colCmpr, req.ntb.schemaRow.nCols); FOREACH(pCol, pStmt->pCols) { SColumnDefNode* pColDef = (SColumnDefNode*)pCol; - toSchema(pColDef, index + 1, req.ntb.schemaRow.pSchema + index); + SSchema* pScheam = req.ntb.schemaRow.pSchema + index; + toSchema(pColDef, index + 1, pScheam); 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)); + int8_t valid = setColCompressByOption( + pScheam->type, &req.colCmpr.pColCmpr[index].alg, columnEncodeVal(pColDef->pOptions->encode), + columnCompressVal(pColDef->pOptions->compress), columnLevelVal(pColDef->pOptions->compressLevel)); + if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; } ++index; } @@ -10743,9 +10748,10 @@ static int buildAlterTableColumnCompress(STranslateContext* pCxt, SAlterTableStm if (!checkColumnEncode(pStmt->pColOptions->encode)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; if (!checkColumnCompress(pStmt->pColOptions->compress)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; if (!checkColumnLevel(pStmt->pColOptions->compressLevel)) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; - setColCompressByOption(&pReq->compress, columnEncodeVal(pStmt->pColOptions->encode), - columnCompressVal(pStmt->pColOptions->compress), - columnLevelVal(pStmt->pColOptions->compressLevel)); + int8_t valid = setColCompressByOption(pSchema->type, &pReq->compress, columnEncodeVal(pStmt->pColOptions->encode), + columnCompressVal(pStmt->pColOptions->compress), + columnLevelVal(pStmt->pColOptions->compressLevel)); + if (!valid) return TSDB_CODE_TSC_ENCODE_PARAM_ERROR; return TSDB_CODE_SUCCESS; } diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 0135904822..975eb321b1 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -63,8 +63,8 @@ #include "td_sz.h" #endif -int32_t tsCompressUnknow2(const char *const input, const int32_t nelements, char *const output, const char type); -int32_t tsDecompressUnknow2(const char *const input, const int32_t nelements, char *const output, const char type); +int32_t tsCompressPlain2(const char *const input, const int32_t nelements, char *const output, const char type); +int32_t tsDecompressPlain2(const char *const input, const int32_t nelements, char *const output, const char type); // delta int32_t tsCompressTimestampImp2(const char *const input, const int32_t nelements, char *const output, const char type); @@ -266,7 +266,7 @@ int32_t l2DecompressImpl_xz(const char *const input, const int32_t compressedSiz return -1; } -TCompressL1FnSet compressL1Dict[] = {{"PLAIN", NULL, tsCompressUnknow2, tsDecompressUnknow2}, +TCompressL1FnSet compressL1Dict[] = {{"PLAIN", NULL, tsCompressPlain2, tsDecompressPlain2}, {"SIMPLE-8B", NULL, tsCompressINTImp2, tsDecompressINTImp2}, {"DELTAI", NULL, tsCompressTimestampImp2, tsDecompressTimestampImp2}, {"BIT-PACKING", NULL, tsCompressBoolImp2, tsDecompressBoolImp2}, @@ -858,13 +858,13 @@ int32_t tsDecompressTimestampImp(const char *const input, const int32_t nelement return nelements * longBytes; } -int32_t tsCompressUnknow2(const char *const input, const int32_t nelements, char *const output, const char type) { +int32_t tsCompressPlain2(const char *const input, const int32_t nelements, char *const output, const char type) { int32_t bytes = tDataTypes[type].type * nelements; output[0] = 0; memcpy(output + 1, input, bytes); return bytes + 1; } -int32_t tsDecompressUnknow2(const char *const input, const int32_t nelements, char *const output, const char type) { +int32_t tsDecompressPlain2(const char *const input, const int32_t nelements, char *const output, const char type) { int32_t bytes = tDataTypes[type].bytes * nelements; memcpy(output, input + 1, bytes); return bytes; @@ -2787,8 +2787,8 @@ int32_t tsCompressBool2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_ int32_t nBuf) { uint32_t tCmprAlg = 0; DEFINE_VAR(cmprAlg) - if (l1 != 4) { - SET_COMPRESS(4, l2, lvl, tCmprAlg); + if (l1 != L1_RLE) { + SET_COMPRESS(L1_RLE, l2, lvl, tCmprAlg); } FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, tCmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_BOOL, 1); } @@ -2797,8 +2797,8 @@ int32_t tsDecompressBool2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int3 int32_t nBuf) { uint32_t tCmprAlg = 0; DEFINE_VAR(cmprAlg) - if (l1 != 4) { - SET_COMPRESS(4, l2, lvl, tCmprAlg); + if (l1 != L1_RLE) { + SET_COMPRESS(L1_RLE, l2, lvl, tCmprAlg); } FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, tCmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_BOOL, 0); } @@ -2808,8 +2808,8 @@ int32_t tsCompressTinyint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int int32_t nBuf) { uint32_t tCmprAlg = 0; DEFINE_VAR(cmprAlg) - if (l1 != L1_XOR) { - SET_COMPRESS(L1_XOR, l2, lvl, tCmprAlg); + if (l1 != L1_SIMPLE_8B) { + SET_COMPRESS(L1_SIMPLE_8B, l2, lvl, tCmprAlg); } FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, tCmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_TINYINT, 1); } @@ -2818,8 +2818,8 @@ int32_t tsDecompressTinyint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, i void *pBuf, int32_t nBuf) { uint32_t tCmprAlg = 0; DEFINE_VAR(cmprAlg) - if (l1 != L1_XOR) { - SET_COMPRESS(L1_XOR, l2, lvl, tCmprAlg); + if (l1 != L1_SIMPLE_8B) { + SET_COMPRESS(L1_SIMPLE_8B, l2, lvl, tCmprAlg); } FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, tCmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_TINYINT, 0); } @@ -2829,8 +2829,8 @@ int32_t tsCompressSmallint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in void *pBuf, int32_t nBuf) { uint32_t tCmprAlg = 0; DEFINE_VAR(cmprAlg) - if (l1 != L1_XOR) { - SET_COMPRESS(L1_XOR, l2, lvl, tCmprAlg); + if (l1 != L1_SIMPLE_8B) { + SET_COMPRESS(L1_SIMPLE_8B, l2, lvl, tCmprAlg); } FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, tCmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_SMALLINT, 1); } @@ -2839,8 +2839,8 @@ int32_t tsDecompressSmallint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, void *pBuf, int32_t nBuf) { uint32_t tCmprAlg = 0; DEFINE_VAR(cmprAlg) - if (l1 != L1_XOR) { - SET_COMPRESS(L1_XOR, l2, lvl, tCmprAlg); + if (l1 != L1_SIMPLE_8B) { + SET_COMPRESS(L1_SIMPLE_8B, l2, lvl, tCmprAlg); } FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, tCmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_SMALLINT, 0); } @@ -2851,8 +2851,8 @@ int32_t tsCompressInt2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t uint32_t tCmprAlg = 0; { DEFINE_VAR(cmprAlg) - if (l1 != L1_XOR) { - SET_COMPRESS(L1_XOR, l2, lvl, tCmprAlg); + if (l1 != L1_SIMPLE_8B) { + SET_COMPRESS(L1_SIMPLE_8B, l2, lvl, tCmprAlg); } } FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, tCmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_INT, 1); @@ -2863,8 +2863,8 @@ int32_t tsDecompressInt2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32 uint32_t tCmprAlg = 0; { DEFINE_VAR(cmprAlg) - if (l1 != L1_XOR) { - SET_COMPRESS(L1_XOR, l2, lvl, tCmprAlg); + if (l1 != L1_SIMPLE_8B) { + SET_COMPRESS(L1_SIMPLE_8B, l2, lvl, tCmprAlg); } } FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, tCmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_INT, 0); @@ -2881,64 +2881,65 @@ int32_t tsDecompressBigint2(void *pIn, int32_t nIn, int32_t nEle, void *pOut, in FUNC_COMPRESS_IMPL(pIn, nIn, nEle, pOut, nOut, cmprAlg, pBuf, nBuf, TSDB_DATA_TYPE_BIGINT, 0); } -int32_t tsFindCompressAlg(int8_t dataType, uint8_t compress, TCompressL1FnSet *l1Fn, TCompressL2FnSet *l2Fn); +// int32_t tsFindCompressAlg(int8_t dataType, uint8_t compress, TCompressL1FnSet *l1Fn, TCompressL2FnSet *l2Fn); -int32_t tsCompressImpl(int8_t type, void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, - void *pBuf, int32_t nBuf) { - TCompressL1FnSet fn1; - TCompressL2FnSet fn2; +// int32_t tsCompressImpl(int8_t type, void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, +// void *pBuf, int32_t nBuf) { +// TCompressL1FnSet fn1; +// TCompressL2FnSet fn2; - if (tsFindCompressAlg(type, cmprAlg, &fn1, &fn2)) return -1; +// if (tsFindCompressAlg(type, cmprAlg, &fn1, &fn2)) return -1; - int32_t len = 0; - uint8_t l1 = COMPRESS_L1_TYPE_U8(cmprAlg); - uint8_t l2 = COMPRESS_L2_TYPE_U8(cmprAlg); - uint8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(cmprAlg); +// int32_t len = 0; +// uint8_t l1 = COMPRESS_L1_TYPE_U8(cmprAlg); +// uint8_t l2 = COMPRESS_L2_TYPE_U8(cmprAlg); +// uint8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(cmprAlg); - if (l2 == L2_DISABLED) { - len = fn1.comprFn(pIn, nEle, pOut, type); - } else { - len = fn1.comprFn(pIn, nEle, pBuf, type); - len = fn2.comprFn(pBuf, len, pOut, nOut, type, lvl); - } - return len; -} -int32_t tsDecompressImpl(int8_t type, void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, - void *pBuf, int32_t nBuf) { - TCompressL1FnSet fn1; - TCompressL2FnSet fn2; +// if (l2 == L2_DISABLED) { +// len = fn1.comprFn(pIn, nEle, pOut, type); +// } else { +// len = fn1.comprFn(pIn, nEle, pBuf, type); +// len = fn2.comprFn(pBuf, len, pOut, nOut, type, lvl); +// } +// return len; +// } +// int32_t tsDecompressImpl(int8_t type, void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t +// cmprAlg, +// void *pBuf, int32_t nBuf) { +// TCompressL1FnSet fn1; +// TCompressL2FnSet fn2; - if (tsFindCompressAlg(type, cmprAlg, &fn1, &fn2) != 0) return -1; +// if (tsFindCompressAlg(type, cmprAlg, &fn1, &fn2) != 0) return -1; - int8_t l1 = COMPRESS_L1_TYPE_U8(cmprAlg); - int8_t l2 = COMPRESS_L2_TYPE_U8(cmprAlg); - int8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(cmprAlg); - int32_t len = 0; - if (l2 == L2_DISABLED) { - len = fn1.decomprFn(pIn, nEle, pOut, type); - } else { - len = fn2.decomprFn(pIn, nIn, pBuf, nBuf, type); - if (len < 0) return -1; - len = fn1.decomprFn(pBuf, nEle, pOut, type); - } - return len; -} +// uint8_t l1 = COMPRESS_L1_TYPE_U8(cmprAlg); +// uint8_t l2 = COMPRESS_L2_TYPE_U8(cmprAlg); +// uint8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(cmprAlg); +// uint32_t len = 0; +// if (l2 == L2_DISABLED) { +// len = fn1.decomprFn(pIn, nEle, pOut, type); +// } else { +// len = fn2.decomprFn(pIn, nIn, pBuf, nBuf, type); +// if (len < 0) return -1; +// len = fn1.decomprFn(pBuf, nEle, pOut, type); +// } +// return len; +// } -int32_t tsFindCompressAlg(int8_t dataType, uint8_t compress, TCompressL1FnSet *l1Fn, TCompressL2FnSet *l2Fn) { - int8_t l1 = COMPRESS_L1_TYPE_U8(compress); - int8_t l2 = COMPRESS_L2_TYPE_U8(compress); - int8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(compress); +// int32_t tsFindCompressAlg(int8_t dataType, uint8_t compress, TCompressL1FnSet *l1Fn, TCompressL2FnSet *l2Fn) { +// uint8_t l1 = COMPRESS_L1_TYPE_U8(compress); +// uint8_t l2 = COMPRESS_L2_TYPE_U8(compress); +// uint8_t lvl = COMPRESS_L2_TYPE_LEVEL_U8(compress); - static int32_t l1Sz = sizeof(compressL1Dict) / sizeof(compressL1Dict[0]); - if (l1 >= l1Sz) return -1; +// static int32_t l1Sz = sizeof(compressL1Dict) / sizeof(compressL1Dict[0]); +// if (l1 >= l1Sz) return -1; - static int32_t l2Sz = sizeof(compressL2Dict) / sizeof(compressL2Dict[0]); - if (l2 >= l2Sz) return -1; +// static int32_t l2Sz = sizeof(compressL2Dict) / sizeof(compressL2Dict[0]); +// if (l2 >= l2Sz) return -1; - *l1Fn = compressL1Dict[l1]; - *l2Fn = compressL2Dict[l2]; - return 0; -} +// *l1Fn = compressL1Dict[l1]; +// *l2Fn = compressL2Dict[l2]; +// return 0; +// } // typedef struct { // int8_t dtype; @@ -3035,12 +3036,5 @@ int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, u SET_COMPRESS(ol1, ol2, nlvl, *dst); return 1; } - return 0; } -// int32_t validCompress(int8_t type, uint8_t encode, uint8_t compress, uint8_t level) { -// if (type == TSDB_DATA_TYPE_BOOL) { - -// } else -// return 0; -// }