Merge pull request #17326 from taosdata/refact/code_format

refact: code format
This commit is contained in:
Hongze Cheng 2022-10-13 13:35:17 +08:00 committed by GitHub
commit 3950c8fc24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
134 changed files with 3858 additions and 4247 deletions

View File

@ -47,7 +47,8 @@ typedef enum {
int32_t grantCheck(EGrantType grant); int32_t grantCheck(EGrantType grant);
#ifndef GRANTS_CFG #ifndef GRANTS_CFG
#define GRANTS_SCHEMA static const SSysDbTableSchema grantsSchema[] = { \ #define GRANTS_SCHEMA \
static const SSysDbTableSchema grantsSchema[] = { \
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
@ -62,7 +63,7 @@ int32_t grantCheck(EGrantType grant);
{.name = "cpu_cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "cpu_cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "speed", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "speed", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
{.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
} }
#define GRANT_CFG_ADD #define GRANT_CFG_ADD
#define GRANT_CFG_SET #define GRANT_CFG_SET
#define GRANT_CFG_GET #define GRANT_CFG_GET

View File

@ -20,6 +20,8 @@
extern "C" { extern "C" {
#endif #endif
// clang-format off
// sql type // sql type
#ifdef TSDB_SQL_C #ifdef TSDB_SQL_C
@ -103,6 +105,8 @@ enum {
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_MAX, "max" ) TSDB_DEFINE_SQL_TYPE( TSDB_SQL_MAX, "max" )
}; };
// clang-format on
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -182,7 +182,8 @@ int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId,
* @param pTableMeta(output, table meta data, NEED to free it by calller) * @param pTableMeta(output, table meta data, NEED to free it by calller)
* @return error code * @return error code
*/ */
int32_t catalogGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta); int32_t catalogGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName,
STableMeta** pTableMeta);
/** /**
* Get a super table's meta data. * Get a super table's meta data.
@ -193,9 +194,10 @@ int32_t catalogGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const S
* @param pTableMeta(output, table meta data, NEED to free it by calller) * @param pTableMeta(output, table meta data, NEED to free it by calller)
* @return error code * @return error code
*/ */
int32_t catalogGetSTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta); int32_t catalogGetSTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName,
STableMeta** pTableMeta);
int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp *rspMsg); int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg);
int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg); int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg);
@ -232,7 +234,8 @@ int32_t catalogRefreshTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, con
* @param isSTable (input, is super table or not, 1:supposed to be stable, 0: supposed not to be stable, -1:not sure) * @param isSTable (input, is super table or not, 1:supposed to be stable, 0: supposed not to be stable, -1:not sure)
* @return error code * @return error code
*/ */
int32_t catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta, int32_t isSTable); int32_t catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName,
STableMeta** pTableMeta, int32_t isSTable);
/** /**
* Get a table's actual vgroup, for stable it's all possible vgroup list. * Get a table's actual vgroup, for stable it's all possible vgroup list.
@ -243,7 +246,8 @@ int32_t catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn,
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller) * @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @return error code * @return error code
*/ */
int32_t catalogGetTableDistVgInfo(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, SArray** pVgroupList); int32_t catalogGetTableDistVgInfo(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName,
SArray** pVgroupList);
/** /**
* Get a table's vgroup from its name's hash value. * Get a table's vgroup from its name's hash value.
@ -267,13 +271,14 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCatalog, SRequestConnInfo* pConn, c
*/ */
int32_t catalogGetAllMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp); int32_t catalogGetAllMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp);
int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId); int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp,
void* param, int64_t* jobId);
int32_t catalogGetQnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* pQnodeList); int32_t catalogGetQnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* pQnodeList);
int32_t catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray** pDnodeList); int32_t catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray** pDnodeList);
int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableVersion **stables, uint32_t *num); int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableVersion** stables, uint32_t* num);
int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbVgVersion** dbs, uint32_t* num); int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbVgVersion** dbs, uint32_t* num);
@ -285,19 +290,20 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes); int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes);
int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg); int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg);
int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp); int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp* pRsp);
int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* pInfo); int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* pInfo);
int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass); int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type,
bool* pass);
int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth); int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth);
int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet); int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet* epSet);
int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo *pConn, char** pVersion); int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo* pConn, char** pVersion);
int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, bool forceUpdate); int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, bool forceUpdate);

View File

@ -20,10 +20,10 @@
extern "C" { extern "C" {
#endif #endif
#include "os.h"
#include "thash.h"
#include "executor.h" #include "executor.h"
#include "os.h"
#include "plannodes.h" #include "plannodes.h"
#include "thash.h"
#define DS_BUF_LOW 1 #define DS_BUF_LOW 1
#define DS_BUF_FULL 2 #define DS_BUF_FULL 2
@ -60,7 +60,7 @@ typedef struct SDataSinkMgtCfg {
uint32_t maxDataBlockNumPerQuery; uint32_t maxDataBlockNumPerQuery;
} SDataSinkMgtCfg; } SDataSinkMgtCfg;
int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg); int32_t dsDataSinkMgtInit(SDataSinkMgtCfg* cfg);
typedef struct SInputData { typedef struct SInputData {
const struct SSDataBlock* pData; const struct SSDataBlock* pData;
@ -86,7 +86,7 @@ typedef struct SOutputData {
*/ */
int32_t dsCreateDataSinker(const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void* pParam); int32_t dsCreateDataSinker(const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void* pParam);
int32_t dsDataSinkGetCacheSize(SDataSinkStat *pStat); int32_t dsDataSinkGetCacheSize(SDataSinkStat* pStat);
/** /**
* Put the result set returned by the executor into datasinker. * Put the result set returned by the executor into datasinker.
@ -114,7 +114,7 @@ void dsGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd);
*/ */
int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput); int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput);
int32_t dsGetCacheSize(DataSinkHandle handle, uint64_t *pSize); int32_t dsGetCacheSize(DataSinkHandle handle, uint64_t* pSize);
/** /**
* After dsGetStatus returns DS_NEED_SCHEDULE, the caller need to put this into the work queue. * After dsGetStatus returns DS_NEED_SCHEDULE, the caller need to put this into the work queue.

View File

@ -1,23 +1,23 @@
/* /*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com> * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
* *
* This program is free software: you can use, redistribute, and/or modify * This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3 * it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation. * or later ("AGPL"), as published by the Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. * FITNESS FOR A PARTICULAR PURPOSE.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TDENGINE_TAOSUDF_H #ifndef TDENGINE_TAOSUDF_H
#define TDENGINE_TAOSUDF_H #define TDENGINE_TAOSUDF_H
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -61,7 +61,6 @@ typedef struct SUdfColumnData {
}; };
} SUdfColumnData; } SUdfColumnData;
typedef struct SUdfColumn { typedef struct SUdfColumn {
SUdfColumnMeta colMeta; SUdfColumnMeta colMeta;
bool hasNull; bool hasNull;
@ -76,8 +75,8 @@ typedef struct SUdfDataBlock {
typedef struct SUdfInterBuf { typedef struct SUdfInterBuf {
int32_t bufLen; int32_t bufLen;
char* buf; char *buf;
int8_t numOfResult; //zero or one int8_t numOfResult; // zero or one
} SUdfInterBuf; } SUdfInterBuf;
typedef void *UdfcFuncHandle; typedef void *UdfcFuncHandle;
@ -92,7 +91,8 @@ typedef int32_t (*TUdfDestroyFunc)();
#define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT) #define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT)
#define udfColDataIsNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] == -1) #define udfColDataIsNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] == -1)
#define udfColDataIsNull_f(pColumn, row) ((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row)))) #define udfColDataIsNull_f(pColumn, row) \
((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row))))
#define udfColDataSetNull_f(pColumn, row) \ #define udfColDataSetNull_f(pColumn, row) \
do { \ do { \
BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \ BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \
@ -116,8 +116,7 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON)) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON))
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) #define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR))
static FORCE_INLINE char *udfColDataGetData(const SUdfColumn *pColumn, int32_t row) {
static FORCE_INLINE char* udfColDataGetData(const SUdfColumn* pColumn, int32_t row) {
if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) {
return pColumn->colData.varLenCol.payload + pColumn->colData.varLenCol.varOffsets[row]; return pColumn->colData.varLenCol.payload + pColumn->colData.varLenCol.varOffsets[row];
} else { } else {
@ -125,13 +124,13 @@ static FORCE_INLINE char* udfColDataGetData(const SUdfColumn* pColumn, int32_t r
} }
} }
static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn* pColumn, int32_t row) { static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn *pColumn, int32_t row) {
if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) {
if (pColumn->colMeta.type == TSDB_DATA_TYPE_JSON) { if (pColumn->colMeta.type == TSDB_DATA_TYPE_JSON) {
if (udfColDataIsNull_var(pColumn, row)) { if (udfColDataIsNull_var(pColumn, row)) {
return true; return true;
} }
char* data = udfColDataGetData(pColumn, row); char *data = udfColDataGetData(pColumn, row);
return (*data == TSDB_DATA_TYPE_NULL); return (*data == TSDB_DATA_TYPE_NULL);
} else { } else {
return udfColDataIsNull_var(pColumn, row); return udfColDataIsNull_var(pColumn, row);
@ -141,29 +140,29 @@ static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn* pColumn, int32_t row
} }
} }
static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t newCapacity) { static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t newCapacity) {
SUdfColumnMeta *meta = &pColumn->colMeta; SUdfColumnMeta *meta = &pColumn->colMeta;
SUdfColumnData *data = &pColumn->colData; SUdfColumnData *data = &pColumn->colData;
if (newCapacity== 0 || newCapacity <= data->rowsAlloc) { if (newCapacity == 0 || newCapacity <= data->rowsAlloc) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int allocCapacity = (data->rowsAlloc< 8) ? 8 : data->rowsAlloc; int allocCapacity = (data->rowsAlloc < 8) ? 8 : data->rowsAlloc;
while (allocCapacity < newCapacity) { while (allocCapacity < newCapacity) {
allocCapacity *= UDF_MEMORY_EXP_GROWTH; allocCapacity *= UDF_MEMORY_EXP_GROWTH;
} }
if (IS_VAR_DATA_TYPE(meta->type)) { if (IS_VAR_DATA_TYPE(meta->type)) {
char* tmp = (char*)realloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity); char *tmp = (char *)realloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
data->varLenCol.varOffsets = (int32_t*)tmp; data->varLenCol.varOffsets = (int32_t *)tmp;
data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity; data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity;
// for payload, add data in udfColDataAppend // for payload, add data in udfColDataAppend
} else { } else {
char* tmp = (char*)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity)); char *tmp = (char *)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity));
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -173,13 +172,13 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t ne
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
tmp = (char*)realloc(data->fixLenCol.data, allocCapacity* meta->bytes); tmp = (char *)realloc(data->fixLenCol.data, allocCapacity * meta->bytes);
if (tmp == NULL) { if (tmp == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
data->fixLenCol.data = tmp; data->fixLenCol.data = tmp;
data->fixLenCol.dataLen = allocCapacity* meta->bytes; data->fixLenCol.dataLen = allocCapacity * meta->bytes;
} }
data->rowsAlloc = allocCapacity; data->rowsAlloc = allocCapacity;
@ -187,8 +186,8 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t ne
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static FORCE_INLINE void udfColDataSetNull(SUdfColumn* pColumn, int32_t row) { static FORCE_INLINE void udfColDataSetNull(SUdfColumn *pColumn, int32_t row) {
udfColEnsureCapacity(pColumn, row+1); udfColEnsureCapacity(pColumn, row + 1);
if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) {
udfColDataSetNull_var(pColumn, row); udfColDataSetNull_var(pColumn, row);
} else { } else {
@ -197,10 +196,10 @@ static FORCE_INLINE void udfColDataSetNull(SUdfColumn* pColumn, int32_t row) {
pColumn->hasNull = true; pColumn->hasNull = true;
} }
static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentRow, const char* pData, bool isNull) { static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentRow, const char *pData, bool isNull) {
SUdfColumnMeta *meta = &pColumn->colMeta; SUdfColumnMeta *meta = &pColumn->colMeta;
SUdfColumnData *data = &pColumn->colData; SUdfColumnData *data = &pColumn->colData;
udfColEnsureCapacity(pColumn, currentRow+1); udfColEnsureCapacity(pColumn, currentRow + 1);
bool isVarCol = IS_VAR_DATA_TYPE(meta->type); bool isVarCol = IS_VAR_DATA_TYPE(meta->type);
if (isNull) { if (isNull) {
udfColDataSetNull(pColumn, currentRow); udfColDataSetNull(pColumn, currentRow);
@ -233,7 +232,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentR
newSize = newSize * UDF_MEMORY_EXP_GROWTH; newSize = newSize * UDF_MEMORY_EXP_GROWTH;
} }
char *buf = (char*)realloc(data->varLenCol.payload, newSize); char *buf = (char *)realloc(data->varLenCol.payload, newSize);
if (buf == NULL) { if (buf == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -249,11 +248,11 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentR
data->varLenCol.payloadLen += dataLen; data->varLenCol.payloadLen += dataLen;
} }
} }
data->numOfRows = (currentRow + 1 > data->numOfRows) ? (currentRow+1) : data->numOfRows; data->numOfRows = (currentRow + 1 > data->numOfRows) ? (currentRow + 1) : data->numOfRows;
return 0; return 0;
} }
typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock* block, SUdfColumn *resultCol); typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock *block, SUdfColumn *resultCol);
typedef int32_t (*TUdfAggStartFunc)(SUdfInterBuf *buf); typedef int32_t (*TUdfAggStartFunc)(SUdfInterBuf *buf);
typedef int32_t (*TUdfAggProcessFunc)(SUdfDataBlock *block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf); typedef int32_t (*TUdfAggProcessFunc)(SUdfDataBlock *block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf);

View File

@ -24,12 +24,12 @@
#define alloc alloc #define alloc alloc
#include <taosudf.h> #include <taosudf.h>
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "tmsg.h" #include <stdint.h>
#include "tcommon.h"
#include "function.h" #include "function.h"
#include "tcommon.h"
#include "tdatablock.h" #include "tdatablock.h"
#include "tmsg.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -43,8 +43,7 @@ extern "C" {
#endif #endif
#define UDF_DNODE_ID_ENV_NAME "DNODE_ID" #define UDF_DNODE_ID_ENV_NAME "DNODE_ID"
// low level APIs
//low level APIs
/** /**
* setup udf * setup udf
* @param udf, in * @param udf, in
@ -62,7 +61,8 @@ int32_t doCallUdfAggProcess(UdfcFuncHandle handle, SSDataBlock *block, SUdfInter
int32_t doCallUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfInterBuf *resultData); int32_t doCallUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfInterBuf *resultData);
// input: interbuf1, interbuf2 // input: interbuf1, interbuf2
// output: resultBuf // output: resultBuf
int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, SUdfInterBuf *resultBuf); int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2,
SUdfInterBuf *resultBuf);
// input: block // input: block
// output: resultData // output: resultData
int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output); int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output);
@ -75,11 +75,11 @@ int32_t doTeardownUdf(UdfcFuncHandle handle);
void freeUdfInterBuf(SUdfInterBuf *buf); void freeUdfInterBuf(SUdfInterBuf *buf);
//high level APIs // high level APIs
bool udfAggGetEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool udfAggGetEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv);
bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo); bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
int32_t udfAggProcess(struct SqlFunctionCtx *pCtx); int32_t udfAggProcess(struct SqlFunctionCtx *pCtx);
int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock); int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock);
int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, SScalarParam *output); int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, SScalarParam *output);

View File

@ -227,7 +227,6 @@ int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInf
int32_t tSerializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo); int32_t tSerializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo);
int32_t tDeserializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo); int32_t tDeserializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo);
typedef struct { typedef struct {
const char *server; const char *server;
uint16_t port; uint16_t port;

View File

@ -61,7 +61,6 @@ typedef struct STableComInfo {
int32_t rowSize; // row size of the schema int32_t rowSize; // row size of the schema
} STableComInfo; } STableComInfo;
typedef struct SIndexMeta { typedef struct SIndexMeta {
#if defined(WINDOWS) || defined(_TD_DARWIN_64) #if defined(WINDOWS) || defined(_TD_DARWIN_64)
size_t avoidCompilationErrors; size_t avoidCompilationErrors;
@ -166,7 +165,7 @@ typedef struct SRequestConnInfo {
SEpSet mgmtEps; SEpSet mgmtEps;
} SRequestConnInfo; } SRequestConnInfo;
typedef void (*__freeFunc)(void *param); typedef void (*__freeFunc)(void* param);
typedef struct SMsgSendInfo { typedef struct SMsgSendInfo {
__async_send_cb_fn_t fp; // async callback function __async_send_cb_fn_t fp; // async callback function
@ -218,7 +217,7 @@ void initQueryModuleMsgHandle();
const SSchema* tGetTbnameColumnSchema(); const SSchema* tGetTbnameColumnSchema();
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags); bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags);
int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta); int32_t queryCreateCTableMetaFromMsg(STableMetaRsp* msg, SCTableMeta* pMeta);
int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STableMeta** pMeta); int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STableMeta** pMeta);
char* jobTaskStatusStr(int32_t status); char* jobTaskStatusStr(int32_t status);
@ -265,7 +264,9 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
#define REQUEST_TOTAL_EXEC_TIMES 2 #define REQUEST_TOTAL_EXEC_TIMES 2
#define IS_SYS_DBNAME(_dbname) (((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || ((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB)))) #define IS_SYS_DBNAME(_dbname) \
(((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || \
((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB))))
#define qFatal(...) \ #define qFatal(...) \
do { \ do { \

View File

@ -72,7 +72,6 @@ typedef struct SQWMsg {
SRpcHandleInfo connInfo; SRpcHandleInfo connInfo;
} SQWMsg; } SQWMsg;
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const SMsgCb *pMsgCb); int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const SMsgCb *pMsgCb);
int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg); int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg);
@ -99,9 +98,11 @@ void qWorkerDestroy(void **qWorkerMgmt);
int32_t qWorkerGetStat(SReadHandle *handle, void *qWorkerMgmt, SQWorkerStat *pStat); int32_t qWorkerGetStat(SReadHandle *handle, void *qWorkerMgmt, SQWorkerStat *pStat);
int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, SQWMsg *qwMsg, SArray *explainRes); int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId,
SQWMsg *qwMsg, SArray *explainRes);
int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, void** pRsp, SArray* explainRes); int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId,
void **pRsp, SArray *explainRes);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -41,7 +41,8 @@ typedef struct SFilterColumnParam {
} SFilterColumnParam; } SFilterColumnParam;
extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options); extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options);
extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData** p, SColumnDataAgg *statis, int16_t numOfCols, int32_t* pFilterResStatus); extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SColumnDataAgg *statis,
int16_t numOfCols, int32_t *pFilterResStatus);
extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param); extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param);
extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param); extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param);
extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict); extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict);

View File

@ -50,11 +50,11 @@ typedef struct SQueryProfileSummary {
typedef struct STaskInfo { typedef struct STaskInfo {
SQueryNodeAddr addr; SQueryNodeAddr addr;
SSubQueryMsg *msg; SSubQueryMsg* msg;
} STaskInfo; } STaskInfo;
typedef struct SSchdFetchParam { typedef struct SSchdFetchParam {
void **pData; void** pData;
int32_t* code; int32_t* code;
} SSchdFetchParam; } SSchdFetchParam;
@ -65,11 +65,11 @@ typedef bool (*schedulerChkKillFp)(void* param);
typedef struct SSchedulerReq { typedef struct SSchedulerReq {
bool syncReq; bool syncReq;
bool localReq; bool localReq;
SRequestConnInfo *pConn; SRequestConnInfo* pConn;
SArray *pNodeList; SArray* pNodeList;
SQueryPlan *pDag; SQueryPlan* pDag;
int64_t allocatorRefId; int64_t allocatorRefId;
const char *sql; const char* sql;
int64_t startTs; int64_t startTs;
schedulerExecFp execFp; schedulerExecFp execFp;
schedulerFetchFp fetchFp; schedulerFetchFp fetchFp;
@ -80,18 +80,17 @@ typedef struct SSchedulerReq {
void** pFetchRes; void** pFetchRes;
} SSchedulerReq; } SSchedulerReq;
int32_t schedulerInit(void); int32_t schedulerInit(void);
int32_t schedulerExecJob(SSchedulerReq *pReq, int64_t *pJob); int32_t schedulerExecJob(SSchedulerReq* pReq, int64_t* pJob);
int32_t schedulerFetchRows(int64_t jobId, SSchedulerReq *pReq); int32_t schedulerFetchRows(int64_t jobId, SSchedulerReq* pReq);
void schedulerFetchRowsA(int64_t job, schedulerFetchFp fp, void* param); void schedulerFetchRowsA(int64_t job, schedulerFetchFp fp, void* param);
int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub); int32_t schedulerGetTasksStatus(int64_t job, SArray* pSub);
void schedulerStopQueryHb(void *pTrans); void schedulerStopQueryHb(void* pTrans);
int32_t schedulerUpdatePolicy(int32_t policy); int32_t schedulerUpdatePolicy(int32_t policy);
int32_t schedulerEnableReSchedule(bool enableResche); int32_t schedulerEnableReSchedule(bool enableResche);
@ -101,7 +100,7 @@ int32_t schedulerEnableReSchedule(bool enableResche);
* @param pJob * @param pJob
* @return * @return
*/ */
//int32_t scheduleCancelJob(void *pJob); // int32_t scheduleCancelJob(void *pJob);
/** /**
* Free the query job * Free the query job

View File

@ -132,7 +132,7 @@ typedef struct SSyncFSM {
void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm); void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm);
void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta); void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta);
void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta);
void (*FpBecomeLeaderCb)(struct SSyncFSM* pFsm); void (*FpBecomeLeaderCb)(struct SSyncFSM* pFsm);

View File

@ -16,8 +16,8 @@
#ifndef _TD_TFS_H_ #ifndef _TD_TFS_H_
#define _TD_TFS_H_ #define _TD_TFS_H_
#include "tdef.h"
#include "monitor.h" #include "monitor.h"
#include "tdef.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -26,28 +26,28 @@ extern "C" {
#include <regex.h> #include <regex.h>
#if !defined(WINDOWS) #if !defined(WINDOWS)
#include <unistd.h>
#include <dirent.h> #include <dirent.h>
#include <sched.h>
#include <wordexp.h>
#include <libgen.h> #include <libgen.h>
#include <sched.h>
#include <unistd.h>
#include <wordexp.h>
#include <sys/utsname.h>
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/shm.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/statvfs.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <termios.h> #include <sys/utsname.h>
#include <sys/statvfs.h>
#include <sys/shm.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <termios.h>
#if defined(DARWIN) #if defined(DARWIN)
#else #else
#include <sys/prctl.h>
#include <argp.h> #include <argp.h>
#include <sys/prctl.h>
#endif #endif
#else #else
@ -82,11 +82,13 @@ extern "C" {
#include <wchar.h> #include <wchar.h>
#include <wctype.h> #include <wctype.h>
#include "taoserror.h" #include "osThread.h"
#include "osAtomic.h" #include "osAtomic.h"
#include "osDef.h" #include "osDef.h"
#include "osDir.h" #include "osDir.h"
#include "osEndian.h" #include "osEndian.h"
#include "osEnv.h"
#include "osFile.h" #include "osFile.h"
#include "osLocale.h" #include "osLocale.h"
#include "osLz4.h" #include "osLz4.h"
@ -94,10 +96,9 @@ extern "C" {
#include "osMemory.h" #include "osMemory.h"
#include "osProc.h" #include "osProc.h"
#include "osRand.h" #include "osRand.h"
#include "osThread.h"
#include "osSemaphore.h" #include "osSemaphore.h"
#include "osSignal.h"
#include "osShm.h" #include "osShm.h"
#include "osSignal.h"
#include "osSleep.h" #include "osSleep.h"
#include "osSocket.h" #include "osSocket.h"
#include "osString.h" #include "osString.h"
@ -106,7 +107,7 @@ extern "C" {
#include "osTime.h" #include "osTime.h"
#include "osTimer.h" #include "osTimer.h"
#include "osTimezone.h" #include "osTimezone.h"
#include "osEnv.h" #include "taoserror.h"
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -21,101 +21,100 @@ extern "C" {
#endif #endif
#if defined(_TD_DARWIN_64) #if defined(_TD_DARWIN_64)
// specific // specific
#ifndef __COMPAR_FN_T #ifndef __COMPAR_FN_T
#define __COMPAR_FN_T #define __COMPAR_FN_T
typedef int(*__compar_fn_t)(const void *, const void *); typedef int (*__compar_fn_t)(const void *, const void *);
#endif #endif
// for send function in tsocket.c // for send function in tsocket.c
#if defined(MSG_NOSIGNAL) #if defined(MSG_NOSIGNAL)
#undef MSG_NOSIGNAL #undef MSG_NOSIGNAL
#endif #endif
#define MSG_NOSIGNAL 0 #define MSG_NOSIGNAL 0
#define SO_NO_CHECK 0x1234 #define SO_NO_CHECK 0x1234
#define SOL_TCP 0x1234 #define SOL_TCP 0x1234
#define TCP_KEEPIDLE 0x1234 #define TCP_KEEPIDLE 0x1234
#ifndef PTHREAD_MUTEX_RECURSIVE_NP #ifndef PTHREAD_MUTEX_RECURSIVE_NP
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
#endif #endif
#endif #endif
#if defined(_ALPINE) #if defined(_ALPINE)
#ifndef __COMPAR_FN_T #ifndef __COMPAR_FN_T
#define __COMPAR_FN_T #define __COMPAR_FN_T
typedef int(*__compar_fn_t)(const void *, const void *); typedef int (*__compar_fn_t)(const void *, const void *);
#endif
void error(int, int, const char *);
#ifndef PTHREAD_MUTEX_RECURSIVE_NP
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
#endif #endif
void error (int, int, const char *);
#ifndef PTHREAD_MUTEX_RECURSIVE_NP
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
#endif
#endif #endif
#if defined(WINDOWS) #if defined(WINDOWS)
char *stpcpy (char *dest, const char *src); char *stpcpy(char *dest, const char *src);
char *stpncpy (char *dest, const char *src, int n); char *stpncpy(char *dest, const char *src, int n);
// specific // specific
#ifndef __COMPAR_FN_T #ifndef __COMPAR_FN_T
#define __COMPAR_FN_T #define __COMPAR_FN_T
typedef int (*__compar_fn_t)(const void *, const void *); typedef int (*__compar_fn_t)(const void *, const void *);
#endif #endif
#define ssize_t int #define ssize_t int
#define _SSIZE_T_ #define _SSIZE_T_
#define bzero(ptr, size) memset((ptr), 0, (size)) #define bzero(ptr, size) memset((ptr), 0, (size))
#define strcasecmp _stricmp #define strcasecmp _stricmp
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define wcsncasecmp _wcsnicmp #define wcsncasecmp _wcsnicmp
#define strtok_r strtok_s #define strtok_r strtok_s
// #define snprintf _snprintf // #define snprintf _snprintf
#define in_addr_t unsigned long #define in_addr_t unsigned long
// #define socklen_t int // #define socklen_t int
char * strsep(char **stringp, const char *delim); char *strsep(char **stringp, const char *delim);
char * getpass(const char *prefix); char *getpass(const char *prefix);
char * strndup(const char *s, int n); char *strndup(const char *s, int n);
// for send function in tsocket.c // for send function in tsocket.c
#define MSG_NOSIGNAL 0 #define MSG_NOSIGNAL 0
#define SO_NO_CHECK 0x1234 #define SO_NO_CHECK 0x1234
#define SOL_TCP 0x1234 #define SOL_TCP 0x1234
#define SHUT_RDWR SD_BOTH #define SHUT_RDWR SD_BOTH
#define SHUT_RD SD_RECEIVE #define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND #define SHUT_WR SD_SEND
#define LOCK_EX 1 #define LOCK_EX 1
#define LOCK_NB 2 #define LOCK_NB 2
#define LOCK_UN 3 #define LOCK_UN 3
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 256 #define PATH_MAX 256
#endif #endif
typedef struct { typedef struct {
int we_wordc; int we_wordc;
char *we_wordv[1]; char *we_wordv[1];
int we_offs; int we_offs;
char wordPos[1025]; char wordPos[1025];
} wordexp_t; } wordexp_t;
int wordexp(char *words, wordexp_t *pwordexp, int flags); int wordexp(char *words, wordexp_t *pwordexp, int flags);
void wordfree(wordexp_t *pwordexp); void wordfree(wordexp_t *pwordexp);
#define openlog(a, b, c) #define openlog(a, b, c)
#define closelog() #define closelog()
#define LOG_ERR 0 #define LOG_ERR 0
#define LOG_INFO 1 #define LOG_INFO 1
void syslog(int unused, const char *format, ...); void syslog(int unused, const char *format, ...);
#endif // WINDOWS #endif // WINDOWS
#ifndef WINDOWS #ifndef WINDOWS
#ifndef O_BINARY #ifndef O_BINARY
#define O_BINARY 0 #define O_BINARY 0
#endif #endif
#endif #endif
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b))) #define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
@ -171,9 +170,15 @@ extern "C" {
#define DEFAULT_DOUBLE_COMP(x, y) \ #define DEFAULT_DOUBLE_COMP(x, y) \
do { \ do { \
if (isnan(x) && isnan(y)) { return 0; } \ if (isnan(x) && isnan(y)) { \
if (isnan(x)) { return -1; } \ return 0; \
if (isnan(y)) { return 1; } \ } \
if (isnan(x)) { \
return -1; \
} \
if (isnan(y)) { \
return 1; \
} \
if ((x) == (y)) { \ if ((x) == (y)) { \
return 0; \ return 0; \
} else { \ } else { \
@ -190,37 +195,43 @@ extern "C" {
#undef threadlocal #undef threadlocal
#ifdef _ISOC11_SOURCE #ifdef _ISOC11_SOURCE
#define threadlocal _Thread_local #define threadlocal _Thread_local
#elif defined(__APPLE__) #elif defined(__APPLE__)
#define threadlocal __thread #define threadlocal __thread
#elif defined(__GNUC__) && !defined(threadlocal) #elif defined(__GNUC__) && !defined(threadlocal)
#define threadlocal __thread #define threadlocal __thread
#else #else
#define threadlocal __declspec( thread ) #define threadlocal __declspec(thread)
#endif #endif
#ifdef WINDOWS #ifdef WINDOWS
#define PRIzu "ld" #define PRIzu "ld"
#else #else
#define PRIzu "zu" #define PRIzu "zu"
#endif #endif
#if !defined(WINDOWS) #if !defined(WINDOWS)
#if defined(_TD_DARWIN_64) #if defined(_TD_DARWIN_64)
// MacOS // MacOS
#if !defined(_GNU_SOURCE) #if !defined(_GNU_SOURCE)
#define setThreadName(name) do { pthread_setname_np((name)); } while (0) #define setThreadName(name) \
#else do { \
// pthread_setname_np not defined pthread_setname_np((name)); \
#define setThreadName(name) } while (0)
#endif
#else
// Linux, length of name must <= 16 (the last '\0' included)
#define setThreadName(name) do { prctl(PR_SET_NAME, (name)); } while (0)
#endif
#else #else
// Windows // pthread_setname_np not defined
#define setThreadName(name) #define setThreadName(name)
#endif
#else
// Linux, length of name must <= 16 (the last '\0' included)
#define setThreadName(name) \
do { \
prctl(PR_SET_NAME, (name)); \
} while (0)
#endif
#else
// Windows
#define setThreadName(name)
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)

View File

@ -19,12 +19,12 @@
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define opendir OPENDIR_FUNC_TAOS_FORBID #define opendir OPENDIR_FUNC_TAOS_FORBID
#define readdir READDIR_FUNC_TAOS_FORBID #define readdir READDIR_FUNC_TAOS_FORBID
#define closedir CLOSEDIR_FUNC_TAOS_FORBID #define closedir CLOSEDIR_FUNC_TAOS_FORBID
#define dirname DIRNAME_FUNC_TAOS_FORBID #define dirname DIRNAME_FUNC_TAOS_FORBID
#undef basename #undef basename
#define basename BASENAME_FUNC_TAOS_FORBID #define basename BASENAME_FUNC_TAOS_FORBID
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
@ -51,7 +51,6 @@ extern "C" {
typedef struct TdDir *TdDirPtr; typedef struct TdDir *TdDirPtr;
typedef struct TdDirEntry *TdDirEntryPtr; typedef struct TdDirEntry *TdDirEntryPtr;
void taosRemoveDir(const char *dirname); void taosRemoveDir(const char *dirname);
bool taosDirExist(const char *dirname); bool taosDirExist(const char *dirname);
int32_t taosMkDir(const char *dirname); int32_t taosMkDir(const char *dirname);
@ -61,13 +60,13 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays);
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen); int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen);
int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen); int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen);
bool taosIsDir(const char *dirname); bool taosIsDir(const char *dirname);
char* taosDirName(char *dirname); char *taosDirName(char *dirname);
char* taosDirEntryBaseName(char *dirname); char *taosDirEntryBaseName(char *dirname);
TdDirPtr taosOpenDir(const char *dirname); TdDirPtr taosOpenDir(const char *dirname);
TdDirEntryPtr taosReadDir(TdDirPtr pDir); TdDirEntryPtr taosReadDir(TdDirPtr pDir);
bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry); bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry);
char* taosGetDirEntryName(TdDirEntryPtr pDirEntry); char *taosGetDirEntryName(TdDirEntryPtr pDirEntry);
int32_t taosCloseDir(TdDirPtr *ppDir); int32_t taosCloseDir(TdDirPtr *ppDir);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -17,6 +17,7 @@
#define _TD_OS_ENV_H_ #define _TD_OS_ENV_H_
#include "osSysinfo.h" #include "osSysinfo.h"
#include "osTimezone.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -34,7 +35,7 @@ extern int64_t tsOpenMax;
extern int64_t tsStreamMax; extern int64_t tsStreamMax;
extern float tsNumOfCores; extern float tsNumOfCores;
extern int64_t tsTotalMemoryKB; extern int64_t tsTotalMemoryKB;
extern char* tsProcPath; extern char *tsProcPath;
extern char configDir[]; extern char configDir[];
extern char tsDataDir[]; extern char tsDataDir[];

View File

@ -24,8 +24,7 @@ extern "C" {
#ifdef __APPLE__ #ifdef __APPLE__
enum EPOLL_EVENTS enum EPOLL_EVENTS {
{
EPOLLIN = 0x001, EPOLLIN = 0x001,
#define EPOLLIN EPOLLIN #define EPOLLIN EPOLLIN
EPOLLPRI = 0x002, EPOLLPRI = 0x002,
@ -56,24 +55,21 @@ enum EPOLL_EVENTS
#define EPOLLONESHOT EPOLLONESHOT #define EPOLLONESHOT EPOLLONESHOT
EPOLLET = 1u << 31 EPOLLET = 1u << 31
#define EPOLLET EPOLLET #define EPOLLET EPOLLET
}; };
/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ #define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */
#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ #define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */
#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ #define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */
typedef union epoll_data {
typedef union epoll_data
{
void *ptr; void *ptr;
int fd; int fd;
uint32_t u32; uint32_t u32;
uint64_t u64; uint64_t u64;
} epoll_data_t; } epoll_data_t;
struct epoll_event struct epoll_event {
{
uint32_t events; /* Epoll events */ uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */ epoll_data_t data; /* User data variable */
}; };
@ -90,4 +86,3 @@ int epoll_close(int epfd);
#endif #endif
#endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_ #endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_

View File

@ -25,7 +25,7 @@ extern "C" {
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define setlocale SETLOCALE_FUNC_TAOS_FORBID #define setlocale SETLOCALE_FUNC_TAOS_FORBID
#endif #endif
char *taosCharsetReplace(char *charsetstr); char *taosCharsetReplace(char *charsetstr);

View File

@ -21,25 +21,25 @@ extern "C" {
#endif #endif
#ifdef WINDOWS #ifdef WINDOWS
int32_t BUILDIN_CLZL(uint64_t val); int32_t BUILDIN_CLZL(uint64_t val);
int32_t BUILDIN_CLZ(uint32_t val); int32_t BUILDIN_CLZ(uint32_t val);
int32_t BUILDIN_CTZL(uint64_t val); int32_t BUILDIN_CTZL(uint64_t val);
int32_t BUILDIN_CTZ(uint32_t val); int32_t BUILDIN_CTZ(uint32_t val);
#elif defined (_TD_LINUX_32) #elif defined(_TD_LINUX_32)
#define BUILDIN_CLZL(val) __builtin_clzll(val) #define BUILDIN_CLZL(val) __builtin_clzll(val)
#define BUILDIN_CTZL(val) __builtin_ctzll(val) #define BUILDIN_CTZL(val) __builtin_ctzll(val)
#define BUILDIN_CLZ(val) __builtin_clz(val) #define BUILDIN_CLZ(val) __builtin_clz(val)
#define BUILDIN_CTZ(val) __builtin_ctz(val) #define BUILDIN_CTZ(val) __builtin_ctz(val)
#elif defined (_TD_ARM_32) #elif defined(_TD_ARM_32)
#define BUILDIN_CLZL(val) __builtin_clzll(val) #define BUILDIN_CLZL(val) __builtin_clzll(val)
#define BUILDIN_CTZL(val) __builtin_ctzll(val) #define BUILDIN_CTZL(val) __builtin_ctzll(val)
#define BUILDIN_CLZ(val) __builtin_clz(val) #define BUILDIN_CLZ(val) __builtin_clz(val)
#define BUILDIN_CTZ(val) __builtin_ctz(val) #define BUILDIN_CTZ(val) __builtin_ctz(val)
#else #else
#define BUILDIN_CLZL(val) __builtin_clzl(val) #define BUILDIN_CLZL(val) __builtin_clzl(val)
#define BUILDIN_CTZL(val) __builtin_ctzl(val) #define BUILDIN_CTZL(val) __builtin_ctzl(val)
#define BUILDIN_CLZ(val) __builtin_clz(val) #define BUILDIN_CLZ(val) __builtin_clz(val)
#define BUILDIN_CTZ(val) __builtin_ctz(val) #define BUILDIN_CTZ(val) __builtin_ctz(val)
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -39,13 +39,13 @@ extern "C" {
#ifdef WINDOWS #ifdef WINDOWS
#define TMAX(a, b) (((a) > (b)) ? (a) : (b)) #define TMAX(a, b) (((a) > (b)) ? (a) : (b))
#define TMIN(a, b) (((a) < (b)) ? (a) : (b)) #define TMIN(a, b) (((a) < (b)) ? (a) : (b))
#define TRANGE(aa, bb, cc) ((aa) = TMAX((aa), (bb)),(aa) = TMIN((aa), (cc))) #define TRANGE(aa, bb, cc) ((aa) = TMAX((aa), (bb)), (aa) = TMIN((aa), (cc)))
#else #else
#define TMAX(a, b) \ #define TMAX(a, b) \
({ \ ({ \
__typeof(a) __a = (a); \ __typeof(a) __a = (a); \
__typeof(b) __b = (b); \ __typeof(b) __b = (b); \
@ -71,7 +71,7 @@ extern "C" {
typedef int32_t (*__compar_fn_t)(const void *, const void *); typedef int32_t (*__compar_fn_t)(const void *, const void *);
#endif #endif
void taosSort(void* arr, int64_t sz, int64_t width, __compar_fn_t compar); void taosSort(void *arr, int64_t sz, int64_t width, __compar_fn_t compar);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -23,10 +23,10 @@ extern "C" {
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following sectio // When you want to use this feature, you should find or add the same function in the following sectio
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define malloc MALLOC_FUNC_TAOS_FORBID #define malloc MALLOC_FUNC_TAOS_FORBID
#define calloc CALLOC_FUNC_TAOS_FORBID #define calloc CALLOC_FUNC_TAOS_FORBID
#define realloc REALLOC_FUNC_TAOS_FORBID #define realloc REALLOC_FUNC_TAOS_FORBID
#define free FREE_FUNC_TAOS_FORBID #define free FREE_FUNC_TAOS_FORBID
#endif #endif
void *taosMemoryMalloc(int32_t size); void *taosMemoryMalloc(int32_t size);

View File

@ -23,14 +23,14 @@ extern "C" {
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define rand RAND_FUNC_TAOS_FORBID #define rand RAND_FUNC_TAOS_FORBID
#define srand SRAND_FUNC_TAOS_FORBID #define srand SRAND_FUNC_TAOS_FORBID
#define rand_r RANDR_FUNC_TAOS_FORBID #define rand_r RANDR_FUNC_TAOS_FORBID
#endif #endif
void taosSeedRand(uint32_t seed); void taosSeedRand(uint32_t seed);
uint32_t taosRand(void); uint32_t taosRand(void);
uint32_t taosRandR(uint32_t *pSeed); uint32_t taosRandR(uint32_t* pSeed);
void taosRandStr(char* str, int32_t size); void taosRandStr(char* str, int32_t size);
uint32_t taosSafeRand(void); uint32_t taosSafeRand(void);

View File

@ -23,10 +23,10 @@ extern "C" {
typedef struct { typedef struct {
int32_t id; int32_t id;
int32_t size; int32_t size;
void* ptr; void *ptr;
} SShm; } SShm;
int32_t taosCreateShm(SShm *pShm, int32_t key, int32_t shmsize) ; int32_t taosCreateShm(SShm *pShm, int32_t key, int32_t shmsize);
void taosDropShm(SShm *pShm); void taosDropShm(SShm *pShm);
int32_t taosAttachShm(SShm *pShm); int32_t taosAttachShm(SShm *pShm);

View File

@ -21,27 +21,27 @@ extern "C" {
#endif #endif
#ifndef SIGALRM #ifndef SIGALRM
#define SIGALRM 1234 #define SIGALRM 1234
#endif #endif
#ifndef SIGHUP #ifndef SIGHUP
#define SIGHUP 1230 #define SIGHUP 1230
#endif #endif
#ifndef SIGCHLD #ifndef SIGCHLD
#define SIGCHLD 1234 #define SIGCHLD 1234
#endif #endif
#ifndef SIGUSR1 #ifndef SIGUSR1
#define SIGUSR1 1234 #define SIGUSR1 1234
#endif #endif
#ifndef SIGUSR2 #ifndef SIGUSR2
#define SIGUSR2 1234 #define SIGUSR2 1234
#endif #endif
#ifndef SIGBREAK #ifndef SIGBREAK
#define SIGBREAK 1234 #define SIGBREAK 1234
#endif #endif
#ifdef WINDOWS #ifdef WINDOWS

View File

@ -23,10 +23,10 @@ extern "C" {
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define Sleep SLEEP_FUNC_TAOS_FORBID #define Sleep SLEEP_FUNC_TAOS_FORBID
#define sleep SLEEP_FUNC_TAOS_FORBID #define sleep SLEEP_FUNC_TAOS_FORBID
#define usleep USLEEP_FUNC_TAOS_FORBID #define usleep USLEEP_FUNC_TAOS_FORBID
#define nanosleep NANOSLEEP_FUNC_TAOS_FORBID #define nanosleep NANOSLEEP_FUNC_TAOS_FORBID
#endif #endif
void taosSsleep(int32_t s); void taosSsleep(int32_t s);

View File

@ -119,8 +119,8 @@ typedef int32_t SocketFd;
typedef SocketFd EpollFd; typedef SocketFd EpollFd;
typedef struct TdSocketServer *TdSocketServerPtr; typedef struct TdSocketServer *TdSocketServerPtr;
typedef struct TdSocket * TdSocketPtr; typedef struct TdSocket *TdSocketPtr;
typedef struct TdEpoll * TdEpollPtr; typedef struct TdEpoll *TdEpollPtr;
int32_t taosSendto(TdSocketPtr pSocket, void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen); int32_t taosSendto(TdSocketPtr pSocket, void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen);
int32_t taosWriteSocket(TdSocketPtr pSocket, void *msg, int len); int32_t taosWriteSocket(TdSocketPtr pSocket, void *msg, int len);

View File

@ -26,31 +26,31 @@ typedef int32_t TdUcs4;
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define iconv_open ICONV_OPEN_FUNC_TAOS_FORBID #define iconv_open ICONV_OPEN_FUNC_TAOS_FORBID
#define iconv_close ICONV_CLOSE_FUNC_TAOS_FORBID #define iconv_close ICONV_CLOSE_FUNC_TAOS_FORBID
#define iconv ICONV_FUNC_TAOS_FORBID #define iconv ICONV_FUNC_TAOS_FORBID
#define wcwidth WCWIDTH_FUNC_TAOS_FORBID #define wcwidth WCWIDTH_FUNC_TAOS_FORBID
#define wcswidth WCSWIDTH_FUNC_TAOS_FORBID #define wcswidth WCSWIDTH_FUNC_TAOS_FORBID
#define mbtowc MBTOWC_FUNC_TAOS_FORBID #define mbtowc MBTOWC_FUNC_TAOS_FORBID
#define mbstowcs MBSTOWCS_FUNC_TAOS_FORBID #define mbstowcs MBSTOWCS_FUNC_TAOS_FORBID
#define wctomb WCTOMB_FUNC_TAOS_FORBID #define wctomb WCTOMB_FUNC_TAOS_FORBID
#define wcstombs WCSTOMBS_FUNC_TAOS_FORBID #define wcstombs WCSTOMBS_FUNC_TAOS_FORBID
#define wcsncpy WCSNCPY_FUNC_TAOS_FORBID #define wcsncpy WCSNCPY_FUNC_TAOS_FORBID
#define wchar_t WCHAR_T_TYPE_TAOS_FORBID #define wchar_t WCHAR_T_TYPE_TAOS_FORBID
#define strcasestr STR_CASE_STR_FORBID #define strcasestr STR_CASE_STR_FORBID
#define strtoll STR_TO_LL_FUNC_TAOS_FORBID #define strtoll STR_TO_LL_FUNC_TAOS_FORBID
#define strtoull STR_TO_ULL_FUNC_TAOS_FORBID #define strtoull STR_TO_ULL_FUNC_TAOS_FORBID
#define strtol STR_TO_L_FUNC_TAOS_FORBID #define strtol STR_TO_L_FUNC_TAOS_FORBID
#define strtoul STR_TO_UL_FUNC_TAOS_FORBID #define strtoul STR_TO_UL_FUNC_TAOS_FORBID
#define strtod STR_TO_LD_FUNC_TAOS_FORBID #define strtod STR_TO_LD_FUNC_TAOS_FORBID
#define strtold STR_TO_D_FUNC_TAOS_FORBID #define strtold STR_TO_D_FUNC_TAOS_FORBID
#define strtof STR_TO_F_FUNC_TAOS_FORBID #define strtof STR_TO_F_FUNC_TAOS_FORBID
#endif #endif
#ifdef WINDOWS #ifdef WINDOWS
#define tstrdup(str) _strdup(str) #define tstrdup(str) _strdup(str)
#else #else
#define tstrdup(str) strdup(str) #define tstrdup(str) strdup(str)
#endif #endif
#define tstrncpy(dst, src, size) \ #define tstrncpy(dst, src, size) \
@ -67,7 +67,7 @@ void taosConvDestroy();
int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs); int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs);
bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len); bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len);
int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes); int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes);
TdUcs4* tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4); TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4);
bool taosValidateEncodec(const char *encodec); bool taosValidateEncodec(const char *encodec);
int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len); int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len);
int32_t taosHexDecode(const char *src, char *dst, int32_t len); int32_t taosHexDecode(const char *src, char *dst, int32_t len);
@ -80,16 +80,16 @@ int32_t taosWcharToMb(char *pStr, TdWchar wchar);
char *taosStrCaseStr(const char *str, const char *pattern); char *taosStrCaseStr(const char *str, const char *pattern);
int64_t taosStr2Int64(const char *str, char** pEnd, int32_t radix); int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix);
uint64_t taosStr2UInt64(const char *str, char** pEnd, int32_t radix); uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix);
int32_t taosStr2Int32(const char *str, char** pEnd, int32_t radix); int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix);
uint32_t taosStr2UInt32(const char *str, char** pEnd, int32_t radix); uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix);
int16_t taosStr2Int16(const char *str, char** pEnd, int32_t radix); int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix);
uint16_t taosStr2UInt16(const char *str, char** pEnd, int32_t radix); uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix);
int8_t taosStr2Int8(const char *str, char** pEnd, int32_t radix); int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix);
uint8_t taosStr2UInt8(const char *str, char** pEnd, int32_t radix); uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix);
double taosStr2Double(const char *str, char** pEnd); double taosStr2Double(const char *str, char **pEnd);
float taosStr2Float(const char *str, char** pEnd); float taosStr2Float(const char *str, char **pEnd);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -23,16 +23,16 @@ extern "C" {
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define popen POPEN_FUNC_TAOS_FORBID #define popen POPEN_FUNC_TAOS_FORBID
#define pclose PCLOSE_FUNC_TAOS_FORBID #define pclose PCLOSE_FUNC_TAOS_FORBID
#define tcsetattr TCSETATTR_FUNC_TAOS_FORBID #define tcsetattr TCSETATTR_FUNC_TAOS_FORBID
#define tcgetattr TCGETATTR_FUNC_TAOS_FORBID #define tcgetattr TCGETATTR_FUNC_TAOS_FORBID
#endif #endif
typedef struct TdCmd *TdCmdPtr; typedef struct TdCmd* TdCmdPtr;
TdCmdPtr taosOpenCmd(const char* cmd); TdCmdPtr taosOpenCmd(const char* cmd);
int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char *__restrict buf); int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char* __restrict buf);
int64_t taosGetLineCmd(TdCmdPtr pCmd, char** __restrict ptrBuf); int64_t taosGetLineCmd(TdCmdPtr pCmd, char** __restrict ptrBuf);
int32_t taosEOFCmd(TdCmdPtr pCmd); int32_t taosEOFCmd(TdCmdPtr pCmd);
int64_t taosCloseCmd(TdCmdPtr* ppCmd); int64_t taosCloseCmd(TdCmdPtr* ppCmd);

