Merge pull request #17326 from taosdata/refact/code_format
refact: code format
This commit is contained in:
commit
3950c8fc24
|
@ -47,7 +47,8 @@ typedef enum {
|
|||
int32_t grantCheck(EGrantType grant);
|
||||
|
||||
#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 = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
|
||||
// sql type
|
||||
|
||||
#ifdef TSDB_SQL_C
|
||||
|
@ -103,6 +105,8 @@ enum {
|
|||
TSDB_DEFINE_SQL_TYPE( TSDB_SQL_MAX, "max" )
|
||||
};
|
||||
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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)
|
||||
* @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.
|
||||
|
@ -193,7 +194,8 @@ int32_t catalogGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const S
|
|||
* @param pTableMeta(output, table meta data, NEED to free it by calller)
|
||||
* @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);
|
||||
|
||||
|
@ -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)
|
||||
* @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.
|
||||
|
@ -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)
|
||||
* @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.
|
||||
|
@ -267,7 +271,8 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCatalog, SRequestConnInfo* pConn, c
|
|||
*/
|
||||
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);
|
||||
|
||||
|
@ -291,7 +296,8 @@ int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp);
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "thash.h"
|
||||
#include "executor.h"
|
||||
#include "os.h"
|
||||
#include "plannodes.h"
|
||||
#include "thash.h"
|
||||
|
||||
#define DS_BUF_LOW 1
|
||||
#define DS_BUF_FULL 2
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#ifndef TDENGINE_TAOSUDF_H
|
||||
#define TDENGINE_TAOSUDF_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -61,7 +61,6 @@ typedef struct SUdfColumnData {
|
|||
};
|
||||
} SUdfColumnData;
|
||||
|
||||
|
||||
typedef struct SUdfColumn {
|
||||
SUdfColumnMeta colMeta;
|
||||
bool hasNull;
|
||||
|
@ -92,7 +91,8 @@ typedef int32_t (*TUdfDestroyFunc)();
|
|||
#define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT)
|
||||
|
||||
#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) \
|
||||
do { \
|
||||
BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \
|
||||
|
@ -116,7 +116,6 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767
|
|||
(((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))
|
||||
|
||||
|
||||
static FORCE_INLINE char *udfColDataGetData(const SUdfColumn *pColumn, int32_t row) {
|
||||
if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) {
|
||||
return pColumn->colData.varLenCol.payload + pColumn->colData.varLenCol.varOffsets[row];
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
#define alloc alloc
|
||||
#include <taosudf.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "tmsg.h"
|
||||
#include "tcommon.h"
|
||||
#include <stdint.h>
|
||||
#include "function.h"
|
||||
#include "tcommon.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tmsg.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -43,7 +43,6 @@ extern "C" {
|
|||
#endif
|
||||
#define UDF_DNODE_ID_ENV_NAME "DNODE_ID"
|
||||
|
||||
|
||||
// low level APIs
|
||||
/**
|
||||
* setup udf
|
||||
|
@ -62,7 +61,8 @@ int32_t doCallUdfAggProcess(UdfcFuncHandle handle, SSDataBlock *block, SUdfInter
|
|||
int32_t doCallUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfInterBuf *resultData);
|
||||
// input: interbuf1, interbuf2
|
||||
// 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
|
||||
// output: resultData
|
||||
int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output);
|
||||
|
|
|
@ -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 tDeserializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo);
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *server;
|
||||
uint16_t port;
|
||||
|
|
|
@ -61,7 +61,6 @@ typedef struct STableComInfo {
|
|||
int32_t rowSize; // row size of the schema
|
||||
} STableComInfo;
|
||||
|
||||
|
||||
typedef struct SIndexMeta {
|
||||
#if defined(WINDOWS) || defined(_TD_DARWIN_64)
|
||||
size_t avoidCompilationErrors;
|
||||
|
@ -265,7 +264,9 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
|
|||
|
||||
#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(...) \
|
||||
do { \
|
||||
|
|
|
@ -72,7 +72,6 @@ typedef struct SQWMsg {
|
|||
SRpcHandleInfo connInfo;
|
||||
} SQWMsg;
|
||||
|
||||
|
||||
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const SMsgCb *pMsgCb);
|
||||
|
||||
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 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
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ typedef struct SFilterColumnParam {
|
|||
} SFilterColumnParam;
|
||||
|
||||
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 filterSetDataFromColId(SFilterInfo *info, void *param);
|
||||
extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict);
|
||||
|
|
|
@ -80,7 +80,6 @@ typedef struct SSchedulerReq {
|
|||
void** pFetchRes;
|
||||
} SSchedulerReq;
|
||||
|
||||
|
||||
int32_t schedulerInit(void);
|
||||
|
||||
int32_t schedulerExecJob(SSchedulerReq* pReq, int64_t* pJob);
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#ifndef _TD_TFS_H_
|
||||
#define _TD_TFS_H_
|
||||
|
||||
#include "tdef.h"
|
||||
#include "monitor.h"
|
||||
#include "tdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -26,28 +26,28 @@ extern "C" {
|
|||
#include <regex.h>
|
||||
|
||||
#if !defined(WINDOWS)
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sched.h>
|
||||
#include <wordexp.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/mman.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <termios.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/wait.h>
|
||||
#include <termios.h>
|
||||
|
||||
#if defined(DARWIN)
|
||||
#else
|
||||
#include <sys/prctl.h>
|
||||
#include <argp.h>
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
#else
|
||||
|
||||
|
@ -82,11 +82,13 @@ extern "C" {
|
|||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include "taoserror.h"
|
||||
#include "osThread.h"
|
||||
|
||||
#include "osAtomic.h"
|
||||
#include "osDef.h"
|
||||
#include "osDir.h"
|
||||
#include "osEndian.h"
|
||||
#include "osEnv.h"
|
||||
#include "osFile.h"
|
||||
#include "osLocale.h"
|
||||
#include "osLz4.h"
|
||||
|
@ -94,10 +96,9 @@ extern "C" {
|
|||
#include "osMemory.h"
|
||||
#include "osProc.h"
|
||||
#include "osRand.h"
|
||||
#include "osThread.h"
|
||||
#include "osSemaphore.h"
|
||||
#include "osSignal.h"
|
||||
#include "osShm.h"
|
||||
#include "osSignal.h"
|
||||
#include "osSleep.h"
|
||||
#include "osSocket.h"
|
||||
#include "osString.h"
|
||||
|
@ -106,7 +107,7 @@ extern "C" {
|
|||
#include "osTime.h"
|
||||
#include "osTimer.h"
|
||||
#include "osTimezone.h"
|
||||
#include "osEnv.h"
|
||||
#include "taoserror.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ extern "C" {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WINDOWS)
|
||||
char *stpcpy(char *dest, const char *src);
|
||||
char *stpncpy(char *dest, const char *src, int n);
|
||||
|
@ -171,9 +170,15 @@ extern "C" {
|
|||
|
||||
#define DEFAULT_DOUBLE_COMP(x, y) \
|
||||
do { \
|
||||
if (isnan(x) && isnan(y)) { return 0; } \
|
||||
if (isnan(x)) { return -1; } \
|
||||
if (isnan(y)) { return 1; } \
|
||||
if (isnan(x) && isnan(y)) { \
|
||||
return 0; \
|
||||
} \
|
||||
if (isnan(x)) { \
|
||||
return -1; \
|
||||
} \
|
||||
if (isnan(y)) { \
|
||||
return 1; \
|
||||
} \
|
||||
if ((x) == (y)) { \
|
||||
return 0; \
|
||||
} else { \
|
||||
|
@ -209,14 +214,20 @@ extern "C" {
|
|||
#if defined(_TD_DARWIN_64)
|
||||
// MacOS
|
||||
#if !defined(_GNU_SOURCE)
|
||||
#define setThreadName(name) do { pthread_setname_np((name)); } while (0)
|
||||
#define setThreadName(name) \
|
||||
do { \
|
||||
pthread_setname_np((name)); \
|
||||
} while (0)
|
||||
#else
|
||||
// pthread_setname_np not defined
|
||||
#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)
|
||||
#define setThreadName(name) \
|
||||
do { \
|
||||
prctl(PR_SET_NAME, (name)); \
|
||||
} while (0)
|
||||
#endif
|
||||
#else
|
||||
// Windows
|
||||
|
|
|
@ -51,7 +51,6 @@ extern "C" {
|
|||
typedef struct TdDir *TdDirPtr;
|
||||
typedef struct TdDirEntry *TdDirEntryPtr;
|
||||
|
||||
|
||||
void taosRemoveDir(const char *dirname);
|
||||
bool taosDirExist(const char *dirname);
|
||||
int32_t taosMkDir(const char *dirname);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define _TD_OS_ENV_H_
|
||||
|
||||
#include "osSysinfo.h"
|
||||
#include "osTimezone.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -24,8 +24,7 @@ extern "C" {
|
|||
|
||||
#ifdef __APPLE__
|
||||
|
||||
enum EPOLL_EVENTS
|
||||
{
|
||||
enum EPOLL_EVENTS {
|
||||
EPOLLIN = 0x001,
|
||||
#define EPOLLIN EPOLLIN
|
||||
EPOLLPRI = 0x002,
|
||||
|
@ -63,17 +62,14 @@ enum EPOLL_EVENTS
|
|||
#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */
|
||||
#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */
|
||||
|
||||
|
||||
typedef union epoll_data
|
||||
{
|
||||
typedef union epoll_data {
|
||||
void *ptr;
|
||||
int fd;
|
||||
uint32_t u32;
|
||||
uint64_t u64;
|
||||
} epoll_data_t;
|
||||
|
||||
struct epoll_event
|
||||
{
|
||||
struct epoll_event {
|
||||
uint32_t events; /* Epoll events */
|
||||
epoll_data_t data; /* User data variable */
|
||||
};
|
||||
|
@ -90,4 +86,3 @@ int epoll_close(int epfd);
|
|||
#endif
|
||||
|
||||
#endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ typedef pthread_key_t TdThreadKey;
|
|||
#define taosThreadCleanupPush pthread_cleanup_push
|
||||
#define taosThreadCleanupPop pthread_cleanup_pop
|
||||
|
||||
|
||||
#ifdef WINDOWS
|
||||
#define TD_PTHREAD_MUTEX_INITIALIZER (TdThreadMutex)(-1)
|
||||
#else
|
||||
|
|
|
@ -26,8 +26,7 @@ extern "C" {
|
|||
#define tzset TZSET_FUNC_TAOS_FORBID
|
||||
#endif
|
||||
|
||||
enum TdTimezone
|
||||
{
|
||||
enum TdTimezone {
|
||||
TdWestZone12 = -12,
|
||||
TdWestZone11,
|
||||
TdWestZone10,
|
||||
|
|
|
@ -38,8 +38,7 @@ typedef struct SBloomFilter {
|
|||
|
||||
SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate);
|
||||
int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len);
|
||||
int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf,
|
||||
uint32_t len);
|
||||
int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, uint32_t len);
|
||||
void tBloomFilterDestroy(SBloomFilter *pBF);
|
||||
void tBloomFilterDump(const SBloomFilter *pBF);
|
||||
bool tBloomFilterIsFull(const SBloomFilter *pBF);
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#ifndef TDIGEST_H
|
||||
#define TDIGEST_H
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950288 /* pi */
|
||||
#endif
|
||||
|
@ -32,7 +34,8 @@
|
|||
#define COMPRESSION 300
|
||||
#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 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 {
|
||||
double mean;
|
||||
|
|
|
@ -28,10 +28,7 @@ typedef void (*_taos_lru_deleter_t)(const void *key, size_t keyLen, void *value)
|
|||
|
||||
typedef struct LRUHandle LRUHandle;
|
||||
|
||||
typedef enum {
|
||||
TAOS_LRU_PRIORITY_HIGH,
|
||||
TAOS_LRU_PRIORITY_LOW
|
||||
} LRUPriority;
|
||||
typedef enum { TAOS_LRU_PRIORITY_HIGH, TAOS_LRU_PRIORITY_LOW } LRUPriority;
|
||||
|
||||
typedef enum {
|
||||
TAOS_LRU_STATUS_OK,
|
||||
|
|
|
@ -53,7 +53,8 @@ typedef struct SDiskbasedBufStatis {
|
|||
* @param handle
|
||||
* @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);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -30,8 +30,7 @@ typedef struct SScalableBf {
|
|||
|
||||
SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate);
|
||||
int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len);
|
||||
int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf,
|
||||
uint32_t len);
|
||||
int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, uint32_t len);
|
||||
void tScalableBfDestroy(SScalableBf *pSBf);
|
||||
int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder *pEncoder);
|
||||
SScalableBf *tScalableBfDecode(SDecoder *pDecoder);
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
#include "os.h"
|
||||
#include "tcrc32c.h"
|
||||
#include "tdef.h"
|
||||
#include "tmd5.h"
|
||||
#include "thash.h"
|
||||
#include "tmd5.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -73,5 +73,3 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet) {
|
|||
|
||||
return ep;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ static int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int
|
|||
static char* forwardToTimeStringEnd(char* str);
|
||||
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,
|
||||
parseLocaltimeDst};
|
||||
static int32_t (*parseLocaltimeFp[])(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) = {
|
||||
parseLocaltime, parseLocaltimeDst};
|
||||
|
||||
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 */
|
||||
|
@ -438,11 +438,9 @@ char getPrecisionUnit(int32_t precision) {
|
|||
}
|
||||
|
||||
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);
|
||||
assert(toPrecision == TSDB_TIME_PRECISION_MILLI ||
|
||||
toPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
toPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
double tempResult = (double)time;
|
||||
switch (fromPrecision) {
|
||||
|
@ -493,7 +491,8 @@ end_:
|
|||
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:
|
||||
// 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 ||
|
||||
// fromPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
|
@ -503,8 +502,8 @@ end_:
|
|||
// ((double)time * factors[fromPrecision][toPrecision]);
|
||||
//}
|
||||
|
||||
|
||||
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = 1626006833631000064
|
||||
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double =
|
||||
// 1626006833631000064
|
||||
int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) {
|
||||
assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
fromPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
|
|
|
@ -209,7 +209,8 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) {
|
|||
uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5);
|
||||
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) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "dmMgmt.h"
|
||||
#include "tconfig.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_CFG_DIR "Configuration directory."
|
||||
#define DM_DMP_CFG "Dump configuration."
|
||||
|
@ -28,6 +29,7 @@
|
|||
#define DM_MACHINE_CODE "Get machine code."
|
||||
#define DM_VERSION "Print program version."
|
||||
#define DM_EMAIL "<support@taosdata.com>"
|
||||
// clang-format on
|
||||
static struct {
|
||||
#ifdef WINDOWS
|
||||
bool winServiceMode;
|
||||
|
|
|
@ -21,7 +21,6 @@ void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) {
|
|||
qndGetLoad(pMgmt->pQnode, &qload);
|
||||
|
||||
qload.dnodeId = pMgmt->pData->dnodeId;
|
||||
|
||||
}
|
||||
|
||||
void qmGetQnodeLoads(SQnodeMgmt *pMgmt, SQnodeLoad *pInfo) {
|
||||
|
|
|
@ -52,17 +52,23 @@ static int32_t dmInitMonitor() {
|
|||
static bool dmCheckDiskSpace() {
|
||||
osUpdate();
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
@ -73,7 +79,8 @@ static bool dmCheckDataDirVersion() {
|
|||
char checkDataDirJsonFileName[PATH_MAX];
|
||||
snprintf(checkDataDirJsonFileName, PATH_MAX, "%s/dnode/dnodeCfg.json", tsDataDir);
|
||||
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 true;
|
||||
|
|
|
@ -183,4 +183,3 @@ void dmGetQnodeLoads(SQnodeLoad *pInfo) {
|
|||
dmReleaseWrapper(pWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// clang-format off
|
||||
|
||||
#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
|
||||
|
|
|
@ -25,7 +25,6 @@ extern "C" {
|
|||
int32_t mndInitQuery(SMnode *pMnode);
|
||||
void mndCleanupQuery(SMnode *pMnode);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndBnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndMnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndSync.h"
|
||||
#include "mndTrans.h"
|
||||
|
|
|
@ -150,4 +150,3 @@ void mndCleanupPerfs(SMnode *pMnode) {
|
|||
taosHashCleanup(pMnode->perfsMeta);
|
||||
pMnode->perfsMeta = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndQnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndSnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
|
|
|
@ -1179,8 +1179,8 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName,
|
|||
SNode *pNode = NULL;
|
||||
FOREACH(pNode, pNodeList) {
|
||||
SColumnNode *pCol = (SColumnNode *)pNode;
|
||||
mInfo("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId,
|
||||
pCol->tableId, pTopic->ctbStbUid);
|
||||
mInfo("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId, pCol->tableId,
|
||||
pTopic->ctbStbUid);
|
||||
|
||||
if (pCol->tableId != suid && pTopic->ctbStbUid != suid) {
|
||||
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);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
mInfo("tsma:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, sql:%s", pSma->name,
|
||||
stbFullName, suid, colId, pSma->sql);
|
||||
mInfo("tsma:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, sql:%s", pSma->name, stbFullName,
|
||||
suid, colId, pSma->sql);
|
||||
|
||||
SNode *pAst = NULL;
|
||||
if (nodesStringToNode(pSma->ast, &pAst) != 0) {
|
||||
|
|
|
@ -1555,8 +1555,8 @@ static int32_t mndCheckDnodeMemory(SMnode *pMnode, SDbObj *pOldDb, SDbObj *pNewD
|
|||
terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE;
|
||||
return -1;
|
||||
} else if (inVgroup) {
|
||||
mInfo("db:%s, vgId:%d, memory in dnode:%d, avail:%" PRId64 " used:%" PRId64, pNewVgroup->dbName,
|
||||
pNewVgroup->vgId, pDnode->id, pDnode->memAvail, pDnode->memUsed);
|
||||
mInfo("db:%s, vgId:%d, memory in dnode:%d, avail:%" PRId64 " used:%" PRId64, pNewVgroup->dbName, pNewVgroup->vgId,
|
||||
pDnode->id, pDnode->memAvail, pDnode->memUsed);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,7 @@ void MndTestFunc::SetComment(SCreateFuncReq* pReq, const char* pComment) {
|
|||
strcpy(pReq->pComment, pComment);
|
||||
}
|
||||
|
||||
void MndTestFunc::SetBufSize(SCreateFuncReq* pReq, int32_t size) {
|
||||
pReq->bufSize = size;
|
||||
}
|
||||
void MndTestFunc::SetBufSize(SCreateFuncReq* pReq, int32_t size) { pReq->bufSize = size; }
|
||||
|
||||
TEST_F(MndTestFunc, 01_Show_Func) {
|
||||
test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", "");
|
||||
|
@ -509,5 +507,4 @@ TEST_F(MndTestFunc, 05_Actual_code) {
|
|||
}
|
||||
tFreeSRetrieveFuncRsp(&retrieveRsp);
|
||||
}
|
||||
|
||||
}
|
|
@ -32,7 +32,8 @@ class MndTestStb : public ::testing::Test {
|
|||
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* 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;
|
||||
|
|
|
@ -306,8 +306,8 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
|
|||
pSdb->commitTerm = pSdb->applyTerm;
|
||||
pSdb->commitConfig = pSdb->applyConfig;
|
||||
memcpy(pSdb->tableVer, tableVer, sizeof(tableVer));
|
||||
mInfo("read sdb file:%s success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64, file,
|
||||
pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig);
|
||||
mInfo("read sdb file:%s success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64, file, pSdb->commitIndex,
|
||||
pSdb->commitTerm, pSdb->commitConfig);
|
||||
|
||||
_OVER:
|
||||
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 (config != NULL) *config = commitConfig;
|
||||
|
||||
mInfo("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64
|
||||
" file:%s",
|
||||
mInfo("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s",
|
||||
pIter, commitIndex, commitTerm, commitConfig, pIter->name);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
#include "tlog.h"
|
||||
#include "tmsg.h"
|
||||
#include "trpc.h"
|
||||
#include "tmsgcb.h"
|
||||
#include "trpc.h"
|
||||
|
||||
#include "qnode.h"
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
*/
|
||||
|
||||
#include "executor.h"
|
||||
#include "libs/function/function.h"
|
||||
#include "qndInt.h"
|
||||
#include "query.h"
|
||||
#include "qworker.h"
|
||||
#include "libs/function/function.h"
|
||||
|
||||
SQnode *qndOpen(const SQnodeOpt *pOption) {
|
||||
SQnode *pQnode = taosMemoryCalloc(1, sizeof(SQnode));
|
||||
|
|
|
@ -78,8 +78,7 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
|
|||
if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1;
|
||||
if (tDecodeI32v(pCoder, &pME->ctbEntry.commentLen) < 0) return -1;
|
||||
if (pME->ctbEntry.commentLen > 0) {
|
||||
if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0)
|
||||
return -1;
|
||||
if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0) return -1;
|
||||
}
|
||||
if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1;
|
||||
if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO)
|
||||
|
|
|
@ -92,7 +92,8 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p
|
|||
days = freqDuration;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -328,4 +328,3 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
|
|||
tdbTbcClose(pCur);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,8 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) {
|
|||
pInfo->elapsedTime += el;
|
||||
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) {
|
||||
goto _exit;
|
||||
}
|
||||
|
@ -150,7 +151,8 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) {
|
|||
}
|
||||
|
||||
// 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 step = backward ? 1 : -1;
|
||||
while (i >= 0 && i < num && uid >= pBlockList[i].minUid && uid <= pBlockList[i].maxUid) {
|
||||
|
@ -195,7 +197,8 @@ 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 step = backward ? 1 : -1;
|
||||
while (i >= 0 && i < num && uid == uidList[i]) {
|
||||
|
@ -319,9 +322,7 @@ _exit:
|
|||
return code;
|
||||
}
|
||||
|
||||
void tLDataIterClose(SLDataIter *pIter) {
|
||||
taosMemoryFree(pIter);
|
||||
}
|
||||
void tLDataIterClose(SLDataIter *pIter) { taosMemoryFree(pIter); }
|
||||
|
||||
void tLDataIterNextBlock(SLDataIter *pIter) {
|
||||
int32_t step = pIter->backward ? -1 : 1;
|
||||
|
@ -383,7 +384,8 @@ static void findNextValidRow(SLDataIter *pIter, const char* idStr) {
|
|||
SBlockData *pBlockData = loadLastBlock(pIter, idStr);
|
||||
|
||||
// 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)) &&
|
||||
pBlockData->aUid != NULL) {
|
||||
i = binarySearchForStartRowIndex((uint64_t *)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward);
|
||||
if (i == -1) {
|
||||
pIter->iRow = -1;
|
||||
|
@ -396,13 +398,15 @@ static void findNextValidRow(SLDataIter *pIter, const char* idStr) {
|
|||
if (!pIter->backward) {
|
||||
/*if (pBlockData->aUid[i] < pIter->uid) {
|
||||
continue;
|
||||
} else */if (pBlockData->aUid[i] > pIter->uid) {
|
||||
} else */
|
||||
if (pBlockData->aUid[i] > pIter->uid) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/*if (pBlockData->aUid[i] > pIter->uid) {
|
||||
continue;
|
||||
} else */if (pBlockData->aUid[i] < pIter->uid) {
|
||||
} else */
|
||||
if (pBlockData->aUid[i] < pIter->uid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -528,7 +532,8 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
|
|||
|
||||
for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file
|
||||
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) {
|
||||
goto _end;
|
||||
}
|
||||
|
|
|
@ -799,4 +799,3 @@ bool vnodeIsLeader(SVnode *pVnode) {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include <tglobal.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <vnodeInt.h>
|
||||
#include <tmsg.h>
|
||||
#include <vnodeInt.h>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
|
@ -441,7 +441,6 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
|
|||
pDataBlock->pDataBlock = taosArrayInit(tSmaNumOfCols, sizeof(SColumnInfoData *));
|
||||
EXPECT_NE(pDataBlock->pDataBlock, nullptr);
|
||||
for (int32_t c = 0; c < tSmaNumOfCols; ++c) {
|
||||
|
||||
SColumnInfoData *pColInfoData = (SColumnInfoData *)taosMemoryCalloc(1, sizeof(SColumnInfoData));
|
||||
EXPECT_NE(pColInfoData, nullptr);
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ typedef struct TdDir {
|
|||
HANDLE hFind;
|
||||
} TdDir;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
WRDE_NOSPACE = 1, /* Ran out of memory. */
|
||||
WRDE_BADCHAR, /* A metachar appears in the wrong place. */
|
||||
WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */
|
||||
|
@ -309,10 +308,12 @@ int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) {
|
|||
// printf("failed to expand path:%s since Out of memory\n", dirname);
|
||||
return -1;
|
||||
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;
|
||||
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;
|
||||
default:
|
||||
// printf("failed to expand path:%s since %s\n", dirname, strerror(errno));
|
||||
|
|
|
@ -75,8 +75,10 @@ void taosPrintBackTrace() {
|
|||
// SymSetOptions(SYMOPT_LOAD_LINES);
|
||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
|
||||
if (SymFromAddr(process, address, &displacementSym, pSymbol) && 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);
|
||||
if (SymFromAddr(process, address, &displacementSym, pSymbol) &&
|
||||
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 {
|
||||
snprintf(buf_tmp, sizeof(buf_tmp), "BackTrace error: %d\n", GetLastError());
|
||||
}
|
||||
|
@ -126,14 +128,13 @@ int32_t taosBackTrace(void **buffer, int32_t size) {
|
|||
|
||||
#ifdef USE_ADDR2LINE
|
||||
|
||||
#include "osThread.h"
|
||||
#include "libdwarf.h"
|
||||
#include "dwarf.h"
|
||||
#include "libdwarf.h"
|
||||
#include "osThread.h"
|
||||
|
||||
#define DW_PR_DUu "llu"
|
||||
|
||||
typedef struct lookup_table
|
||||
{
|
||||
typedef struct lookup_table {
|
||||
Dwarf_Line *table;
|
||||
Dwarf_Line_Context *ctxts;
|
||||
int cnt;
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
#ifdef WINDOWS
|
||||
#include "windows.h"
|
||||
#include "wincrypt.h"
|
||||
#include "windows.h"
|
||||
#else
|
||||
#include <sys/file.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "os.h"
|
||||
|
||||
|
||||
#if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
|
|
@ -214,7 +214,6 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool taosCheckSystemIsLittleEnd() {
|
||||
union check {
|
||||
int16_t i;
|
||||
|
@ -338,7 +337,8 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
|
|||
#ifdef WINDOWS
|
||||
char value[100];
|
||||
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);
|
||||
SYSTEM_INFO si;
|
||||
memset(&si, 0, sizeof(SYSTEM_INFO));
|
||||
|
@ -776,8 +776,9 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
|
|||
#ifdef WINDOWS
|
||||
GUID 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],
|
||||
guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
|
||||
snprintf(uid, uidlen, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3,
|
||||
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;
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
|
@ -971,14 +972,17 @@ SysNameInfo taosGetSysNameInfo() {
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool taosCheckCurrentInDll() {
|
||||
#ifdef WINDOWS
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
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);
|
||||
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 false;
|
||||
|
|
|
@ -21,9 +21,7 @@ int32_t taosThreadCreate(TdThread * tid, const TdThreadAttr * attr, void *(*star
|
|||
return pthread_create(tid, attr, start, arg);
|
||||
}
|
||||
|
||||
int32_t taosThreadAttrDestroy(TdThreadAttr * attr) {
|
||||
return pthread_attr_destroy(attr);
|
||||
}
|
||||
int32_t taosThreadAttrDestroy(TdThreadAttr *attr) { return pthread_attr_destroy(attr); }
|
||||
|
||||
int32_t taosThreadAttrGetDetachState(const TdThreadAttr *attr, int32_t *detachstate) {
|
||||
return pthread_attr_getdetachstate(attr, detachstate);
|
||||
|
@ -49,9 +47,7 @@ int32_t taosThreadAttrGetStackSize(const TdThreadAttr * attr, size_t * stacksize
|
|||
return pthread_attr_getstacksize(attr, stacksize);
|
||||
}
|
||||
|
||||
int32_t taosThreadAttrInit(TdThreadAttr * attr) {
|
||||
return pthread_attr_init(attr);
|
||||
}
|
||||
int32_t taosThreadAttrInit(TdThreadAttr *attr) { return pthread_attr_init(attr); }
|
||||
|
||||
int32_t taosThreadAttrSetDetachState(TdThreadAttr *attr, int32_t detachstate) {
|
||||
return pthread_attr_setdetachstate(attr, detachstate);
|
||||
|
@ -77,117 +73,77 @@ int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize) {
|
|||
return pthread_attr_setstacksize(attr, stacksize);
|
||||
}
|
||||
|
||||
int32_t taosThreadCancel(TdThread thread) {
|
||||
return pthread_cancel(thread);
|
||||
}
|
||||
int32_t taosThreadCancel(TdThread thread) { return pthread_cancel(thread); }
|
||||
|
||||
int32_t taosThreadCondDestroy(TdThreadCond * cond) {
|
||||
return pthread_cond_destroy(cond);
|
||||
}
|
||||
int32_t taosThreadCondDestroy(TdThreadCond *cond) { return pthread_cond_destroy(cond); }
|
||||
|
||||
int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr) {
|
||||
return pthread_cond_init(cond, attr);
|
||||
}
|
||||
int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr) { return pthread_cond_init(cond, attr); }
|
||||
|
||||
int32_t taosThreadCondSignal(TdThreadCond * cond) {
|
||||
return pthread_cond_signal(cond);
|
||||
}
|
||||
int32_t taosThreadCondSignal(TdThreadCond *cond) { return pthread_cond_signal(cond); }
|
||||
|
||||
int32_t taosThreadCondBroadcast(TdThreadCond * cond) {
|
||||
return pthread_cond_broadcast(cond);
|
||||
}
|
||||
int32_t taosThreadCondBroadcast(TdThreadCond *cond) { return pthread_cond_broadcast(cond); }
|
||||
|
||||
int32_t taosThreadCondWait(TdThreadCond * cond, TdThreadMutex * mutex) {
|
||||
return pthread_cond_wait(cond, mutex);
|
||||
}
|
||||
int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex) { return pthread_cond_wait(cond, mutex); }
|
||||
|
||||
int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime) {
|
||||
return pthread_cond_timedwait(cond, mutex, abstime);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrDestroy(TdThreadCondAttr * attr) {
|
||||
return pthread_condattr_destroy(attr);
|
||||
}
|
||||
int32_t taosThreadCondAttrDestroy(TdThreadCondAttr *attr) { return pthread_condattr_destroy(attr); }
|
||||
|
||||
int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr *attr, int32_t *pshared) {
|
||||
return pthread_condattr_getpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadCondAttrInit(TdThreadCondAttr * attr) {
|
||||
return pthread_condattr_init(attr);
|
||||
}
|
||||
int32_t taosThreadCondAttrInit(TdThreadCondAttr *attr) { return pthread_condattr_init(attr); }
|
||||
|
||||
int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr *attr, int32_t pshared) {
|
||||
return pthread_condattr_setpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadDetach(TdThread thread) {
|
||||
return pthread_detach(thread);
|
||||
}
|
||||
int32_t taosThreadDetach(TdThread thread) { return pthread_detach(thread); }
|
||||
|
||||
int32_t taosThreadEqual(TdThread t1, TdThread t2) {
|
||||
return pthread_equal(t1, t2);
|
||||
}
|
||||
int32_t taosThreadEqual(TdThread t1, TdThread t2) { return pthread_equal(t1, t2); }
|
||||
|
||||
void taosThreadExit(void *valuePtr) {
|
||||
return pthread_exit(valuePtr);
|
||||
}
|
||||
void taosThreadExit(void *valuePtr) { return pthread_exit(valuePtr); }
|
||||
|
||||
int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param) {
|
||||
return pthread_getschedparam(thread, policy, param);
|
||||
}
|
||||
|
||||
void *taosThreadGetSpecific(TdThreadKey key) {
|
||||
return pthread_getspecific(key);
|
||||
}
|
||||
void *taosThreadGetSpecific(TdThreadKey key) { return pthread_getspecific(key); }
|
||||
|
||||
int32_t taosThreadJoin(TdThread thread, void **valuePtr) {
|
||||
return pthread_join(thread, valuePtr);
|
||||
}
|
||||
int32_t taosThreadJoin(TdThread thread, void **valuePtr) { return pthread_join(thread, valuePtr); }
|
||||
|
||||
int32_t taosThreadKeyCreate(TdThreadKey *key, void (*destructor)(void *)) {
|
||||
return pthread_key_create(key, destructor);
|
||||
}
|
||||
|
||||
int32_t taosThreadKeyDelete(TdThreadKey key) {
|
||||
return pthread_key_delete(key);
|
||||
}
|
||||
int32_t taosThreadKeyDelete(TdThreadKey key) { return pthread_key_delete(key); }
|
||||
|
||||
int32_t taosThreadKill(TdThread thread, int32_t sig) {
|
||||
return pthread_kill(thread, sig);
|
||||
}
|
||||
int32_t taosThreadKill(TdThread thread, int32_t sig) { return pthread_kill(thread, sig); }
|
||||
|
||||
// int32_t taosThreadMutexConsistent(TdThreadMutex* mutex) {
|
||||
// return pthread_mutex_consistent(mutex);
|
||||
// }
|
||||
|
||||
int32_t taosThreadMutexDestroy(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_destroy(mutex);
|
||||
}
|
||||
int32_t taosThreadMutexDestroy(TdThreadMutex *mutex) { return pthread_mutex_destroy(mutex); }
|
||||
|
||||
int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr) {
|
||||
return pthread_mutex_init(mutex, attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexLock(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_lock(mutex);
|
||||
}
|
||||
int32_t taosThreadMutexLock(TdThreadMutex *mutex) { return pthread_mutex_lock(mutex); }
|
||||
|
||||
// int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime) {
|
||||
// return pthread_mutex_timedlock(mutex, abstime);
|
||||
// }
|
||||
|
||||
int32_t taosThreadMutexTryLock(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_trylock(mutex);
|
||||
}
|
||||
int32_t taosThreadMutexTryLock(TdThreadMutex *mutex) { return pthread_mutex_trylock(mutex); }
|
||||
|
||||
int32_t taosThreadMutexUnlock(TdThreadMutex * mutex) {
|
||||
return pthread_mutex_unlock(mutex);
|
||||
}
|
||||
int32_t taosThreadMutexUnlock(TdThreadMutex *mutex) { return pthread_mutex_unlock(mutex); }
|
||||
|
||||
int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr * attr) {
|
||||
return pthread_mutexattr_destroy(attr);
|
||||
}
|
||||
int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr *attr) { return pthread_mutexattr_destroy(attr); }
|
||||
|
||||
int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr *attr, int32_t *pshared) {
|
||||
return pthread_mutexattr_getpshared(attr, pshared);
|
||||
|
@ -201,9 +157,7 @@ int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr * attr, int32_t *kind
|
|||
return pthread_mutexattr_gettype(attr, kind);
|
||||
}
|
||||
|
||||
int32_t taosThreadMutexAttrInit(TdThreadMutexAttr * attr) {
|
||||
return pthread_mutexattr_init(attr);
|
||||
}
|
||||
int32_t taosThreadMutexAttrInit(TdThreadMutexAttr *attr) { return pthread_mutexattr_init(attr); }
|
||||
|
||||
int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr *attr, int32_t pshared) {
|
||||
return pthread_mutexattr_setpshared(attr, pshared);
|
||||
|
@ -221,17 +175,13 @@ int32_t taosThreadOnce(TdThreadOnce * onceControl, void(*initRoutine)(void)) {
|
|||
return pthread_once(onceControl, initRoutine);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockDestroy(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_destroy(rwlock);
|
||||
}
|
||||
int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock) { return pthread_rwlock_destroy(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr) {
|
||||
return pthread_rwlock_init(rwlock, attr);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_rdlock(rwlock);
|
||||
}
|
||||
int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_rdlock(rwlock); }
|
||||
|
||||
// int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime) {
|
||||
// return pthread_rwlock_timedrdlock(rwlock, abstime);
|
||||
|
@ -241,57 +191,37 @@ int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock) {
|
|||
// return pthread_rwlock_timedwrlock(rwlock, abstime);
|
||||
// }
|
||||
|
||||
int32_t taosThreadRwlockTryRdlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_tryrdlock(rwlock);
|
||||
}
|
||||
int32_t taosThreadRwlockTryRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_tryrdlock(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockTryWrlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_trywrlock(rwlock);
|
||||
}
|
||||
int32_t taosThreadRwlockTryWrlock(TdThreadRwlock *rwlock) { return pthread_rwlock_trywrlock(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockUnlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_unlock(rwlock);
|
||||
}
|
||||
int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock) { return pthread_rwlock_unlock(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockWrlock(TdThreadRwlock * rwlock) {
|
||||
return pthread_rwlock_wrlock(rwlock);
|
||||
}
|
||||
int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock) { return pthread_rwlock_wrlock(rwlock); }
|
||||
|
||||
int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr * attr) {
|
||||
return pthread_rwlockattr_destroy(attr);
|
||||
}
|
||||
int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr *attr) { return pthread_rwlockattr_destroy(attr); }
|
||||
|
||||
int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr *attr, int32_t *pshared) {
|
||||
return pthread_rwlockattr_getpshared(attr, pshared);
|
||||
}
|
||||
|
||||
int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr * attr) {
|
||||
return pthread_rwlockattr_init(attr);
|
||||
}
|
||||
int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr *attr) { return pthread_rwlockattr_init(attr); }
|
||||
|
||||
int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr *attr, int32_t pshared) {
|
||||
return pthread_rwlockattr_setpshared(attr, pshared);
|
||||
}
|
||||
|
||||
TdThread taosThreadSelf(void) {
|
||||
return pthread_self();
|
||||
}
|
||||
TdThread taosThreadSelf(void) { return pthread_self(); }
|
||||
|
||||
int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate) {
|
||||
return pthread_setcancelstate(state, oldstate);
|
||||
}
|
||||
int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate) { return pthread_setcancelstate(state, oldstate); }
|
||||
|
||||
int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype) {
|
||||
return pthread_setcanceltype(type, oldtype);
|
||||
}
|
||||
int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype) { return pthread_setcanceltype(type, oldtype); }
|
||||
|
||||
int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param) {
|
||||
return pthread_setschedparam(thread, policy, param);
|
||||
}
|
||||
|
||||
int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) {
|
||||
return pthread_setspecific(key, value);
|
||||
}
|
||||
int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) { return pthread_setspecific(key, value); }
|
||||
|
||||
int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock) {
|
||||
#ifdef TD_USE_SPINLOCK_AS_MUTEX
|
||||
|
@ -334,10 +264,6 @@ int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void taosThreadTestCancel(void) {
|
||||
return pthread_testcancel();
|
||||
}
|
||||
void taosThreadTestCancel(void) { return pthread_testcancel(); }
|
||||
|
||||
void taosThreadClear(TdThread *thread) {
|
||||
memset(thread, 0, sizeof(TdThread));
|
||||
}
|
||||
void taosThreadClear(TdThread *thread) { memset(thread, 0, sizeof(TdThread)); }
|
|
@ -167,7 +167,8 @@ int taosInitTimer(void (*callback)(int), int ms) {
|
|||
|
||||
r = taosThreadCreate(&timer_thread, NULL, timer_routine, NULL);
|
||||
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
|
||||
abort();
|
||||
}
|
||||
|
|
|
@ -740,7 +740,8 @@ char *tz_win[554][2]={{"Asia/Shanghai", "China Standard Time"},
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8_t *outDaylight, enum TdTimezone *tsTimezone) {
|
||||
void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8_t *outDaylight,
|
||||
enum TdTimezone *tsTimezone) {
|
||||
if (inTimezoneStr == NULL || inTimezoneStr[0] == 0) return;
|
||||
|
||||
char *buf = taosMemoryMalloc(strlen(inTimezoneStr) + 1);
|
||||
|
@ -828,7 +829,8 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
|||
char value[100];
|
||||
char keyPath[100];
|
||||
DWORD bufferSize = sizeof(value);
|
||||
RegGetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "TimeZoneKeyName", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize);
|
||||
RegGetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "TimeZoneKeyName",
|
||||
RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize);
|
||||
strcpy(outTimezoneStr, "not configured");
|
||||
*tsTimezone = 0;
|
||||
if (bufferSize > 0) {
|
||||
|
@ -840,7 +842,8 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
|||
RegGetValue(HKEY_LOCAL_MACHINE, keyPath, "Display", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize);
|
||||
if (bufferSize > 0) {
|
||||
// value[4] = (value[4] == '+' ? '-' : '+');
|
||||
sprintf(outTimezoneStr, "%s (UTC, %c%c%c%c%c)", outTimezoneStr, value[4], value[5], value[6], value[8], value[9]);
|
||||
sprintf(outTimezoneStr, "%s (UTC, %c%c%c%c%c)", outTimezoneStr, value[4], value[5], value[6], value[8],
|
||||
value[9]);
|
||||
*tsTimezone = taosStr2Int32(&value[4], NULL, 10);
|
||||
}
|
||||
break;
|
||||
|
@ -964,7 +967,8 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
|||
* Asia/Shanghai (CST, +0800)
|
||||
* Europe/London (BST, +0100)
|
||||
*/
|
||||
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
|
||||
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-",
|
||||
abs(tz));
|
||||
} else {
|
||||
printf("There is not /etc/timezone.\n");
|
||||
}
|
||||
|
|
|
@ -85,8 +85,7 @@ int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len) {
|
|||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
||||
int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf,
|
||||
uint32_t len) {
|
||||
int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, uint32_t len) {
|
||||
uint64_t h1 = (uint64_t)pBF->hashFn1(keyBuf, len);
|
||||
uint64_t h2 = (uint64_t)pBF->hashFn2(keyBuf, len);
|
||||
const register uint64_t size = pBF->numBits;
|
||||
|
@ -145,6 +144,4 @@ _error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool tBloomFilterIsFull(const SBloomFilter *pBF) {
|
||||
return pBF->size >= pBF->expectedEntries;
|
||||
}
|
||||
bool tBloomFilterIsFull(const SBloomFilter *pBF) { return pBF->size >= pBF->expectedEntries; }
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "tcache.h"
|
||||
#include "taoserror.h"
|
||||
#include "osThread.h"
|
||||
#include "taoserror.h"
|
||||
#include "tlog.h"
|
||||
#include "tutil.h"
|
||||
|
||||
|
|
|
@ -392,7 +392,6 @@ int32_t compareInt16Uint64(const void *pLeft, const void *pRight) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t compareInt32Int8(const void *pLeft, const void *pRight) {
|
||||
int32_t left = GET_INT32_VAL(pLeft);
|
||||
int8_t right = GET_INT8_VAL(pRight);
|
||||
|
@ -997,10 +996,7 @@ int32_t compareUint64Uint32(const void *pLeft, const void *pRight) {
|
|||
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
|
||||
* TSDB_MATCH: Match
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "tconfig.h"
|
||||
#include "cJSON.h"
|
||||
#include "taoserror.h"
|
||||
#include "tenv.h"
|
||||
#include "tgrant.h"
|
||||
#include "tjson.h"
|
||||
#include "tlog.h"
|
||||
#include "tutil.h"
|
||||
#include "tenv.h"
|
||||
#include "cJSON.h"
|
||||
#include "tjson.h"
|
||||
#include "tgrant.h"
|
||||
|
||||
#define CFG_NAME_PRINT_LEN 24
|
||||
#define CFG_SRC_PRINT_LEN 12
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,9 +24,9 @@
|
|||
* Copyright (c) 2016, Usman Masood <usmanm at fastmail dot fm>
|
||||
*/
|
||||
|
||||
#include "tdigest.h"
|
||||
#include "os.h"
|
||||
#include "osMath.h"
|
||||
#include "tdigest.h"
|
||||
|
||||
#define INTERPOLATE(x, x0, x1) (((x) - (x0)) / ((x1) - (x0)))
|
||||
//#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (q) - 1) + M_PI / 2) / M_PI)
|
||||
|
@ -65,25 +65,20 @@ TDigest *tdigestNewFrom(void* pBuf, int32_t compression) {
|
|||
static int32_t cmpCentroid(const void *a, const void *b) {
|
||||
SCentroid *c1 = (SCentroid *)a;
|
||||
SCentroid *c2 = (SCentroid *)b;
|
||||
if (c1->mean < c2->mean)
|
||||
return -1;
|
||||
if (c1->mean > c2->mean)
|
||||
return 1;
|
||||
if (c1->mean < c2->mean) return -1;
|
||||
if (c1->mean > c2->mean) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void mergeCentroid(SMergeArgs *args, SCentroid *merge) {
|
||||
double k2;
|
||||
SCentroid *c = &args->centroids[args->idx];
|
||||
|
||||
args->weight_so_far += merge->weight;
|
||||
k2 = INTEGRATED_LOCATION(args->t->size,
|
||||
args->weight_so_far / args->t->total_weight);
|
||||
k2 = INTEGRATED_LOCATION(args->t->size, args->weight_so_far / args->t->total_weight);
|
||||
// idx++
|
||||
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->k1 = k2;
|
||||
|
@ -110,8 +105,7 @@ void tdigestCompress(TDigest *t) {
|
|||
int32_t i, j;
|
||||
SMergeArgs args;
|
||||
|
||||
if (t->num_buffered_pts <= 0)
|
||||
return;
|
||||
if (t->num_buffered_pts <= 0) return;
|
||||
|
||||
unmerged_centroids = (SCentroid *)taosMemoryMalloc(sizeof(SCentroid) * t->num_buffered_pts);
|
||||
for (i = 0; i < num_unmerged; i++) {
|
||||
|
@ -175,8 +169,7 @@ void tdigestCompress(TDigest *t) {
|
|||
}
|
||||
|
||||
void tdigestAdd(TDigest *t, double x, int64_t w) {
|
||||
if (w == 0)
|
||||
return;
|
||||
if (w == 0) return;
|
||||
|
||||
int32_t i = t->num_buffered_pts;
|
||||
if (i > 0 && t->buffered_pts[i - 1].value == x) {
|
||||
|
@ -187,14 +180,11 @@ void tdigestAdd(TDigest* t, double x, int64_t w) {
|
|||
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) {
|
||||
if (t == NULL)
|
||||
return 0;
|
||||
if (t == NULL) return 0;
|
||||
|
||||
int32_t i;
|
||||
double left, right;
|
||||
|
@ -202,15 +192,11 @@ double tdigestCDF(TDigest *t, double x) {
|
|||
SCentroid *a, *b, tmp;
|
||||
|
||||
tdigestCompress(t);
|
||||
if (t->num_centroids == 0)
|
||||
return NAN;
|
||||
if (x < t->min)
|
||||
return 0;
|
||||
if (x > t->max)
|
||||
return 1;
|
||||
if (t->num_centroids == 0) return NAN;
|
||||
if (x < t->min) return 0;
|
||||
if (x > t->max) return 1;
|
||||
if (t->num_centroids == 1) {
|
||||
if (FLOAT_EQ(t->max, t->min))
|
||||
return 0.5;
|
||||
if (FLOAT_EQ(t->max, t->min)) return 0.5;
|
||||
|
||||
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);
|
||||
|
||||
if (x < a->mean + right) {
|
||||
double cdf = (weight_so_far
|
||||
+ a->weight
|
||||
* INTERPOLATE(x, a->mean - left, a->mean + right))
|
||||
/ t->total_weight;
|
||||
double cdf = (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) / t->total_weight;
|
||||
return TMAX(cdf, 0.0);
|
||||
}
|
||||
|
||||
|
@ -245,16 +228,14 @@ double tdigestCDF(TDigest *t, double x) {
|
|||
right = t->max - a->mean;
|
||||
|
||||
if (x < a->mean + right) {
|
||||
return (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right))
|
||||
/ t->total_weight;
|
||||
return (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) / t->total_weight;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
double tdigestQuantile(TDigest *t, double q) {
|
||||
if (t == NULL)
|
||||
return 0;
|
||||
if (t == NULL) return 0;
|
||||
|
||||
int32_t i;
|
||||
double left, right, idx;
|
||||
|
@ -262,14 +243,10 @@ double tdigestQuantile(TDigest *t, double q) {
|
|||
SCentroid *a, *b, tmp;
|
||||
|
||||
tdigestCompress(t);
|
||||
if (t->num_centroids == 0)
|
||||
return NAN;
|
||||
if (t->num_centroids == 1)
|
||||
return t->centroids[0].mean;
|
||||
if (FLOAT_EQ(q, 0.0))
|
||||
return t->min;
|
||||
if (FLOAT_EQ(q, 1.0))
|
||||
return t->max;
|
||||
if (t->num_centroids == 0) return NAN;
|
||||
if (t->num_centroids == 1) return t->centroids[0].mean;
|
||||
if (FLOAT_EQ(q, 0.0)) return t->min;
|
||||
if (FLOAT_EQ(q, 1.0)) return t->max;
|
||||
|
||||
idx = q * t->total_weight;
|
||||
weight_so_far = 0;
|
||||
|
|
|
@ -890,5 +890,3 @@ void *taosHashAcquire(SHashObj *pHashObj, const void *key, size_t keyLen) {
|
|||
void taosHashRelease(SHashObj *pHashObj, void *p) { taosHashCancelIterate(pHashObj, p); }
|
||||
|
||||
int64_t taosHashGetCompTimes(SHashObj *pHashObj) { return atomic_load_64(&pHashObj->compTimes); }
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "thash.h"
|
||||
#include "tcompare.h"
|
||||
#include "thash.h"
|
||||
#include "types.h"
|
||||
|
||||
#define ROTL32(x, r) ((x) << (r) | (x) >> (32u - (r)))
|
||||
|
@ -29,7 +29,8 @@
|
|||
(h) *= 0x85ebca6b; \
|
||||
(h) ^= (h) >> 13; \
|
||||
(h) *= 0xc2b2ae35; \
|
||||
(h) ^= (h) >> 16; } while (0)
|
||||
(h) ^= (h) >> 16; \
|
||||
} while (0)
|
||||
|
||||
uint32_t MurmurHash3_32(const char *key, uint32_t len) {
|
||||
const uint8_t *data = (const uint8_t *)key;
|
||||
|
@ -98,13 +99,20 @@ uint64_t MurmurHash3_64(const char *key, uint32_t len) {
|
|||
}
|
||||
|
||||
switch (len & 7) {
|
||||
case 7: h ^= (uint64_t)data[6] << 48; /* fall-thru */
|
||||
case 6: h ^= (uint64_t)data[5] << 40; /* fall-thru */
|
||||
case 5: h ^= (uint64_t)data[4] << 32; /* fall-thru */
|
||||
case 4: h ^= (uint64_t)data[3] << 24; /* fall-thru */
|
||||
case 3: h ^= (uint64_t)data[2] << 16; /* fall-thru */
|
||||
case 2: h ^= (uint64_t)data[1] << 8; /* fall-thru */
|
||||
case 1: h ^= (uint64_t)data[0];
|
||||
case 7:
|
||||
h ^= (uint64_t)data[6] << 48; /* fall-thru */
|
||||
case 6:
|
||||
h ^= (uint64_t)data[5] << 40; /* fall-thru */
|
||||
case 5:
|
||||
h ^= (uint64_t)data[4] << 32; /* fall-thru */
|
||||
case 4:
|
||||
h ^= (uint64_t)data[3] << 24; /* fall-thru */
|
||||
case 3:
|
||||
h ^= (uint64_t)data[2] << 16; /* fall-thru */
|
||||
case 2:
|
||||
h ^= (uint64_t)data[1] << 8; /* fall-thru */
|
||||
case 1:
|
||||
h ^= (uint64_t)data[0];
|
||||
h *= m; /* fall-thru */
|
||||
};
|
||||
|
||||
|
@ -210,9 +218,15 @@ int32_t taosDoubleEqual(const void *a, const void *b, size_t UNUSED_PARAM(sz)) {
|
|||
_equal_fn_t taosGetDefaultEqualFunction(int32_t type) {
|
||||
_equal_fn_t fn = NULL;
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_FLOAT: fn = taosFloatEqual; break;
|
||||
case TSDB_DATA_TYPE_DOUBLE: fn = taosDoubleEqual; break;
|
||||
default: fn = memcmp; break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
fn = taosFloatEqual;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
fn = taosDoubleEqual;
|
||||
break;
|
||||
default:
|
||||
fn = memcmp;
|
||||
break;
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,8 @@ struct SDiskbasedBuf {
|
|||
};
|
||||
|
||||
static int32_t createDiskFile(SDiskbasedBuf* pBuf) {
|
||||
pBuf->pFile = taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
|
||||
pBuf->pFile =
|
||||
taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
|
||||
if (pBuf->pFile == NULL) {
|
||||
return TAOS_SYSTEM_ERROR(errno);
|
||||
}
|
||||
|
@ -402,7 +403,8 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) {
|
|||
|
||||
// allocate buf
|
||||
if (availablePage == NULL) {
|
||||
pi->pData = taosMemoryCalloc(1, getAllocPageSize(pBuf->pageSize)); // add extract bytes in case of zipped buffer increased.
|
||||
pi->pData =
|
||||
taosMemoryCalloc(1, getAllocPageSize(pBuf->pageSize)); // add extract bytes in case of zipped buffer increased.
|
||||
} else {
|
||||
pi->pData = availablePage;
|
||||
}
|
||||
|
@ -438,7 +440,8 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) {
|
|||
#endif
|
||||
return (void*)(GET_DATA_PAYLOAD(*pi));
|
||||
} else { // not in memory
|
||||
assert((*pi)->pData == NULL && (*pi)->pn == NULL && (((*pi)->length >= 0 && (*pi)->offset >= 0) || ((*pi)->length == -1 && (*pi)->offset == -1)));
|
||||
assert((*pi)->pData == NULL && (*pi)->pn == NULL &&
|
||||
(((*pi)->length >= 0 && (*pi)->offset >= 0) || ((*pi)->length == -1 && (*pi)->offset == -1)));
|
||||
|
||||
char* availablePage = NULL;
|
||||
if (NO_IN_MEM_AVAILABLE_PAGES(pBuf)) {
|
||||
|
@ -520,12 +523,12 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) {
|
|||
{
|
||||
SDiskbasedBufStatis* ps = &pBuf->statis;
|
||||
if (ps->loadPages == 0) {
|
||||
uDebug(
|
||||
"Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages)",
|
||||
ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages);
|
||||
uDebug("Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages)", ps->getPages,
|
||||
ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages);
|
||||
} else {
|
||||
uDebug(
|
||||
"Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f Kb",
|
||||
"Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f "
|
||||
"Kb",
|
||||
ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f,
|
||||
ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages));
|
||||
}
|
||||
|
@ -614,7 +617,8 @@ void dBufPrintStatis(const SDiskbasedBuf* pBuf) {
|
|||
|
||||
if (ps->loadPages > 0) {
|
||||
printf(
|
||||
"Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f Kb\n",
|
||||
"Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f "
|
||||
"Kb\n",
|
||||
ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f,
|
||||
ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages));
|
||||
} else {
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
#define DEFAULT_GROWTH 2
|
||||
#define DEFAULT_TIGHTENING_RATIO 0.5
|
||||
|
||||
static SBloomFilter *tScalableBfAddFilter(SScalableBf *pSBf, uint64_t expectedEntries,
|
||||
double errorRate);
|
||||
static SBloomFilter *tScalableBfAddFilter(SScalableBf *pSBf, uint64_t expectedEntries, double errorRate);
|
||||
|
||||
SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate) {
|
||||
const uint32_t defaultSize = 8;
|
||||
|
@ -46,8 +45,7 @@ SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate) {
|
|||
int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len) {
|
||||
int32_t size = taosArrayGetSize(pSBf->bfArray);
|
||||
for (int32_t i = size - 2; i >= 0; --i) {
|
||||
if (tBloomFilterNoContain(taosArrayGetP(pSBf->bfArray, i),
|
||||
keyBuf, len) != TSDB_CODE_SUCCESS) {
|
||||
if (tBloomFilterNoContain(taosArrayGetP(pSBf->bfArray, i), keyBuf, len) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +53,7 @@ int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len) {
|
|||
SBloomFilter *pNormalBf = taosArrayGetP(pSBf->bfArray, size - 1);
|
||||
ASSERT(pNormalBf);
|
||||
if (tBloomFilterIsFull(pNormalBf)) {
|
||||
pNormalBf = tScalableBfAddFilter(pSBf,
|
||||
pNormalBf->expectedEntries * pSBf->growth,
|
||||
pNormalBf = tScalableBfAddFilter(pSBf, pNormalBf->expectedEntries * pSBf->growth,
|
||||
pNormalBf->errorRate * DEFAULT_TIGHTENING_RATIO);
|
||||
if (pNormalBf == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -65,20 +62,17 @@ int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len) {
|
|||
return tBloomFilterPut(pNormalBf, keyBuf, len);
|
||||
}
|
||||
|
||||
int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf,
|
||||
uint32_t len) {
|
||||
int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, uint32_t len) {
|
||||
int32_t size = taosArrayGetSize(pSBf->bfArray);
|
||||
for (int32_t i = size - 1; i >= 0; --i) {
|
||||
if (tBloomFilterNoContain(taosArrayGetP(pSBf->bfArray, i),
|
||||
keyBuf, len) != TSDB_CODE_SUCCESS) {
|
||||
if (tBloomFilterNoContain(taosArrayGetP(pSBf->bfArray, i), keyBuf, len) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SBloomFilter *tScalableBfAddFilter(SScalableBf *pSBf, uint64_t expectedEntries,
|
||||
double errorRate) {
|
||||
static SBloomFilter *tScalableBfAddFilter(SScalableBf *pSBf, uint64_t expectedEntries, double errorRate) {
|
||||
SBloomFilter *pNormalBf = tBloomFilterInit(expectedEntries, errorRate);
|
||||
if (pNormalBf == NULL) {
|
||||
return NULL;
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
#define _DEFAULT_SOURCE
|
||||
#include "ttimer.h"
|
||||
#include "taoserror.h"
|
||||
#include "tdef.h"
|
||||
#include "tlog.h"
|
||||
#include "tsched.h"
|
||||
#include "tdef.h"
|
||||
|
||||
#define tmrFatal(...) \
|
||||
{ \
|
||||
|
|
|
@ -49,9 +49,7 @@ static void remove_batch_test() {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
TEST(arrayTest, array_list_test) {
|
||||
remove_batch_test();
|
||||
}
|
||||
TEST(arrayTest, array_list_test) { remove_batch_test(); }
|
||||
|
||||
TEST(arrayTest, array_search_test) {
|
||||
SArray* pa = (SArray*)taosArrayInit(4, sizeof(int32_t));
|
||||
|
@ -80,7 +78,6 @@ TEST(arrayTest, array_search_test) {
|
|||
} else {
|
||||
ASSERT_EQ(taosArrayGet(pa, idx), pRet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
taosArrayDestroy(pa);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "tscalablebf.h"
|
||||
#include "taoserror.h"
|
||||
#include "tscalablebf.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -55,7 +55,6 @@ TEST(TD_UTIL_BLOOMFILTER_TEST, normal_bloomFilter) {
|
|||
tBloomFilterDestroy(pBF2);
|
||||
tBloomFilterDestroy(pBF3);
|
||||
tBloomFilterDestroy(pBF4);
|
||||
|
||||
}
|
||||
|
||||
TEST(TD_UTIL_BLOOMFILTER_TEST, scalable_bloomFilter) {
|
||||
|
@ -116,7 +115,6 @@ TEST(TD_UTIL_BLOOMFILTER_TEST, scalable_bloomFilter) {
|
|||
GTEST_ASSERT_EQ(tScalableBfNoContain(pSBF1, &ts, sizeof(int64_t)), TSDB_CODE_FAILED);
|
||||
}
|
||||
|
||||
|
||||
int64_t size = 10000;
|
||||
SScalableBf *pSBF4 = tScalableBfInit(size, 0.001);
|
||||
for (int64_t i = 0; i < 1000; i++) {
|
||||
|
@ -136,5 +134,4 @@ TEST(TD_UTIL_BLOOMFILTER_TEST, scalable_bloomFilter) {
|
|||
|
||||
tScalableBfDestroy(pSBF1);
|
||||
tScalableBfDestroy(pSBF4);
|
||||
|
||||
}
|
|
@ -3,9 +3,9 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "os.h"
|
||||
#include "taos.h"
|
||||
#include "taosdef.h"
|
||||
#include "thash.h"
|
||||
#include "taos.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -15,7 +15,8 @@ typedef struct TESTSTRUCT {
|
|||
|
||||
// the simple test code for basic operations
|
||||
void simpleTest() {
|
||||
SHashObj* hashTable = (SHashObj*) taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK);
|
||||
SHashObj* hashTable =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK);
|
||||
ASSERT_EQ(taosHashGetSize(hashTable), 0);
|
||||
|
||||
// put 400 elements in the hash table
|
||||
|
@ -52,7 +53,8 @@ void simpleTest() {
|
|||
}
|
||||
|
||||
void stringKeyTest() {
|
||||
auto* hashTable = (SHashObj*) taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||
auto* hashTable =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||
ASSERT_EQ(taosHashGetSize(hashTable), 0);
|
||||
|
||||
char key[128] = {0};
|
||||
|
@ -93,16 +95,15 @@ void stringKeyTest() {
|
|||
taosHashCleanup(hashTable);
|
||||
}
|
||||
|
||||
void functionTest() {
|
||||
|
||||
}
|
||||
void functionTest() {}
|
||||
|
||||
/**
|
||||
* evaluate the performance issue, by add 10million elements in to hash table in
|
||||
* a single threads situation
|
||||
*/
|
||||
void noLockPerformanceTest() {
|
||||
auto* hashTable = (SHashObj*) taosHashInit(4096, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||
auto* hashTable =
|
||||
(SHashObj*)taosHashInit(4096, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||
ASSERT_EQ(taosHashGetSize(hashTable), 0);
|
||||
|
||||
char key[128] = {0};
|
||||
|
@ -131,7 +132,8 @@ void noLockPerformanceTest() {
|
|||
}
|
||||
|
||||
et = taosGetTimestampUs();
|
||||
printf("Elpased time:%" PRId64 " us to fetch all %d elements, avg cost:%lf us\n", et - st, num, (et - st)/(double) num);
|
||||
printf("Elpased time:%" PRId64 " us to fetch all %d elements, avg cost:%lf us\n", et - st, num,
|
||||
(et - st) / (double)num);
|
||||
|
||||
printf("The maximum length of overflow linklist in hash table is:%d\n", taosHashGetMaxOverflowLinkLength(hashTable));
|
||||
taosHashCleanup(hashTable);
|
||||
|
@ -142,12 +144,11 @@ void multithreadsTest() {
|
|||
}
|
||||
|
||||
// check the function robustness
|
||||
void invalidOperationTest() {
|
||||
|
||||
}
|
||||
void invalidOperationTest() {}
|
||||
|
||||
void acquireRleaseTest() {
|
||||
SHashObj* hashTable = (SHashObj*) taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||
SHashObj* hashTable =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
|
||||
ASSERT_EQ(taosHashGetSize(hashTable), 0);
|
||||
|
||||
int32_t key = 2;
|
||||
|
@ -198,13 +199,20 @@ void acquireRleaseTest() {
|
|||
}
|
||||
|
||||
void perfTest() {
|
||||
SHashObj* hash1h = (SHashObj*) taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash1s = (SHashObj*) taosHashInit(1000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash10s = (SHashObj*) taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash100s = (SHashObj*) taosHashInit(100000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash1m = (SHashObj*) taosHashInit(1000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash10m = (SHashObj*) taosHashInit(10000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash100m = (SHashObj*) taosHashInit(100000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash1h =
|
||||
(SHashObj*)taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash1s =
|
||||
(SHashObj*)taosHashInit(1000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash10s =
|
||||
(SHashObj*)taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash100s =
|
||||
(SHashObj*)taosHashInit(100000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash1m =
|
||||
(SHashObj*)taosHashInit(1000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash10m =
|
||||
(SHashObj*)taosHashInit(10000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
SHashObj* hash100m =
|
||||
(SHashObj*)taosHashInit(100000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
|
||||
char* name = (char*)taosMemoryCalloc(50000000, 9);
|
||||
for (int64_t i = 0; i < 50000000; ++i) {
|
||||
|
@ -295,7 +303,6 @@ void perfTest() {
|
|||
int64_t end100m = taosGetTimestampMs();
|
||||
int64_t end100mCt = taosHashGetCompTimes(hash100m);
|
||||
|
||||
|
||||
SArray* sArray[1000] = {0};
|
||||
for (int64_t i = 0; i < 1000; ++i) {
|
||||
sArray[i] = taosArrayInit(100000, 9);
|
||||
|
@ -391,8 +398,7 @@ void perfTest() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
|
|
|
@ -159,7 +159,6 @@ void recyclePageTest() {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
TEST(testCase, resultBufferTest) {
|
||||
taosSeedRand(taosGetTimestampSec());
|
||||
simpleTest();
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#include "tref.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "os.h"
|
||||
#include "tref.h"
|
||||
#include "tlog.h"
|
||||
#include "tglobal.h"
|
||||
#include "taoserror.h"
|
||||
#include "tglobal.h"
|
||||
#include "tlog.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -83,9 +82,7 @@ void *acquireRelease(void *param) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void myfree(void *p) {
|
||||
taosMemoryFree(p);
|
||||
}
|
||||
void myfree(void *p) { taosMemoryFree(p); }
|
||||
|
||||
void *openRefSpace(void *param) {
|
||||
SRefSpace *pSpace = (SRefSpace *)param;
|
||||
|
@ -189,4 +186,3 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
return num;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
PRJ_ROOT_DIR=$(readlink -f -- "$(dirname $0)/../..")
|
||||
FORMAT_BIN=clang-format-14
|
||||
|
||||
ORIGIN_DIR=$(pwd)
|
||||
|
||||
cd ${PRJ_ROOT_DIR}
|
||||
|
||||
FORMAT_DIR_LIST=(
|
||||
"include"
|
||||
"source/os"
|
||||
"source/util"
|
||||
"source/common"
|
||||
# "source/libs"
|
||||
# "source/client"
|
||||
"source/dnode"
|
||||
)
|
||||
|
||||
for d in ${FORMAT_DIR_LIST[@]}; do
|
||||
for f in $(find ${PRJ_ROOT_DIR}/$d/ -regex '.*\.\(cpp\|hpp\|c\|h\)'); do
|
||||
${FORMAT_BIN} -i $f
|
||||
done
|
||||
done
|
||||
|
||||
cd ${ORIGIN_DIR}
|
Loading…
Reference in New Issue