Merge remote-tracking branch 'origin/3.0' into fix/tsim
This commit is contained in:
commit
47f7ce67a7
|
@ -48,9 +48,12 @@ extern "C" {
|
|||
#define TD_VTYPE_NONE 0x02U // none or unknown/undefined
|
||||
#define TD_VTYPE_MAX 0x03U //
|
||||
|
||||
#define TD_VTYPE_NORM_BYTE 0x0U
|
||||
#define TD_VTYPE_NULL_BYTE 0x55U
|
||||
#define TD_VTYPE_NONE_BYTE 0xAAU
|
||||
#define TD_VTYPE_NORM_BYTE_I 0x0U
|
||||
#define TD_VTYPE_NULL_BYTE_I 0xFFU
|
||||
|
||||
#define TD_VTYPE_NORM_BYTE_II 0x0U
|
||||
#define TD_VTYPE_NULL_BYTE_II 0x55U
|
||||
#define TD_VTYPE_NONE_BYTE_II 0xAAU
|
||||
|
||||
#define TD_ROWS_ALL_NORM 0x00U
|
||||
#define TD_ROWS_NULL_NORM 0x01U
|
||||
|
@ -224,8 +227,10 @@ static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TD
|
|||
int32_t tdSetBitmapValTypeN(void *pBitmap, int16_t nEle, TDRowValT valType, int8_t bitmapMode);
|
||||
static FORCE_INLINE int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pValType);
|
||||
static FORCE_INLINE int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pValType);
|
||||
static FORCE_INLINE int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType, int8_t bitmapMode);
|
||||
static FORCE_INLINE bool tdIsBitmapValTypeNormII(const void *pBitmap, int16_t idx);
|
||||
static FORCE_INLINE int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValType,
|
||||
int8_t bitmapMode);
|
||||
static FORCE_INLINE bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode);
|
||||
bool tdIsBitmapBlkNorm(const void *pBitmap, int32_t numOfBits, int8_t bitmapMode);
|
||||
int32_t tdAppendValToDataCol(SDataCol *pCol, TDRowValT valType, const void *val, int32_t numOfRows, int32_t maxPoints,
|
||||
int8_t bitmapMode);
|
||||
static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val,
|
||||
|
@ -233,7 +238,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowVa
|
|||
static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val,
|
||||
bool isCopyVarData, int8_t colType, int16_t colIdx, int32_t offset,
|
||||
col_id_t colId);
|
||||
int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols);
|
||||
int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
|
@ -327,9 +332,9 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx,
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static FORCE_INLINE bool tdIsBitmapValTypeNormII(const void *pBitmap, int16_t idx) {
|
||||
static FORCE_INLINE bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode) {
|
||||
TDRowValT valType = 0;
|
||||
tdGetBitmapValTypeII(pBitmap, idx, &valType);
|
||||
tdGetBitmapValType(pBitmap, idx, &valType, bitmapMode);
|
||||
if (tdValTypeIsNorm(valType)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -248,8 +248,8 @@ typedef struct tDataTypeDescriptor {
|
|||
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize);
|
||||
int32_t (*decompFunc)(const char *const input, int32_t compressedSize, const int32_t nelements, char *const output,
|
||||
int32_t outputSize, char algorithm, char *const buffer, int32_t bufferSize);
|
||||
void (*statisFunc)(const void* pBitmap, const void *pData, int32_t numofrow, int64_t *min, int64_t *max, int64_t *sum, int16_t *minindex,
|
||||
int16_t *maxindex, int16_t *numofnull);
|
||||
void (*statisFunc)(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numofrow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minindex, int16_t *maxindex, int16_t *numofnull);
|
||||
} tDataTypeDescriptor;
|
||||
|
||||
extern tDataTypeDescriptor tDataTypes[15];
|
||||
|
|
|
@ -36,12 +36,12 @@ void *taosMemoryStrDup(void *ptr);
|
|||
void taosMemoryFree(void *ptr);
|
||||
int32_t taosMemorySize(void *ptr);
|
||||
|
||||
#define taosMemoryFreeClear(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
taosMemoryFree((void*)ptr); \
|
||||
(ptr) = NULL; \
|
||||
} \
|
||||
#define taosMemoryFreeClear(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
taosMemoryFree((void *)ptr); \
|
||||
(ptr) = NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -69,9 +69,9 @@ void taos_cleanup(void) {
|
|||
rpcCleanup();
|
||||
catalogDestroy();
|
||||
schedulerDestroy();
|
||||
taosCloseLog();
|
||||
|
||||
tscInfo("all local resources released");
|
||||
taosCloseLog();
|
||||
}
|
||||
|
||||
setConfRet taos_set_config(const char *config) {
|
||||
|
|
|
@ -238,7 +238,7 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char *inputCfgDir, const char *e
|
|||
|
||||
if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgDir) != 0) {
|
||||
if (cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile) != 0) {
|
||||
uError("failed to load from config file:%s since %s", cfgFile, terrstr());
|
||||
uInfo("cfg file:%s not read since %s", cfgFile, terrstr());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,19 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "trow.h"
|
||||
|
||||
const uint8_t tdVTypeByte[3] = {
|
||||
TD_VTYPE_NORM_BYTE, // TD_VTYPE_NORM
|
||||
TD_VTYPE_NONE_BYTE, // TD_VTYPE_NONE
|
||||
TD_VTYPE_NULL_BYTE, // TD_VTYPE_NULL
|
||||
const uint8_t tdVTypeByte[2][3] = {{
|
||||
// 2 bits
|
||||
TD_VTYPE_NORM_BYTE_II,
|
||||
TD_VTYPE_NONE_BYTE_II,
|
||||
TD_VTYPE_NULL_BYTE_II,
|
||||
},
|
||||
{
|
||||
// 1 bit
|
||||
TD_VTYPE_NORM_BYTE_I,
|
||||
TD_VTYPE_NULL_BYTE_I,
|
||||
TD_VTYPE_NULL_BYTE_I, // padding
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// declaration
|
||||
|
@ -266,21 +275,53 @@ static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index, bool setBit
|
|||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief Set bitmap area by byte preferentially and then by bit.
|
||||
*
|
||||
* @param pBitmap
|
||||
* @param nEle
|
||||
* @param valType
|
||||
* @param bitmapMode 0 for 2 bits, 1 for 1 bit
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tdSetBitmapValTypeN(void *pBitmap, int16_t nEle, TDRowValT valType, int8_t bitmapMode) {
|
||||
TASSERT(valType < TD_VTYPE_MAX);
|
||||
int16_t nBytes = nEle / TD_VTYPE_PARTS;
|
||||
int32_t nBytes = (bitmapMode == 0 ? nEle / TD_VTYPE_PARTS : nEle / TD_VTYPE_PARTS_I);
|
||||
uint8_t vTypeByte = tdVTypeByte[bitmapMode][valType];
|
||||
for (int i = 0; i < nBytes; ++i) {
|
||||
*(uint8_t *)pBitmap = tdVTypeByte[valType];
|
||||
*(uint8_t *)pBitmap = vTypeByte;
|
||||
pBitmap = POINTER_SHIFT(pBitmap, 1);
|
||||
}
|
||||
int16_t nLeft = nEle - nBytes * TD_VTYPE_BITS;
|
||||
|
||||
int32_t nLeft = nEle - nBytes * (bitmapMode == 0 ? TD_VTYPE_BITS : TD_VTYPE_BITS_I);
|
||||
for (int j = 0; j < nLeft; ++j) {
|
||||
tdSetBitmapValType(pBitmap, j, valType, bitmapMode);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
bool tdIsBitmapBlkNorm(const void *pBitmap, int32_t numOfBits, int8_t bitmapMode) {
|
||||
int32_t nBytes = (bitmapMode == 0 ? numOfBits / TD_VTYPE_PARTS : numOfBits / TD_VTYPE_PARTS_I);
|
||||
uint8_t vTypeByte = tdVTypeByte[bitmapMode][TD_VTYPE_NORM];
|
||||
for (int i = 0; i < nBytes; ++i) {
|
||||
if (*((uint8_t *)pBitmap) != vTypeByte) {
|
||||
return false;
|
||||
}
|
||||
pBitmap = POINTER_SHIFT(pBitmap, 1);
|
||||
}
|
||||
|
||||
int32_t nLeft = numOfBits - nBytes * (bitmapMode == 0 ? TD_VTYPE_BITS : TD_VTYPE_BITS_I);
|
||||
|
||||
for (int j = 0; j < nLeft; ++j) {
|
||||
uint8_t vType;
|
||||
tdGetBitmapValType(pBitmap, j, &vType, bitmapMode);
|
||||
if (vType != TD_VTYPE_NORM) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void dataColSetNoneAt(SDataCol *pCol, int index, bool setBitmap, int8_t bitmapMode) {
|
||||
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||
pCol->dataOff[index] = pCol->len;
|
||||
|
|
|
@ -50,8 +50,8 @@ const int32_t TYPE_BYTES[15] = {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
static void getStatics_bool(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_bool(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int8_t *data = (int8_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
|
@ -62,7 +62,7 @@ static void getStatics_bool(const void *pBitmap, const void *pData, int32_t numO
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (data[i] == TSDB_DATA_BOOL_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ static void getStatics_bool(const void *pBitmap, const void *pData, int32_t numO
|
|||
}
|
||||
}
|
||||
|
||||
static void getStatics_i8(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_i8(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int8_t *data = (int8_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
|
@ -83,7 +83,7 @@ static void getStatics_i8(const void *pBitmap, const void *pData, int32_t numOfR
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ static void getStatics_i8(const void *pBitmap, const void *pData, int32_t numOfR
|
|||
}
|
||||
}
|
||||
|
||||
static void getStatics_u8(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_u8(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
uint8_t *data = (uint8_t *)pData;
|
||||
uint64_t _min = UINT64_MAX;
|
||||
uint64_t _max = 0;
|
||||
|
@ -106,7 +106,7 @@ static void getStatics_u8(const void *pBitmap, const void *pData, int32_t numOfR
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ static void getStatics_u8(const void *pBitmap, const void *pData, int32_t numOfR
|
|||
*sum = _sum;
|
||||
}
|
||||
|
||||
static void getStatics_i16(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_i16(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int16_t *data = (int16_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
|
@ -131,7 +131,7 @@ static void getStatics_i16(const void *pBitmap, const void *pData, int32_t numOf
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -140,8 +140,8 @@ static void getStatics_i16(const void *pBitmap, const void *pData, int32_t numOf
|
|||
}
|
||||
}
|
||||
|
||||
static void getStatics_u16(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_u16(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
uint16_t *data = (uint16_t *)pData;
|
||||
uint64_t _min = UINT64_MAX;
|
||||
uint64_t _max = 0;
|
||||
|
@ -154,7 +154,7 @@ static void getStatics_u16(const void *pBitmap, const void *pData, int32_t numOf
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -167,8 +167,8 @@ static void getStatics_u16(const void *pBitmap, const void *pData, int32_t numOf
|
|||
*sum = _sum;
|
||||
}
|
||||
|
||||
static void getStatics_i32(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_i32(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int32_t *data = (int32_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
|
@ -179,7 +179,7 @@ static void getStatics_i32(const void *pBitmap, const void *pData, int32_t numOf
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -188,8 +188,8 @@ static void getStatics_i32(const void *pBitmap, const void *pData, int32_t numOf
|
|||
}
|
||||
}
|
||||
|
||||
static void getStatics_u32(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_u32(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
uint32_t *data = (uint32_t *)pData;
|
||||
uint64_t _min = UINT64_MAX;
|
||||
uint64_t _max = 0;
|
||||
|
@ -202,7 +202,7 @@ static void getStatics_u32(const void *pBitmap, const void *pData, int32_t numOf
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -215,8 +215,8 @@ static void getStatics_u32(const void *pBitmap, const void *pData, int32_t numOf
|
|||
*sum = _sum;
|
||||
}
|
||||
|
||||
static void getStatics_i64(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_i64(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int64_t *data = (int64_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
|
@ -227,7 +227,7 @@ static void getStatics_i64(const void *pBitmap, const void *pData, int32_t numOf
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -236,8 +236,8 @@ static void getStatics_i64(const void *pBitmap, const void *pData, int32_t numOf
|
|||
}
|
||||
}
|
||||
|
||||
static void getStatics_u64(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_u64(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
uint64_t *data = (uint64_t *)pData;
|
||||
uint64_t _min = UINT64_MAX;
|
||||
uint64_t _max = 0;
|
||||
|
@ -250,7 +250,7 @@ static void getStatics_u64(const void *pBitmap, const void *pData, int32_t numOf
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -263,8 +263,8 @@ static void getStatics_u64(const void *pBitmap, const void *pData, int32_t numOf
|
|||
*sum = _sum;
|
||||
}
|
||||
|
||||
static void getStatics_f(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_f(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
float *data = (float *)pData;
|
||||
float fmin = FLT_MAX;
|
||||
float fmax = -FLT_MAX;
|
||||
|
@ -276,7 +276,7 @@ static void getStatics_f(const void *pBitmap, const void *pData, int32_t numOfRo
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -300,8 +300,8 @@ static void getStatics_f(const void *pBitmap, const void *pData, int32_t numOfRo
|
|||
SET_DOUBLE_VAL(min, fmin);
|
||||
}
|
||||
|
||||
static void getStatics_d(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_d(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
double *data = (double *)pData;
|
||||
double dmin = DBL_MAX;
|
||||
double dmax = -DBL_MAX;
|
||||
|
@ -313,7 +313,7 @@ static void getStatics_d(const void *pBitmap, const void *pData, int32_t numOfRo
|
|||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -337,14 +337,14 @@ static void getStatics_d(const void *pBitmap, const void *pData, int32_t numOfRo
|
|||
SET_DOUBLE_PTR(min, &dmin);
|
||||
}
|
||||
|
||||
static void getStatics_bin(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_bin(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
const char *data = pData;
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (isNull(data, TSDB_DATA_TYPE_BINARY)) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
}
|
||||
|
||||
|
@ -358,14 +358,14 @@ static void getStatics_bin(const void *pBitmap, const void *pData, int32_t numOf
|
|||
*maxIndex = 0;
|
||||
}
|
||||
|
||||
static void getStatics_nchr(const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min, int64_t *max, int64_t *sum,
|
||||
int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
static void getStatics_nchr(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
const char *data = pData;
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (isNull(data, TSDB_DATA_TYPE_NCHAR)) {
|
||||
if (!tdIsBitmapValTypeNormII(pBitmap, i)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
}
|
||||
|
||||
|
@ -405,19 +405,19 @@ tDataTypeDescriptor tDataTypes[15] = {
|
|||
};
|
||||
|
||||
char tTokenTypeSwitcher[13] = {
|
||||
TSDB_DATA_TYPE_NULL, // no type
|
||||
TSDB_DATA_TYPE_BINARY, // TK_ID
|
||||
TSDB_DATA_TYPE_BOOL, // TK_BOOL
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_TINYINT
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_SMALLINT
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_INTEGER
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_BIGINT
|
||||
TSDB_DATA_TYPE_DOUBLE, // TK_FLOAT
|
||||
TSDB_DATA_TYPE_DOUBLE, // TK_DOUBLE
|
||||
TSDB_DATA_TYPE_BINARY, // TK_STRING
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_TIMESTAMP
|
||||
TSDB_DATA_TYPE_NULL, // no type
|
||||
TSDB_DATA_TYPE_BINARY, // TK_ID
|
||||
TSDB_DATA_TYPE_BOOL, // TK_BOOL
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_TINYINT
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_SMALLINT
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_INTEGER
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_BIGINT
|
||||
TSDB_DATA_TYPE_DOUBLE, // TK_FLOAT
|
||||
TSDB_DATA_TYPE_DOUBLE, // TK_DOUBLE
|
||||
TSDB_DATA_TYPE_BINARY, // TK_STRING
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_TIMESTAMP
|
||||
TSDB_DATA_TYPE_VARCHAR, // TK_BINARY
|
||||
TSDB_DATA_TYPE_NCHAR, // TK_NCHAR
|
||||
TSDB_DATA_TYPE_NCHAR, // TK_NCHAR
|
||||
};
|
||||
|
||||
float floatMin = -FLT_MAX, floatMax = FLT_MAX;
|
||||
|
|
|
@ -262,6 +262,7 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
|
|||
vmCloseVnodes(pMgmt);
|
||||
vmStopWorker(pMgmt);
|
||||
vnodeCleanup();
|
||||
tfsClose(pMgmt->pTfs);
|
||||
// walCleanUp();
|
||||
taosMemoryFree(pMgmt);
|
||||
pWrapper->pMgmt = NULL;
|
||||
|
|
|
@ -1354,7 +1354,7 @@ char *mndGetDbStr(char *src) {
|
|||
return pos;
|
||||
}
|
||||
|
||||
static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables) {
|
||||
static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, int32_t rows, int64_t numOfTables, bool sysDb) {
|
||||
int32_t cols = 0;
|
||||
|
||||
char* buf = taosMemoryMalloc(pShow->bytes[cols]);
|
||||
|
@ -1366,100 +1366,117 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in
|
|||
ASSERT(0);
|
||||
}
|
||||
|
||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, buf, false);
|
||||
taosMemoryFree(buf);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->createdTime, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.numOfVgroups, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&numOfTables, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.replications, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.quorum, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.daysPerFile, false);
|
||||
|
||||
char tmp[128] = {0};
|
||||
int32_t len = 0;
|
||||
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
||||
len = sprintf(&tmp[VARSTR_HEADER_SIZE], "%d,%d,%d", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2, pDb->cfg.daysToKeep0);
|
||||
} else {
|
||||
len = sprintf(&tmp[VARSTR_HEADER_SIZE], "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2);
|
||||
}
|
||||
|
||||
varDataSetLen(tmp, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)tmp, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheBlockSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.totalBlocks, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.minRows, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.maxRows, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walLevel, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.fsyncPeriod, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.compression, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheLastRow, false);
|
||||
|
||||
char *prec = NULL;
|
||||
switch (pDb->cfg.precision) {
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
prec = TSDB_TIME_PRECISION_MILLI_STR;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
prec = TSDB_TIME_PRECISION_MICRO_STR;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
prec = TSDB_TIME_PRECISION_NANO_STR;
|
||||
break;
|
||||
default:
|
||||
prec = "none";
|
||||
break;
|
||||
}
|
||||
|
||||
char t[10] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(t, prec, 2);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)t, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.ttl, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.singleSTable, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.streamMode, false);
|
||||
|
||||
char *status = "ready";
|
||||
char b[24] = {0};
|
||||
char b[24] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(b, status, strlen(status));
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)b, false);
|
||||
if (sysDb) {
|
||||
for(int32_t i = 0; i < pShow->numOfColumns; ++i) {
|
||||
SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i);
|
||||
if (i == 0) {
|
||||
colDataAppend(pColInfo, rows, buf, false);
|
||||
} else if (i == 3) {
|
||||
colDataAppend(pColInfo, rows, (const char *)&numOfTables, false);
|
||||
} else if (i == 20) {
|
||||
colDataAppend(pColInfo, rows, b, false);
|
||||
} else {
|
||||
colDataAppendNULL(pColInfo, rows);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, buf, false);
|
||||
taosMemoryFree(buf);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->createdTime, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.numOfVgroups, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&numOfTables, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.replications, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.quorum, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.daysPerFile, false);
|
||||
|
||||
char tmp[128] = {0};
|
||||
int32_t len = 0;
|
||||
if (pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep1 || pDb->cfg.daysToKeep0 > pDb->cfg.daysToKeep2) {
|
||||
len = sprintf(&tmp[VARSTR_HEADER_SIZE], "%d,%d,%d", pDb->cfg.daysToKeep1, pDb->cfg.daysToKeep2,
|
||||
pDb->cfg.daysToKeep0);
|
||||
} else {
|
||||
len = sprintf(&tmp[VARSTR_HEADER_SIZE], "%d,%d,%d", pDb->cfg.daysToKeep0, pDb->cfg.daysToKeep1,
|
||||
pDb->cfg.daysToKeep2);
|
||||
}
|
||||
|
||||
varDataSetLen(tmp, len);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)tmp, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheBlockSize, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.totalBlocks, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.minRows, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.maxRows, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.walLevel, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.fsyncPeriod, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.compression, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.cacheLastRow, false);
|
||||
|
||||
char *prec = NULL;
|
||||
switch (pDb->cfg.precision) {
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
prec = TSDB_TIME_PRECISION_MILLI_STR;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
prec = TSDB_TIME_PRECISION_MICRO_STR;
|
||||
break;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
prec = TSDB_TIME_PRECISION_NANO_STR;
|
||||
break;
|
||||
default:
|
||||
prec = "none";
|
||||
break;
|
||||
}
|
||||
|
||||
char t[10] = {0};
|
||||
STR_WITH_SIZE_TO_VARSTR(t, prec, 2);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)t, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.ttl, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.singleSTable, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.streamMode, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||
colDataAppend(pColInfo, rows, (const char *)b, false);
|
||||
}
|
||||
|
||||
// pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity);
|
||||
// *(int8_t *)pWrite = pDb->cfg.update;
|
||||
|
@ -1508,13 +1525,13 @@ static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo
|
|||
if (!pShow->sysDbRsp) {
|
||||
SDbObj infoschemaDb = {0};
|
||||
setInformationSchemaDbCfg(&infoschemaDb);
|
||||
dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14);
|
||||
dumpDbInfoData(pBlock, &infoschemaDb, pShow, numOfRows, 14, true);
|
||||
|
||||
numOfRows += 1;
|
||||
|
||||
SDbObj perfschemaDb = {0};
|
||||
setPerfSchemaDbCfg(&perfschemaDb);
|
||||
dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3);
|
||||
dumpDbInfoData(pBlock, &perfschemaDb, pShow, numOfRows, 3, true);
|
||||
|
||||
numOfRows += 1;
|
||||
pShow->sysDbRsp = true;
|
||||
|
@ -1529,7 +1546,7 @@ static int32_t mndRetrieveDbs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo
|
|||
int32_t numOfTables = 0;
|
||||
sdbTraverse(pSdb, SDB_VGROUP, mndGetTablesOfDbFp, &numOfTables, NULL, NULL);
|
||||
|
||||
dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables);
|
||||
dumpDbInfoData(pBlock, pDb, pShow, numOfRows, numOfTables, false);
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pDb);
|
||||
}
|
||||
|
|
|
@ -1201,6 +1201,23 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write SDataCols to data file.
|
||||
*
|
||||
* @param pRepo
|
||||
* @param pTable
|
||||
* @param pDFile
|
||||
* @param pDFileAggr
|
||||
* @param pDataCols The pDataCols would be generated from mem/imem directly with 2 bits bitmap or from tsdbRead
|
||||
* interface with 1 bit bitmap.
|
||||
* @param pBlock
|
||||
* @param isLast
|
||||
* @param isSuper
|
||||
* @param ppBuf
|
||||
* @param ppCBuf
|
||||
* @param ppExBuf
|
||||
* @return int
|
||||
*/
|
||||
int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDFileAggr, SDataCols *pDataCols,
|
||||
SBlock *pBlock, bool isLast, bool isSuper, void **ppBuf, void **ppCBuf, void **ppExBuf) {
|
||||
STsdbCfg *pCfg = REPO_CFG(pRepo);
|
||||
|
@ -1244,14 +1261,15 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
|||
pBlockCol->type = pDataCol->type;
|
||||
pAggrBlkCol->colId = pDataCol->colId;
|
||||
|
||||
if (tDataTypes[pDataCol->type].statisFunc) {
|
||||
if (isSuper && pColumn->sma && tDataTypes[pDataCol->type].statisFunc) {
|
||||
#if 0
|
||||
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pBlockCol->min), &(pBlockCol->max),
|
||||
&(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
|
||||
&(pBlockCol->numOfNull));
|
||||
#endif
|
||||
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pBitmap, pDataCol->pData, rowsToWrite, &(pAggrBlkCol->min), &(pAggrBlkCol->max),
|
||||
&(pAggrBlkCol->sum), &(pAggrBlkCol->minIndex), &(pAggrBlkCol->maxIndex),
|
||||
(*tDataTypes[pDataCol->type].statisFunc)(pDataCols->bitmapMode, pDataCol->pBitmap, pDataCol->pData, rowsToWrite,
|
||||
&(pAggrBlkCol->min), &(pAggrBlkCol->max), &(pAggrBlkCol->sum),
|
||||
&(pAggrBlkCol->minIndex), &(pAggrBlkCol->maxIndex),
|
||||
&(pAggrBlkCol->numOfNull));
|
||||
|
||||
if (pAggrBlkCol->numOfNull == 0) {
|
||||
|
@ -1259,13 +1277,16 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
|||
} else {
|
||||
TD_SET_COL_ROWS_MISC(pBlockCol);
|
||||
}
|
||||
} else if (tdIsBitmapBlkNorm(pDataCol->pBitmap, rowsToWrite, pDataCols->bitmapMode)) {
|
||||
// check if all rows normal
|
||||
TD_SET_COL_ROWS_NORM(pBlockCol);
|
||||
} else {
|
||||
TD_SET_COL_ROWS_MISC(pBlockCol);
|
||||
}
|
||||
|
||||
++nColsNotAllNull;
|
||||
|
||||
if (pColumn->sma) {
|
||||
if (isSuper && pColumn->sma) {
|
||||
++nColsOfBlockSma;
|
||||
}
|
||||
}
|
||||
|
@ -1277,7 +1298,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
|
|||
uint32_t toffset = 0;
|
||||
int32_t tsize = (int32_t)tsdbBlockStatisSize(nColsNotAllNull, SBlockVerLatest);
|
||||
int32_t lsize = tsize;
|
||||
uint32_t tsizeAggr = (uint32_t)tsdbBlockAggrSize(nColsNotAllNull, SBlockVerLatest);
|
||||
uint32_t tsizeAggr = (uint32_t)tsdbBlockAggrSize(nColsOfBlockSma, SBlockVerLatest);
|
||||
int32_t keyLen = 0;
|
||||
int32_t nBitmaps = (int32_t)TD_BITMAP_BYTES(rowsToWrite);
|
||||
int32_t sBitmaps = isSuper ? (int32_t)TD_BITMAP_BYTES_I(rowsToWrite) : nBitmaps;
|
||||
|
|
|
@ -237,33 +237,45 @@ static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum, int32_t maxParaNum, int32_t primaryParaNo) {
|
||||
static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, int32_t minParaNum, int32_t maxParaNum, bool hasSep) {
|
||||
int32_t paraNum = LIST_LENGTH(pFunc->pParameterList);
|
||||
if (paraNum < minParaNum || paraNum > maxParaNum) {
|
||||
return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
|
||||
uint8_t resultType = TSDB_DATA_TYPE_NCHAR;
|
||||
uint8_t resultType = TSDB_DATA_TYPE_BINARY;
|
||||
int32_t resultBytes = 0;
|
||||
int32_t sepBytes = 0;
|
||||
for (int32_t i = 0; i < LIST_LENGTH(pFunc->pParameterList); ++i) {
|
||||
|
||||
/* For concat/concat_ws function, if params have NCHAR type, promote the final result to NCHAR */
|
||||
for (int32_t i = 0; i < paraNum; ++i) {
|
||||
SNode* pPara = nodesListGetNode(pFunc->pParameterList, i);
|
||||
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
||||
int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes;
|
||||
if (!IS_VAR_DATA_TYPE(paraType)) {
|
||||
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
|
||||
}
|
||||
if (i < primaryParaNo) {
|
||||
sepBytes = paraBytes;
|
||||
continue;
|
||||
if (TSDB_DATA_TYPE_NCHAR == paraType) {
|
||||
resultType = paraType;
|
||||
}
|
||||
if (TSDB_DATA_TYPE_BINARY == paraType) {
|
||||
resultType = TSDB_DATA_TYPE_BINARY;
|
||||
}
|
||||
resultBytes += paraBytes;
|
||||
}
|
||||
if (sepBytes > 0) {
|
||||
resultBytes += sepBytes * (paraNum - 2);
|
||||
|
||||
for (int32_t i = 0; i < paraNum; ++i) {
|
||||
SNode* pPara = nodesListGetNode(pFunc->pParameterList, i);
|
||||
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
||||
int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes;
|
||||
int32_t factor = 1;
|
||||
if (TSDB_DATA_TYPE_NCHAR == resultType && TSDB_DATA_TYPE_VARCHAR == paraType) {
|
||||
factor *= TSDB_NCHAR_SIZE;
|
||||
}
|
||||
resultBytes += paraBytes * factor;
|
||||
|
||||
if (i == 0) {
|
||||
sepBytes = paraBytes * factor;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSep) {
|
||||
resultBytes += sepBytes * (paraNum - 3);
|
||||
}
|
||||
|
||||
pFunc->node.resType = (SDataType) { .bytes = resultBytes, .type = resultType };
|
||||
|
@ -271,11 +283,11 @@ static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
|
|||
}
|
||||
|
||||
static int32_t translateConcat(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
return translateConcatImpl(pFunc, pErrBuf, len, 2, 8, 0);
|
||||
return translateConcatImpl(pFunc, pErrBuf, len, 2, 8, false);
|
||||
}
|
||||
|
||||
static int32_t translateConcatWs(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
return translateConcatImpl(pFunc, pErrBuf, len, 3, 9, 1);
|
||||
return translateConcatImpl(pFunc, pErrBuf, len, 3, 9, true);
|
||||
}
|
||||
|
||||
static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
|
||||
|
|
|
@ -1226,7 +1226,7 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
|
|||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_VARCHAR:
|
||||
case TSDB_DATA_TYPE_VARBINARY:
|
||||
pVal->pz = pNode->datum.p + VARSTR_HEADER_SIZE;
|
||||
pVal->pz = pNode->datum.p;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
case TSDB_DATA_TYPE_DECIMAL:
|
||||
|
|
|
@ -1470,6 +1470,9 @@ void qWorkerDestroy(void **qWorkerMgmt) {
|
|||
|
||||
//TODO FREE ALL
|
||||
|
||||
taosHashCleanup(mgmt->ctxHash);
|
||||
taosHashCleanup(mgmt->schHash);
|
||||
|
||||
taosMemoryFreeClear(*qWorkerMgmt);
|
||||
}
|
||||
|
||||
|
|
|
@ -313,8 +313,8 @@ static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t concatCopyHelper(const char *input, char *output, bool hasNcharCol, int32_t type, int16_t *dataLen) {
|
||||
if (hasNcharCol && type == TSDB_DATA_TYPE_VARCHAR) {
|
||||
static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar, int32_t type, int16_t *dataLen) {
|
||||
if (hasNchar && type == TSDB_DATA_TYPE_VARCHAR) {
|
||||
TdUcs4 *newBuf = taosMemoryCalloc((varDataLen(input) + 1) * TSDB_NCHAR_SIZE, 1);
|
||||
bool ret = taosMbsToUcs4(varDataVal(input), varDataLen(input), newBuf, (varDataLen(input) + 1) * TSDB_NCHAR_SIZE, NULL);
|
||||
if (!ret) {
|
||||
|
@ -345,10 +345,6 @@ static int32_t getNumOfNullEntries(SColumnInfoData *pColumnInfoData, int32_t num
|
|||
}
|
||||
|
||||
int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
if (inputNum < 2 || inputNum > 8) { // concat accpet 2-8 input strings
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SColumnInfoData **pInputData = taosMemoryCalloc(inputNum, sizeof(SColumnInfoData *));
|
||||
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||
char **input = taosMemoryCalloc(inputNum, POINTER_BYTES);
|
||||
|
@ -356,15 +352,8 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
|
||||
int32_t inputLen = 0;
|
||||
int32_t numOfRows = 0;
|
||||
bool hasNcharCol = false;
|
||||
bool hasNchar = (GET_PARAM_TYPE(pOutput) == TSDB_DATA_TYPE_NCHAR) ? true : false;
|
||||
for (int32_t i = 0; i < inputNum; ++i) {
|
||||
int32_t type = GET_PARAM_TYPE(&pInput[i]);
|
||||
if (!IS_VAR_DATA_TYPE(type)) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||
hasNcharCol = true;
|
||||
}
|
||||
if (pInput[i].numOfRows > numOfRows) {
|
||||
numOfRows = pInput[i].numOfRows;
|
||||
}
|
||||
|
@ -373,7 +362,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
pInputData[i] = pInput[i].columnData;
|
||||
input[i] = pInputData[i]->pData + pInputData[i]->varmeta.offset[0];
|
||||
int32_t factor = 1;
|
||||
if (hasNcharCol && (GET_PARAM_TYPE(&pInput[i]) == TSDB_DATA_TYPE_VARCHAR)) {
|
||||
if (hasNchar && (GET_PARAM_TYPE(&pInput[i]) == TSDB_DATA_TYPE_VARCHAR)) {
|
||||
factor = TSDB_NCHAR_SIZE;
|
||||
}
|
||||
|
||||
|
@ -405,7 +394,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
|
||||
int16_t dataLen = 0;
|
||||
for (int32_t i = 0; i < inputNum; ++i) {
|
||||
int32_t ret = concatCopyHelper(input[i], output, hasNcharCol, GET_PARAM_TYPE(&pInput[i]), &dataLen);
|
||||
int32_t ret = concatCopyHelper(input[i], output, hasNchar, GET_PARAM_TYPE(&pInput[i]), &dataLen);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -428,10 +417,6 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
|
|||
|
||||
|
||||
int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) {
|
||||
if (inputNum < 3 || inputNum > 9) { // concat accpet 3-9 input strings including the separator
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
SColumnInfoData **pInputData = taosMemoryCalloc(inputNum, sizeof(SColumnInfoData *));
|
||||
SColumnInfoData *pOutputData = pOutput->columnData;
|
||||
char **input = taosMemoryCalloc(inputNum, POINTER_BYTES);
|
||||
|
@ -439,15 +424,8 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
|
||||
int32_t inputLen = 0;
|
||||
int32_t numOfRows = 0;
|
||||
bool hasNcharCol = false;
|
||||
bool hasNchar = (GET_PARAM_TYPE(pOutput) == TSDB_DATA_TYPE_NCHAR) ? true : false;
|
||||
for (int32_t i = 1; i < inputNum; ++i) {
|
||||
int32_t type = GET_PARAM_TYPE(&pInput[i]);
|
||||
if (!IS_VAR_DATA_TYPE(GET_PARAM_TYPE(&pInput[i]))) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
if (type == TSDB_DATA_TYPE_NCHAR) {
|
||||
hasNcharCol = true;
|
||||
}
|
||||
if (pInput[i].numOfRows > numOfRows) {
|
||||
numOfRows = pInput[i].numOfRows;
|
||||
}
|
||||
|
@ -456,7 +434,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
pInputData[i] = pInput[i].columnData;
|
||||
input[i] = pInputData[i]->pData + pInputData[i]->varmeta.offset[0];
|
||||
int32_t factor = 1;
|
||||
if (hasNcharCol && (GET_PARAM_TYPE(&pInput[i]) == TSDB_DATA_TYPE_VARCHAR)) {
|
||||
if (hasNchar && (GET_PARAM_TYPE(&pInput[i]) == TSDB_DATA_TYPE_VARCHAR)) {
|
||||
factor = TSDB_NCHAR_SIZE;
|
||||
}
|
||||
|
||||
|
@ -487,7 +465,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
continue;
|
||||
}
|
||||
|
||||
int32_t ret = concatCopyHelper(input[i], output, hasNcharCol, GET_PARAM_TYPE(&pInput[i]), &dataLen);
|
||||
int32_t ret = concatCopyHelper(input[i], output, hasNchar, GET_PARAM_TYPE(&pInput[i]), &dataLen);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -499,7 +477,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
|
|||
if (i < inputNum - 1) {
|
||||
//insert the separator
|
||||
char *sep = pInputData[0]->pData;
|
||||
int32_t ret = concatCopyHelper(sep, output, hasNcharCol, GET_PARAM_TYPE(&pInput[0]), &dataLen);
|
||||
int32_t ret = concatCopyHelper(sep, output, hasNchar, GET_PARAM_TYPE(&pInput[0]), &dataLen);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -910,6 +910,8 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_trav_fn_t fp, void *param1)
|
|||
|
||||
void taosStopCacheRefreshWorker(void) {
|
||||
stopRefreshWorker = true;
|
||||
taosThreadJoin(cacheRefreshWorker, NULL);
|
||||
taosArrayDestroy(pCacheArrayList);
|
||||
}
|
||||
|
||||
size_t taosCacheGetNumOfObj(const SCacheObj* pCacheObj) {
|
||||
|
|
|
@ -591,12 +591,12 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
|
|||
}
|
||||
|
||||
int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
|
||||
uInfo("load from env variables not implemented yet");
|
||||
uDebug("load from env variables not implemented yet");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *filepath) {
|
||||
uInfo("load from env file not implemented yet");
|
||||
uDebug("load from env file not implemented yet");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -655,6 +655,6 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
|||
}
|
||||
|
||||
int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||
uInfo("load from apoll url not implemented yet");
|
||||
uDebug("load from apoll url not implemented yet");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -38,27 +38,26 @@
|
|||
#define LOG_BUF_MUTEX(x) ((x)->buffMutex)
|
||||
|
||||
typedef struct {
|
||||
char *buffer;
|
||||
int32_t buffStart;
|
||||
int32_t buffEnd;
|
||||
int32_t buffSize;
|
||||
int32_t minBuffSize;
|
||||
TdFilePtr pFile;
|
||||
int32_t stop;
|
||||
TdThread asyncThread;
|
||||
char *buffer;
|
||||
int32_t buffStart;
|
||||
int32_t buffEnd;
|
||||
int32_t buffSize;
|
||||
int32_t minBuffSize;
|
||||
TdFilePtr pFile;
|
||||
int32_t stop;
|
||||
TdThread asyncThread;
|
||||
TdThreadMutex buffMutex;
|
||||
tsem_t buffNotEmpty;
|
||||
} SLogBuff;
|
||||
|
||||
typedef struct {
|
||||
int32_t fileNum;
|
||||
int32_t maxLines;
|
||||
int32_t lines;
|
||||
int32_t flag;
|
||||
int32_t openInProgress;
|
||||
pid_t pid;
|
||||
char logName[LOG_FILE_NAME_LEN];
|
||||
SLogBuff *logHandle;
|
||||
int32_t fileNum;
|
||||
int32_t maxLines;
|
||||
int32_t lines;
|
||||
int32_t flag;
|
||||
int32_t openInProgress;
|
||||
pid_t pid;
|
||||
char logName[LOG_FILE_NAME_LEN];
|
||||
SLogBuff *logHandle;
|
||||
TdThreadMutex logMutex;
|
||||
} SLogObj;
|
||||
|
||||
|
@ -100,7 +99,7 @@ int64_t dbgBigWN = 0;
|
|||
int64_t dbgWSize = 0;
|
||||
|
||||
static void *taosAsyncOutputLog(void *param);
|
||||
static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t msgLen);
|
||||
static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen);
|
||||
static SLogBuff *taosLogBuffNew(int32_t bufSize);
|
||||
static void taosCloseLogByFd(TdFilePtr pFile);
|
||||
static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum);
|
||||
|
@ -136,16 +135,24 @@ static void taosStopLog() {
|
|||
}
|
||||
}
|
||||
|
||||
static void taosLogBuffDestroy() {
|
||||
taosThreadMutexDestroy(&tsLogObj.logHandle->buffMutex);
|
||||
taosCloseFile(&tsLogObj.logHandle->pFile);
|
||||
taosMemoryFreeClear(tsLogObj.logHandle->buffer);
|
||||
memset(&tsLogObj.logHandle->buffer, 0, sizeof(tsLogObj.logHandle->buffer));
|
||||
taosThreadMutexDestroy(&tsLogObj.logMutex);
|
||||
taosMemoryFreeClear(tsLogObj.logHandle);
|
||||
memset(&tsLogObj.logHandle, 0, sizeof(tsLogObj.logHandle));
|
||||
tsLogObj.logHandle = NULL;
|
||||
}
|
||||
|
||||
void taosCloseLog() {
|
||||
taosStopLog();
|
||||
if (taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) {
|
||||
taosThreadJoin(tsLogObj.logHandle->asyncThread, NULL);
|
||||
}
|
||||
tsLogInited = 0;
|
||||
// In case that other threads still use log resources causing invalid write in valgrind
|
||||
// we comment two lines below.
|
||||
// taosLogBuffDestroy(tsLogObj.logHandle);
|
||||
// taosCloseLog();
|
||||
taosLogBuffDestroy(tsLogObj.logHandle);
|
||||
}
|
||||
|
||||
static bool taosLockLogFile(TdFilePtr pFile) {
|
||||
|
@ -231,7 +238,7 @@ static int32_t taosOpenNewLogFile() {
|
|||
tsLogObj.openInProgress = 1;
|
||||
|
||||
uInfo("open new log file ......");
|
||||
TdThread thread;
|
||||
TdThread thread;
|
||||
TdThreadAttr attr;
|
||||
taosThreadAttrInit(&attr);
|
||||
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
@ -506,45 +513,45 @@ static void taosCloseLogByFd(TdFilePtr pFile) {
|
|||
}
|
||||
|
||||
static SLogBuff *taosLogBuffNew(int32_t bufSize) {
|
||||
SLogBuff *tLogBuff = NULL;
|
||||
SLogBuff *pLogBuf = NULL;
|
||||
|
||||
tLogBuff = taosMemoryCalloc(1, sizeof(SLogBuff));
|
||||
if (tLogBuff == NULL) return NULL;
|
||||
pLogBuf = taosMemoryCalloc(1, sizeof(SLogBuff));
|
||||
if (pLogBuf == NULL) return NULL;
|
||||
|
||||
LOG_BUF_BUFFER(tLogBuff) = taosMemoryMalloc(bufSize);
|
||||
if (LOG_BUF_BUFFER(tLogBuff) == NULL) goto _err;
|
||||
LOG_BUF_BUFFER(pLogBuf) = taosMemoryMalloc(bufSize);
|
||||
if (LOG_BUF_BUFFER(pLogBuf) == NULL) goto _err;
|
||||
|
||||
LOG_BUF_START(tLogBuff) = LOG_BUF_END(tLogBuff) = 0;
|
||||
LOG_BUF_SIZE(tLogBuff) = bufSize;
|
||||
tLogBuff->minBuffSize = bufSize / 10;
|
||||
tLogBuff->stop = 0;
|
||||
LOG_BUF_START(pLogBuf) = LOG_BUF_END(pLogBuf) = 0;
|
||||
LOG_BUF_SIZE(pLogBuf) = bufSize;
|
||||
pLogBuf->minBuffSize = bufSize / 10;
|
||||
pLogBuf->stop = 0;
|
||||
|
||||
if (taosThreadMutexInit(&LOG_BUF_MUTEX(tLogBuff), NULL) < 0) goto _err;
|
||||
// tsem_init(&(tLogBuff->buffNotEmpty), 0, 0);
|
||||
if (taosThreadMutexInit(&LOG_BUF_MUTEX(pLogBuf), NULL) < 0) goto _err;
|
||||
// tsem_init(&(pLogBuf->buffNotEmpty), 0, 0);
|
||||
|
||||
return tLogBuff;
|
||||
return pLogBuf;
|
||||
|
||||
_err:
|
||||
taosMemoryFreeClear(LOG_BUF_BUFFER(tLogBuff));
|
||||
taosMemoryFreeClear(tLogBuff);
|
||||
taosMemoryFreeClear(LOG_BUF_BUFFER(pLogBuf));
|
||||
taosMemoryFreeClear(pLogBuf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void taosCopyLogBuffer(SLogBuff *tLogBuff, int32_t start, int32_t end, const char *msg, int32_t msgLen) {
|
||||
static void taosCopyLogBuffer(SLogBuff *pLogBuf, int32_t start, int32_t end, const char *msg, int32_t msgLen) {
|
||||
if (start > end) {
|
||||
memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, msgLen);
|
||||
memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, msgLen);
|
||||
} else {
|
||||
if (LOG_BUF_SIZE(tLogBuff) - end < msgLen) {
|
||||
memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, LOG_BUF_SIZE(tLogBuff) - end);
|
||||
memcpy(LOG_BUF_BUFFER(tLogBuff), msg + LOG_BUF_SIZE(tLogBuff) - end, msgLen - LOG_BUF_SIZE(tLogBuff) + end);
|
||||
if (LOG_BUF_SIZE(pLogBuf) - end < msgLen) {
|
||||
memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, LOG_BUF_SIZE(pLogBuf) - end);
|
||||
memcpy(LOG_BUF_BUFFER(pLogBuf), msg + LOG_BUF_SIZE(pLogBuf) - end, msgLen - LOG_BUF_SIZE(pLogBuf) + end);
|
||||
} else {
|
||||
memcpy(LOG_BUF_BUFFER(tLogBuff) + end, msg, msgLen);
|
||||
memcpy(LOG_BUF_BUFFER(pLogBuf) + end, msg, msgLen);
|
||||
}
|
||||
}
|
||||
LOG_BUF_END(tLogBuff) = (LOG_BUF_END(tLogBuff) + msgLen) % LOG_BUF_SIZE(tLogBuff);
|
||||
LOG_BUF_END(pLogBuf) = (LOG_BUF_END(pLogBuf) + msgLen) % LOG_BUF_SIZE(pLogBuf);
|
||||
}
|
||||
|
||||
static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t msgLen) {
|
||||
static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msgLen) {
|
||||
int32_t start = 0;
|
||||
int32_t end = 0;
|
||||
int32_t remainSize = 0;
|
||||
|
@ -552,13 +559,13 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t ms
|
|||
char tmpBuf[40] = {0};
|
||||
int32_t tmpBufLen = 0;
|
||||
|
||||
if (tLogBuff == NULL || tLogBuff->stop) return -1;
|
||||
if (pLogBuf == NULL || pLogBuf->stop) return -1;
|
||||
|
||||
taosThreadMutexLock(&LOG_BUF_MUTEX(tLogBuff));
|
||||
start = LOG_BUF_START(tLogBuff);
|
||||
end = LOG_BUF_END(tLogBuff);
|
||||
taosThreadMutexLock(&LOG_BUF_MUTEX(pLogBuf));
|
||||
start = LOG_BUF_START(pLogBuf);
|
||||
end = LOG_BUF_END(pLogBuf);
|
||||
|
||||
remainSize = (start > end) ? (start - end - 1) : (start + LOG_BUF_SIZE(tLogBuff) - end - 1);
|
||||
remainSize = (start > end) ? (start - end - 1) : (start + LOG_BUF_SIZE(pLogBuf) - end - 1);
|
||||
|
||||
if (lostLine > 0) {
|
||||
sprintf(tmpBuf, "...Lost %" PRId64 " lines here...\n", lostLine);
|
||||
|
@ -568,47 +575,47 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, const char *msg, int32_t ms
|
|||
if (remainSize <= msgLen || ((lostLine > 0) && (remainSize <= (msgLen + tmpBufLen)))) {
|
||||
lostLine++;
|
||||
tsAsyncLogLostLines++;
|
||||
taosThreadMutexUnlock(&LOG_BUF_MUTEX(tLogBuff));
|
||||
taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lostLine > 0) {
|
||||
taosCopyLogBuffer(tLogBuff, start, end, tmpBuf, tmpBufLen);
|
||||
taosCopyLogBuffer(pLogBuf, start, end, tmpBuf, tmpBufLen);
|
||||
lostLine = 0;
|
||||
}
|
||||
|
||||
taosCopyLogBuffer(tLogBuff, LOG_BUF_START(tLogBuff), LOG_BUF_END(tLogBuff), msg, msgLen);
|
||||
taosCopyLogBuffer(pLogBuf, LOG_BUF_START(pLogBuf), LOG_BUF_END(pLogBuf), msg, msgLen);
|
||||
|
||||
// int32_t w = atomic_sub_fetch_32(&waitLock, 1);
|
||||
/*
|
||||
if (w <= 0 || ((remainSize - msgLen - tmpBufLen) < (LOG_BUF_SIZE(tLogBuff) * 4 /5))) {
|
||||
tsem_post(&(tLogBuff->buffNotEmpty));
|
||||
if (w <= 0 || ((remainSize - msgLen - tmpBufLen) < (LOG_BUF_SIZE(pLogBuf) * 4 /5))) {
|
||||
tsem_post(&(pLogBuf->buffNotEmpty));
|
||||
dbgPostN++;
|
||||
} else {
|
||||
dbgNoPostN++;
|
||||
}
|
||||
*/
|
||||
|
||||
taosThreadMutexUnlock(&LOG_BUF_MUTEX(tLogBuff));
|
||||
taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t taosGetLogRemainSize(SLogBuff *tLogBuff, int32_t start, int32_t end) {
|
||||
static int32_t taosGetLogRemainSize(SLogBuff *pLogBuf, int32_t start, int32_t end) {
|
||||
int32_t rSize = end - start;
|
||||
|
||||
return rSize >= 0 ? rSize : LOG_BUF_SIZE(tLogBuff) + rSize;
|
||||
return rSize >= 0 ? rSize : LOG_BUF_SIZE(pLogBuf) + rSize;
|
||||
}
|
||||
|
||||
static void taosWriteLog(SLogBuff *tLogBuff) {
|
||||
static void taosWriteLog(SLogBuff *pLogBuf) {
|
||||
static int32_t lastDuration = 0;
|
||||
int32_t remainChecked = 0;
|
||||
int32_t start, end, pollSize;
|
||||
|
||||
do {
|
||||
if (remainChecked == 0) {
|
||||
start = LOG_BUF_START(tLogBuff);
|
||||
end = LOG_BUF_END(tLogBuff);
|
||||
start = LOG_BUF_START(pLogBuf);
|
||||
end = LOG_BUF_END(pLogBuf);
|
||||
|
||||
if (start == end) {
|
||||
dbgEmptyW++;
|
||||
|
@ -616,8 +623,8 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
|
|||
return;
|
||||
}
|
||||
|
||||
pollSize = taosGetLogRemainSize(tLogBuff, start, end);
|
||||
if (pollSize < tLogBuff->minBuffSize) {
|
||||
pollSize = taosGetLogRemainSize(pLogBuf, start, end);
|
||||
if (pollSize < pLogBuf->minBuffSize) {
|
||||
lastDuration += tsWriteInterval;
|
||||
if (lastDuration < LOG_MAX_WAIT_MSEC) {
|
||||
break;
|
||||
|
@ -628,38 +635,38 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
|
|||
}
|
||||
|
||||
if (start < end) {
|
||||
taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff) + start, pollSize);
|
||||
taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, pollSize);
|
||||
} else {
|
||||
int32_t tsize = LOG_BUF_SIZE(tLogBuff) - start;
|
||||
taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff) + start, tsize);
|
||||
int32_t tsize = LOG_BUF_SIZE(pLogBuf) - start;
|
||||
taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf) + start, tsize);
|
||||
|
||||
taosWriteFile(tLogBuff->pFile, LOG_BUF_BUFFER(tLogBuff), end);
|
||||
taosWriteFile(pLogBuf->pFile, LOG_BUF_BUFFER(pLogBuf), end);
|
||||
}
|
||||
|
||||
dbgWN++;
|
||||
dbgWSize += pollSize;
|
||||
|
||||
if (pollSize < tLogBuff->minBuffSize) {
|
||||
if (pollSize < pLogBuf->minBuffSize) {
|
||||
dbgSmallWN++;
|
||||
if (tsWriteInterval < LOG_MAX_INTERVAL) {
|
||||
tsWriteInterval += LOG_INTERVAL_STEP;
|
||||
}
|
||||
} else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 3) {
|
||||
} else if (pollSize > LOG_BUF_SIZE(pLogBuf) / 3) {
|
||||
dbgBigWN++;
|
||||
tsWriteInterval = LOG_MIN_INTERVAL;
|
||||
} else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 4) {
|
||||
} else if (pollSize > LOG_BUF_SIZE(pLogBuf) / 4) {
|
||||
if (tsWriteInterval > LOG_MIN_INTERVAL) {
|
||||
tsWriteInterval -= LOG_INTERVAL_STEP;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_BUF_START(tLogBuff) = (LOG_BUF_START(tLogBuff) + pollSize) % LOG_BUF_SIZE(tLogBuff);
|
||||
LOG_BUF_START(pLogBuf) = (LOG_BUF_START(pLogBuf) + pollSize) % LOG_BUF_SIZE(pLogBuf);
|
||||
|
||||
start = LOG_BUF_START(tLogBuff);
|
||||
end = LOG_BUF_END(tLogBuff);
|
||||
start = LOG_BUF_START(pLogBuf);
|
||||
end = LOG_BUF_END(pLogBuf);
|
||||
|
||||
pollSize = taosGetLogRemainSize(tLogBuff, start, end);
|
||||
if (pollSize < tLogBuff->minBuffSize) {
|
||||
pollSize = taosGetLogRemainSize(pLogBuf, start, end);
|
||||
if (pollSize < pLogBuf->minBuffSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -670,16 +677,16 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
|
|||
}
|
||||
|
||||
static void *taosAsyncOutputLog(void *param) {
|
||||
SLogBuff *tLogBuff = (SLogBuff *)param;
|
||||
SLogBuff *pLogBuf = (SLogBuff *)param;
|
||||
setThreadName("log");
|
||||
|
||||
while (1) {
|
||||
taosMsleep(tsWriteInterval);
|
||||
|
||||
// Polling the buffer
|
||||
taosWriteLog(tLogBuff);
|
||||
taosWriteLog(pLogBuf);
|
||||
|
||||
if (tLogBuff->stop) break;
|
||||
if (pLogBuf->stop) break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
|
||||
$loop_cnt = 0
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#define MAX_BACKGROUND_SCRIPT_NUM 10
|
||||
#define MAX_FILE_NAME_LEN 256
|
||||
#define MAX_ERROR_LEN 1024
|
||||
#define MAX_QUERY_VALUE_LEN 40
|
||||
#define MAX_QUERY_VALUE_LEN 1024
|
||||
#define MAX_QUERY_COL_NUM 100
|
||||
#define MAX_QUERY_ROW_NUM 100
|
||||
#define MAX_SYSTEM_RESULT_LEN 2048
|
||||
|
|
|
@ -368,7 +368,8 @@ bool simExecuteRunBackCmd(SScript *script, char *option) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void simReplaceStr(char *buf, char *src, char *dst) {
|
||||
bool simReplaceStr(char *buf, char *src, char *dst) {
|
||||
bool replaced = false;
|
||||
char *begin = strstr(buf, src);
|
||||
if (begin != NULL) {
|
||||
int32_t srcLen = (int32_t)strlen(src);
|
||||
|
@ -383,13 +384,16 @@ void simReplaceStr(char *buf, char *src, char *dst) {
|
|||
}
|
||||
|
||||
memcpy(begin, dst, dstLen);
|
||||
replaced = true;
|
||||
}
|
||||
|
||||
simInfo("system cmd is %s", buf);
|
||||
return replaced;
|
||||
}
|
||||
|
||||
bool simExecuteSystemCmd(SScript *script, char *option) {
|
||||
char buf[4096] = {0};
|
||||
bool replaced = false;
|
||||
|
||||
#ifndef WINDOWS
|
||||
sprintf(buf, "cd %s; ", simScriptDir);
|
||||
|
@ -404,7 +408,7 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
|
|||
}
|
||||
|
||||
if (useValgrind) {
|
||||
simReplaceStr(buf, "exec.sh", "exec.sh -v");
|
||||
replaced = simReplaceStr(buf, "exec.sh", "exec.sh -v");
|
||||
}
|
||||
|
||||
simLogSql(buf, true);
|
||||
|
@ -422,6 +426,11 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
|
|||
|
||||
sprintf(script->system_exit_code, "%d", code);
|
||||
script->linePos++;
|
||||
if (replaced && strstr(buf, "start") != NULL) {
|
||||
simInfo("====> startup is slow in valgrind mode, so sleep 5 seconds after exec.sh -s start");
|
||||
taosMsleep(5000);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ static tsem_t cancelSem;
|
|||
|
||||
static struct argp_option options[] = {
|
||||
{"host", 'h', "HOST", 0, "TDengine server FQDN to connect. The default host is localhost."},
|
||||
{"password", 'p', 0, 0, "The password to use when connecting to the server."},
|
||||
{"password", 'p', 0, 0, "The password to use when connecting to the server."},
|
||||
{"port", 'P', "PORT", 0, "The TCP/IP port number to use for the connection."},
|
||||
{"user", 'u', "USER", 0, "The user name to use when connecting to the server."},
|
||||
{"auth", 'A', "Auth", 0, "The auth string to use when connecting to the server."},
|
||||
|
|
Loading…
Reference in New Issue