View File

@ -44,7 +44,6 @@ typedef pthread_key_t TdThreadKey;
#define taosThreadCleanupPush pthread_cleanup_push #define taosThreadCleanupPush pthread_cleanup_push
#define taosThreadCleanupPop pthread_cleanup_pop #define taosThreadCleanupPop pthread_cleanup_pop
#ifdef WINDOWS #ifdef WINDOWS
#define TD_PTHREAD_MUTEX_INITIALIZER (TdThreadMutex)(-1) #define TD_PTHREAD_MUTEX_INITIALIZER (TdThreadMutex)(-1)
#else #else
@ -54,179 +53,179 @@ typedef pthread_key_t TdThreadKey;
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define pthread_t PTHREAD_T_TYPE_TAOS_FORBID #define pthread_t PTHREAD_T_TYPE_TAOS_FORBID
#define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID #define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID
#define pthread_mutex_t PTHREAD_MUTEX_T_TYPE_TAOS_FORBID #define pthread_mutex_t PTHREAD_MUTEX_T_TYPE_TAOS_FORBID
#define pthread_mutexattr_t PTHREAD_MUTEXATTR_T_TYPE_TAOS_FORBID #define pthread_mutexattr_t PTHREAD_MUTEXATTR_T_TYPE_TAOS_FORBID
#define pthread_rwlock_t PTHREAD_RWLOCK_T_TYPE_TAOS_FORBID #define pthread_rwlock_t PTHREAD_RWLOCK_T_TYPE_TAOS_FORBID
#define pthread_attr_t PTHREAD_ATTR_T_TYPE_TAOS_FORBID #define pthread_attr_t PTHREAD_ATTR_T_TYPE_TAOS_FORBID
#define pthread_once_t PTHREAD_ONCE_T_TYPE_TAOS_FORBID #define pthread_once_t PTHREAD_ONCE_T_TYPE_TAOS_FORBID
#define pthread_rwlockattr_t PTHREAD_RWLOCKATTR_T_TYPE_TAOS_FORBID #define pthread_rwlockattr_t PTHREAD_RWLOCKATTR_T_TYPE_TAOS_FORBID
#define pthread_cond_t PTHREAD_COND_T_TYPE_TAOS_FORBID #define pthread_cond_t PTHREAD_COND_T_TYPE_TAOS_FORBID
#define pthread_condattr_t PTHREAD_CONDATTR_T_TYPE_TAOS_FORBID #define pthread_condattr_t PTHREAD_CONDATTR_T_TYPE_TAOS_FORBID
#define pthread_key_t PTHREAD_KEY_T_TYPE_TAOS_FORBID #define pthread_key_t PTHREAD_KEY_T_TYPE_TAOS_FORBID
#define pthread_barrier_t PTHREAD_BARRIER_T_TYPE_TAOS_FORBID #define pthread_barrier_t PTHREAD_BARRIER_T_TYPE_TAOS_FORBID
#define pthread_barrierattr_t PTHREAD_BARRIERATTR_T_TYPE_TAOS_FORBID #define pthread_barrierattr_t PTHREAD_BARRIERATTR_T_TYPE_TAOS_FORBID
#define pthread_create PTHREAD_CREATE_FUNC_TAOS_FORBID #define pthread_create PTHREAD_CREATE_FUNC_TAOS_FORBID
#define pthread_attr_destroy PTHREAD_ATTR_DESTROY_FUNC_TAOS_FORBID #define pthread_attr_destroy PTHREAD_ATTR_DESTROY_FUNC_TAOS_FORBID
#define pthread_attr_getdetachstate PTHREAD_ATTR_GETDETACHSTATE_FUNC_TAOS_FORBID #define pthread_attr_getdetachstate PTHREAD_ATTR_GETDETACHSTATE_FUNC_TAOS_FORBID
#define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED_FUNC_TAOS_FORBID #define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED_FUNC_TAOS_FORBID
#define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM_FUNC_TAOS_FORBID #define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM_FUNC_TAOS_FORBID
#define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY_FUNC_TAOS_FORBID #define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY_FUNC_TAOS_FORBID
#define pthread_attr_getscope PTHREAD_ATTR_GETSCOPE_FUNC_TAOS_FORBID #define pthread_attr_getscope PTHREAD_ATTR_GETSCOPE_FUNC_TAOS_FORBID
#define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE_FUNC_TAOS_FORBID #define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE_FUNC_TAOS_FORBID
#define pthread_attr_init PTHREAD_ATTR_INIT_FUNC_TAOS_FORBID #define pthread_attr_init PTHREAD_ATTR_INIT_FUNC_TAOS_FORBID
#define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE_FUNC_TAOS_FORBID #define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE_FUNC_TAOS_FORBID
#define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED_FUNC_TAOS_FORBID #define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED_FUNC_TAOS_FORBID
#define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM_FUNC_TAOS_FORBID #define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM_FUNC_TAOS_FORBID
#define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY_FUNC_TAOS_FORBID #define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY_FUNC_TAOS_FORBID
#define pthread_attr_setscope PTHREAD_ATTR_SETSCOPE_FUNC_TAOS_FORBID #define pthread_attr_setscope PTHREAD_ATTR_SETSCOPE_FUNC_TAOS_FORBID
#define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE_FUNC_TAOS_FORBID #define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE_FUNC_TAOS_FORBID
#define pthread_barrier_destroy PTHREAD_BARRIER_DESTROY_FUNC_TAOS_FORBID #define pthread_barrier_destroy PTHREAD_BARRIER_DESTROY_FUNC_TAOS_FORBID
#define pthread_barrier_init PTHREAD_BARRIER_INIT_FUNC_TAOS_FORBID #define pthread_barrier_init PTHREAD_BARRIER_INIT_FUNC_TAOS_FORBID
#define pthread_barrier_wait PTHREAD_BARRIER_WAIT_FUNC_TAOS_FORBID #define pthread_barrier_wait PTHREAD_BARRIER_WAIT_FUNC_TAOS_FORBID
#define pthread_barrierattr_destroy PTHREAD_BARRIERATTR_DESTROY_FUNC_TAOS_FORBID #define pthread_barrierattr_destroy PTHREAD_BARRIERATTR_DESTROY_FUNC_TAOS_FORBID
#define pthread_barrierattr_getpshared PTHREAD_BARRIERATTR_GETPSHARED_FUNC_TAOS_FORBID #define pthread_barrierattr_getpshared PTHREAD_BARRIERATTR_GETPSHARED_FUNC_TAOS_FORBID
#define pthread_barrierattr_init PTHREAD_BARRIERATTR_INIT_FUNC_TAOS_FORBID #define pthread_barrierattr_init PTHREAD_BARRIERATTR_INIT_FUNC_TAOS_FORBID
#define pthread_barrierattr_setpshared PTHREAD_BARRIERATTR_SETPSHARED_FUNC_TAOS_FORBID #define pthread_barrierattr_setpshared PTHREAD_BARRIERATTR_SETPSHARED_FUNC_TAOS_FORBID
#define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID #define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID
#define pthread_cond_destroy PTHREAD_COND_DESTROY_FUNC_TAOS_FORBID #define pthread_cond_destroy PTHREAD_COND_DESTROY_FUNC_TAOS_FORBID
#define pthread_cond_init PTHREAD_COND_INIT_FUNC_TAOS_FORBID #define pthread_cond_init PTHREAD_COND_INIT_FUNC_TAOS_FORBID
#define pthread_cond_signal PTHREAD_COND_SIGNAL_FUNC_TAOS_FORBID #define pthread_cond_signal PTHREAD_COND_SIGNAL_FUNC_TAOS_FORBID
#define pthread_cond_broadcast PTHREAD_COND_BROADCAST_FUNC_TAOS_FORBID #define pthread_cond_broadcast PTHREAD_COND_BROADCAST_FUNC_TAOS_FORBID
#define pthread_cond_wait PTHREAD_COND_WAIT_FUNC_TAOS_FORBID #define pthread_cond_wait PTHREAD_COND_WAIT_FUNC_TAOS_FORBID
#define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT_FUNC_TAOS_FORBID #define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT_FUNC_TAOS_FORBID
#define pthread_condattr_destroy PTHREAD_CONDATTR_DESTROY_FUNC_TAOS_FORBID #define pthread_condattr_destroy PTHREAD_CONDATTR_DESTROY_FUNC_TAOS_FORBID
#define pthread_condattr_getpshared PTHREAD_CONDATTR_GETPSHARED_FUNC_TAOS_FORBID #define pthread_condattr_getpshared PTHREAD_CONDATTR_GETPSHARED_FUNC_TAOS_FORBID
#define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID #define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID
#define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID #define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID
#define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID #define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID
#define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID #define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID
#define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID #define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID
#define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID #define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID
#define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID #define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID
#define pthread_join PTHREAD_JOIN_FUNC_TAOS_FORBID #define pthread_join PTHREAD_JOIN_FUNC_TAOS_FORBID
#define pthread_key_create PTHREAD_KEY_CREATE_FUNC_TAOS_FORBID #define pthread_key_create PTHREAD_KEY_CREATE_FUNC_TAOS_FORBID
#define pthread_key_delete PTHREAD_KEY_DELETE_FUNC_TAOS_FORBID #define pthread_key_delete PTHREAD_KEY_DELETE_FUNC_TAOS_FORBID
#define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID #define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID
#define pthread_mutex_consistent PTHREAD_MUTEX_CONSISTENT_FUNC_TAOS_FORBID #define pthread_mutex_consistent PTHREAD_MUTEX_CONSISTENT_FUNC_TAOS_FORBID
#define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY_FUNC_TAOS_FORBID #define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY_FUNC_TAOS_FORBID
#define pthread_mutex_init PTHREAD_MUTEX_INIT_FUNC_TAOS_FORBID #define pthread_mutex_init PTHREAD_MUTEX_INIT_FUNC_TAOS_FORBID
#define pthread_mutex_lock PTHREAD_MUTEX_LOCK_FUNC_TAOS_FORBID #define pthread_mutex_lock PTHREAD_MUTEX_LOCK_FUNC_TAOS_FORBID
#define pthread_mutex_timedlock PTHREAD_MUTEX_TIMEDLOCK_FUNC_TAOS_FORBID #define pthread_mutex_timedlock PTHREAD_MUTEX_TIMEDLOCK_FUNC_TAOS_FORBID
#define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK_FUNC_TAOS_FORBID #define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK_FUNC_TAOS_FORBID
#define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK_FUNC_TAOS_FORBID #define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK_FUNC_TAOS_FORBID
#define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY_FUNC_TAOS_FORBID #define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY_FUNC_TAOS_FORBID
#define pthread_mutexattr_getpshared PTHREAD_MUTEXATTR_GETPSHARED_FUNC_TAOS_FORBID #define pthread_mutexattr_getpshared PTHREAD_MUTEXATTR_GETPSHARED_FUNC_TAOS_FORBID
#define pthread_mutexattr_getrobust PTHREAD_MUTEXATTR_GETROBUST_FUNC_TAOS_FORBID #define pthread_mutexattr_getrobust PTHREAD_MUTEXATTR_GETROBUST_FUNC_TAOS_FORBID
#define pthread_mutexattr_gettype PTHREAD_MUTEXATTR_GETTYPE_FUNC_TAOS_FORBID #define pthread_mutexattr_gettype PTHREAD_MUTEXATTR_GETTYPE_FUNC_TAOS_FORBID
#define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT_FUNC_TAOS_FORBID #define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT_FUNC_TAOS_FORBID
#define pthread_mutexattr_setpshared PTHREAD_MUTEXATTR_SETPSHARED_FUNC_TAOS_FORBID #define pthread_mutexattr_setpshared PTHREAD_MUTEXATTR_SETPSHARED_FUNC_TAOS_FORBID
#define pthread_mutexattr_setrobust PTHREAD_MUTEXATTR_SETROBUST_FUNC_TAOS_FORBID #define pthread_mutexattr_setrobust PTHREAD_MUTEXATTR_SETROBUST_FUNC_TAOS_FORBID
#define pthread_mutexattr_settype PTHREAD_MUTEXATTR_SETTYPE_FUNC_TAOS_FORBID #define pthread_mutexattr_settype PTHREAD_MUTEXATTR_SETTYPE_FUNC_TAOS_FORBID
#define pthread_once PTHREAD_ONCE_FUNC_TAOS_FORBID #define pthread_once PTHREAD_ONCE_FUNC_TAOS_FORBID
#define pthread_rwlock_destroy PTHREAD_RWLOCK_DESTROY_FUNC_TAOS_FORBID #define pthread_rwlock_destroy PTHREAD_RWLOCK_DESTROY_FUNC_TAOS_FORBID
#define pthread_rwlock_init PTHREAD_RWLOCK_INIT_FUNC_TAOS_FORBID #define pthread_rwlock_init PTHREAD_RWLOCK_INIT_FUNC_TAOS_FORBID
#define pthread_rwlock_rdlock PTHREAD_RWLOCK_RDLOCK_FUNC_TAOS_FORBID #define pthread_rwlock_rdlock PTHREAD_RWLOCK_RDLOCK_FUNC_TAOS_FORBID
#define pthread_rwlock_timedrdlock PTHREAD_RWLOCK_TIMEDRDLOCK_FUNC_TAOS_FORBID #define pthread_rwlock_timedrdlock PTHREAD_RWLOCK_TIMEDRDLOCK_FUNC_TAOS_FORBID
#define pthread_rwlock_timedwrlock PTHREAD_RWLOCK_TIMEDWRLOCK_FUNC_TAOS_FORBID #define pthread_rwlock_timedwrlock PTHREAD_RWLOCK_TIMEDWRLOCK_FUNC_TAOS_FORBID
#define pthread_rwlock_tryrdlock PTHREAD_RWLOCK_TRYRDLOCK_FUNC_TAOS_FORBID #define pthread_rwlock_tryrdlock PTHREAD_RWLOCK_TRYRDLOCK_FUNC_TAOS_FORBID
#define pthread_rwlock_trywrlock PTHREAD_RWLOCK_TRYWRLOCK_FUNC_TAOS_FORBID #define pthread_rwlock_trywrlock PTHREAD_RWLOCK_TRYWRLOCK_FUNC_TAOS_FORBID
#define pthread_rwlock_unlock PTHREAD_RWLOCK_UNLOCK_FUNC_TAOS_FORBID #define pthread_rwlock_unlock PTHREAD_RWLOCK_UNLOCK_FUNC_TAOS_FORBID
#define pthread_rwlock_wrlock PTHREAD_RWLOCK_WRLOCK_FUNC_TAOS_FORBID #define pthread_rwlock_wrlock PTHREAD_RWLOCK_WRLOCK_FUNC_TAOS_FORBID
#define pthread_rwlockattr_destroy PTHREAD_RWLOCKATTR_DESTROY_FUNC_TAOS_FORBID #define pthread_rwlockattr_destroy PTHREAD_RWLOCKATTR_DESTROY_FUNC_TAOS_FORBID
#define pthread_rwlockattr_getpshared PTHREAD_RWLOCKATTR_GETPSHARED_FUNC_TAOS_FORBID #define pthread_rwlockattr_getpshared PTHREAD_RWLOCKATTR_GETPSHARED_FUNC_TAOS_FORBID
#define pthread_rwlockattr_init PTHREAD_RWLOCKATTR_INIT_FUNC_TAOS_FORBID #define pthread_rwlockattr_init PTHREAD_RWLOCKATTR_INIT_FUNC_TAOS_FORBID
#define pthread_rwlockattr_setpshared PTHREAD_RWLOCKATTR_SETPSHARED_FUNC_TAOS_FORBID #define pthread_rwlockattr_setpshared PTHREAD_RWLOCKATTR_SETPSHARED_FUNC_TAOS_FORBID
#define pthread_self PTHREAD_SELF_FUNC_TAOS_FORBID #define pthread_self PTHREAD_SELF_FUNC_TAOS_FORBID
#define pthread_setcancelstate PTHREAD_SETCANCELSTATE_FUNC_TAOS_FORBID #define pthread_setcancelstate PTHREAD_SETCANCELSTATE_FUNC_TAOS_FORBID
#define pthread_setcanceltype PTHREAD_SETCANCELTYPE_FUNC_TAOS_FORBID #define pthread_setcanceltype PTHREAD_SETCANCELTYPE_FUNC_TAOS_FORBID
#define pthread_setschedparam PTHREAD_SETSCHEDPARAM_FUNC_TAOS_FORBID #define pthread_setschedparam PTHREAD_SETSCHEDPARAM_FUNC_TAOS_FORBID
#define pthread_setspecific PTHREAD_SETSPECIFIC_FUNC_TAOS_FORBID #define pthread_setspecific PTHREAD_SETSPECIFIC_FUNC_TAOS_FORBID
#define pthread_spin_destroy PTHREAD_SPIN_DESTROY_FUNC_TAOS_FORBID #define pthread_spin_destroy PTHREAD_SPIN_DESTROY_FUNC_TAOS_FORBID
#define pthread_spin_init PTHREAD_SPIN_INIT_FUNC_TAOS_FORBID #define pthread_spin_init PTHREAD_SPIN_INIT_FUNC_TAOS_FORBID
#define pthread_spin_lock PTHREAD_SPIN_LOCK_FUNC_TAOS_FORBID #define pthread_spin_lock PTHREAD_SPIN_LOCK_FUNC_TAOS_FORBID
#define pthread_spin_trylock PTHREAD_SPIN_TRYLOCK_FUNC_TAOS_FORBID #define pthread_spin_trylock PTHREAD_SPIN_TRYLOCK_FUNC_TAOS_FORBID
#define pthread_spin_unlock PTHREAD_SPIN_UNLOCK_FUNC_TAOS_FORBID #define pthread_spin_unlock PTHREAD_SPIN_UNLOCK_FUNC_TAOS_FORBID
#define pthread_testcancel PTHREAD_TESTCANCEL_FUNC_TAOS_FORBID #define pthread_testcancel PTHREAD_TESTCANCEL_FUNC_TAOS_FORBID
#define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID #define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID
#define sigwait SIGWAIT_FUNC_TAOS_FORBID #define sigwait SIGWAIT_FUNC_TAOS_FORBID
#endif #endif
int32_t taosThreadCreate(TdThread * tid, const TdThreadAttr * attr, void *(*start)(void *), void *arg); int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void *(*start)(void *), void *arg);
int32_t taosThreadAttrDestroy(TdThreadAttr * attr); int32_t taosThreadAttrDestroy(TdThreadAttr *attr);
int32_t taosThreadAttrGetDetachState(const TdThreadAttr * attr, int32_t *detachstate); int32_t taosThreadAttrGetDetachState(const TdThreadAttr *attr, int32_t *detachstate);
int32_t taosThreadAttrGetInheritSched(const TdThreadAttr * attr, int32_t *inheritsched); int32_t taosThreadAttrGetInheritSched(const TdThreadAttr *attr, int32_t *inheritsched);
int32_t taosThreadAttrGetSchedParam(const TdThreadAttr * attr, struct sched_param *param); int32_t taosThreadAttrGetSchedParam(const TdThreadAttr *attr, struct sched_param *param);
int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr * attr, int32_t *policy); int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr *attr, int32_t *policy);
int32_t taosThreadAttrGetScope(const TdThreadAttr * attr, int32_t *contentionscope); int32_t taosThreadAttrGetScope(const TdThreadAttr *attr, int32_t *contentionscope);
int32_t taosThreadAttrGetStackSize(const TdThreadAttr * attr, size_t * stacksize); int32_t taosThreadAttrGetStackSize(const TdThreadAttr *attr, size_t *stacksize);
int32_t taosThreadAttrInit(TdThreadAttr * attr); int32_t taosThreadAttrInit(TdThreadAttr *attr);
int32_t taosThreadAttrSetDetachState(TdThreadAttr * attr, int32_t detachstate); int32_t taosThreadAttrSetDetachState(TdThreadAttr *attr, int32_t detachstate);
int32_t taosThreadAttrSetInheritSched(TdThreadAttr * attr, int32_t inheritsched); int32_t taosThreadAttrSetInheritSched(TdThreadAttr *attr, int32_t inheritsched);
int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_param *param); int32_t taosThreadAttrSetSchedParam(TdThreadAttr *attr, const struct sched_param *param);
int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr * attr, int32_t policy); int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr *attr, int32_t policy);
int32_t taosThreadAttrSetScope(TdThreadAttr * attr, int32_t contentionscope); int32_t taosThreadAttrSetScope(TdThreadAttr *attr, int32_t contentionscope);
int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize); int32_t taosThreadAttrSetStackSize(TdThreadAttr *attr, size_t stacksize);
int32_t taosThreadCancel(TdThread thread); int32_t taosThreadCancel(TdThread thread);
int32_t taosThreadCondDestroy(TdThreadCond * cond); int32_t taosThreadCondDestroy(TdThreadCond *cond);
int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr); int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr);
int32_t taosThreadCondSignal(TdThreadCond * cond); int32_t taosThreadCondSignal(TdThreadCond *cond);
int32_t taosThreadCondBroadcast(TdThreadCond * cond); int32_t taosThreadCondBroadcast(TdThreadCond *cond);
int32_t taosThreadCondWait(TdThreadCond * cond, TdThreadMutex * mutex); int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex);
int32_t taosThreadCondTimedWait(TdThreadCond * cond, TdThreadMutex * mutex, const struct timespec *abstime); int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime);
int32_t taosThreadCondAttrDestroy(TdThreadCondAttr * attr); int32_t taosThreadCondAttrDestroy(TdThreadCondAttr *attr);
int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr * attr, int32_t *pshared); int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr *attr, int32_t *pshared);
int32_t taosThreadCondAttrInit(TdThreadCondAttr * attr); int32_t taosThreadCondAttrInit(TdThreadCondAttr *attr);
int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr * attr, int32_t pshared); int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr *attr, int32_t pshared);
int32_t taosThreadDetach(TdThread thread); int32_t taosThreadDetach(TdThread thread);
int32_t taosThreadEqual(TdThread t1, TdThread t2); int32_t taosThreadEqual(TdThread t1, TdThread t2);
void taosThreadExit(void *valuePtr); void taosThreadExit(void *valuePtr);
int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param); int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param);
void *taosThreadGetSpecific(TdThreadKey key); void *taosThreadGetSpecific(TdThreadKey key);
int32_t taosThreadJoin(TdThread thread, void **valuePtr); int32_t taosThreadJoin(TdThread thread, void **valuePtr);
int32_t taosThreadKeyCreate(TdThreadKey * key, void(*destructor)(void *)); int32_t taosThreadKeyCreate(TdThreadKey *key, void (*destructor)(void *));
int32_t taosThreadKeyDelete(TdThreadKey key); int32_t taosThreadKeyDelete(TdThreadKey key);
int32_t taosThreadKill(TdThread thread, int32_t sig); int32_t taosThreadKill(TdThread thread, int32_t sig);
// int32_t taosThreadMutexConsistent(TdThreadMutex* mutex); // int32_t taosThreadMutexConsistent(TdThreadMutex* mutex);
int32_t taosThreadMutexDestroy(TdThreadMutex * mutex); int32_t taosThreadMutexDestroy(TdThreadMutex *mutex);
int32_t taosThreadMutexInit(TdThreadMutex * mutex, const TdThreadMutexAttr * attr); int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr);
int32_t taosThreadMutexLock(TdThreadMutex * mutex); int32_t taosThreadMutexLock(TdThreadMutex *mutex);
// int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime); // int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime);
int32_t taosThreadMutexTryLock(TdThreadMutex * mutex); int32_t taosThreadMutexTryLock(TdThreadMutex *mutex);
int32_t taosThreadMutexUnlock(TdThreadMutex * mutex); int32_t taosThreadMutexUnlock(TdThreadMutex *mutex);
int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr * attr); int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr *attr);
int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr * attr, int32_t *pshared); int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr *attr, int32_t *pshared);
// int32_t taosThreadMutexAttrGetRobust(const TdThreadMutexAttr * attr, int32_t * robust); // int32_t taosThreadMutexAttrGetRobust(const TdThreadMutexAttr * attr, int32_t * robust);
int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr * attr, int32_t *kind); int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr *attr, int32_t *kind);
int32_t taosThreadMutexAttrInit(TdThreadMutexAttr * attr); int32_t taosThreadMutexAttrInit(TdThreadMutexAttr *attr);
int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr * attr, int32_t pshared); int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr *attr, int32_t pshared);
// int32_t taosThreadMutexAttrSetRobust(TdThreadMutexAttr * attr, int32_t robust); // int32_t taosThreadMutexAttrSetRobust(TdThreadMutexAttr * attr, int32_t robust);
int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr * attr, int32_t kind); int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr *attr, int32_t kind);
int32_t taosThreadOnce(TdThreadOnce * onceControl, void(*initRoutine)(void)); int32_t taosThreadOnce(TdThreadOnce *onceControl, void (*initRoutine)(void));
int32_t taosThreadRwlockDestroy(TdThreadRwlock * rwlock); int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock);
int32_t taosThreadRwlockInit(TdThreadRwlock * rwlock, const TdThreadRwlockAttr * attr); int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr);
int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock); int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock);
// int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime); // int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime);
// int32_t taosThreadRwlockTimedWrlock(TdThreadRwlock * rwlock, const struct timespec *abstime); // int32_t taosThreadRwlockTimedWrlock(TdThreadRwlock * rwlock, const struct timespec *abstime);
int32_t taosThreadRwlockTryRdlock(TdThreadRwlock * rwlock); int32_t taosThreadRwlockTryRdlock(TdThreadRwlock *rwlock);
int32_t taosThreadRwlockTryWrlock(TdThreadRwlock * rwlock); int32_t taosThreadRwlockTryWrlock(TdThreadRwlock *rwlock);
int32_t taosThreadRwlockUnlock(TdThreadRwlock * rwlock); int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock);
int32_t taosThreadRwlockWrlock(TdThreadRwlock * rwlock); int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock);
int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr * attr); int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr *attr);
int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr * attr, int32_t *pshared); int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr *attr, int32_t *pshared);
int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr * attr); int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr *attr);
int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr * attr, int32_t pshared); int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr *attr, int32_t pshared);
TdThread taosThreadSelf(void); TdThread taosThreadSelf(void);
int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate); int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate);
int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype); int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype);
int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param); int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param);
int32_t taosThreadSetSpecific(TdThreadKey key, const void *value); int32_t taosThreadSetSpecific(TdThreadKey key, const void *value);
int32_t taosThreadSpinDestroy(TdThreadSpinlock * lock); int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock);
int32_t taosThreadSpinInit(TdThreadSpinlock * lock, int32_t pshared); int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int32_t pshared);
int32_t taosThreadSpinLock(TdThreadSpinlock * lock); int32_t taosThreadSpinLock(TdThreadSpinlock *lock);
int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock); int32_t taosThreadSpinTrylock(TdThreadSpinlock *lock);
int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock); int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock);
void taosThreadTestCancel(void); void taosThreadTestCancel(void);
void taosThreadClear(TdThread *thread); void taosThreadClear(TdThread *thread);

