From 5e631fc86f2b4783a250f213cb45ee9d77f4e977 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Thu, 12 Aug 2021 09:49:31 +0800 Subject: [PATCH] [TD-5623]: Added Global config 'CompressColDaata' to enable/disable col compression. Default to 0. --- src/common/inc/tglobal.h | 1 + src/common/src/tglobal.c | 18 ++++++++++++++++++ src/query/src/queryMain.c | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 10673beb92..947fed60e4 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -60,6 +60,7 @@ extern char tsLocale[]; extern char tsCharset[]; // default encode string extern int8_t tsEnableCoreFile; extern int32_t tsCompressMsgSize; +extern int32_t tsCompressColData; extern int32_t tsMaxNumOfDistinctResults; extern char tsTempDir[]; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index c7e7a7362b..44b3e87e7d 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -75,6 +75,14 @@ int32_t tsMaxBinaryDisplayWidth = 30; */ int32_t tsCompressMsgSize = -1; +/* denote if server needs to compress the retrieved column data before adding to the rpc response message body. + * 0: disable column data compression + * 1: enable column data compression + * This option is default to disabled. Once enabled, compression will be conducted if any column has size more + * than QUERY_COMP_THRESHOLD. Otherwise, no further compression is needed. + */ +int32_t tsCompressColData = 0; + // client int32_t tsMaxSQLStringLen = TSDB_MAX_ALLOWED_SQL_LEN; int32_t tsMaxWildCardsLen = TSDB_PATTERN_STRING_MAX_LEN; @@ -991,6 +999,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "compressColData"; + cfg.ptr = &tsCompressColData; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "maxSQLLength"; cfg.ptr = &tsMaxSQLStringLen; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index ab63d863bc..d25f5eab7a 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -357,7 +357,7 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co } (*pRsp)->precision = htons(pQueryAttr->precision); - (*pRsp)->compressed = (int8_t)checkNeedToCompressQueryCol(pQInfo); + (*pRsp)->compressed = (int8_t)(tsCompressColData && checkNeedToCompressQueryCol(pQInfo)); if (GET_NUM_OF_RESULTS(&(pQInfo->runtimeEnv)) > 0 && pQInfo->code == TSDB_CODE_SUCCESS) { doDumpQueryResult(pQInfo, (*pRsp)->data, (*pRsp)->compressed, &compLen); -- GitLab