View File

@ -23,11 +23,11 @@ extern "C" {
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define timer_create TIMER_CREATE_FUNC_TAOS_FORBID #define timer_create TIMER_CREATE_FUNC_TAOS_FORBID
#define timer_settime TIMER_SETTIME_FUNC_TAOS_FORBID #define timer_settime TIMER_SETTIME_FUNC_TAOS_FORBID
#define timer_delete TIMER_DELETE_FUNC_TAOS_FORBID #define timer_delete TIMER_DELETE_FUNC_TAOS_FORBID
#define timeSetEvent TIMESETEVENT_SETTIME_FUNC_TAOS_FORBID #define timeSetEvent TIMESETEVENT_SETTIME_FUNC_TAOS_FORBID
#define timeKillEvent TIMEKILLEVENT_SETTIME_FUNC_TAOS_FORBID #define timeKillEvent TIMEKILLEVENT_SETTIME_FUNC_TAOS_FORBID
#endif #endif
#define MSECONDS_PER_TICK 5 #define MSECONDS_PER_TICK 5

View File

@ -23,12 +23,11 @@ extern "C" {
// If the error is in a third-party library, place this header file under the third-party library header file. // If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section. // When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC #ifndef ALLOW_FORBID_FUNC
#define tzset TZSET_FUNC_TAOS_FORBID #define tzset TZSET_FUNC_TAOS_FORBID
#endif #endif
enum TdTimezone enum TdTimezone {
{ TdWestZone12 = -12,
TdWestZone12=-12,
TdWestZone11, TdWestZone11,
TdWestZone10, TdWestZone10,
TdWestZone9, TdWestZone9,

View File

@ -38,13 +38,12 @@ typedef struct SBloomFilter {
SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate); SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate);
int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len); int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len);
int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, uint32_t len);
uint32_t len);
void tBloomFilterDestroy(SBloomFilter *pBF); void tBloomFilterDestroy(SBloomFilter *pBF);
void tBloomFilterDump(const SBloomFilter *pBF); void tBloomFilterDump(const SBloomFilter *pBF);
bool tBloomFilterIsFull(const SBloomFilter *pBF); bool tBloomFilterIsFull(const SBloomFilter *pBF);
int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder* pEncoder); int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder *pEncoder);
SBloomFilter* tBloomFilterDecode(SDecoder* pDecoder); SBloomFilter *tBloomFilterDecode(SDecoder *pDecoder);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -105,11 +105,11 @@ int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal);
const char *cfgStypeStr(ECfgSrcType type); const char *cfgStypeStr(ECfgSrcType type);
const char *cfgDtypeStr(ECfgDataType type); const char *cfgDtypeStr(ECfgDataType type);
void cfgDumpItemValue(SConfigItem *pItem, char* buf, int32_t bufSize, int32_t* pLen); void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump); void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl); int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -22,6 +22,8 @@
#ifndef TDIGEST_H #ifndef TDIGEST_H
#define TDIGEST_H #define TDIGEST_H
#include "os.h"
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288 /* pi */ #define M_PI 3.14159265358979323846264338327950288 /* pi */
#endif #endif
@ -32,17 +34,18 @@
#define COMPRESSION 300 #define COMPRESSION 300
#define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1 + ADDITION_CENTROID_NUM) #define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1 + ADDITION_CENTROID_NUM)
#define GET_THRESHOLD(compression) (7.5 + 0.37 * compression - 2e-4 * pow(compression, 2)) #define GET_THRESHOLD(compression) (7.5 + 0.37 * compression - 2e-4 * pow(compression, 2))
#define TDIGEST_SIZE(compression) (sizeof(TDigest) + sizeof(SCentroid)*GET_CENTROID(compression) + sizeof(SPt)*GET_THRESHOLD(compression)) #define TDIGEST_SIZE(compression) \
(sizeof(TDigest) + sizeof(SCentroid) * GET_CENTROID(compression) + sizeof(SPt) * GET_THRESHOLD(compression))
typedef struct SCentroid { typedef struct SCentroid {
double mean; double mean;
int64_t weight; int64_t weight;
}SCentroid; } SCentroid;
typedef struct SPt { typedef struct SPt {
double value; double value;
int64_t weight; int64_t weight;
}SPt; } SPt;
typedef struct TDigest { typedef struct TDigest {
double compression; double compression;
@ -58,14 +61,14 @@ typedef struct TDigest {
int32_t num_centroids; int32_t num_centroids;
SCentroid *centroids; SCentroid *centroids;
}TDigest; } TDigest;
TDigest *tdigestNewFrom(void* pBuf, int32_t compression); TDigest *tdigestNewFrom(void *pBuf, int32_t compression);
void tdigestAdd(TDigest *t, double x, int64_t w); void tdigestAdd(TDigest *t, double x, int64_t w);
void tdigestMerge(TDigest *t1, TDigest *t2); void tdigestMerge(TDigest *t1, TDigest *t2);
double tdigestQuantile(TDigest *t, double q); double tdigestQuantile(TDigest *t, double q);
void tdigestCompress(TDigest *t); void tdigestCompress(TDigest *t);
void tdigestFreeFrom(TDigest *t); void tdigestFreeFrom(TDigest *t);
void tdigestAutoFill(TDigest* t, int32_t compression); void tdigestAutoFill(TDigest *t, int32_t compression);
#endif /* TDIGEST_H */ #endif /* TDIGEST_H */

View File

@ -118,7 +118,7 @@ int32_t taosHashGetDup(SHashObj *pHashObj, const void *key, size_t keyLen, void
* @param size * @param size
* @return * @return
*/ */
int32_t taosHashGetDup_m(SHashObj* pHashObj, const void* key, size_t keyLen, void** destBuf, int32_t* size); int32_t taosHashGetDup_m(SHashObj *pHashObj, const void *key, size_t keyLen, void **destBuf, int32_t *size);
/** /**
* remove item with the specified key * remove item with the specified key
@ -169,13 +169,13 @@ void *taosHashIterate(SHashObj *pHashObj, void *p);
*/ */
void taosHashCancelIterate(SHashObj *pHashObj, void *p); void taosHashCancelIterate(SHashObj *pHashObj, void *p);
/** /**
* Get the corresponding key information for a given data in hash table * Get the corresponding key information for a given data in hash table
* @param data * @param data
* @param keyLen * @param keyLen
* @return * @return
*/ */
void *taosHashGetKey(void *data, size_t* keyLen); void *taosHashGetKey(void *data, size_t *keyLen);
/** /**
* return the payload data with the specified key(reference number added) * return the payload data with the specified key(reference number added)

View File

@ -28,10 +28,7 @@ typedef void (*_taos_lru_deleter_t)(const void *key, size_t keyLen, void *value)
typedef struct LRUHandle LRUHandle; typedef struct LRUHandle LRUHandle;
typedef enum { typedef enum { TAOS_LRU_PRIORITY_HIGH, TAOS_LRU_PRIORITY_LOW } LRUPriority;
TAOS_LRU_PRIORITY_HIGH,
TAOS_LRU_PRIORITY_LOW
} LRUPriority;
typedef enum { typedef enum {
TAOS_LRU_STATUS_OK, TAOS_LRU_STATUS_OK,
@ -45,15 +42,15 @@ void taosLRUCacheCleanup(SLRUCache *cache);
LRUStatus taosLRUCacheInsert(SLRUCache *cache, const void *key, size_t keyLen, void *value, size_t charge, LRUStatus taosLRUCacheInsert(SLRUCache *cache, const void *key, size_t keyLen, void *value, size_t charge,
_taos_lru_deleter_t deleter, LRUHandle **handle, LRUPriority priority); _taos_lru_deleter_t deleter, LRUHandle **handle, LRUPriority priority);
LRUHandle *taosLRUCacheLookup(SLRUCache * cache, const void *key, size_t keyLen); LRUHandle *taosLRUCacheLookup(SLRUCache *cache, const void *key, size_t keyLen);
void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen); void taosLRUCacheErase(SLRUCache *cache, const void *key, size_t keyLen);
void taosLRUCacheEraseUnrefEntries(SLRUCache *cache); void taosLRUCacheEraseUnrefEntries(SLRUCache *cache);
bool taosLRUCacheRef(SLRUCache *cache, LRUHandle *handle); bool taosLRUCacheRef(SLRUCache *cache, LRUHandle *handle);
bool taosLRUCacheRelease(SLRUCache *cache, LRUHandle *handle, bool eraseIfLastRef); bool taosLRUCacheRelease(SLRUCache *cache, LRUHandle *handle, bool eraseIfLastRef);
void* taosLRUCacheValue(SLRUCache *cache, LRUHandle *handle); void *taosLRUCacheValue(SLRUCache *cache, LRUHandle *handle);
size_t taosLRUCacheGetUsage(SLRUCache *cache); size_t taosLRUCacheGetUsage(SLRUCache *cache);
size_t taosLRUCacheGetPinnedUsage(SLRUCache *cache); size_t taosLRUCacheGetPinnedUsage(SLRUCache *cache);

View File

@ -53,7 +53,8 @@ typedef struct SDiskbasedBufStatis {
* @param handle * @param handle
* @return * @return
*/ */
int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMemBufSize, const char* id, const char* dir); int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMemBufSize, const char* id,
const char* dir);
/** /**
* *
@ -158,7 +159,7 @@ void setBufPageCompressOnDisk(SDiskbasedBuf* pBuf, bool comp);
* @param pBuf * @param pBuf
* @param pageId * @param pageId
*/ */
void dBufSetBufPageRecycled(SDiskbasedBuf *pBuf, void* pPage); void dBufSetBufPageRecycled(SDiskbasedBuf* pBuf, void* pPage);
/** /**
* Print the statistics when closing this buffer * Print the statistics when closing this buffer

View File

@ -30,11 +30,10 @@ typedef struct SScalableBf {
SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate); SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate);
int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len); int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len);
int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, uint32_t len);
uint32_t len);
void tScalableBfDestroy(SScalableBf *pSBf); void tScalableBfDestroy(SScalableBf *pSBf);
int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder* pEncoder); int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder *pEncoder);
SScalableBf* tScalableBfDecode(SDecoder* pDecoder); SScalableBf *tScalableBfDecode(SDecoder *pDecoder);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -26,7 +26,7 @@ TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param);
bool taosDestroyThread(TdThread* pthread); bool taosDestroyThread(TdThread* pthread);
bool taosThreadRunning(TdThread* pthread); bool taosThreadRunning(TdThread* pthread);
typedef void *(*ThreadFp)(void *param); typedef void* (*ThreadFp)(void* param);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -19,8 +19,8 @@
#include "os.h" #include "os.h"
#include "tcrc32c.h" #include "tcrc32c.h"
#include "tdef.h" #include "tdef.h"
#include "tmd5.h"
#include "thash.h" #include "thash.h"
#include "tmd5.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -73,5 +73,3 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet) {
return ep; return ep;
} }

View File

@ -81,8 +81,8 @@ static int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int
static char* forwardToTimeStringEnd(char* str); static char* forwardToTimeStringEnd(char* str);
static bool checkTzPresent(const char* str, int32_t len); static bool checkTzPresent(const char* str, int32_t len);
static int32_t (*parseLocaltimeFp[])(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) = {parseLocaltime, static int32_t (*parseLocaltimeFp[])(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) = {
parseLocaltimeDst}; parseLocaltime, parseLocaltimeDst};
int32_t taosParseTime(const char* timestr, int64_t* utime, int32_t len, int32_t timePrec, int8_t day_light) { int32_t taosParseTime(const char* timestr, int64_t* utime, int32_t len, int32_t timePrec, int8_t day_light) {
/* parse datatime string in with tz */ /* parse datatime string in with tz */
@ -324,7 +324,7 @@ static FORCE_INLINE bool validateTm(struct tm* pTm) {
int32_t leapYearMonthDay = 29; int32_t leapYearMonthDay = 29;
int32_t year = pTm->tm_year + 1900; int32_t year = pTm->tm_year + 1900;
bool isLeapYear = ((year % 100) == 0)? ((year % 400) == 0):((year % 4) == 0); bool isLeapYear = ((year % 100) == 0) ? ((year % 400) == 0) : ((year % 4) == 0);
if (isLeapYear && (pTm->tm_mon == 1)) { if (isLeapYear && (pTm->tm_mon == 1)) {
if (pTm->tm_mday > leapYearMonthDay) { if (pTm->tm_mday > leapYearMonthDay) {
@ -343,7 +343,7 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePr
*time = 0; *time = 0;
struct tm tm = {0}; struct tm tm = {0};
char *str; char* str;
if (delim == 'T') { if (delim == 'T') {
str = taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm); str = taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm);
} else if (delim == 0) { } else if (delim == 0) {
@ -353,7 +353,7 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePr
} }
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
//if parse failed, try "%Y-%m-%d" format // if parse failed, try "%Y-%m-%d" format
str = taosStrpTime(timestr, "%Y-%m-%d", &tm); str = taosStrpTime(timestr, "%Y-%m-%d", &tm);
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
return -1; return -1;
@ -390,7 +390,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim
struct tm tm = {0}; struct tm tm = {0};
tm.tm_isdst = -1; tm.tm_isdst = -1;
char *str; char* str;
if (delim == 'T') { if (delim == 'T') {
str = taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm); str = taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm);
} else if (delim == 0) { } else if (delim == 0) {
@ -400,7 +400,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim
} }
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
//if parse failed, try "%Y-%m-%d" format // if parse failed, try "%Y-%m-%d" format
str = taosStrpTime(timestr, "%Y-%m-%d", &tm); str = taosStrpTime(timestr, "%Y-%m-%d", &tm);
if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) {
return -1; return -1;
@ -438,14 +438,12 @@ char getPrecisionUnit(int32_t precision) {
} }
int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) {
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
fromPrecision == TSDB_TIME_PRECISION_MICRO ||
fromPrecision == TSDB_TIME_PRECISION_NANO); fromPrecision == TSDB_TIME_PRECISION_NANO);
assert(toPrecision == TSDB_TIME_PRECISION_MILLI || assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO ||
toPrecision == TSDB_TIME_PRECISION_MICRO ||
toPrecision == TSDB_TIME_PRECISION_NANO); toPrecision == TSDB_TIME_PRECISION_NANO);
double tempResult = (double)time; double tempResult = (double)time;
switch(fromPrecision) { switch (fromPrecision) {
case TSDB_TIME_PRECISION_MILLI: { case TSDB_TIME_PRECISION_MILLI: {
switch (toPrecision) { switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI: case TSDB_TIME_PRECISION_MILLI:
@ -471,7 +469,7 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec
time *= 1000; time *= 1000;
goto end_; goto end_;
} }
} //end from micro } // end from micro
case TSDB_TIME_PRECISION_NANO: { case TSDB_TIME_PRECISION_NANO: {
switch (toPrecision) { switch (toPrecision) {
case TSDB_TIME_PRECISION_MILLI: case TSDB_TIME_PRECISION_MILLI:
@ -481,20 +479,21 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec
case TSDB_TIME_PRECISION_NANO: case TSDB_TIME_PRECISION_NANO:
return time; return time;
} }
} //end from nano } // end from nano
default: { default: {
assert(0); assert(0);
return time; // only to pass windows compilation return time; // only to pass windows compilation
} }
} //end switch fromPrecision } // end switch fromPrecision
end_: end_:
if (tempResult >= (double)INT64_MAX) return INT64_MAX; if (tempResult >= (double)INT64_MAX) return INT64_MAX;
if (tempResult <= (double)INT64_MIN) return INT64_MIN; // INT64_MIN means NULL if (tempResult <= (double)INT64_MIN) return INT64_MIN; // INT64_MIN means NULL
return time; return time;
} }
// !!!!notice:there are precision problems, double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = 1626006833631000064 // !!!!notice:there are precision problems, double lose precison if time is too large, for example:
//int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { // 1626006833631000000*1.0 = double = 1626006833631000064
// int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) {
// assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || // assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
// fromPrecision == TSDB_TIME_PRECISION_NANO); // fromPrecision == TSDB_TIME_PRECISION_NANO);
// assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO || // assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO ||
@ -503,53 +502,53 @@ end_:
// ((double)time * factors[fromPrecision][toPrecision]); // ((double)time * factors[fromPrecision][toPrecision]);
//} //}
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double =
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = 1626006833631000064 // 1626006833631000064
int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) { int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) {
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
fromPrecision == TSDB_TIME_PRECISION_NANO); fromPrecision == TSDB_TIME_PRECISION_NANO);
int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1}; int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1};
double tmp = time; double tmp = time;
switch (toUnit) { switch (toUnit) {
case 's':{ case 's': {
tmp /= (NANOSECOND_PER_SEC/factors[fromPrecision]); // the result of division is an integer tmp /= (NANOSECOND_PER_SEC / factors[fromPrecision]); // the result of division is an integer
time /= (NANOSECOND_PER_SEC/factors[fromPrecision]); time /= (NANOSECOND_PER_SEC / factors[fromPrecision]);
break; break;
} }
case 'm': case 'm':
tmp /= (NANOSECOND_PER_MINUTE/factors[fromPrecision]); // the result of division is an integer tmp /= (NANOSECOND_PER_MINUTE / factors[fromPrecision]); // the result of division is an integer
time /= (NANOSECOND_PER_MINUTE/factors[fromPrecision]); time /= (NANOSECOND_PER_MINUTE / factors[fromPrecision]);
break; break;
case 'h': case 'h':
tmp /= (NANOSECOND_PER_HOUR/factors[fromPrecision]); // the result of division is an integer tmp /= (NANOSECOND_PER_HOUR / factors[fromPrecision]); // the result of division is an integer
time /= (NANOSECOND_PER_HOUR/factors[fromPrecision]); time /= (NANOSECOND_PER_HOUR / factors[fromPrecision]);
break; break;
case 'd': case 'd':
tmp /= (NANOSECOND_PER_DAY/factors[fromPrecision]); // the result of division is an integer tmp /= (NANOSECOND_PER_DAY / factors[fromPrecision]); // the result of division is an integer
time /= (NANOSECOND_PER_DAY/factors[fromPrecision]); time /= (NANOSECOND_PER_DAY / factors[fromPrecision]);
break; break;
case 'w': case 'w':
tmp /= (NANOSECOND_PER_WEEK/factors[fromPrecision]); // the result of division is an integer tmp /= (NANOSECOND_PER_WEEK / factors[fromPrecision]); // the result of division is an integer
time /= (NANOSECOND_PER_WEEK/factors[fromPrecision]); time /= (NANOSECOND_PER_WEEK / factors[fromPrecision]);
break; break;
case 'a': case 'a':
tmp /= (NANOSECOND_PER_MSEC/factors[fromPrecision]); // the result of division is an integer tmp /= (NANOSECOND_PER_MSEC / factors[fromPrecision]); // the result of division is an integer
time /= (NANOSECOND_PER_MSEC/factors[fromPrecision]); time /= (NANOSECOND_PER_MSEC / factors[fromPrecision]);
break; break;
case 'u': case 'u':
// the result of (NANOSECOND_PER_USEC/(double)factors[fromPrecision]) maybe a double // the result of (NANOSECOND_PER_USEC/(double)factors[fromPrecision]) maybe a double
switch (fromPrecision) { switch (fromPrecision) {
case TSDB_TIME_PRECISION_MILLI:{ case TSDB_TIME_PRECISION_MILLI: {
tmp *= 1000; tmp *= 1000;
time *= 1000; time *= 1000;
break; break;
} }
case TSDB_TIME_PRECISION_MICRO:{ case TSDB_TIME_PRECISION_MICRO: {
tmp /= 1; tmp /= 1;
time /= 1; time /= 1;
break; break;
} }
case TSDB_TIME_PRECISION_NANO:{ case TSDB_TIME_PRECISION_NANO: {
tmp /= 1000; tmp /= 1000;
time /= 1000; time /= 1000;
break; break;
@ -569,9 +568,9 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
return time; return time;
} }
int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, int64_t *timeVal) { int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal) {
int32_t charLen = varDataLen(inputData); int32_t charLen = varDataLen(inputData);
char *newColData; char* newColData;
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY) { if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY) {
newColData = taosMemoryCalloc(1, charLen + 1); newColData = taosMemoryCalloc(1, charLen + 1);
memcpy(newColData, varDataVal(inputData), charLen); memcpy(newColData, varDataVal(inputData), charLen);
@ -583,8 +582,8 @@ int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec
taosMemoryFree(newColData); taosMemoryFree(newColData);
} else if (type == TSDB_DATA_TYPE_NCHAR) { } else if (type == TSDB_DATA_TYPE_NCHAR) {
newColData = taosMemoryCalloc(1, charLen + TSDB_NCHAR_SIZE); newColData = taosMemoryCalloc(1, charLen + TSDB_NCHAR_SIZE);
int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(inputData), charLen, newColData); int len = taosUcs4ToMbs((TdUcs4*)varDataVal(inputData), charLen, newColData);
if (len < 0){ if (len < 0) {
taosMemoryFree(newColData); taosMemoryFree(newColData);
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }

View File

@ -209,7 +209,8 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) {
uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5); uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5);
assert((int32_t)newSize > pTSBuf->numOfAlloc); assert((int32_t)newSize > pTSBuf->numOfAlloc);
STSGroupBlockInfoEx* tmp = (STSGroupBlockInfoEx*)taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize); STSGroupBlockInfoEx* tmp =
(STSGroupBlockInfoEx*)taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize);
if (tmp == NULL) { if (tmp == NULL) {
return NULL; return NULL;
} }

View File

@ -15,9 +15,10 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "dmMgmt.h" #include "dmMgmt.h"
#include "tconfig.h"
#include "mnode.h" #include "mnode.h"
#include "tconfig.h"
// clang-format off
#define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'." #define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'."
#define DM_CFG_DIR "Configuration directory." #define DM_CFG_DIR "Configuration directory."
#define DM_DMP_CFG "Dump configuration." #define DM_DMP_CFG "Dump configuration."
@ -28,6 +29,7 @@
#define DM_MACHINE_CODE "Get machine code." #define DM_MACHINE_CODE "Get machine code."
#define DM_VERSION "Print program version." #define DM_VERSION "Print program version."
#define DM_EMAIL "<support@taosdata.com>" #define DM_EMAIL "<support@taosdata.com>"
// clang-format on
static struct { static struct {
#ifdef WINDOWS #ifdef WINDOWS
bool winServiceMode; bool winServiceMode;
@ -101,10 +103,10 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
global.dumpConfig = true; global.dumpConfig = true;
} else if (strcmp(argv[i], "-V") == 0) { } else if (strcmp(argv[i], "-V") == 0) {
global.printVersion = true; global.printVersion = true;
#ifdef WINDOWS #ifdef WINDOWS
} else if (strcmp(argv[i], "--win_service") == 0) { } else if (strcmp(argv[i], "--win_service") == 0) {
global.winServiceMode = true; global.winServiceMode = true;
#endif #endif
} else if (strcmp(argv[i], "-e") == 0) { } else if (strcmp(argv[i], "-e") == 0) {
global.envCmd[cmdEnvIndex] = argv[++i]; global.envCmd[cmdEnvIndex] = argv[++i];
cmdEnvIndex++; cmdEnvIndex++;
@ -183,7 +185,7 @@ int main(int argc, char const *argv[]) {
} }
#ifdef WINDOWS #ifdef WINDOWS
int mainWindows(int argc,char** argv); int mainWindows(int argc, char **argv);
if (global.winServiceMode) { if (global.winServiceMode) {
stratWindowsService(mainWindows); stratWindowsService(mainWindows);
} else { } else {
@ -191,7 +193,7 @@ int main(int argc, char const *argv[]) {
} }
return 0; return 0;
} }
int mainWindows(int argc,char** argv) { int mainWindows(int argc, char **argv) {
#endif #endif
if (global.generateGrant) { if (global.generateGrant) {

View File

@ -101,7 +101,7 @@ void dmStopMonitorThread(SDnodeMgmt *pMgmt) {
static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
SDnodeMgmt *pMgmt = pInfo->ahandle; SDnodeMgmt *pMgmt = pInfo->ahandle;
int32_t code = -1; int32_t code = -1;
STraceId * trace = &pMsg->info.traceId; STraceId *trace = &pMsg->info.traceId;
dGTrace("msg:%p, will be processed in dnode queue, type:%s", pMsg, TMSG_INFO(pMsg->msgType)); dGTrace("msg:%p, will be processed in dnode queue, type:%s", pMsg, TMSG_INFO(pMsg->msgType));
switch (pMsg->msgType) { switch (pMsg->msgType) {

View File

@ -51,7 +51,7 @@ int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg); int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg *pMsg);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -21,7 +21,6 @@ void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) {
qndGetLoad(pMgmt->pQnode, &qload); qndGetLoad(pMgmt->pQnode, &qload);
qload.dnodeId = pMgmt->pData->dnodeId; qload.dnodeId = pMgmt->pData->dnodeId;
} }
void qmGetQnodeLoads(SQnodeMgmt *pMgmt, SQnodeLoad *pInfo) { void qmGetQnodeLoads(SQnodeMgmt *pMgmt, SQnodeLoad *pInfo) {

View File

@ -52,17 +52,23 @@ static int32_t dmInitMonitor() {
static bool dmCheckDiskSpace() { static bool dmCheckDiskSpace() {
osUpdate(); osUpdate();
if (!osDataSpaceAvailable()) { if (!osDataSpaceAvailable()) {
dError("free disk size: %f GB, too little, require %f GB at least at least , quit", (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0); dError("free disk size: %f GB, too little, require %f GB at least at least , quit",
(double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
(double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0);
terrno = TSDB_CODE_NO_AVAIL_DISK; terrno = TSDB_CODE_NO_AVAIL_DISK;
return false; return false;
} }
if (!osLogSpaceAvailable()) { if (!osLogSpaceAvailable()) {
dError("free disk size: %f GB, too little, require %f GB at least at least, quit", (double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0); dError("free disk size: %f GB, too little, require %f GB at least at least, quit",
(double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
(double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0);
terrno = TSDB_CODE_NO_AVAIL_DISK; terrno = TSDB_CODE_NO_AVAIL_DISK;
return false; return false;
} }
if (!osTempSpaceAvailable()) { if (!osTempSpaceAvailable()) {
dError("free disk size: %f GB, too little, require %f GB at least at least, quit", (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0); dError("free disk size: %f GB, too little, require %f GB at least at least, quit",
(double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0,
(double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0);
terrno = TSDB_CODE_NO_AVAIL_DISK; terrno = TSDB_CODE_NO_AVAIL_DISK;
return false; return false;
} }
@ -73,7 +79,8 @@ static bool dmCheckDataDirVersion() {
char checkDataDirJsonFileName[PATH_MAX]; char checkDataDirJsonFileName[PATH_MAX];
snprintf(checkDataDirJsonFileName, PATH_MAX, "%s/dnode/dnodeCfg.json", tsDataDir); snprintf(checkDataDirJsonFileName, PATH_MAX, "%s/dnode/dnodeCfg.json", tsDataDir);
if (taosCheckExistFile(checkDataDirJsonFileName)) { if (taosCheckExistFile(checkDataDirJsonFileName)) {
dError("The default data directory %s contains old data of tdengine 2.x, please clear it before running!", tsDataDir); dError("The default data directory %s contains old data of tdengine 2.x, please clear it before running!",
tsDataDir);
return false; return false;
} }
return true; return true;

View File

@ -183,4 +183,3 @@ void dmGetQnodeLoads(SQnodeLoad *pInfo) {
dmReleaseWrapper(pWrapper); dmReleaseWrapper(pWrapper);
} }
} }

View File

@ -91,8 +91,8 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) {
static void dmCleanupProcQueue(SProcQueue *queue) {} static void dmCleanupProcQueue(SProcQueue *queue) {}
static inline int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, SRpcMsg *pMsg, EProcFuncType ftype) { static inline int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, SRpcMsg *pMsg, EProcFuncType ftype) {
const void * pHead = pMsg; const void *pHead = pMsg;
const void * pBody = pMsg->pCont; const void *pBody = pMsg->pCont;
const int16_t rawHeadLen = sizeof(SRpcMsg); const int16_t rawHeadLen = sizeof(SRpcMsg);
const int32_t rawBodyLen = pMsg->contLen; const int32_t rawBodyLen = pMsg->contLen;
const int16_t headLen = CEIL8(rawHeadLen); const int16_t headLen = CEIL8(rawHeadLen);
@ -261,7 +261,7 @@ int32_t dmInitProc(struct SMgmtWrapper *pWrapper) {
proc->wrapper = pWrapper; proc->wrapper = pWrapper;
proc->name = pWrapper->name; proc->name = pWrapper->name;
SShm * shm = &proc->shm; SShm *shm = &proc->shm;
int32_t cstart = 0; int32_t cstart = 0;
int32_t csize = CEIL8(shm->size / 2); int32_t csize = CEIL8(shm->size / 2);
int32_t pstart = csize; int32_t pstart = csize;
@ -285,13 +285,13 @@ int32_t dmInitProc(struct SMgmtWrapper *pWrapper) {
} }
static void *dmConsumChildQueue(void *param) { static void *dmConsumChildQueue(void *param) {
SProc * proc = param; SProc *proc = param;
SMgmtWrapper *pWrapper = proc->wrapper; SMgmtWrapper *pWrapper = proc->wrapper;
SProcQueue * queue = proc->cqueue; SProcQueue *queue = proc->cqueue;
int32_t numOfMsgs = 0; int32_t numOfMsgs = 0;
int32_t code = 0; int32_t code = 0;
EProcFuncType ftype = DND_FUNC_REQ; EProcFuncType ftype = DND_FUNC_REQ;
SRpcMsg * pMsg = NULL; SRpcMsg *pMsg = NULL;
dDebug("node:%s, start to consume from cqueue", proc->name); dDebug("node:%s, start to consume from cqueue", proc->name);
do { do {
@ -328,13 +328,13 @@ static void *dmConsumChildQueue(void *param) {
} }
static void *dmConsumParentQueue(void *param) { static void *dmConsumParentQueue(void *param) {
SProc * proc = param; SProc *proc = param;
SMgmtWrapper *pWrapper = proc->wrapper; SMgmtWrapper *pWrapper = proc->wrapper;
SProcQueue * queue = proc->pqueue; SProcQueue *queue = proc->pqueue;
int32_t numOfMsgs = 0; int32_t numOfMsgs = 0;
int32_t code = 0; int32_t code = 0;
EProcFuncType ftype = DND_FUNC_REQ; EProcFuncType ftype = DND_FUNC_REQ;
SRpcMsg * pMsg = NULL; SRpcMsg *pMsg = NULL;
dDebug("node:%s, start to consume from pqueue", proc->name); dDebug("node:%s, start to consume from pqueue", proc->name);
do { do {

View File

@ -44,7 +44,6 @@
extern "C" { extern "C" {
#endif #endif
// clang-format off // clang-format off
#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} #define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}

View File

@ -47,7 +47,7 @@ class Testbase {
int32_t connId; int32_t connId;
public: public:
int32_t SendShowReq(int8_t showType, const char *tb, const char* db); int32_t SendShowReq(int8_t showType, const char* tb, const char* db);
int32_t GetShowRows(); int32_t GetShowRows();
#if 0 #if 0

View File

@ -37,7 +37,7 @@ void Testbase::InitLog(const char* path) {
taosGetSystemInfo(); taosGetSystemInfo();
tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 0.1; tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 0.1;
if (taosInitLog("taosdlog", 1) != 0) { if (taosInitLog("taosdlog", 1) != 0) {
printf("failed to init log file\n"); printf("failed to init log file\n");
} }
} }

View File

@ -22,12 +22,12 @@
#include "mndInt.h" #include "mndInt.h"
int32_t mndInitGrant(SMnode *pMnode); int32_t mndInitGrant(SMnode * pMnode);
void mndCleanupGrant(); void mndCleanupGrant();
void grantParseParameter(); void grantParseParameter();
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value); void grantReset(SMnode * pMnode, EGrantType grant, uint64_t value);
void grantAdd(EGrantType grant, uint64_t value); void grantAdd(EGrantType grant, uint64_t value);
void grantRestore(EGrantType grant, uint64_t value); void grantRestore(EGrantType grant, uint64_t value);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -25,7 +25,6 @@ extern "C" {
int32_t mndInitQuery(SMnode *pMnode); int32_t mndInitQuery(SMnode *pMnode);
void mndCleanupQuery(SMnode *pMnode); void mndCleanupQuery(SMnode *pMnode);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -35,7 +35,7 @@ SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName);
int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreate, SDbObj *pDb); int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreate, SDbObj *pDb);
int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb); int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb);
void mndFreeStb(SStbObj *pStb); void mndFreeStb(SStbObj *pStb);
int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char* dbFName, char* stbFName, void **pCont, int32_t *pLen); int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, void **pCont, int32_t *pLen);
void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst); void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst);
void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize); void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize);

View File

@ -15,8 +15,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "mndBnode.h" #include "mndBnode.h"
#include "mndPrivilege.h"
#include "mndDnode.h" #include "mndDnode.h"
#include "mndPrivilege.h"
#include "mndShow.h" #include "mndShow.h"
#include "mndTrans.h" #include "mndTrans.h"
#include "mndUser.h" #include "mndUser.h"

View File

@ -102,21 +102,21 @@ void dumpDb(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression)); tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression));
tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications)); tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications));
tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict)); tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict));
tjsonAddStringToObject(item, "cacheLast",i642str( pObj->cfg.cacheLast)); tjsonAddStringToObject(item, "cacheLast", i642str(pObj->cfg.cacheLast));
tjsonAddStringToObject(item, "hashMethod", i642str(pObj->cfg.hashMethod)); tjsonAddStringToObject(item, "hashMethod", i642str(pObj->cfg.hashMethod));
tjsonAddStringToObject(item, "hashPrefix", i642str(pObj->cfg.hashPrefix)); tjsonAddStringToObject(item, "hashPrefix", i642str(pObj->cfg.hashPrefix));
tjsonAddStringToObject(item, "hashSuffix", i642str(pObj->cfg.hashSuffix)); tjsonAddStringToObject(item, "hashSuffix", i642str(pObj->cfg.hashSuffix));
tjsonAddStringToObject(item, "sstTrigger", i642str(pObj->cfg.sstTrigger)); tjsonAddStringToObject(item, "sstTrigger", i642str(pObj->cfg.sstTrigger));
tjsonAddStringToObject(item, "tsdbPageSize",i642str( pObj->cfg.tsdbPageSize)); tjsonAddStringToObject(item, "tsdbPageSize", i642str(pObj->cfg.tsdbPageSize));
tjsonAddStringToObject(item, "schemaless", i642str(pObj->cfg.schemaless)); tjsonAddStringToObject(item, "schemaless", i642str(pObj->cfg.schemaless));
tjsonAddStringToObject(item, "walLevel",i642str( pObj->cfg.walLevel)); tjsonAddStringToObject(item, "walLevel", i642str(pObj->cfg.walLevel));
tjsonAddStringToObject(item, "walFsyncPeriod", i642str(pObj->cfg.walFsyncPeriod)); tjsonAddStringToObject(item, "walFsyncPeriod", i642str(pObj->cfg.walFsyncPeriod));
tjsonAddStringToObject(item, "walRetentionPeriod", i642str(pObj->cfg.walRetentionPeriod)); tjsonAddStringToObject(item, "walRetentionPeriod", i642str(pObj->cfg.walRetentionPeriod));
tjsonAddStringToObject(item, "walRetentionSize",i642str( pObj->cfg.walRetentionSize)); tjsonAddStringToObject(item, "walRetentionSize", i642str(pObj->cfg.walRetentionSize));
tjsonAddStringToObject(item, "walRollPeriod", i642str(pObj->cfg.walRollPeriod)); tjsonAddStringToObject(item, "walRollPeriod", i642str(pObj->cfg.walRollPeriod));
tjsonAddStringToObject(item, "walSegmentSize", i642str(pObj->cfg.walSegmentSize)); tjsonAddStringToObject(item, "walSegmentSize", i642str(pObj->cfg.walSegmentSize));
tjsonAddStringToObject(item, "numOfRetensions",i642str( pObj->cfg.numOfRetensions)); tjsonAddStringToObject(item, "numOfRetensions", i642str(pObj->cfg.numOfRetensions));
for (int32_t i = 0; i < pObj->cfg.numOfRetensions; ++i) { for (int32_t i = 0; i < pObj->cfg.numOfRetensions; ++i) {
SJson *rentensions = tjsonAddArrayToObject(item, "rentensions"); SJson *rentensions = tjsonAddArrayToObject(item, "rentensions");
SJson *rentension = tjsonCreateObject(); SJson *rentension = tjsonCreateObject();
@ -126,7 +126,7 @@ void dumpDb(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "freq", i642str(pRetension->freq)); tjsonAddStringToObject(item, "freq", i642str(pRetension->freq));
tjsonAddStringToObject(item, "freqUnit", i642str(pRetension->freqUnit)); tjsonAddStringToObject(item, "freqUnit", i642str(pRetension->freqUnit));
tjsonAddStringToObject(item, "keep", i642str(pRetension->keep)); tjsonAddStringToObject(item, "keep", i642str(pRetension->keep));
tjsonAddStringToObject(item, "keepUnit",i642str( pRetension->keepUnit)); tjsonAddStringToObject(item, "keepUnit", i642str(pRetension->keepUnit));
} }
sdbRelease(pSdb, pObj); sdbRelease(pSdb, pObj);
@ -150,21 +150,21 @@ void dumpStb(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
tjsonAddStringToObject(item, "tagVer",i642str( pObj->tagVer)); tjsonAddStringToObject(item, "tagVer", i642str(pObj->tagVer));
tjsonAddStringToObject(item, "colVer", i642str(pObj->colVer)); tjsonAddStringToObject(item, "colVer", i642str(pObj->colVer));
tjsonAddStringToObject(item, "smaVer", i642str(pObj->smaVer)); tjsonAddStringToObject(item, "smaVer", i642str(pObj->smaVer));
tjsonAddStringToObject(item, "nextColId", i642str(pObj->nextColId)); tjsonAddStringToObject(item, "nextColId", i642str(pObj->nextColId));
tjsonAddStringToObject(item, "watermark1", i642str(pObj->watermark[0])); tjsonAddStringToObject(item, "watermark1", i642str(pObj->watermark[0]));
tjsonAddStringToObject(item, "watermark2", i642str(pObj->watermark[1])); tjsonAddStringToObject(item, "watermark2", i642str(pObj->watermark[1]));
tjsonAddStringToObject(item, "maxdelay0",i642str( pObj->maxdelay[0])); tjsonAddStringToObject(item, "maxdelay0", i642str(pObj->maxdelay[0]));
tjsonAddStringToObject(item, "maxdelay1",i642str( pObj->maxdelay[1])); tjsonAddStringToObject(item, "maxdelay1", i642str(pObj->maxdelay[1]));
tjsonAddStringToObject(item, "ttl",i642str( pObj->ttl)); tjsonAddStringToObject(item, "ttl", i642str(pObj->ttl));
tjsonAddStringToObject(item, "numOfFuncs",i642str( pObj->numOfFuncs)); tjsonAddStringToObject(item, "numOfFuncs", i642str(pObj->numOfFuncs));
tjsonAddStringToObject(item, "commentLen", i642str(pObj->commentLen)); tjsonAddStringToObject(item, "commentLen", i642str(pObj->commentLen));
tjsonAddStringToObject(item, "ast1Len", i642str(pObj->ast1Len)); tjsonAddStringToObject(item, "ast1Len", i642str(pObj->ast1Len));
tjsonAddStringToObject(item, "ast2Len",i642str( pObj->ast2Len)); tjsonAddStringToObject(item, "ast2Len", i642str(pObj->ast2Len));
tjsonAddStringToObject(item, "numOfColumns",i642str( pObj->numOfColumns)); tjsonAddStringToObject(item, "numOfColumns", i642str(pObj->numOfColumns));
SJson *columns = tjsonAddArrayToObject(item, "columns"); SJson *columns = tjsonAddArrayToObject(item, "columns");
for (int32_t i = 0; i < pObj->numOfColumns; ++i) { for (int32_t i = 0; i < pObj->numOfColumns; ++i) {
SJson *column = tjsonCreateObject(); SJson *column = tjsonCreateObject();
@ -188,7 +188,7 @@ void dumpStb(SSdb *pSdb, SJson *json) {
SSchema *pTag = &pObj->pTags[i]; SSchema *pTag = &pObj->pTags[i];
tjsonAddStringToObject(tag, "type", i642str(pTag->type)); tjsonAddStringToObject(tag, "type", i642str(pTag->type));
tjsonAddStringToObject(tag, "typestr", tDataTypes[pTag->type].name); tjsonAddStringToObject(tag, "typestr", tDataTypes[pTag->type].name);
tjsonAddStringToObject(tag, "flags",i642str( pTag->flags)); tjsonAddStringToObject(tag, "flags", i642str(pTag->flags));
tjsonAddStringToObject(tag, "colId", i642str(pTag->colId)); tjsonAddStringToObject(tag, "colId", i642str(pTag->colId));
tjsonAddStringToObject(tag, "bytes", i642str(pTag->bytes)); tjsonAddStringToObject(tag, "bytes", i642str(pTag->bytes));
tjsonAddStringToObject(tag, "name", pTag->name); tjsonAddStringToObject(tag, "name", pTag->name);
@ -219,16 +219,16 @@ void dumpSma(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
tjsonAddStringToObject(item, "dstTbUid", i642str(pObj->dstTbUid)); tjsonAddStringToObject(item, "dstTbUid", i642str(pObj->dstTbUid));
tjsonAddStringToObject(item, "intervalUnit", i642str(pObj->intervalUnit)); tjsonAddStringToObject(item, "intervalUnit", i642str(pObj->intervalUnit));
tjsonAddStringToObject(item, "slidingUnit",i642str( pObj->slidingUnit)); tjsonAddStringToObject(item, "slidingUnit", i642str(pObj->slidingUnit));
tjsonAddStringToObject(item, "timezone", i642str(pObj->timezone)); tjsonAddStringToObject(item, "timezone", i642str(pObj->timezone));
tjsonAddStringToObject(item, "dstVgId",i642str( pObj->dstVgId)); tjsonAddStringToObject(item, "dstVgId", i642str(pObj->dstVgId));
tjsonAddStringToObject(item, "interval", i642str(pObj->interval)); tjsonAddStringToObject(item, "interval", i642str(pObj->interval));
tjsonAddStringToObject(item, "offset", i642str(pObj->offset)); tjsonAddStringToObject(item, "offset", i642str(pObj->offset));
tjsonAddStringToObject(item, "sliding", i642str(pObj->sliding)); tjsonAddStringToObject(item, "sliding", i642str(pObj->sliding));
tjsonAddStringToObject(item, "exprLen",i642str( pObj->exprLen)); tjsonAddStringToObject(item, "exprLen", i642str(pObj->exprLen));
tjsonAddStringToObject(item, "tagsFilterLen", i642str(pObj->tagsFilterLen)); tjsonAddStringToObject(item, "tagsFilterLen", i642str(pObj->tagsFilterLen));
tjsonAddStringToObject(item, "sqlLen",i642str( pObj->sqlLen)); tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
tjsonAddStringToObject(item, "astLen",i642str( pObj->astLen)); tjsonAddStringToObject(item, "astLen", i642str(pObj->astLen));
sdbRelease(pSdb, pObj); sdbRelease(pSdb, pObj);
} }
} }
@ -247,13 +247,13 @@ void dumpVgroup(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "vgId", i642str(pObj->vgId)); tjsonAddStringToObject(item, "vgId", i642str(pObj->vgId));
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
tjsonAddStringToObject(item, "version",i642str(pObj->version)); tjsonAddStringToObject(item, "version", i642str(pObj->version));
tjsonAddStringToObject(item, "hashBegin", i642str(pObj->hashBegin)); tjsonAddStringToObject(item, "hashBegin", i642str(pObj->hashBegin));
tjsonAddStringToObject(item, "hashEnd", i642str(pObj->hashEnd)); tjsonAddStringToObject(item, "hashEnd", i642str(pObj->hashEnd));
tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->dbName)); tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->dbName));
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
tjsonAddStringToObject(item, "isTsma", i642str(pObj->isTsma)); tjsonAddStringToObject(item, "isTsma", i642str(pObj->isTsma));
tjsonAddStringToObject(item, "replica",i642str( pObj->replica)); tjsonAddStringToObject(item, "replica", i642str(pObj->replica));
for (int32_t i = 0; i < pObj->replica; ++i) { for (int32_t i = 0; i < pObj->replica; ++i) {
SJson *replicas = tjsonAddArrayToObject(item, "replicas"); SJson *replicas = tjsonAddArrayToObject(item, "replicas");
SJson *replica = tjsonCreateObject(); SJson *replica = tjsonCreateObject();
@ -281,13 +281,13 @@ void dumpTopic(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid));
tjsonAddStringToObject(item, "version",i642str( pObj->version)); tjsonAddStringToObject(item, "version", i642str(pObj->version));
tjsonAddStringToObject(item, "subType",i642str( pObj->subType)); tjsonAddStringToObject(item, "subType", i642str(pObj->subType));
tjsonAddStringToObject(item, "withMeta", i642str(pObj->withMeta)); tjsonAddStringToObject(item, "withMeta", i642str(pObj->withMeta));
tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid)); tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid));
tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen)); tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
tjsonAddStringToObject(item, "astLen",i642str( pObj->astLen)); tjsonAddStringToObject(item, "astLen", i642str(pObj->astLen));
tjsonAddStringToObject(item, "sqlLen",i642str( pObj->sqlLen)); tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen));
tjsonAddStringToObject(item, "ntbUid", i642str(pObj->ntbUid)); tjsonAddStringToObject(item, "ntbUid", i642str(pObj->ntbUid));
tjsonAddStringToObject(item, "ctbStbUid", i642str(pObj->ctbStbUid)); tjsonAddStringToObject(item, "ctbStbUid", i642str(pObj->ctbStbUid));
sdbRelease(pSdb, pObj); sdbRelease(pSdb, pObj);
@ -365,9 +365,9 @@ void dumpStream(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "totalLevel", i642str(pObj->totalLevel)); tjsonAddStringToObject(item, "totalLevel", i642str(pObj->totalLevel));
tjsonAddStringToObject(item, "smaId", i642str(pObj->smaId)); tjsonAddStringToObject(item, "smaId", i642str(pObj->smaId));
tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); tjsonAddStringToObject(item, "uid", i642str(pObj->uid));
tjsonAddStringToObject(item, "status",i642str( pObj->status)); tjsonAddStringToObject(item, "status", i642str(pObj->status));
tjsonAddStringToObject(item, "igExpired",i642str( pObj->igExpired)); tjsonAddStringToObject(item, "igExpired", i642str(pObj->igExpired));
tjsonAddStringToObject(item, "trigger",i642str( pObj->trigger)); tjsonAddStringToObject(item, "trigger", i642str(pObj->trigger));
tjsonAddStringToObject(item, "triggerParam", i642str(pObj->triggerParam)); tjsonAddStringToObject(item, "triggerParam", i642str(pObj->triggerParam));
tjsonAddStringToObject(item, "watermark", i642str(pObj->watermark)); tjsonAddStringToObject(item, "watermark", i642str(pObj->watermark));
tjsonAddStringToObject(item, "sourceDbUid", i642str(pObj->sourceDbUid)); tjsonAddStringToObject(item, "sourceDbUid", i642str(pObj->sourceDbUid));
@ -419,9 +419,9 @@ void dumpUser(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "acct", pObj->acct); tjsonAddStringToObject(item, "acct", pObj->acct);
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
tjsonAddStringToObject(item, "superUser",i642str( pObj->superUser)); tjsonAddStringToObject(item, "superUser", i642str(pObj->superUser));
tjsonAddStringToObject(item, "authVersion", i642str(pObj->authVersion)); tjsonAddStringToObject(item, "authVersion", i642str(pObj->authVersion));
tjsonAddStringToObject(item, "numOfReadDbs",i642str( taosHashGetSize(pObj->readDbs))); tjsonAddStringToObject(item, "numOfReadDbs", i642str(taosHashGetSize(pObj->readDbs)));
tjsonAddStringToObject(item, "numOfWriteDbs", i642str(taosHashGetSize(pObj->writeDbs))); tjsonAddStringToObject(item, "numOfWriteDbs", i642str(taosHashGetSize(pObj->writeDbs)));
sdbRelease(pSdb, pObj); sdbRelease(pSdb, pObj);
} }
@ -438,10 +438,10 @@ void dumpDnode(SSdb *pSdb, SJson *json) {
SJson *item = tjsonCreateObject(); SJson *item = tjsonCreateObject();
tjsonAddItemToArray(items, item); tjsonAddItemToArray(items, item);
tjsonAddStringToObject(item, "id",i642str( pObj->id)); tjsonAddStringToObject(item, "id", i642str(pObj->id));
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
tjsonAddStringToObject(item, "port",i642str( pObj->port)); tjsonAddStringToObject(item, "port", i642str(pObj->port));
tjsonAddStringToObject(item, "fqdn", pObj->fqdn); tjsonAddStringToObject(item, "fqdn", pObj->fqdn);
sdbRelease(pSdb, pObj); sdbRelease(pSdb, pObj);
} }
@ -462,7 +462,7 @@ void dumpSnode(SSdb *pSdb, SJson *json) {
SJson *item = tjsonCreateObject(); SJson *item = tjsonCreateObject();
tjsonAddItemToArray(items, item); tjsonAddItemToArray(items, item);
tjsonAddStringToObject(item, "id",i642str( pObj->id)); tjsonAddStringToObject(item, "id", i642str(pObj->id));
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime));
sdbRelease(pSdb, pObj); sdbRelease(pSdb, pObj);
@ -538,15 +538,15 @@ void dumpTrans(SSdb *pSdb, SJson *json) {
tjsonAddStringToObject(item, "id", i642str(pObj->id)); tjsonAddStringToObject(item, "id", i642str(pObj->id));
tjsonAddStringToObject(item, "stage", i642str(pObj->stage)); tjsonAddStringToObject(item, "stage", i642str(pObj->stage));
tjsonAddStringToObject(item, "policy", i642str(pObj->policy)); tjsonAddStringToObject(item, "policy", i642str(pObj->policy));
tjsonAddStringToObject(item, "conflict",i642str( pObj->conflict)); tjsonAddStringToObject(item, "conflict", i642str(pObj->conflict));
tjsonAddStringToObject(item, "exec", i642str(pObj->exec)); tjsonAddStringToObject(item, "exec", i642str(pObj->exec));
tjsonAddStringToObject(item, "oper", i642str(pObj->oper)); tjsonAddStringToObject(item, "oper", i642str(pObj->oper));
tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime));
tjsonAddStringToObject(item, "dbname", pObj->dbname); tjsonAddStringToObject(item, "dbname", pObj->dbname);
tjsonAddStringToObject(item, "stbname", pObj->stbname); tjsonAddStringToObject(item, "stbname", pObj->stbname);
tjsonAddStringToObject(item, "opername", pObj->opername); tjsonAddStringToObject(item, "opername", pObj->opername);
tjsonAddStringToObject(item, "commitLogNum",i642str( taosArrayGetSize(pObj->commitActions))); tjsonAddStringToObject(item, "commitLogNum", i642str(taosArrayGetSize(pObj->commitActions)));
tjsonAddStringToObject(item, "redoActionNum",i642str(taosArrayGetSize(pObj->redoActions))); tjsonAddStringToObject(item, "redoActionNum", i642str(taosArrayGetSize(pObj->redoActions)));
tjsonAddStringToObject(item, "undoActionNum", i642str(taosArrayGetSize(pObj->undoActions))); tjsonAddStringToObject(item, "undoActionNum", i642str(taosArrayGetSize(pObj->undoActions)));
sdbRelease(pSdb, pObj); sdbRelease(pSdb, pObj);
} }

View File

@ -15,8 +15,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "mndMnode.h" #include "mndMnode.h"
#include "mndPrivilege.h"
#include "mndDnode.h" #include "mndDnode.h"
#include "mndPrivilege.h"
#include "mndShow.h" #include "mndShow.h"
#include "mndSync.h" #include "mndSync.h"
#include "mndTrans.h" #include "mndTrans.h"

View File

@ -46,7 +46,7 @@ int32_t mndPerfsInitMeta(SHashObj *hash) {
meta.tversion = 1; meta.tversion = 1;
size_t size = 0; size_t size = 0;
const SSysTableMeta* pSysDbTableMeta = NULL; const SSysTableMeta *pSysDbTableMeta = NULL;
getPerfDbMeta(&pSysDbTableMeta, &size); getPerfDbMeta(&pSysDbTableMeta, &size);
for (int32_t i = 0; i < size; ++i) { for (int32_t i = 0; i < size; ++i) {
@ -150,4 +150,3 @@ void mndCleanupPerfs(SMnode *pMnode) {
taosHashCleanup(pMnode->perfsMeta); taosHashCleanup(pMnode->perfsMeta);
pMnode->perfsMeta = NULL; pMnode->perfsMeta = NULL;
} }

View File

@ -15,8 +15,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "mndQnode.h" #include "mndQnode.h"
#include "mndPrivilege.h"
#include "mndDnode.h" #include "mndDnode.h"
#include "mndPrivilege.h"
#include "mndShow.h" #include "mndShow.h"
#include "mndTrans.h" #include "mndTrans.h"
#include "mndUser.h" #include "mndUser.h"

View File

@ -67,33 +67,33 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
int32_t code = 0; int32_t code = 0;
int32_t offset = 0; int32_t offset = 0;
int32_t rspSize = 0; int32_t rspSize = 0;
SBatchReq *batchReq = (SBatchReq*)pMsg->pCont; SBatchReq *batchReq = (SBatchReq *)pMsg->pCont;
int32_t msgNum = ntohl(batchReq->msgNum); int32_t msgNum = ntohl(batchReq->msgNum);
offset += sizeof(SBatchReq); offset += sizeof(SBatchReq);
SBatchMsg req = {0}; SBatchMsg req = {0};
SBatchRsp rsp = {0}; SBatchRsp rsp = {0};
SRpcMsg reqMsg = *pMsg; SRpcMsg reqMsg = *pMsg;
SRpcMsg rspMsg = {0}; SRpcMsg rspMsg = {0};
void* pRsp = NULL; void *pRsp = NULL;
SMnode *pMnode = pMsg->info.node; SMnode *pMnode = pMsg->info.node;
SArray* batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp)); SArray *batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp));
if (NULL == batchRsp) { if (NULL == batchRsp) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit; goto _exit;
} }
for (int32_t i = 0; i < msgNum; ++i) { for (int32_t i = 0; i < msgNum; ++i) {
req.msgIdx = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
offset += sizeof(req.msgIdx); offset += sizeof(req.msgIdx);
req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
offset += sizeof(req.msgType); offset += sizeof(req.msgType);
req.msgLen = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); req.msgLen = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
offset += sizeof(req.msgLen); offset += sizeof(req.msgLen);
req.msg = (char*)pMsg->pCont + offset; req.msg = (char *)pMsg->pCont + offset;
offset += req.msgLen; offset += req.msgLen;
reqMsg.msgType = req.msgType; reqMsg.msgType = req.msgType;
@ -133,20 +133,20 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
goto _exit; goto _exit;
} }
*(int32_t*)((char*)pRsp + offset) = htonl(msgNum); *(int32_t *)((char *)pRsp + offset) = htonl(msgNum);
offset += sizeof(msgNum); offset += sizeof(msgNum);
for (int32_t i = 0; i < msgNum; ++i) { for (int32_t i = 0; i < msgNum; ++i) {
SBatchRsp *p = taosArrayGet(batchRsp, i); SBatchRsp *p = taosArrayGet(batchRsp, i);
*(int32_t*)((char*)pRsp + offset) = htonl(p->reqType); *(int32_t *)((char *)pRsp + offset) = htonl(p->reqType);
offset += sizeof(p->reqType); offset += sizeof(p->reqType);
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgIdx); *(int32_t *)((char *)pRsp + offset) = htonl(p->msgIdx);
offset += sizeof(p->msgIdx); offset += sizeof(p->msgIdx);
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen); *(int32_t *)((char *)pRsp + offset) = htonl(p->msgLen);
offset += sizeof(p->msgLen); offset += sizeof(p->msgLen);
*(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode); *(int32_t *)((char *)pRsp + offset) = htonl(p->rspCode);
offset += sizeof(p->rspCode); offset += sizeof(p->rspCode);
memcpy((char*)pRsp + offset, p->msg, p->msgLen); memcpy((char *)pRsp + offset, p->msg, p->msgLen);
offset += p->msgLen; offset += p->msgLen;
rpcFreeCont(p->msg); rpcFreeCont(p->msg);

View File

@ -15,8 +15,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "mndSnode.h" #include "mndSnode.h"
#include "mndPrivilege.h"
#include "mndDnode.h" #include "mndDnode.h"
#include "mndPrivilege.h"
#include "mndShow.h" #include "mndShow.h"
#include "mndTrans.h" #include "mndTrans.h"
#include "mndUser.h" #include "mndUser.h"

View File

@ -1179,8 +1179,8 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName,
SNode *pNode = NULL; SNode *pNode = NULL;
FOREACH(pNode, pNodeList) { FOREACH(pNode, pNodeList) {
SColumnNode *pCol = (SColumnNode *)pNode; SColumnNode *pCol = (SColumnNode *)pNode;
mInfo("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId, mInfo("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId, pCol->tableId,
pCol->tableId, pTopic->ctbStbUid); pTopic->ctbStbUid);
if (pCol->tableId != suid && pTopic->ctbStbUid != suid) { if (pCol->tableId != suid && pTopic->ctbStbUid != suid) {
mInfo("topic:%s, check colId:%d passed", pTopic->name, pCol->colId); mInfo("topic:%s, check colId:%d passed", pTopic->name, pCol->colId);
@ -1256,8 +1256,8 @@ static int32_t mndCheckAlterColForTSma(SMnode *pMnode, const char *stbFullName,
pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma);
if (pIter == NULL) break; if (pIter == NULL) break;
mInfo("tsma:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, sql:%s", pSma->name, mInfo("tsma:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, sql:%s", pSma->name, stbFullName,
stbFullName, suid, colId, pSma->sql); suid, colId, pSma->sql);
SNode *pAst = NULL; SNode *pAst = NULL;
if (nodesStringToNode(pSma->ast, &pAst) != 0) { if (nodesStringToNode(pSma->ast, &pAst) != 0) {

View File

@ -1555,8 +1555,8 @@ static int32_t mndCheckDnodeMemory(SMnode *pMnode, SDbObj *pOldDb, SDbObj *pNewD
terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE; terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE;
return -1; return -1;
} else if (inVgroup) { } else if (inVgroup) {
mInfo("db:%s, vgId:%d, memory in dnode:%d, avail:%" PRId64 " used:%" PRId64, pNewVgroup->dbName, mInfo("db:%s, vgId:%d, memory in dnode:%d, avail:%" PRId64 " used:%" PRId64, pNewVgroup->dbName, pNewVgroup->vgId,
pNewVgroup->vgId, pDnode->id, pDnode->memAvail, pDnode->memUsed); pDnode->id, pDnode->memAvail, pDnode->memUsed);
} else { } else {
} }
} }

View File

@ -29,7 +29,7 @@ class MndTestFunc : public ::testing::Test {
Testbase MndTestFunc::test; Testbase MndTestFunc::test;
void MndTestFunc::SetCode(SCreateFuncReq *pReq, const char *pCode, int32_t size) { void MndTestFunc::SetCode(SCreateFuncReq* pReq, const char* pCode, int32_t size) {
pReq->pCode = (char*)taosMemoryMalloc(size); pReq->pCode = (char*)taosMemoryMalloc(size);
memcpy(pReq->pCode, pCode, size); memcpy(pReq->pCode, pCode, size);
pReq->codeLen = size; pReq->codeLen = size;
@ -41,9 +41,7 @@ void MndTestFunc::SetComment(SCreateFuncReq* pReq, const char* pComment) {
strcpy(pReq->pComment, pComment); strcpy(pReq->pComment, pComment);
} }
void MndTestFunc::SetBufSize(SCreateFuncReq* pReq, int32_t size) { void MndTestFunc::SetBufSize(SCreateFuncReq* pReq, int32_t size) { pReq->bufSize = size; }
pReq->bufSize = size;
}
TEST_F(MndTestFunc, 01_Show_Func) { TEST_F(MndTestFunc, 01_Show_Func) {
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", ""); test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", "");
@ -509,5 +507,4 @@ TEST_F(MndTestFunc, 05_Actual_code) {
} }
tFreeSRetrieveFuncRsp(&retrieveRsp); tFreeSRetrieveFuncRsp(&retrieveRsp);
} }
} }

View File

@ -32,7 +32,8 @@ class MndTestStb : public ::testing::Test {
void* BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes, int32_t* pContLen); void* BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes, int32_t* pContLen);
void* BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen); void* BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
void* BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen); void* BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen);
void* BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes, int32_t* pContLen, int32_t verInBlock); void* BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes, int32_t* pContLen,
int32_t verInBlock);
}; };
Testbase MndTestStb::test; Testbase MndTestStb::test;

View File

@ -306,8 +306,8 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
pSdb->commitTerm = pSdb->applyTerm; pSdb->commitTerm = pSdb->applyTerm;
pSdb->commitConfig = pSdb->applyConfig; pSdb->commitConfig = pSdb->applyConfig;
memcpy(pSdb->tableVer, tableVer, sizeof(tableVer)); memcpy(pSdb->tableVer, tableVer, sizeof(tableVer));
mInfo("read sdb file:%s success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64, file, mInfo("read sdb file:%s success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64, file, pSdb->commitIndex,
pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig); pSdb->commitTerm, pSdb->commitConfig);
_OVER: _OVER:
taosCloseFile(&pFile); taosCloseFile(&pFile);
@ -556,8 +556,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter
if (term != NULL) *term = commitTerm; if (term != NULL) *term = commitTerm;
if (config != NULL) *config = commitConfig; if (config != NULL) *config = commitConfig;
mInfo("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 mInfo("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s",
" file:%s",
pIter, commitIndex, commitTerm, commitConfig, pIter->name); pIter, commitIndex, commitTerm, commitConfig, pIter->name);
return 0; return 0;
} }

View File

@ -20,8 +20,8 @@
#include "tlog.h" #include "tlog.h"
#include "tmsg.h" #include "tmsg.h"
#include "trpc.h"
#include "tmsgcb.h" #include "tmsgcb.h"
#include "trpc.h"
#include "qnode.h" #include "qnode.h"

View File

@ -14,10 +14,10 @@
*/ */
#include "executor.h" #include "executor.h"
#include "libs/function/function.h"
#include "qndInt.h" #include "qndInt.h"
#include "query.h" #include "query.h"
#include "qworker.h" #include "qworker.h"
#include "libs/function/function.h"
SQnode *qndOpen(const SQnodeOpt *pOption) { SQnode *qndOpen(const SQnodeOpt *pOption) {
SQnode *pQnode = taosMemoryCalloc(1, sizeof(SQnode)); SQnode *pQnode = taosMemoryCalloc(1, sizeof(SQnode));
@ -64,7 +64,7 @@ int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) {
return 0; return 0;
} }
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg) { int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg *pMsg) {
if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) { if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) {
return 0; return 0;
} }

View File

@ -34,7 +34,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
if (tEncodeI64(pCoder, pME->ctbEntry.ctime) < 0) return -1; if (tEncodeI64(pCoder, pME->ctbEntry.ctime) < 0) return -1;
if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1; if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1;
if (tEncodeI32v(pCoder, pME->ctbEntry.commentLen) < 0) return -1; if (tEncodeI32v(pCoder, pME->ctbEntry.commentLen) < 0) return -1;
if (pME->ctbEntry.commentLen > 0){ if (pME->ctbEntry.commentLen > 0) {
if (tEncodeCStr(pCoder, pME->ctbEntry.comment) < 0) return -1; if (tEncodeCStr(pCoder, pME->ctbEntry.comment) < 0) return -1;
} }
if (tEncodeI64(pCoder, pME->ctbEntry.suid) < 0) return -1; if (tEncodeI64(pCoder, pME->ctbEntry.suid) < 0) return -1;
@ -43,7 +43,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
if (tEncodeI64(pCoder, pME->ntbEntry.ctime) < 0) return -1; if (tEncodeI64(pCoder, pME->ntbEntry.ctime) < 0) return -1;
if (tEncodeI32(pCoder, pME->ntbEntry.ttlDays) < 0) return -1; if (tEncodeI32(pCoder, pME->ntbEntry.ttlDays) < 0) return -1;
if (tEncodeI32v(pCoder, pME->ntbEntry.commentLen) < 0) return -1; if (tEncodeI32v(pCoder, pME->ntbEntry.commentLen) < 0) return -1;
if (pME->ntbEntry.commentLen > 0){ if (pME->ntbEntry.commentLen > 0) {
if (tEncodeCStr(pCoder, pME->ntbEntry.comment) < 0) return -1; if (tEncodeCStr(pCoder, pME->ntbEntry.comment) < 0) return -1;
} }
if (tEncodeI32v(pCoder, pME->ntbEntry.ncid) < 0) return -1; if (tEncodeI32v(pCoder, pME->ntbEntry.ncid) < 0) return -1;
@ -77,9 +77,8 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
if (tDecodeI64(pCoder, &pME->ctbEntry.ctime) < 0) return -1; if (tDecodeI64(pCoder, &pME->ctbEntry.ctime) < 0) return -1;
if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1; if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1;
if (tDecodeI32v(pCoder, &pME->ctbEntry.commentLen) < 0) return -1; if (tDecodeI32v(pCoder, &pME->ctbEntry.commentLen) < 0) return -1;
if (pME->ctbEntry.commentLen > 0){ if (pME->ctbEntry.commentLen > 0) {
if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0) if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0) return -1;
return -1;
} }
if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1; if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1;
if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO) if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO)
@ -87,7 +86,7 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
if (tDecodeI64(pCoder, &pME->ntbEntry.ctime) < 0) return -1; if (tDecodeI64(pCoder, &pME->ntbEntry.ctime) < 0) return -1;
if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1; if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1;
if (tDecodeI32v(pCoder, &pME->ntbEntry.commentLen) < 0) return -1; if (tDecodeI32v(pCoder, &pME->ntbEntry.commentLen) < 0) return -1;
if (pME->ntbEntry.commentLen > 0){ if (pME->ntbEntry.commentLen > 0) {
if (tDecodeCStr(pCoder, &pME->ntbEntry.comment) < 0) return -1; if (tDecodeCStr(pCoder, &pME->ntbEntry.comment) < 0) return -1;
} }
if (tDecodeI32v(pCoder, &pME->ntbEntry.ncid) < 0) return -1; if (tDecodeI32v(pCoder, &pME->ntbEntry.ncid) < 0) return -1;

View File

@ -92,7 +92,8 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p
days = freqDuration; days = freqDuration;
} }
end: end:
smaInfo("vgId:%d, evaluated duration for level %" PRIi8 " is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration); smaInfo("vgId:%d, evaluated duration for level %" PRIi8 " is %d, raw val:%d", TD_VID(pVnode), level + 1, days,
duration);
return days; return days;
} }

View File

@ -328,4 +328,3 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
tdbTbcClose(pCur); tdbTbcClose(pCur);
return 0; return 0;
} }

View File

@ -28,17 +28,17 @@ struct SLDataIter {
uint64_t uid; uint64_t uid;
STimeWindow timeWindow; STimeWindow timeWindow;
SVersionRange verRange; SVersionRange verRange;
SSttBlockLoadInfo* pBlockLoadInfo; SSttBlockLoadInfo *pBlockLoadInfo;
}; };
SSttBlockLoadInfo* tCreateLastBlockLoadInfo(STSchema* pSchema, int16_t* colList, int32_t numOfCols) { SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols) {
SSttBlockLoadInfo* pLoadInfo = taosMemoryCalloc(TSDB_DEFAULT_STT_FILE, sizeof(SSttBlockLoadInfo)); SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(TSDB_DEFAULT_STT_FILE, sizeof(SSttBlockLoadInfo));
if (pLoadInfo == NULL) { if (pLoadInfo == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL; return NULL;
} }
for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) { for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
pLoadInfo[i].blockIndex[0] = -1; pLoadInfo[i].blockIndex[0] = -1;
pLoadInfo[i].blockIndex[1] = -1; pLoadInfo[i].blockIndex[1] = -1;
pLoadInfo[i].currentLoadBlockIndex = 1; pLoadInfo[i].currentLoadBlockIndex = 1;
@ -62,8 +62,8 @@ SSttBlockLoadInfo* tCreateLastBlockLoadInfo(STSchema* pSchema, int16_t* colList,
return pLoadInfo; return pLoadInfo;
} }
void resetLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) { void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) { for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
pLoadInfo[i].currentLoadBlockIndex = 1; pLoadInfo[i].currentLoadBlockIndex = 1;
pLoadInfo[i].blockIndex[0] = -1; pLoadInfo[i].blockIndex[0] = -1;
pLoadInfo[i].blockIndex[1] = -1; pLoadInfo[i].blockIndex[1] = -1;
@ -75,15 +75,15 @@ void resetLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) {
} }
} }
void getLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo, int64_t* blocks, double* el) { void getLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, int64_t *blocks, double *el) {
for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) { for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
*el += pLoadInfo[i].elapsedTime; *el += pLoadInfo[i].elapsedTime;
*blocks += pLoadInfo[i].loadBlocks; *blocks += pLoadInfo[i].loadBlocks;
} }
} }
void* destroyLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) { void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo) {
for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) { for (int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
pLoadInfo[i].currentLoadBlockIndex = 1; pLoadInfo[i].currentLoadBlockIndex = 1;
pLoadInfo[i].blockIndex[0] = -1; pLoadInfo[i].blockIndex[0] = -1;
pLoadInfo[i].blockIndex[1] = -1; pLoadInfo[i].blockIndex[1] = -1;
@ -98,10 +98,10 @@ void* destroyLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) {
return NULL; return NULL;
} }
static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) { static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) {
int32_t code = 0; int32_t code = 0;
SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo; SSttBlockLoadInfo *pInfo = pIter->pBlockLoadInfo;
if (pInfo->blockIndex[0] == pIter->iSttBlk) { if (pInfo->blockIndex[0] == pIter->iSttBlk) {
return &pInfo->blockData[0]; return &pInfo->blockData[0];
} }
@ -114,7 +114,7 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) {
if (pIter->pSttBlk != NULL) { // current block not loaded yet if (pIter->pSttBlk != NULL) { // current block not loaded yet
int64_t st = taosGetTimestampUs(); int64_t st = taosGetTimestampUs();
SBlockData* pBlock = &pInfo->blockData[pInfo->currentLoadBlockIndex]; SBlockData *pBlock = &pInfo->blockData[pInfo->currentLoadBlockIndex];
TABLEID id = {0}; TABLEID id = {0};
if (pIter->pSttBlk->suid != 0) { if (pIter->pSttBlk->suid != 0) {
@ -126,11 +126,12 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) {
tBlockDataInit(pBlock, &id, pInfo->pSchema, pInfo->colIds, pInfo->numOfCols); tBlockDataInit(pBlock, &id, pInfo->pSchema, pInfo->colIds, pInfo->numOfCols);
code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, pBlock); code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, pBlock);
double el = (taosGetTimestampUs() - st)/ 1000.0; double el = (taosGetTimestampUs() - st) / 1000.0;
pInfo->elapsedTime += el; pInfo->elapsedTime += el;
pInfo->loadBlocks += 1; pInfo->loadBlocks += 1;
tsdbDebug("read last block, index:%d, last file index:%d, elapsed time:%.2f ms, %s", pIter->iSttBlk, pIter->iStt, el, idStr); tsdbDebug("read last block, index:%d, last file index:%d, elapsed time:%.2f ms, %s", pIter->iSttBlk, pIter->iStt,
el, idStr);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto _exit; goto _exit;
} }
@ -141,7 +142,7 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) {
return &pInfo->blockData[pInfo->currentLoadBlockIndex]; return &pInfo->blockData[pInfo->currentLoadBlockIndex];
_exit: _exit:
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
terrno = code; terrno = code;
} }
@ -150,16 +151,17 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) {
} }
// find the earliest block that contains the required records // find the earliest block that contains the required records
static FORCE_INLINE int32_t findEarliestIndex(int32_t index, uint64_t uid, const SSttBlk* pBlockList, int32_t num, int32_t backward) { static FORCE_INLINE int32_t findEarliestIndex(int32_t index, uint64_t uid, const SSttBlk *pBlockList, int32_t num,
int32_t backward) {
int32_t i = index; int32_t i = index;
int32_t step = backward? 1:-1; int32_t step = backward ? 1 : -1;
while (i >= 0 && i < num && uid >= pBlockList[i].minUid && uid <= pBlockList[i].maxUid) { while (i >= 0 && i < num && uid >= pBlockList[i].minUid && uid <= pBlockList[i].maxUid) {
i += step; i += step;
} }
return i - step; return i - step;
} }
static int32_t binarySearchForStartBlock(SSttBlk*pBlockList, int32_t num, uint64_t uid, int32_t backward) { static int32_t binarySearchForStartBlock(SSttBlk *pBlockList, int32_t num, uint64_t uid, int32_t backward) {
int32_t midPos = -1; int32_t midPos = -1;
if (num <= 0) { if (num <= 0) {
return -1; return -1;
@ -195,16 +197,17 @@ static int32_t binarySearchForStartBlock(SSttBlk*pBlockList, int32_t num, uint64
} }
} }
static FORCE_INLINE int32_t findEarliestRow(int32_t index, uint64_t uid, const uint64_t* uidList, int32_t num, int32_t backward) { static FORCE_INLINE int32_t findEarliestRow(int32_t index, uint64_t uid, const uint64_t *uidList, int32_t num,
int32_t backward) {
int32_t i = index; int32_t i = index;
int32_t step = backward? 1:-1; int32_t step = backward ? 1 : -1;
while (i >= 0 && i < num && uid == uidList[i]) { while (i >= 0 && i < num && uid == uidList[i]) {
i += step; i += step;
} }
return i - step; return i - step;
} }
static int32_t binarySearchForStartRowIndex(uint64_t* uidList, int32_t num, uint64_t uid, int32_t backward) { static int32_t binarySearchForStartRowIndex(uint64_t *uidList, int32_t num, uint64_t uid, int32_t backward) {
int32_t firstPos = 0; int32_t firstPos = 0;
int32_t lastPos = num - 1; int32_t lastPos = num - 1;
@ -236,8 +239,8 @@ static int32_t binarySearchForStartRowIndex(uint64_t* uidList, int32_t num, uint
} }
int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t iStt, int8_t backward, uint64_t suid, int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t iStt, int8_t backward, uint64_t suid,
uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange, SSttBlockLoadInfo* pBlockLoadInfo, uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange, SSttBlockLoadInfo *pBlockLoadInfo,
const char* idStr) { const char *idStr) {
int32_t code = 0; int32_t code = 0;
*pIter = taosMemoryCalloc(1, sizeof(SLDataIter)); *pIter = taosMemoryCalloc(1, sizeof(SLDataIter));
if (*pIter == NULL) { if (*pIter == NULL) {
@ -277,7 +280,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
} else if (pStart->suid != suid) { } else if (pStart->suid != suid) {
// no qualified stt block existed // no qualified stt block existed
(*pIter)->iSttBlk = -1; (*pIter)->iSttBlk = -1;
double el = (taosGetTimestampUs() - st)/1000.0; double el = (taosGetTimestampUs() - st) / 1000.0;
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr); tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
return code; return code;
} }
@ -302,7 +305,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t
} }
} }
double el = (taosGetTimestampUs() - st)/1000.0; double el = (taosGetTimestampUs() - st) / 1000.0;
tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr); tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr);
} }
@ -319,9 +322,7 @@ _exit:
return code; return code;
} }
void tLDataIterClose(SLDataIter *pIter) { void tLDataIterClose(SLDataIter *pIter) { taosMemoryFree(pIter); }
taosMemoryFree(pIter);
}
void tLDataIterNextBlock(SLDataIter *pIter) { void tLDataIterNextBlock(SLDataIter *pIter) {
int32_t step = pIter->backward ? -1 : 1; int32_t step = pIter->backward ? -1 : 1;
@ -374,7 +375,7 @@ void tLDataIterNextBlock(SLDataIter *pIter) {
} }
} }
static void findNextValidRow(SLDataIter *pIter, const char* idStr) { static void findNextValidRow(SLDataIter *pIter, const char *idStr) {
int32_t step = pIter->backward ? -1 : 1; int32_t step = pIter->backward ? -1 : 1;
bool hasVal = false; bool hasVal = false;
@ -383,8 +384,9 @@ static void findNextValidRow(SLDataIter *pIter, const char* idStr) {
SBlockData *pBlockData = loadLastBlock(pIter, idStr); SBlockData *pBlockData = loadLastBlock(pIter, idStr);
// mostly we only need to find the start position for a given table // mostly we only need to find the start position for a given table
if ((((i == 0) && (!pIter->backward)) || (i == pBlockData->nRow - 1 && pIter->backward)) && pBlockData->aUid != NULL) { if ((((i == 0) && (!pIter->backward)) || (i == pBlockData->nRow - 1 && pIter->backward)) &&
i = binarySearchForStartRowIndex((uint64_t*)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward); pBlockData->aUid != NULL) {
i = binarySearchForStartRowIndex((uint64_t *)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward);
if (i == -1) { if (i == -1) {
pIter->iRow = -1; pIter->iRow = -1;
return; return;
@ -396,13 +398,15 @@ static void findNextValidRow(SLDataIter *pIter, const char* idStr) {
if (!pIter->backward) { if (!pIter->backward) {
/*if (pBlockData->aUid[i] < pIter->uid) { /*if (pBlockData->aUid[i] < pIter->uid) {
continue; continue;
} else */if (pBlockData->aUid[i] > pIter->uid) { } else */
if (pBlockData->aUid[i] > pIter->uid) {
break; break;
} }
} else { } else {
/*if (pBlockData->aUid[i] > pIter->uid) { /*if (pBlockData->aUid[i] > pIter->uid) {
continue; continue;
} else */if (pBlockData->aUid[i] < pIter->uid) { } else */
if (pBlockData->aUid[i] < pIter->uid) {
break; break;
} }
} }
@ -440,7 +444,7 @@ static void findNextValidRow(SLDataIter *pIter, const char* idStr) {
pIter->iRow = (hasVal) ? i : -1; pIter->iRow = (hasVal) ? i : -1;
} }
bool tLDataIterNextRow(SLDataIter *pIter, const char* idStr) { bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
int32_t code = 0; int32_t code = 0;
int32_t step = pIter->backward ? -1 : 1; int32_t step = pIter->backward ? -1 : 1;
@ -527,8 +531,9 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
pMTree->destroyLoadInfo = destroyLoadInfo; pMTree->destroyLoadInfo = destroyLoadInfo;
for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file
struct SLDataIter* pIter = NULL; struct SLDataIter *pIter = NULL;
code = tLDataIterOpen(&pIter, pFReader, i, pMTree->backward, suid, uid, pTimeWindow, pVerRange, &pMTree->pLoadInfo[i], pMTree->idStr); code = tLDataIterOpen(&pIter, pFReader, i, pMTree->backward, suid, uid, pTimeWindow, pVerRange,
&pMTree->pLoadInfo[i], pMTree->idStr);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto _end; goto _end;
} }

View File

@ -799,4 +799,3 @@ bool vnodeIsLeader(SVnode *pVnode) {
return true; return true;
} }

View File

@ -20,8 +20,8 @@
#include <tglobal.h> #include <tglobal.h>
#include <iostream> #include <iostream>
#include <vnodeInt.h>
#include <tmsg.h> #include <tmsg.h>
#include <vnodeInt.h>
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings" #pragma GCC diagnostic ignored "-Wwrite-strings"
@ -441,7 +441,6 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
pDataBlock->pDataBlock = taosArrayInit(tSmaNumOfCols, sizeof(SColumnInfoData *)); pDataBlock->pDataBlock = taosArrayInit(tSmaNumOfCols, sizeof(SColumnInfoData *));
EXPECT_NE(pDataBlock->pDataBlock, nullptr); EXPECT_NE(pDataBlock->pDataBlock, nullptr);
for (int32_t c = 0; c < tSmaNumOfCols; ++c) { for (int32_t c = 0; c < tSmaNumOfCols; ++c) {
SColumnInfoData *pColInfoData = (SColumnInfoData *)taosMemoryCalloc(1, sizeof(SColumnInfoData)); SColumnInfoData *pColInfoData = (SColumnInfoData *)taosMemoryCalloc(1, sizeof(SColumnInfoData));
EXPECT_NE(pColInfoData, nullptr); EXPECT_NE(pColInfoData, nullptr);

View File

@ -31,14 +31,13 @@ typedef struct TdDir {
HANDLE hFind; HANDLE hFind;
} TdDir; } TdDir;
enum enum {
{
WRDE_NOSPACE = 1, /* Ran out of memory. */ WRDE_NOSPACE = 1, /* Ran out of memory. */
WRDE_BADCHAR, /* A metachar appears in the wrong place. */ WRDE_BADCHAR, /* A metachar appears in the wrong place. */
WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */ WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */
WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */ WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */
WRDE_SYNTAX /* Shell syntax error. */ WRDE_SYNTAX /* Shell syntax error. */
}; };
int wordexp(char *words, wordexp_t *pwordexp, int flags) { int wordexp(char *words, wordexp_t *pwordexp, int flags) {
pwordexp->we_offs = 0; pwordexp->we_offs = 0;
@ -301,18 +300,20 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) { int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
wordexp_t full_path; wordexp_t full_path;
switch (wordexp (dirname, &full_path, 0)) { switch (wordexp(dirname, &full_path, 0)) {
case 0: case 0:
break; break;
case WRDE_NOSPACE: case WRDE_NOSPACE:
wordfree (&full_path); wordfree(&full_path);
// printf("failed to expand path:%s since Out of memory\n", dirname); // printf("failed to expand path:%s since Out of memory\n", dirname);
return -1; return -1;
case WRDE_BADCHAR: case WRDE_BADCHAR:
// printf("failed to expand path:%s since illegal occurrence of newline or one of |, &, ;, <, >, (, ), {, }\n", dirname); // printf("failed to expand path:%s since illegal occurrence of newline or one of |, &, ;, <, >, (, ), {, }\n",
// dirname);
return -1; return -1;
case WRDE_SYNTAX: case WRDE_SYNTAX:
// printf("failed to expand path:%s since Shell syntax error, such as unbalanced parentheses or unmatched quotes\n", dirname); // printf("failed to expand path:%s since Shell syntax error, such as unbalanced parentheses or unmatched
// quotes\n", dirname);
return -1; return -1;
default: default:
// printf("failed to expand path:%s since %s\n", dirname, strerror(errno)); // printf("failed to expand path:%s since %s\n", dirname, strerror(errno));
@ -417,7 +418,7 @@ TdDirPtr taosOpenDir(const char *dirname) {
DIR *pDir = opendir(dirname); DIR *pDir = opendir(dirname);
if (pDir == NULL) return NULL; if (pDir == NULL) return NULL;
TdDirPtr dirPtr = (TdDirPtr)taosMemoryMalloc(sizeof(TdDir)); TdDirPtr dirPtr = (TdDirPtr)taosMemoryMalloc(sizeof(TdDir));
dirPtr->dirEntryPtr = (TdDirEntryPtr)&(dirPtr->dirEntry1); dirPtr->dirEntryPtr = (TdDirEntryPtr) & (dirPtr->dirEntry1);
dirPtr->pDir = pDir; dirPtr->pDir = pDir;
return dirPtr; return dirPtr;
#else #else
@ -435,7 +436,7 @@ TdDirEntryPtr taosReadDir(TdDirPtr pDir) {
} }
return (TdDirEntryPtr) & (pDir->dirEntry.findFileData); return (TdDirEntryPtr) & (pDir->dirEntry.findFileData);
#elif defined(DARWIN) #elif defined(DARWIN)
if (readdir_r(pDir->pDir, (dirent*)&(pDir->dirEntry), (dirent**)&(pDir->dirEntryPtr)) == 0) { if (readdir_r(pDir->pDir, (dirent *)&(pDir->dirEntry), (dirent **)&(pDir->dirEntryPtr)) == 0) {
return pDir->dirEntryPtr; return pDir->dirEntryPtr;
} else { } else {
return NULL; return NULL;

View File

@ -35,7 +35,7 @@ int64_t tsOpenMax = 0;
int64_t tsStreamMax = 0; int64_t tsStreamMax = 0;
float tsNumOfCores = 0; float tsNumOfCores = 0;
int64_t tsTotalMemoryKB = 0; int64_t tsTotalMemoryKB = 0;
char* tsProcPath = NULL; char *tsProcPath = NULL;
void osDefaultInit() { void osDefaultInit() {
taosSeedRand(taosSafeRand()); taosSeedRand(taosSafeRand());

View File

@ -58,7 +58,7 @@ typedef struct TdFile {
#define FILE_WITH_LOCK 1 #define FILE_WITH_LOCK 1
typedef struct AutoDelFile * AutoDelFilePtr; typedef struct AutoDelFile *AutoDelFilePtr;
typedef struct AutoDelFile { typedef struct AutoDelFile {
char *name; char *name;
AutoDelFilePtr lastAutoDelFilePtr; AutoDelFilePtr lastAutoDelFilePtr;
@ -706,11 +706,11 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
int64_t sentbytes; int64_t sentbytes;
while (leftbytes > 0) { while (leftbytes > 0) {
#ifdef _TD_ARM_32 #ifdef _TD_ARM_32
sentbytes = sendfile(pFileOut->fd, pFileIn->fd, (long int*)offset, leftbytes); sentbytes = sendfile(pFileOut->fd, pFileIn->fd, (long int *)offset, leftbytes);
#else #else
sentbytes = sendfile(pFileOut->fd, pFileIn->fd, offset, leftbytes); sentbytes = sendfile(pFileOut->fd, pFileIn->fd, offset, leftbytes);
#endif #endif
if (sentbytes == -1) { if (sentbytes == -1) {
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
continue; continue;

View File

@ -77,7 +77,7 @@ void taosSetSystemLocale(const char *inLocale, const char *inCharSet) {
// default locale or user specified locale is not valid, abort launch // default locale or user specified locale is not valid, abort launch
if (inLocale == NULL || strlen(inLocale) == 0) { if (inLocale == NULL || strlen(inLocale) == 0) {
//printf("Invalid locale:%s, please set the valid locale in config file\n", inLocale); // printf("Invalid locale:%s, please set the valid locale in config file\n", inLocale);
} }
if (!taosValidateEncodec(inCharSet)) { if (!taosValidateEncodec(inCharSet)) {

View File

@ -52,7 +52,7 @@ int32_t taosBackTrace(void **buffer, int32_t size) {
#pragma comment(lib, "dbghelp.lib") #pragma comment(lib, "dbghelp.lib")
void taosPrintBackTrace() { void taosPrintBackTrace() {
#define MAX_STACK_FRAMES 20 #define MAX_STACK_FRAMES 20
void *pStack[MAX_STACK_FRAMES]; void *pStack[MAX_STACK_FRAMES];
@ -72,15 +72,17 @@ void taosPrintBackTrace() {
DWORD displacementLine = 0; DWORD displacementLine = 0;
IMAGEHLP_LINE64 line; IMAGEHLP_LINE64 line;
//SymSetOptions(SYMOPT_LOAD_LINES); // SymSetOptions(SYMOPT_LOAD_LINES);
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
if (SymFromAddr(process, address, &displacementSym, pSymbol) && SymGetLineFromAddr64(process, address, &displacementLine, &line)) { if (SymFromAddr(process, address, &displacementSym, pSymbol) &&
snprintf(buf_tmp,sizeof(buf_tmp),"BackTrace %08" PRId64 " %s:%d %s\n", taosGetSelfPthreadId(), line.FileName, line.LineNumber, pSymbol->Name); SymGetLineFromAddr64(process, address, &displacementLine, &line)) {
snprintf(buf_tmp, sizeof(buf_tmp), "BackTrace %08" PRId64 " %s:%d %s\n", taosGetSelfPthreadId(), line.FileName,
line.LineNumber, pSymbol->Name);
} else { } else {
snprintf(buf_tmp,sizeof(buf_tmp),"BackTrace error: %d\n",GetLastError()); snprintf(buf_tmp, sizeof(buf_tmp), "BackTrace error: %d\n", GetLastError());
} }
write(1,buf_tmp,strlen(buf_tmp)); write(1, buf_tmp, strlen(buf_tmp));
} }
} }
#endif #endif
@ -126,14 +128,13 @@ int32_t taosBackTrace(void **buffer, int32_t size) {
#ifdef USE_ADDR2LINE #ifdef USE_ADDR2LINE
#include "osThread.h"
#include "libdwarf.h"
#include "dwarf.h" #include "dwarf.h"
#include "libdwarf.h"
#include "osThread.h"
#define DW_PR_DUu "llu" #define DW_PR_DUu "llu"
typedef struct lookup_table typedef struct lookup_table {
{
Dwarf_Line *table; Dwarf_Line *table;
Dwarf_Line_Context *ctxts; Dwarf_Line_Context *ctxts;
int cnt; int cnt;

View File

@ -16,8 +16,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#ifdef WINDOWS #ifdef WINDOWS
#include "windows.h"
#include "wincrypt.h" #include "wincrypt.h"
#include "windows.h"
#else #else
#include <sys/file.h> #include <sys/file.h>
#include <unistd.h> #include <unistd.h>
@ -27,7 +27,7 @@ void taosSeedRand(uint32_t seed) { return srand(seed); }
uint32_t taosRand(void) { return rand(); } uint32_t taosRand(void) { return rand(); }
uint32_t taosRandR(uint32_t *pSeed) { uint32_t taosRandR(uint32_t* pSeed) {
#ifdef WINDOWS #ifdef WINDOWS
return rand_s(pSeed); return rand_s(pSeed);
#else #else

View File

@ -47,7 +47,7 @@ void taosDflSignal(int32_t signum) {
signal(signum, SIG_DFL); signal(signum, SIG_DFL);
} }
void taosKillChildOnParentStopped() { } void taosKillChildOnParentStopped() {}
#else #else

View File

@ -17,7 +17,6 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "os.h" #include "os.h"
#if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) #if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
#include <unistd.h> #include <unistd.h>
#endif #endif

View File

@ -26,10 +26,10 @@ extern int wcswidth(const wchar_t *s, size_t n);
#ifdef WINDOWS #ifdef WINDOWS
char *strsep(char **stringp, const char *delim) { char *strsep(char **stringp, const char *delim) {
char * s; char *s;
const char *spanp; const char *spanp;
int32_t c, sc; int32_t c, sc;
char * tok; char *tok;
if ((s = *stringp) == NULL) return (NULL); if ((s = *stringp) == NULL) return (NULL);
for (tok = s;;) { for (tok = s;;) {
c = *s++; c = *s++;
@ -50,7 +50,7 @@ char *strsep(char **stringp, const char *delim) {
/* Duplicate a string, up to at most size characters */ /* Duplicate a string, up to at most size characters */
char *strndup(const char *s, int size) { char *strndup(const char *s, int size) {
size_t l; size_t l;
char * s2; char *s2;
l = strlen(s); l = strlen(s);
if (l > size) l = size; if (l > size) l = size;
s2 = malloc(l + 1); s2 = malloc(l + 1);

View File

@ -214,7 +214,6 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
return 0; return 0;
} }
bool taosCheckSystemIsLittleEnd() { bool taosCheckSystemIsLittleEnd() {
union check { union check {
int16_t i; int16_t i;
@ -338,10 +337,11 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
#ifdef WINDOWS #ifdef WINDOWS
char value[100]; char value[100];
DWORD bufferSize = sizeof(value); DWORD bufferSize = sizeof(value);
RegGetValue(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); RegGetValue(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString",
RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize);
tstrncpy(cpuModel, value, maxLen); tstrncpy(cpuModel, value, maxLen);
SYSTEM_INFO si; SYSTEM_INFO si;
memset(&si,0,sizeof(SYSTEM_INFO)); memset(&si, 0, sizeof(SYSTEM_INFO));
GetSystemInfo(&si); GetSystemInfo(&si);
*numOfCores = si.dwNumberOfProcessors; *numOfCores = si.dwNumberOfProcessors;
return 0; return 0;
@ -776,8 +776,9 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
#ifdef WINDOWS #ifdef WINDOWS
GUID guid; GUID guid;
CoCreateGuid(&guid); CoCreateGuid(&guid);
snprintf(uid, uidlen, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], snprintf(uid, uidlen, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3,
guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6],
guid.Data4[7]);
return 0; return 0;
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
@ -971,14 +972,17 @@ SysNameInfo taosGetSysNameInfo() {
#endif #endif
} }
bool taosCheckCurrentInDll() { bool taosCheckCurrentInDll() {
#ifdef WINDOWS #ifdef WINDOWS
MEMORY_BASIC_INFORMATION mbi; MEMORY_BASIC_INFORMATION mbi;
char path[PATH_MAX] = {0}; char path[PATH_MAX] = {0};
GetModuleFileName(((VirtualQuery(taosCheckCurrentInDll,&mbi,sizeof(mbi)) != 0) ? (HMODULE)mbi.AllocationBase : NULL), path, PATH_MAX); GetModuleFileName(
((VirtualQuery(taosCheckCurrentInDll, &mbi, sizeof(mbi)) != 0) ? (HMODULE)mbi.AllocationBase : NULL), path,
PATH_MAX);
int strLastIndex = strlen(path); int strLastIndex = strlen(path);
if ((path[strLastIndex-3] == 'd' || path[strLastIndex-3] == 'D') && (path[strLastIndex-2] == 'l' || path[strLastIndex-2] == 'L') && (path[strLastIndex-1] == 'l' || path[strLastIndex-1] == 'L')) { if ((path[strLastIndex - 3] == 'd' || path[strLastIndex - 3] == 'D') &&
(path[strLastIndex - 2] == 'l' || path[strLastIndex - 2] == 'L') &&
(path[strLastIndex - 1] == 'l' || path[strLastIndex - 1] == 'L')) {
return true; return true;
} }
return false; return false;

View File

@ -18,7 +18,7 @@
#include "os.h" #include "os.h"
#if defined(WINDOWS) #if defined(WINDOWS)
typedef void (*MainWindows)(int argc,char** argv); typedef void (*MainWindows)(int argc, char** argv);
MainWindows mainWindowsFunc = NULL; MainWindows mainWindowsFunc = NULL;
SERVICE_STATUS ServiceStatus; SERVICE_STATUS ServiceStatus;
@ -31,14 +31,14 @@ void WINAPI windowsServiceCtrlHandle(DWORD request) {
ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
DWORD nError = GetLastError(); DWORD nError = GetLastError();
printf("failed to send stopped status to windows service: %d",nError); printf("failed to send stopped status to windows service: %d", nError);
} }
break; break;
default: default:
return; return;
} }
} }
void WINAPI mainWindowsService(int argc,char** argv) { void WINAPI mainWindowsService(int argc, char** argv) {
int ret = 0; int ret = 0;
ServiceStatus.dwServiceType = SERVICE_WIN32; ServiceStatus.dwServiceType = SERVICE_WIN32;
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
@ -50,19 +50,19 @@ void WINAPI mainWindowsService(int argc,char** argv) {
hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle); hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle);
if (hServiceStatusHandle == 0) { if (hServiceStatusHandle == 0) {
DWORD nError = GetLastError(); DWORD nError = GetLastError();
printf("failed to register windows service ctrl handler: %d",nError); printf("failed to register windows service ctrl handler: %d", nError);
} }
ServiceStatus.dwCurrentState = SERVICE_RUNNING; ServiceStatus.dwCurrentState = SERVICE_RUNNING;
if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
DWORD nError = GetLastError(); DWORD nError = GetLastError();
printf("failed to send running status to windows service: %d",nError); printf("failed to send running status to windows service: %d", nError);
} }
if (mainWindowsFunc != NULL) mainWindowsFunc(argc, argv); if (mainWindowsFunc != NULL) mainWindowsFunc(argc, argv);
ServiceStatus.dwCurrentState = SERVICE_STOPPED; ServiceStatus.dwCurrentState = SERVICE_STOPPED;
if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) {
DWORD nError = GetLastError(); DWORD nError = GetLastError();
printf("failed to send stopped status to windows service: %d",nError); printf("failed to send stopped status to windows service: %d", nError);
} }
} }
void stratWindowsService(MainWindows mainWindows) { void stratWindowsService(MainWindows mainWindows) {
@ -248,7 +248,7 @@ TdCmdPtr taosOpenCmd(const char* cmd) {
#endif #endif
} }
int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char *__restrict buf) { int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char* __restrict buf) {
if (pCmd == NULL || buf == NULL) { if (pCmd == NULL || buf == NULL) {
return -1; return -1;
} }

View File

@ -17,179 +17,135 @@
#include <pthread.h> #include <pthread.h>
#include "os.h" #include "os.h"
int32_t taosThreadCreate(TdThread * tid, const TdThreadAttr * attr, void *(*start)(void *), void *arg) { int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void *(*start)(void *), void *arg) {
return pthread_create(tid, attr, start, arg); return pthread_create(tid, attr, start, arg);
} }
int32_t taosThreadAttrDestroy(TdThreadAttr * attr) { int32_t taosThreadAttrDestroy(TdThreadAttr *attr) { return pthread_attr_destroy(attr); }
return pthread_attr_destroy(attr);
}
int32_t taosThreadAttrGetDetachState(const TdThreadAttr * attr, int32_t *detachstate) { int32_t taosThreadAttrGetDetachState(const TdThreadAttr *attr, int32_t *detachstate) {
return pthread_attr_getdetachstate(attr, detachstate); return pthread_attr_getdetachstate(attr, detachstate);
} }
int32_t taosThreadAttrGetInheritSched(const TdThreadAttr * attr, int32_t *inheritsched) { int32_t taosThreadAttrGetInheritSched(const TdThreadAttr *attr, int32_t *inheritsched) {
return pthread_attr_getinheritsched(attr, inheritsched); return pthread_attr_getinheritsched(attr, inheritsched);
} }
int32_t taosThreadAttrGetSchedParam(const TdThreadAttr * attr, struct sched_param *param) { int32_t taosThreadAttrGetSchedParam(const TdThreadAttr *attr, struct sched_param *param) {
return pthread_attr_getschedparam(attr, param); return pthread_attr_getschedparam(attr, param);
} }
int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr * attr, int32_t *policy) { int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr *attr, int32_t *policy) {
return pthread_attr_getschedpolicy(attr, policy); return pthread_attr_getschedpolicy(attr, policy);
} }
int32_t taosThreadAttrGetScope(const TdThreadAttr * attr, int32_t *contentionscope) { int32_t taosThreadAttrGetScope(const TdThreadAttr *attr, int32_t *contentionscope) {
return pthread_attr_getscope(attr, contentionscope); return pthread_attr_getscope(attr, contentionscope);
} }
int32_t taosThreadAttrGetStackSize(const TdThreadAttr * attr, size_t * stacksize) { int32_t taosThreadAttrGetStackSize(const TdThreadAttr *attr, size_t *stacksize) {
return pthread_attr_getstacksize(attr, stacksize); return pthread_attr_getstacksize(attr, stacksize);
} }
int32_t taosThreadAttrInit(TdThreadAttr * attr) { int32_t taosThreadAttrInit(TdThreadAttr *attr) { return pthread_attr_init(attr); }
return pthread_attr_init(attr);
}
int32_t taosThreadAttrSetDetachState(TdThreadAttr * attr, int32_t detachstate) { int32_t taosThreadAttrSetDetachState(TdThreadAttr *attr, int32_t detachstate) {
return pthread_attr_setdetachstate(attr, detachstate); return pthread_attr_setdetachstate(attr, detachstate);
} }
int32_t taosThreadAttrSetInheritSched(TdThreadAttr * attr, int32_t inheritsched) { int32_t taosThreadAttrSetInheritSched(TdThreadAttr *attr, int32_t inheritsched) {
return pthread_attr_setinheritsched(attr, inheritsched); return pthread_attr_setinheritsched(attr, inheritsched);
} }
int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_param *param) { int32_t taosThreadAttrSetSchedParam(TdThreadAttr *attr, const struct sched_param *param) {
return pthread_attr_setschedparam(attr, param); return pthread_attr_setschedparam(attr, param);
} }
int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr * attr, int32_t policy) { int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr *attr, int32_t policy) {
return pthread_attr_setschedpolicy(attr, policy); return pthread_attr_setschedpolicy(attr, policy);
} }
int32_t taosThreadAttrSetScope(TdThreadAttr * attr, int32_t contentionscope) { int32_t taosThreadAttrSetScope(TdThreadAttr *attr, int32_t contentionscope) {
return pthread_attr_setscope(attr, contentionscope); return pthread_attr_setscope(attr, contentionscope);
} }
int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize) { int32_t taosThreadAttrSetStackSize(TdThreadAttr *attr, size_t stacksize) {
return pthread_attr_setstacksize(attr, stacksize); return pthread_attr_setstacksize(attr, stacksize);
} }
int32_t taosThreadCancel(TdThread thread) { int32_t taosThreadCancel(TdThread thread) { return pthread_cancel(thread); }
return pthread_cancel(thread);
}
int32_t taosThreadCondDestroy(TdThreadCond * cond) { int32_t taosThreadCondDestroy(TdThreadCond *cond) { return pthread_cond_destroy(cond); }
return pthread_cond_destroy(cond);
}
int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr) { int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr) { return pthread_cond_init(cond, attr); }
return pthread_cond_init(cond, attr);
}
int32_t taosThreadCondSignal(TdThreadCond * cond) { int32_t taosThreadCondSignal(TdThreadCond *cond) { return pthread_cond_signal(cond); }
return pthread_cond_signal(cond);
}
int32_t taosThreadCondBroadcast(TdThreadCond * cond) { int32_t taosThreadCondBroadcast(TdThreadCond *cond) { return pthread_cond_broadcast(cond); }
return pthread_cond_broadcast(cond);
}
int32_t taosThreadCondWait(TdThreadCond * cond, TdThreadMutex * mutex) { int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex) { return pthread_cond_wait(cond, mutex); }
return pthread_cond_wait(cond, mutex);
}
int32_t taosThreadCondTimedWait(TdThreadCond * cond, TdThreadMutex * mutex, const struct timespec *abstime) { int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime) {
return pthread_cond_timedwait(cond, mutex, abstime); return pthread_cond_timedwait(cond, mutex, abstime);
} }
int32_t taosThreadCondAttrDestroy(TdThreadCondAttr * attr) { int32_t taosThreadCondAttrDestroy(TdThreadCondAttr *attr) { return pthread_condattr_destroy(attr); }
return pthread_condattr_destroy(attr);
}
int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr * attr, int32_t *pshared) { int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr *attr, int32_t *pshared) {
return pthread_condattr_getpshared(attr, pshared); return pthread_condattr_getpshared(attr, pshared);
} }
int32_t taosThreadCondAttrInit(TdThreadCondAttr * attr) { int32_t taosThreadCondAttrInit(TdThreadCondAttr *attr) { return pthread_condattr_init(attr); }
return pthread_condattr_init(attr);
}
int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr * attr, int32_t pshared) { int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr *attr, int32_t pshared) {
return pthread_condattr_setpshared(attr, pshared); return pthread_condattr_setpshared(attr, pshared);
} }
int32_t taosThreadDetach(TdThread thread) { int32_t taosThreadDetach(TdThread thread) { return pthread_detach(thread); }
return pthread_detach(thread);
}
int32_t taosThreadEqual(TdThread t1, TdThread t2) { int32_t taosThreadEqual(TdThread t1, TdThread t2) { return pthread_equal(t1, t2); }
return pthread_equal(t1, t2);
}
void taosThreadExit(void *valuePtr) { void taosThreadExit(void *valuePtr) { return pthread_exit(valuePtr); }
return pthread_exit(valuePtr);
}
int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param) { int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param) {
return pthread_getschedparam(thread, policy, param); return pthread_getschedparam(thread, policy, param);
} }
void *taosThreadGetSpecific(TdThreadKey key) { void *taosThreadGetSpecific(TdThreadKey key) { return pthread_getspecific(key); }
return pthread_getspecific(key);
}
int32_t taosThreadJoin(TdThread thread, void **valuePtr) { int32_t taosThreadJoin(TdThread thread, void **valuePtr) { return pthread_join(thread, valuePtr); }
return pthread_join(thread, valuePtr);
}
int32_t taosThreadKeyCreate(TdThreadKey * key, void(*destructor)(void *)) { int32_t taosThreadKeyCreate(TdThreadKey *key, void (*destructor)(void *)) {
return pthread_key_create(key, destructor); return pthread_key_create(key, destructor);
} }
int32_t taosThreadKeyDelete(TdThreadKey key) { int32_t taosThreadKeyDelete(TdThreadKey key) { return pthread_key_delete(key); }
return pthread_key_delete(key);
}
int32_t taosThreadKill(TdThread thread, int32_t sig) { int32_t taosThreadKill(TdThread thread, int32_t sig) { return pthread_kill(thread, sig); }
return pthread_kill(thread, sig);
}
// int32_t taosThreadMutexConsistent(TdThreadMutex* mutex) { // int32_t taosThreadMutexConsistent(TdThreadMutex* mutex) {
// return pthread_mutex_consistent(mutex); // return pthread_mutex_consistent(mutex);
// } // }
int32_t taosThreadMutexDestroy(TdThreadMutex * mutex) { int32_t taosThreadMutexDestroy(TdThreadMutex *mutex) { return pthread_mutex_destroy(mutex); }
return pthread_mutex_destroy(mutex);
}
int32_t taosThreadMutexInit(TdThreadMutex * mutex, const TdThreadMutexAttr * attr) { int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr) {
return pthread_mutex_init(mutex, attr); return pthread_mutex_init(mutex, attr);
} }
int32_t taosThreadMutexLock(TdThreadMutex * mutex) { int32_t taosThreadMutexLock(TdThreadMutex *mutex) { return pthread_mutex_lock(mutex); }
return pthread_mutex_lock(mutex);
}
// int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime) { // int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime) {
// return pthread_mutex_timedlock(mutex, abstime); // return pthread_mutex_timedlock(mutex, abstime);
// } // }
int32_t taosThreadMutexTryLock(TdThreadMutex * mutex) { int32_t taosThreadMutexTryLock(TdThreadMutex *mutex) { return pthread_mutex_trylock(mutex); }
return pthread_mutex_trylock(mutex);
}
int32_t taosThreadMutexUnlock(TdThreadMutex * mutex) { int32_t taosThreadMutexUnlock(TdThreadMutex *mutex) { return pthread_mutex_unlock(mutex); }
return pthread_mutex_unlock(mutex);
}
int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr * attr) { int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr *attr) { return pthread_mutexattr_destroy(attr); }
return pthread_mutexattr_destroy(attr);
}
int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr * attr, int32_t *pshared) { int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr *attr, int32_t *pshared) {
return pthread_mutexattr_getpshared(attr, pshared); return pthread_mutexattr_getpshared(attr, pshared);
} }
@ -197,15 +153,13 @@ int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr * attr, int32_t *p
// return pthread_mutexattr_getrobust(attr, robust); // return pthread_mutexattr_getrobust(attr, robust);
// } // }
int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr * attr, int32_t *kind) { int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr *attr, int32_t *kind) {
return pthread_mutexattr_gettype(attr, kind); return pthread_mutexattr_gettype(attr, kind);
} }
int32_t taosThreadMutexAttrInit(TdThreadMutexAttr * attr) { int32_t taosThreadMutexAttrInit(TdThreadMutexAttr *attr) { return pthread_mutexattr_init(attr); }
return pthread_mutexattr_init(attr);
}
int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr * attr, int32_t pshared) { int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr *attr, int32_t pshared) {
return pthread_mutexattr_setpshared(attr, pshared); return pthread_mutexattr_setpshared(attr, pshared);
} }
@ -213,25 +167,21 @@ int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr * attr, int32_t pshared)
// return pthread_mutexattr_setrobust(attr, robust); // return pthread_mutexattr_setrobust(attr, robust);
// } // }
int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr * attr, int32_t kind) { int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr *attr, int32_t kind) {
return pthread_mutexattr_settype(attr, kind); return pthread_mutexattr_settype(attr, kind);
} }
int32_t taosThreadOnce(TdThreadOnce * onceControl, void(*initRoutine)(void)) { int32_t taosThreadOnce(TdThreadOnce *onceControl, void (*initRoutine)(void)) {
return pthread_once(onceControl, initRoutine); return pthread_once(onceControl, initRoutine);
} }
int32_t taosThreadRwlockDestroy(TdThreadRwlock * rwlock) { int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock) { return pthread_rwlock_destroy(rwlock); }
return pthread_rwlock_destroy(rwlock);
}
int32_t taosThreadRwlockInit(TdThreadRwlock * rwlock, const TdThreadRwlockAttr * attr) { int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr) {
return pthread_rwlock_init(rwlock, attr); return pthread_rwlock_init(rwlock, attr);
} }
int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock) { int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_rdlock(rwlock); }
return pthread_rwlock_rdlock(rwlock);
}
// int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime) { // int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime) {
// return pthread_rwlock_timedrdlock(rwlock, abstime); // return pthread_rwlock_timedrdlock(rwlock, abstime);
@ -241,103 +191,79 @@ int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock) {
// return pthread_rwlock_timedwrlock(rwlock, abstime); // return pthread_rwlock_timedwrlock(rwlock, abstime);
// } // }
int32_t taosThreadRwlockTryRdlock(TdThreadRwlock * rwlock) { int32_t taosThreadRwlockTryRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_tryrdlock(rwlock); }
return pthread_rwlock_tryrdlock(rwlock);
}
int32_t taosThreadRwlockTryWrlock(TdThreadRwlock * rwlock) { int32_t taosThreadRwlockTryWrlock(TdThreadRwlock *rwlock) { return pthread_rwlock_trywrlock(rwlock); }
return pthread_rwlock_trywrlock(rwlock);
}
int32_t taosThreadRwlockUnlock(TdThreadRwlock * rwlock) { int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock) { return pthread_rwlock_unlock(rwlock); }
return pthread_rwlock_unlock(rwlock);
}
int32_t taosThreadRwlockWrlock(TdThreadRwlock * rwlock) { int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock) { return pthread_rwlock_wrlock(rwlock); }
return pthread_rwlock_wrlock(rwlock);
}
int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr * attr) { int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr *attr) { return pthread_rwlockattr_destroy(attr); }
return pthread_rwlockattr_destroy(attr);
}
int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr * attr, int32_t *pshared) { int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr *attr, int32_t *pshared) {
return pthread_rwlockattr_getpshared(attr, pshared); return pthread_rwlockattr_getpshared(attr, pshared);
} }
int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr * attr) { int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr *attr) { return pthread_rwlockattr_init(attr); }
return pthread_rwlockattr_init(attr);
}
int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr * attr, int32_t pshared) { int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr *attr, int32_t pshared) {
return pthread_rwlockattr_setpshared(attr, pshared); return pthread_rwlockattr_setpshared(attr, pshared);
} }
TdThread taosThreadSelf(void) { TdThread taosThreadSelf(void) { return pthread_self(); }
return pthread_self();
}
int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate) { int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate) { return pthread_setcancelstate(state, oldstate); }
return pthread_setcancelstate(state, oldstate);
}
int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype) { int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype) { return pthread_setcanceltype(type, oldtype); }
return pthread_setcanceltype(type, oldtype);
}
int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param) { int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param) {
return pthread_setschedparam(thread, policy, param); return pthread_setschedparam(thread, policy, param);
} }
int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) { int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) { return pthread_setspecific(key, value); }
return pthread_setspecific(key, value);
}
int32_t taosThreadSpinDestroy(TdThreadSpinlock * lock) { int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock) {
#ifdef TD_USE_SPINLOCK_AS_MUTEX #ifdef TD_USE_SPINLOCK_AS_MUTEX
return pthread_mutex_destroy((pthread_mutex_t*)lock); return pthread_mutex_destroy((pthread_mutex_t *)lock);
#else #else
return pthread_spin_destroy((pthread_spinlock_t*)lock); return pthread_spin_destroy((pthread_spinlock_t *)lock);
#endif #endif
} }
int32_t taosThreadSpinInit(TdThreadSpinlock * lock, int32_t pshared) { int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int32_t pshared) {
#ifdef TD_USE_SPINLOCK_AS_MUTEX #ifdef TD_USE_SPINLOCK_AS_MUTEX
assert(pshared == 0); assert(pshared == 0);
return pthread_mutex_init((pthread_mutex_t*)lock, NULL); return pthread_mutex_init((pthread_mutex_t *)lock, NULL);
#else #else
return pthread_spin_init((pthread_spinlock_t*)lock, pshared); return pthread_spin_init((pthread_spinlock_t *)lock, pshared);
#endif #endif
} }
int32_t taosThreadSpinLock(TdThreadSpinlock * lock) { int32_t taosThreadSpinLock(TdThreadSpinlock *lock) {
#ifdef TD_USE_SPINLOCK_AS_MUTEX #ifdef TD_USE_SPINLOCK_AS_MUTEX
return pthread_mutex_lock((pthread_mutex_t*)lock); return pthread_mutex_lock((pthread_mutex_t *)lock);
#else #else
return pthread_spin_lock((pthread_spinlock_t*)lock); return pthread_spin_lock((pthread_spinlock_t *)lock);
#endif #endif
} }
int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock) { int32_t taosThreadSpinTrylock(TdThreadSpinlock *lock) {
#ifdef TD_USE_SPINLOCK_AS_MUTEX #ifdef TD_USE_SPINLOCK_AS_MUTEX
return pthread_mutex_trylock((pthread_mutex_t*)lock); return pthread_mutex_trylock((pthread_mutex_t *)lock);
#else #else
return pthread_spin_trylock((pthread_spinlock_t*)lock); return pthread_spin_trylock((pthread_spinlock_t *)lock);
#endif #endif
} }
int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock) { int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock) {
#ifdef TD_USE_SPINLOCK_AS_MUTEX #ifdef TD_USE_SPINLOCK_AS_MUTEX
return pthread_mutex_unlock((pthread_mutex_t*)lock); return pthread_mutex_unlock((pthread_mutex_t *)lock);
#else #else
return pthread_spin_unlock((pthread_spinlock_t*)lock); return pthread_spin_unlock((pthread_spinlock_t *)lock);
#endif #endif
} }
void taosThreadTestCancel(void) { void taosThreadTestCancel(void) { return pthread_testcancel(); }
return pthread_testcancel();
}
void taosThreadClear(TdThread *thread) { void taosThreadClear(TdThread *thread) { memset(thread, 0, sizeof(TdThread)); }
memset(thread, 0, sizeof(TdThread));
}

View File

@ -86,7 +86,7 @@ static void taosDeleteTimer(void *tharg) {
static TdThread timerThread; static TdThread timerThread;
static timer_t timerId; static timer_t timerId;
static volatile bool stopTimer = false; static volatile bool stopTimer = false;
static void * taosProcessAlarmSignal(void *tharg) { static void *taosProcessAlarmSignal(void *tharg) {
// Block the signal // Block the signal
sigset_t sigset; sigset_t sigset;
sigemptyset(&sigset); sigemptyset(&sigset);
@ -167,7 +167,8 @@ int taosInitTimer(void (*callback)(int), int ms) {
r = taosThreadCreate(&timer_thread, NULL, timer_routine, NULL); r = taosThreadCreate(&timer_thread, NULL, timer_routine, NULL);
if (r) { if (r) {
fprintf(stderr, "==%s[%d]%s()==failed to create timer thread\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__); fprintf(stderr, "==%s[%d]%s()==failed to create timer thread\n", taosDirEntryBaseName(__FILE__), __LINE__,
__func__);
// since no caller of this func checks the return value for the moment // since no caller of this func checks the return value for the moment
abort(); abort();
} }

File diff suppressed because it is too large Load Diff

View File

@ -175,11 +175,11 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size
c = compar(key, p); c = compar(key, p);
if (c == 0) { if (c == 0) {
if (flags == TD_GT){ if (flags == TD_GT) {
lidx = midx + 1; lidx = midx + 1;
} else if(flags == TD_LT){ } else if (flags == TD_LT) {
ridx = midx - 1; ridx = midx - 1;
}else{ } else {
break; break;
} }
} else if (c < 0) { } else if (c < 0) {

View File

@ -51,12 +51,12 @@ SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate) {
// ln(2)^2 = 0.480453013918201 // ln(2)^2 = 0.480453013918201
// m = - n * ln(P) / ( ln(2) )^2 // m = - n * ln(P) / ( ln(2) )^2
// m is the size of bloom filter, n is expected entries, P is false positive probability // m is the size of bloom filter, n is expected entries, P is false positive probability
pBF->numUnits = (uint64_t) ceil(expectedEntries * lnRate / 0.480453013918201 / UNIT_NUM_BITS); pBF->numUnits = (uint64_t)ceil(expectedEntries * lnRate / 0.480453013918201 / UNIT_NUM_BITS);
pBF->numBits = pBF->numUnits * 64; pBF->numBits = pBF->numUnits * 64;
pBF->size = 0; pBF->size = 0;
// ln(2) = 0.693147180559945 // ln(2) = 0.693147180559945
pBF->hashFunctions = (uint32_t) ceil(lnRate / 0.693147180559945); pBF->hashFunctions = (uint32_t)ceil(lnRate / 0.693147180559945);
pBF->hashFn1 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP); pBF->hashFn1 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP);
pBF->hashFn2 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_NCHAR); pBF->hashFn2 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_NCHAR);
pBF->buffer = taosMemoryCalloc(pBF->numUnits, sizeof(uint64_t)); pBF->buffer = taosMemoryCalloc(pBF->numUnits, sizeof(uint64_t));
@ -85,8 +85,7 @@ int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len) {
return TSDB_CODE_FAILED; return TSDB_CODE_FAILED;
} }
int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, uint32_t len) {
uint32_t len) {
uint64_t h1 = (uint64_t)pBF->hashFn1(keyBuf, len); uint64_t h1 = (uint64_t)pBF->hashFn1(keyBuf, len);
uint64_t h2 = (uint64_t)pBF->hashFn2(keyBuf, len); uint64_t h2 = (uint64_t)pBF->hashFn2(keyBuf, len);
const register uint64_t size = pBF->numBits; const register uint64_t size = pBF->numBits;
@ -108,21 +107,21 @@ void tBloomFilterDestroy(SBloomFilter *pBF) {
taosMemoryFree(pBF); taosMemoryFree(pBF);
} }
int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder* pEncoder) { int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder *pEncoder) {
if (tEncodeU32(pEncoder, pBF->hashFunctions) < 0) return -1; if (tEncodeU32(pEncoder, pBF->hashFunctions) < 0) return -1;
if (tEncodeU64(pEncoder, pBF->expectedEntries) < 0) return -1; if (tEncodeU64(pEncoder, pBF->expectedEntries) < 0) return -1;
if (tEncodeU64(pEncoder, pBF->numUnits) < 0) return -1; if (tEncodeU64(pEncoder, pBF->numUnits) < 0) return -1;
if (tEncodeU64(pEncoder, pBF->numBits) < 0) return -1; if (tEncodeU64(pEncoder, pBF->numBits) < 0) return -1;
if (tEncodeU64(pEncoder, pBF->size) < 0) return -1; if (tEncodeU64(pEncoder, pBF->size) < 0) return -1;
for (uint64_t i = 0; i < pBF->numUnits; i++) { for (uint64_t i = 0; i < pBF->numUnits; i++) {
uint64_t* pUnits = (uint64_t*)pBF->buffer; uint64_t *pUnits = (uint64_t *)pBF->buffer;
if (tEncodeU64(pEncoder, pUnits[i]) < 0) return -1; if (tEncodeU64(pEncoder, pUnits[i]) < 0) return -1;
} }
if (tEncodeDouble(pEncoder, pBF->errorRate) < 0) return -1; if (tEncodeDouble(pEncoder, pBF->errorRate) < 0) return -1;
return 0; return 0;
} }
SBloomFilter* tBloomFilterDecode(SDecoder* pDecoder) { SBloomFilter *tBloomFilterDecode(SDecoder *pDecoder) {
SBloomFilter *pBF = taosMemoryCalloc(1, sizeof(SBloomFilter)); SBloomFilter *pBF = taosMemoryCalloc(1, sizeof(SBloomFilter));
pBF->buffer = NULL; pBF->buffer = NULL;
if (tDecodeU32(pDecoder, &pBF->hashFunctions) < 0) goto _error; if (tDecodeU32(pDecoder, &pBF->hashFunctions) < 0) goto _error;
@ -132,7 +131,7 @@ SBloomFilter* tBloomFilterDecode(SDecoder* pDecoder) {
if (tDecodeU64(pDecoder, &pBF->size) < 0) goto _error; if (tDecodeU64(pDecoder, &pBF->size) < 0) goto _error;
pBF->buffer = taosMemoryCalloc(pBF->numUnits, sizeof(uint64_t)); pBF->buffer = taosMemoryCalloc(pBF->numUnits, sizeof(uint64_t));
for (int32_t i = 0; i < pBF->numUnits; i++) { for (int32_t i = 0; i < pBF->numUnits; i++) {
uint64_t* pUnits = (uint64_t*)pBF->buffer; uint64_t *pUnits = (uint64_t *)pBF->buffer;
if (tDecodeU64(pDecoder, pUnits + i) < 0) goto _error; if (tDecodeU64(pDecoder, pUnits + i) < 0) goto _error;
} }
if (tDecodeDouble(pDecoder, &pBF->errorRate) < 0) goto _error; if (tDecodeDouble(pDecoder, &pBF->errorRate) < 0) goto _error;
@ -145,6 +144,4 @@ _error:
return NULL; return NULL;
} }
bool tBloomFilterIsFull(const SBloomFilter *pBF) { bool tBloomFilterIsFull(const SBloomFilter *pBF) { return pBF->size >= pBF->expectedEntries; }
return pBF->size >= pBF->expectedEntries;
}

View File

@ -15,8 +15,8 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "tcache.h" #include "tcache.h"
#include "taoserror.h"
#include "osThread.h" #include "osThread.h"
#include "taoserror.h"
#include "tlog.h" #include "tlog.h"
#include "tutil.h" #include "tutil.h"
@ -35,7 +35,7 @@ typedef struct SCacheNode {
uint64_t addedTime; // the added time when this element is added or updated into cache uint64_t addedTime; // the added time when this element is added or updated into cache
uint64_t lifespan; // life duration when this element should be remove from cache uint64_t lifespan; // life duration when this element should be remove from cache
int64_t expireTime; // expire time int64_t expireTime; // expire time
void* signature; void *signature;
struct STrashElem *pTNodeHeader; // point to trash node head struct STrashElem *pTNodeHeader; // point to trash node head
uint16_t keyLen : 15; // max key size: 32kb uint16_t keyLen : 15; // max key size: 32kb
bool inTrashcan : 1; // denote if it is in trash or not bool inTrashcan : 1; // denote if it is in trash or not

View File

@ -226,23 +226,23 @@ int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight) {
// string > number > bool > null // string > number > bool > null
// ref: https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison // ref: https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison
int32_t compareJsonVal(const void *pLeft, const void *pRight) { int32_t compareJsonVal(const void *pLeft, const void *pRight) {
char leftType = *(char*)pLeft; char leftType = *(char *)pLeft;
char rightType = *(char*)pRight; char rightType = *(char *)pRight;
if(leftType != rightType){ if (leftType != rightType) {
return leftType > rightType ? 1 : -1; return leftType > rightType ? 1 : -1;
} }
char* realDataLeft = POINTER_SHIFT(pLeft, CHAR_BYTES); char *realDataLeft = POINTER_SHIFT(pLeft, CHAR_BYTES);
char* realDataRight = POINTER_SHIFT(pRight, CHAR_BYTES); char *realDataRight = POINTER_SHIFT(pRight, CHAR_BYTES);
if(leftType == TSDB_DATA_TYPE_BOOL) { if (leftType == TSDB_DATA_TYPE_BOOL) {
DEFAULT_COMP(GET_INT8_VAL(realDataLeft), GET_INT8_VAL(realDataRight)); DEFAULT_COMP(GET_INT8_VAL(realDataLeft), GET_INT8_VAL(realDataRight));
}else if(leftType == TSDB_DATA_TYPE_DOUBLE){ } else if (leftType == TSDB_DATA_TYPE_DOUBLE) {
DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(realDataLeft), GET_DOUBLE_VAL(realDataRight)); DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(realDataLeft), GET_DOUBLE_VAL(realDataRight));
}else if(leftType == TSDB_DATA_TYPE_NCHAR){ } else if (leftType == TSDB_DATA_TYPE_NCHAR) {
return compareLenPrefixedWStr(realDataLeft, realDataRight); return compareLenPrefixedWStr(realDataLeft, realDataRight);
}else if(leftType == TSDB_DATA_TYPE_NULL) { } else if (leftType == TSDB_DATA_TYPE_NULL) {
return 0; return 0;
}else{ } else {
assert(0); assert(0);
return 0; return 0;
} }
@ -392,7 +392,6 @@ int32_t compareInt16Uint64(const void *pLeft, const void *pRight) {
return 0; return 0;
} }
int32_t compareInt32Int8(const void *pLeft, const void *pRight) { int32_t compareInt32Int8(const void *pLeft, const void *pRight) {
int32_t left = GET_INT32_VAL(pLeft); int32_t left = GET_INT32_VAL(pLeft);
int8_t right = GET_INT8_VAL(pRight); int8_t right = GET_INT8_VAL(pRight);
@ -997,10 +996,7 @@ int32_t compareUint64Uint32(const void *pLeft, const void *pRight) {
return 0; return 0;
} }
int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { return compareJsonVal(pRight, pLeft); }
int32_t compareJsonValDesc(const void *pLeft, const void *pRight) {
return compareJsonVal(pRight, pLeft);
}
/* /*
* Compare two strings * Compare two strings
* TSDB_MATCH: Match * TSDB_MATCH: Match

View File

@ -15,13 +15,13 @@
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include "tconfig.h" #include "tconfig.h"
#include "cJSON.h"
#include "taoserror.h" #include "taoserror.h"
#include "tenv.h"
#include "tgrant.h"
#include "tjson.h"
#include "tlog.h" #include "tlog.h"
#include "tutil.h" #include "tutil.h"
#include "tenv.h"
#include "cJSON.h"
#include "tjson.h"
#include "tgrant.h"
#define CFG_NAME_PRINT_LEN 24 #define CFG_NAME_PRINT_LEN 24
#define CFG_SRC_PRINT_LEN 12 #define CFG_SRC_PRINT_LEN 12
@ -508,7 +508,7 @@ const char *cfgDtypeStr(ECfgDataType type) {
} }
} }
void cfgDumpItemValue(SConfigItem *pItem, char* buf, int32_t bufSize, int32_t* pLen) { void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen) {
int32_t len = 0; int32_t len = 0;
switch (pItem->dtype) { switch (pItem->dtype) {
case CFG_DTYPE_BOOL: case CFG_DTYPE_BOOL:
@ -634,11 +634,11 @@ int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
int32_t code = 0; int32_t code = 0;
char **pEnv = environ; char **pEnv = environ;
line[1023] = 0; line[1023] = 0;
while(*pEnv != NULL) { while (*pEnv != NULL) {
name = value = value2 = value3 = NULL; name = value = value2 = value3 = NULL;
olen = vlen = vlen2 = vlen3 = 0; olen = vlen = vlen2 = vlen3 = 0;
strncpy(line, *pEnv, sizeof(line)-1); strncpy(line, *pEnv, sizeof(line) - 1);
pEnv++; pEnv++;
taosEnvToCfg(line, line); taosEnvToCfg(line, line);
@ -676,9 +676,9 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
int32_t code = 0; int32_t code = 0;
int32_t index = 0; int32_t index = 0;
if (envCmd == NULL) return 0; if (envCmd == NULL) return 0;
while (envCmd[index]!=NULL) { while (envCmd[index] != NULL) {
strncpy(buf, envCmd[index], sizeof(buf)-1); strncpy(buf, envCmd[index], sizeof(buf) - 1);
buf[sizeof(buf)-1] = 0; buf[sizeof(buf) - 1] = 0;
taosEnvToCfg(buf, buf); taosEnvToCfg(buf, buf);
index++; index++;
@ -720,13 +720,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
ssize_t _bytes = 0; ssize_t _bytes = 0;
const char *filepath = ".env"; const char *filepath = ".env";
if (envFile != NULL && strlen(envFile)>0) { if (envFile != NULL && strlen(envFile) > 0) {
if (!taosCheckExistFile(envFile)) { if (!taosCheckExistFile(envFile)) {
uError("failed to load env file: %s", envFile); uError("failed to load env file: %s", envFile);
return -1; return -1;
} }
filepath = envFile; filepath = envFile;
}else { } else {
if (!taosCheckExistFile(filepath)) { if (!taosCheckExistFile(filepath)) {
uInfo("failed to load env file: %s", filepath); uInfo("failed to load env file: %s", filepath);
return 0; return 0;
@ -747,7 +747,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
if (_bytes <= 0) { if (_bytes <= 0) {
break; break;
} }
if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0; if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
taosEnvToCfg(line, line); taosEnvToCfg(line, line);
paGetToken(line, &name, &olen); paGetToken(line, &name, &olen);
@ -808,7 +808,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
break; break;
} }
if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0; if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
paGetToken(line, &name, &olen); paGetToken(line, &name, &olen);
if (olen == 0) continue; if (olen == 0) continue;
@ -941,13 +941,13 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END); size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END);
char *buf = taosMemoryMalloc(fileSize); char *buf = taosMemoryMalloc(fileSize);
taosLSeekFile(pFile, 0, SEEK_SET); taosLSeekFile(pFile, 0, SEEK_SET);
if(taosReadFile(pFile, buf, fileSize) <= 0) { if (taosReadFile(pFile, buf, fileSize) <= 0) {
taosCloseFile(&pFile); taosCloseFile(&pFile);
uError("load json file error: %s", filepath); uError("load json file error: %s", filepath);
return -1; return -1;
} }
taosCloseFile(&pFile); taosCloseFile(&pFile);
SJson* pJson = tjsonParse(buf); SJson *pJson = tjsonParse(buf);
if (NULL == pJson) { if (NULL == pJson) {
const char *jsonParseError = tjsonGetError(); const char *jsonParseError = tjsonGetError();
if (jsonParseError != NULL) { if (jsonParseError != NULL) {
@ -958,8 +958,8 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
taosMemoryFreeClear(buf); taosMemoryFreeClear(buf);
int32_t jsonArraySize = tjsonGetArraySize(pJson); int32_t jsonArraySize = tjsonGetArraySize(pJson);
for(int32_t i = 0; i < jsonArraySize; i++) { for (int32_t i = 0; i < jsonArraySize; i++) {
cJSON* item = tjsonGetArrayItem(pJson, i); cJSON *item = tjsonGetArrayItem(pJson, i);
if (item == NULL) break; if (item == NULL) break;
char *itemName = NULL, *itemValueString = NULL; char *itemName = NULL, *itemValueString = NULL;
tjsonGetObjectName(item, &itemName); tjsonGetObjectName(item, &itemName);
@ -971,7 +971,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
cfgLineBuf = taosMemoryMalloc(itemNameLen + itemValueStringLen + 2); cfgLineBuf = taosMemoryMalloc(itemNameLen + itemValueStringLen + 2);
memcpy(cfgLineBuf, itemName, itemNameLen); memcpy(cfgLineBuf, itemName, itemNameLen);
cfgLineBuf[itemNameLen] = ' '; cfgLineBuf[itemNameLen] = ' ';
memcpy(&cfgLineBuf[itemNameLen+1], itemValueString, itemValueStringLen); memcpy(&cfgLineBuf[itemNameLen + 1], itemValueString, itemValueStringLen);
cfgLineBuf[itemNameLen + itemValueStringLen + 1] = '\0'; cfgLineBuf[itemNameLen + itemValueStringLen + 1] = '\0';
paGetToken(cfgLineBuf, &name, &olen); paGetToken(cfgLineBuf, &name, &olen);
@ -1010,19 +1010,19 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
return 0; return 0;
} }
int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl) { int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl) {
int32_t index = 0; int32_t index = 0;
if (envCmd == NULL) return 0; if (envCmd == NULL) return 0;
while (envCmd[index]!=NULL) { while (envCmd[index] != NULL) {
if (strncmp(envCmd[index], "TAOS_APOLLO_URL", 14) == 0) { if (strncmp(envCmd[index], "TAOS_APOLLO_URL", 14) == 0) {
char *p = strchr(envCmd[index], '='); char *p = strchr(envCmd[index], '=');
if (p != NULL) { if (p != NULL) {
p++; p++;
if (*p == '\'') { if (*p == '\'') {
p++; p++;
p[strlen(p)-1] = '\0'; p[strlen(p) - 1] = '\0';
} }
memcpy(apolloUrl, p, TMIN(strlen(p)+1,PATH_MAX)); memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
uInfo("get apollo url from env cmd success"); uInfo("get apollo url from env cmd success");
return 0; return 0;
} }
@ -1033,8 +1033,8 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl
char line[1024]; char line[1024];
char **pEnv = environ; char **pEnv = environ;
line[1023] = 0; line[1023] = 0;
while(*pEnv != NULL) { while (*pEnv != NULL) {
strncpy(line, *pEnv, sizeof(line)-1); strncpy(line, *pEnv, sizeof(line) - 1);
pEnv++; pEnv++;
if (strncmp(line, "TAOS_APOLLO_URL", 14) == 0) { if (strncmp(line, "TAOS_APOLLO_URL", 14) == 0) {
char *p = strchr(line, '='); char *p = strchr(line, '=');
@ -1042,23 +1042,23 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl
p++; p++;
if (*p == '\'') { if (*p == '\'') {
p++; p++;
p[strlen(p)-1] = '\0'; p[strlen(p) - 1] = '\0';
} }
memcpy(apolloUrl, p, TMIN(strlen(p)+1,PATH_MAX)); memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
uInfo("get apollo url from env variables success, apolloUrl=%s",apolloUrl); uInfo("get apollo url from env variables success, apolloUrl=%s", apolloUrl);
return 0; return 0;
} }
} }
} }
const char *filepath = ".env"; const char *filepath = ".env";
if (envFile != NULL && strlen(envFile)>0) { if (envFile != NULL && strlen(envFile) > 0) {
if (!taosCheckExistFile(envFile)) { if (!taosCheckExistFile(envFile)) {
uError("failed to load env file: %s", envFile); uError("failed to load env file: %s", envFile);
return -1; return -1;
} }
filepath = envFile; filepath = envFile;
}else { } else {
if (!taosCheckExistFile(filepath)) { if (!taosCheckExistFile(filepath)) {
uInfo("failed to load env file: %s", filepath); uInfo("failed to load env file: %s", filepath);
return 0; return 0;
@ -1072,16 +1072,16 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl
if (_bytes <= 0) { if (_bytes <= 0) {
break; break;
} }
if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0; if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
if (strncmp(line, "TAOS_APOLLO_URL", 14) == 0) { if (strncmp(line, "TAOS_APOLLO_URL", 14) == 0) {
char *p = strchr(line, '='); char *p = strchr(line, '=');
if (p != NULL) { if (p != NULL) {
p++; p++;
if (*p == '\'') { if (*p == '\'') {
p++; p++;
p[strlen(p)-1] = '\0'; p[strlen(p) - 1] = '\0';
} }
memcpy(apolloUrl, p, TMIN(strlen(p)+1,PATH_MAX)); memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX));
taosCloseFile(&pFile); taosCloseFile(&pFile);
uInfo("get apollo url from env file success"); uInfo("get apollo url from env file success");
return 0; return 0;

File diff suppressed because it is too large Load Diff

View File

@ -24,13 +24,13 @@
* Copyright (c) 2016, Usman Masood <usmanm at fastmail dot fm> * Copyright (c) 2016, Usman Masood <usmanm at fastmail dot fm>
*/ */
#include "tdigest.h"
#include "os.h" #include "os.h"
#include "osMath.h" #include "osMath.h"
#include "tdigest.h"
#define INTERPOLATE(x, x0, x1) (((x) - (x0)) / ((x1) - (x0))) #define INTERPOLATE(x, x0, x1) (((x) - (x0)) / ((x1) - (x0)))
//#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (q) - 1) + M_PI / 2) / M_PI) //#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (q) - 1) + M_PI / 2) / M_PI)
#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (double)(q) - 1)/M_PI + (double)1/2)) #define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (double)(q)-1) / M_PI + (double)1 / 2))
#define FLOAT_EQ(f1, f2) (fabs((f1) - (f2)) <= FLT_EPSILON) #define FLOAT_EQ(f1, f2) (fabs((f1) - (f2)) <= FLT_EPSILON)
typedef struct SMergeArgs { typedef struct SMergeArgs {
@ -41,16 +41,16 @@ typedef struct SMergeArgs {
double k1; double k1;
double min; double min;
double max; double max;
}SMergeArgs; } SMergeArgs;
void tdigestAutoFill(TDigest* t, int32_t compression) { void tdigestAutoFill(TDigest *t, int32_t compression) {
t->centroids = (SCentroid*)((char*)t + sizeof(TDigest)); t->centroids = (SCentroid *)((char *)t + sizeof(TDigest));
t->buffered_pts = (SPt*) ((char*)t + sizeof(TDigest) + sizeof(SCentroid) * (int32_t)GET_CENTROID(compression)); t->buffered_pts = (SPt *)((char *)t + sizeof(TDigest) + sizeof(SCentroid) * (int32_t)GET_CENTROID(compression));
} }
TDigest *tdigestNewFrom(void* pBuf, int32_t compression) { TDigest *tdigestNewFrom(void *pBuf, int32_t compression) {
memset(pBuf, 0, (size_t)TDIGEST_SIZE(compression)); memset(pBuf, 0, (size_t)TDIGEST_SIZE(compression));
TDigest* t = (TDigest*)pBuf; TDigest *t = (TDigest *)pBuf;
tdigestAutoFill(t, compression); tdigestAutoFill(t, compression);
t->compression = compression; t->compression = compression;
@ -63,34 +63,29 @@ TDigest *tdigestNewFrom(void* pBuf, int32_t compression) {
} }
static int32_t cmpCentroid(const void *a, const void *b) { static int32_t cmpCentroid(const void *a, const void *b) {
SCentroid *c1 = (SCentroid *) a; SCentroid *c1 = (SCentroid *)a;
SCentroid *c2 = (SCentroid *) b; SCentroid *c2 = (SCentroid *)b;
if (c1->mean < c2->mean) if (c1->mean < c2->mean) return -1;
return -1; if (c1->mean > c2->mean) return 1;
if (c1->mean > c2->mean)
return 1;
return 0; return 0;
} }
static void mergeCentroid(SMergeArgs *args, SCentroid *merge) { static void mergeCentroid(SMergeArgs *args, SCentroid *merge) {
double k2; double k2;
SCentroid *c = &args->centroids[args->idx]; SCentroid *c = &args->centroids[args->idx];
args->weight_so_far += merge->weight; args->weight_so_far += merge->weight;
k2 = INTEGRATED_LOCATION(args->t->size, k2 = INTEGRATED_LOCATION(args->t->size, args->weight_so_far / args->t->total_weight);
args->weight_so_far / args->t->total_weight); // idx++
//idx++ if (k2 - args->k1 > 1 && c->weight > 0) {
if(k2 - args->k1 > 1 && c->weight > 0) { if (args->idx + 1 < args->t->size && merge->mean != args->centroids[args->idx].mean) {
if(args->idx + 1 < args->t->size
&& merge->mean != args->centroids[args->idx].mean) {
args->idx++; args->idx++;
} }
args->k1 = k2; args->k1 = k2;
} }
c = &args->centroids[args->idx]; c = &args->centroids[args->idx];
if(c->mean == merge->mean) { if (c->mean == merge->mean) {
c->weight += merge->weight; c->weight += merge->weight;
} else { } else {
c->weight += merge->weight; c->weight += merge->weight;
@ -110,10 +105,9 @@ void tdigestCompress(TDigest *t) {
int32_t i, j; int32_t i, j;
SMergeArgs args; SMergeArgs args;
if (t->num_buffered_pts <= 0) if (t->num_buffered_pts <= 0) return;
return;
unmerged_centroids = (SCentroid*)taosMemoryMalloc(sizeof(SCentroid) * t->num_buffered_pts); unmerged_centroids = (SCentroid *)taosMemoryMalloc(sizeof(SCentroid) * t->num_buffered_pts);
for (i = 0; i < num_unmerged; i++) { for (i = 0; i < num_unmerged; i++) {
SPt *p = t->buffered_pts + i; SPt *p = t->buffered_pts + i;
SCentroid *c = &unmerged_centroids[i]; SCentroid *c = &unmerged_centroids[i];
@ -126,7 +120,7 @@ void tdigestCompress(TDigest *t) {
taosSort(unmerged_centroids, num_unmerged, sizeof(SCentroid), cmpCentroid); taosSort(unmerged_centroids, num_unmerged, sizeof(SCentroid), cmpCentroid);
memset(&args, 0, sizeof(SMergeArgs)); memset(&args, 0, sizeof(SMergeArgs));
args.centroids = (SCentroid*)taosMemoryMalloc((size_t)(sizeof(SCentroid) * t->size)); args.centroids = (SCentroid *)taosMemoryMalloc((size_t)(sizeof(SCentroid) * t->size));
memset(args.centroids, 0, (size_t)(sizeof(SCentroid) * t->size)); memset(args.centroids, 0, (size_t)(sizeof(SCentroid) * t->size));
args.t = t; args.t = t;
@ -154,7 +148,7 @@ void tdigestCompress(TDigest *t) {
mergeCentroid(&args, &unmerged_centroids[i++]); mergeCentroid(&args, &unmerged_centroids[i++]);
assert(args.idx < t->size); assert(args.idx < t->size);
} }
taosMemoryFree((void*)unmerged_centroids); taosMemoryFree((void *)unmerged_centroids);
while (j < t->num_centroids) { while (j < t->num_centroids) {
mergeCentroid(&args, &t->centroids[j++]); mergeCentroid(&args, &t->centroids[j++]);
@ -171,15 +165,14 @@ void tdigestCompress(TDigest *t) {
} }
memcpy(t->centroids, args.centroids, sizeof(SCentroid) * t->num_centroids); memcpy(t->centroids, args.centroids, sizeof(SCentroid) * t->num_centroids);
taosMemoryFree((void*)args.centroids); taosMemoryFree((void *)args.centroids);
} }
void tdigestAdd(TDigest* t, double x, int64_t w) { void tdigestAdd(TDigest *t, double x, int64_t w) {
if (w == 0) if (w == 0) return;
return;
int32_t i = t->num_buffered_pts; int32_t i = t->num_buffered_pts;
if(i > 0 && t->buffered_pts[i-1].value == x ) { if (i > 0 && t->buffered_pts[i - 1].value == x) {
t->buffered_pts[i].weight = w; t->buffered_pts[i].weight = w;
} else { } else {
t->buffered_pts[i].value = x; t->buffered_pts[i].value = x;
@ -187,14 +180,11 @@ void tdigestAdd(TDigest* t, double x, int64_t w) {
t->num_buffered_pts++; t->num_buffered_pts++;
} }
if (t->num_buffered_pts >= t->threshold) tdigestCompress(t);
if (t->num_buffered_pts >= t->threshold)
tdigestCompress(t);
} }
double tdigestCDF(TDigest *t, double x) { double tdigestCDF(TDigest *t, double x) {
if (t == NULL) if (t == NULL) return 0;
return 0;
int32_t i; int32_t i;
double left, right; double left, right;
@ -202,15 +192,11 @@ double tdigestCDF(TDigest *t, double x) {
SCentroid *a, *b, tmp; SCentroid *a, *b, tmp;
tdigestCompress(t); tdigestCompress(t);
if (t->num_centroids == 0) if (t->num_centroids == 0) return NAN;
return NAN; if (x < t->min) return 0;
if (x < t->min) if (x > t->max) return 1;
return 0;
if (x > t->max)
return 1;
if (t->num_centroids == 1) { if (t->num_centroids == 1) {
if (FLOAT_EQ(t->max, t->min)) if (FLOAT_EQ(t->max, t->min)) return 0.5;
return 0.5;
return INTERPOLATE(x, t->min, t->max); return INTERPOLATE(x, t->min, t->max);
} }
@ -230,10 +216,7 @@ double tdigestCDF(TDigest *t, double x) {
right = (b->mean - a->mean) * a->weight / (a->weight + b->weight); right = (b->mean - a->mean) * a->weight / (a->weight + b->weight);
if (x < a->mean + right) { if (x < a->mean + right) {
double cdf = (weight_so_far double cdf = (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) / t->total_weight;
+ a->weight
* INTERPOLATE(x, a->mean - left, a->mean + right))
/ t->total_weight;
return TMAX(cdf, 0.0); return TMAX(cdf, 0.0);
} }
@ -245,16 +228,14 @@ double tdigestCDF(TDigest *t, double x) {
right = t->max - a->mean; right = t->max - a->mean;
if (x < a->mean + right) { if (x < a->mean + right) {
return (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) return (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) / t->total_weight;
/ t->total_weight;
} }
return 1; return 1;
} }
double tdigestQuantile(TDigest *t, double q) { double tdigestQuantile(TDigest *t, double q) {
if (t == NULL) if (t == NULL) return 0;
return 0;
int32_t i; int32_t i;
double left, right, idx; double left, right, idx;
@ -262,14 +243,10 @@ double tdigestQuantile(TDigest *t, double q) {
SCentroid *a, *b, tmp; SCentroid *a, *b, tmp;
tdigestCompress(t); tdigestCompress(t);
if (t->num_centroids == 0) if (t->num_centroids == 0) return NAN;
return NAN; if (t->num_centroids == 1) return t->centroids[0].mean;
if (t->num_centroids == 1) if (FLOAT_EQ(q, 0.0)) return t->min;
return t->centroids[0].mean; if (FLOAT_EQ(q, 1.0)) return t->max;
if (FLOAT_EQ(q, 0.0))
return t->min;
if (FLOAT_EQ(q, 1.0))
return t->max;
idx = q * t->total_weight; idx = q * t->total_weight;
weight_so_far = 0; weight_so_far = 0;
@ -284,7 +261,7 @@ double tdigestQuantile(TDigest *t, double q) {
left = right; left = right;
b = c; b = c;
right = (b->weight * a->mean + a->weight * b->mean)/ (a->weight + b->weight); right = (b->weight * a->mean + a->weight * b->mean) / (a->weight + b->weight);
if (idx < weight_so_far + a->weight) { if (idx < weight_so_far + a->weight) {
double p = (idx - weight_so_far) / a->weight; double p = (idx - weight_so_far) / a->weight;
return left * (1 - p) + right * p; return left * (1 - p) + right * p;
@ -307,10 +284,10 @@ double tdigestQuantile(TDigest *t, double q) {
void tdigestMerge(TDigest *t1, TDigest *t2) { void tdigestMerge(TDigest *t1, TDigest *t2) {
// SPoints // SPoints
int32_t num_pts = t2->num_buffered_pts; int32_t num_pts = t2->num_buffered_pts;
for(int32_t i = num_pts - 1; i >= 0; i--) { for (int32_t i = num_pts - 1; i >= 0; i--) {
SPt* p = t2->buffered_pts + i; SPt *p = t2->buffered_pts + i;
tdigestAdd(t1, p->value, p->weight); tdigestAdd(t1, p->value, p->weight);
t2->num_buffered_pts --; t2->num_buffered_pts--;
} }
// centroids // centroids
for (int32_t i = 0; i < t2->num_centroids; i++) { for (int32_t i = 0; i < t2->num_centroids; i++) {

View File

@ -62,9 +62,9 @@ int32_t taosEnvToCfg(const char *envStr, char *cfgStr) {
if (p != NULL) { if (p != NULL) {
char buf[CFG_NAME_MAX_LEN]; char buf[CFG_NAME_MAX_LEN];
if (*(p+1) == '\'') { if (*(p + 1) == '\'') {
*(p+1)= ' '; *(p + 1) = ' ';
char *pEnd = &cfgStr[strlen(cfgStr)-1]; char *pEnd = &cfgStr[strlen(cfgStr) - 1];
if (*pEnd == '\'') *pEnd = '\0'; if (*pEnd == '\'') *pEnd = '\0';
} }
*p = '\0'; *p = '\0';

View File

@ -890,5 +890,3 @@ void *taosHashAcquire(SHashObj *pHashObj, const void *key, size_t keyLen) {
void taosHashRelease(SHashObj *pHashObj, void *p) { taosHashCancelIterate(pHashObj, p); } void taosHashRelease(SHashObj *pHashObj, void *p) { taosHashCancelIterate(pHashObj, p); }
int64_t taosHashGetCompTimes(SHashObj *pHashObj) { return atomic_load_64(&pHashObj->compTimes); } int64_t taosHashGetCompTimes(SHashObj *pHashObj) { return atomic_load_64(&pHashObj->compTimes); }

Some files were not shown because too many files have changed in this diff Show More