diff --git a/include/util/tconfig.h b/include/util/tconfig.h index 11dd5414ec66eefc9cf1435ccbd3f51cad69e9f4..64a1a408279d7abf86bfb31ef8aa82d4f922aad4 100644 --- a/include/util/tconfig.h +++ b/include/util/tconfig.h @@ -17,7 +17,6 @@ #ifndef _TD_CONFIG_H_ #define _TD_CONFIG_H_ -#include "os.h" #include "tarray.h" #ifdef __cplusplus @@ -54,11 +53,11 @@ typedef struct SConfigItem { bool tsc; char *name; union { - bool bval; - float fval; - int32_t i32; - int64_t i64; - char *str; + bool bval; + float fval; + int32_t i32; + int64_t i64; + char *str; }; union { int64_t imin; @@ -80,7 +79,7 @@ typedef struct SConfig SConfig; SConfig *cfgInit(); int32_t cfgLoad(SConfig *pCfg, ECfgSrcType cfgType, const char *sourceStr); -int32_t cfgLoadArray(SConfig *pCfg, SArray *pArgs); // SConfigPair +int32_t cfgLoadArray(SConfig *pCfg, SArray *pArgs); // SConfigPair void cfgCleanup(SConfig *pCfg); int32_t cfgGetSize(SConfig *pCfg); diff --git a/include/util/tdef.h b/include/util/tdef.h index b4795a0ecf0c0b30963f3d4c7bb9d2c4ca2863d3..d17e5be99e7fe5eb6cfe06d42fa08bde48e062da 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -13,10 +13,8 @@ * along with this program. If not, see . */ -// clang-format off - -#ifndef _TD_UTIL_DEF_H -#define _TD_UTIL_DEF_H +#ifndef _TD_UTIL_DEF_H_ +#define _TD_UTIL_DEF_H_ #include "os.h" @@ -26,89 +24,91 @@ extern "C" { #define TSDB__packed -#define TSKEY int64_t -#define TSKEY_MIN INT64_MIN -#define TSKEY_MAX (INT64_MAX - 1) +#define TSKEY int64_t +#define TSKEY_MIN INT64_MIN +#define TSKEY_MAX (INT64_MAX - 1) #define TSKEY_INITIAL_VAL TSKEY_MIN // Bytes for each type. extern const int32_t TYPE_BYTES[15]; // TODO: replace and remove code below -#define CHAR_BYTES sizeof(char) -#define SHORT_BYTES sizeof(int16_t) -#define INT_BYTES sizeof(int32_t) -#define LONG_BYTES sizeof(int64_t) -#define FLOAT_BYTES sizeof(float) -#define DOUBLE_BYTES sizeof(double) -#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*) -#define TSDB_KEYSIZE sizeof(TSKEY) -#define TSDB_NCHAR_SIZE sizeof(int32_t) +#define CHAR_BYTES sizeof(char) +#define SHORT_BYTES sizeof(int16_t) +#define INT_BYTES sizeof(int32_t) +#define LONG_BYTES sizeof(int64_t) +#define FLOAT_BYTES sizeof(float) +#define DOUBLE_BYTES sizeof(double) +#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*) +#define TSDB_KEYSIZE sizeof(TSKEY) +#define TSDB_NCHAR_SIZE sizeof(int32_t) // NULL definition -#define TSDB_DATA_BOOL_NULL 0x02 -#define TSDB_DATA_TINYINT_NULL 0x80 -#define TSDB_DATA_SMALLINT_NULL 0x8000 -#define TSDB_DATA_INT_NULL 0x80000000L -#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L -#define TSDB_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL - -#define TSDB_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN -#define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN -#define TSDB_DATA_NCHAR_NULL 0xFFFFFFFF -#define TSDB_DATA_BINARY_NULL 0xFF - -#define TSDB_DATA_UTINYINT_NULL 0xFF -#define TSDB_DATA_USMALLINT_NULL 0xFFFF -#define TSDB_DATA_UINT_NULL 0xFFFFFFFF -#define TSDB_DATA_UBIGINT_NULL 0xFFFFFFFFFFFFFFFFL - -#define TSDB_DATA_NULL_STR "NULL" -#define TSDB_DATA_NULL_STR_L "null" - -#define TSDB_NETTEST_USER "nettestinternal" -#define TSDB_DEFAULT_USER "root" +#define TSDB_DATA_BOOL_NULL 0x02 +#define TSDB_DATA_TINYINT_NULL 0x80 +#define TSDB_DATA_SMALLINT_NULL 0x8000 +#define TSDB_DATA_INT_NULL 0x80000000L +#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L +#define TSDB_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL + +#define TSDB_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN +#define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN +#define TSDB_DATA_NCHAR_NULL 0xFFFFFFFF +#define TSDB_DATA_BINARY_NULL 0xFF + +#define TSDB_DATA_UTINYINT_NULL 0xFF +#define TSDB_DATA_USMALLINT_NULL 0xFFFF +#define TSDB_DATA_UINT_NULL 0xFFFFFFFF +#define TSDB_DATA_UBIGINT_NULL 0xFFFFFFFFFFFFFFFFL + +#define TSDB_DATA_NULL_STR "NULL" +#define TSDB_DATA_NULL_STR_L "null" + +#define TSDB_NETTEST_USER "nettestinternal" +#define TSDB_DEFAULT_USER "root" #ifdef _TD_POWER_ -#define TSDB_DEFAULT_PASS "powerdb" +#define TSDB_DEFAULT_PASS "powerdb" #elif (_TD_TQ_ == true) -#define TSDB_DEFAULT_PASS "tqueue" +#define TSDB_DEFAULT_PASS "tqueue" #elif (_TD_PRO_ == true) -#define TSDB_DEFAULT_PASS "prodb" +#define TSDB_DEFAULT_PASS "prodb" #else -#define TSDB_DEFAULT_PASS "taosdata" +#define TSDB_DEFAULT_PASS "taosdata" #endif -#define SHELL_MAX_PASSWORD_LEN 20 +#define SHELL_MAX_PASSWORD_LEN 20 -#define TSDB_TRUE 1 -#define TSDB_FALSE 0 -#define TSDB_OK 0 +#define TSDB_TRUE 1 +#define TSDB_FALSE 0 +#define TSDB_OK 0 #define TSDB_ERR -1 #define TS_PATH_DELIMITER "." #define TS_ESCAPE_CHAR '`' -#define TSDB_TIME_PRECISION_MILLI 0 -#define TSDB_TIME_PRECISION_MICRO 1 -#define TSDB_TIME_PRECISION_NANO 2 +#define TSDB_TIME_PRECISION_MILLI 0 +#define TSDB_TIME_PRECISION_MICRO 1 +#define TSDB_TIME_PRECISION_NANO 2 #define TSDB_TIME_PRECISION_MILLI_STR "ms" #define TSDB_TIME_PRECISION_MICRO_STR "us" #define TSDB_TIME_PRECISION_NANO_STR "ns" -#define TSDB_TICK_PER_SECOND(precision) ((int64_t)((precision)==TSDB_TIME_PRECISION_MILLI ? 1e3L : ((precision)==TSDB_TIME_PRECISION_MICRO ? 1e6L : 1e9L))) +#define TSDB_TICK_PER_SECOND(precision) \ + ((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI ? 1e3L \ + : ((precision) == TSDB_TIME_PRECISION_MICRO ? 1e6L : 1e9L))) #define T_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) -#define T_APPEND_MEMBER(dst, ptr, type, member) \ -do {\ - memcpy((void *)(dst), (void *)(&((ptr)->member)), T_MEMBER_SIZE(type, member));\ - dst = (void *)((char *)(dst) + T_MEMBER_SIZE(type, member));\ -} while(0) -#define T_READ_MEMBER(src, type, target) \ -do { \ - (target) = *(type *)(src); \ - (src) = (void *)((char *)src + sizeof(type));\ -} while(0) +#define T_APPEND_MEMBER(dst, ptr, type, member) \ + do { \ + memcpy((void *)(dst), (void *)(&((ptr)->member)), T_MEMBER_SIZE(type, member)); \ + dst = (void *)((char *)(dst) + T_MEMBER_SIZE(type, member)); \ + } while (0) +#define T_READ_MEMBER(src, type, target) \ + do { \ + (target) = *(type *)(src); \ + (src) = (void *)((char *)src + sizeof(type)); \ + } while (0) typedef enum EOperatorType { // arithmetic operator @@ -149,262 +149,258 @@ typedef enum EOperatorType { OP_TYPE_JSON_CONTAINS } EOperatorType; - typedef enum ELogicConditionType { LOGIC_COND_TYPE_AND, LOGIC_COND_TYPE_OR, LOGIC_COND_TYPE_NOT, } ELogicConditionType; +#define FUNCTION_CEIL 4500 +#define FUNCTION_FLOOR 4501 +#define FUNCTION_ABS 4502 +#define FUNCTION_ROUND 4503 -#define FUNCTION_CEIL 4500 -#define FUNCTION_FLOOR 4501 -#define FUNCTION_ABS 4502 -#define FUNCTION_ROUND 4503 - -#define FUNCTION_LENGTH 4800 -#define FUNCTION_CONCAT 4801 -#define FUNCTION_LTRIM 4802 -#define FUNCTION_RTRIM 4803 +#define FUNCTION_LENGTH 4800 +#define FUNCTION_CONCAT 4801 +#define FUNCTION_LTRIM 4802 +#define FUNCTION_RTRIM 4803 -#define TSDB_NAME_DELIMITER_LEN 1 +#define TSDB_NAME_DELIMITER_LEN 1 -#define TSDB_UNI_LEN 24 -#define TSDB_USER_LEN TSDB_UNI_LEN +#define TSDB_UNI_LEN 24 +#define TSDB_USER_LEN TSDB_UNI_LEN // ACCOUNT is a 32 bit positive integer // this is the length of its string representation, including the terminator zero -#define TSDB_ACCT_ID_LEN 11 - -#define TSDB_MAX_COLUMNS 4096 -#define TSDB_MIN_COLUMNS 2 //PRIMARY COLUMN(timestamp) + other columns - -#define TSDB_NODE_NAME_LEN 64 -#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string -#define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string -#define TSDB_DB_NAME_LEN 65 -#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN) - -#define TSDB_FUNC_NAME_LEN 65 -#define TSDB_FUNC_COMMENT_LEN 4096 -#define TSDB_FUNC_CODE_LEN (65535 - 512) -#define TSDB_FUNC_BUF_SIZE 512 -#define TSDB_FUNC_TYPE_SCALAR 1 -#define TSDB_FUNC_TYPE_AGGREGATE 2 -#define TSDB_FUNC_MAX_RETRIEVE 1024 - -#define TSDB_TYPE_STR_MAX_LEN 32 -#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) -#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN -#define TSDB_CONSUMER_GROUP_LEN 192 -#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CONSUMER_GROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2) -#define TSDB_PARTITION_KEY_LEN (TSDB_CONSUMER_GROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2) -#define TSDB_COL_NAME_LEN 65 -#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64 -#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE -#define TSDB_MAX_SQL_SHOW_LEN 1024 -#define TSDB_MAX_ALLOWED_SQL_LEN (1*1024*1024u) // sql length should be less than 1mb - -#define TSDB_APP_NAME_LEN TSDB_UNI_LEN -#define TSDB_STB_COMMENT_LEN 1024 - /** - * In some scenarios uint16_t (0~65535) is used to store the row len. - * - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header. - * - Secondly, if all cols are VarDataT type except primary key, we need 4 bits to store the offset, thus - * the final value is 65531-(4096-1)*4 = 49151. - */ -#define TSDB_MAX_BYTES_PER_ROW 49151 -#define TSDB_MAX_TAGS_LEN 16384 -#define TSDB_MAX_TAGS 128 -#define TSDB_MAX_TAG_CONDITIONS 1024 - -#define TSDB_AUTH_LEN 16 -#define TSDB_PASSWORD_LEN 32 -#define TSDB_USET_PASSWORD_LEN 129 -#define TSDB_VERSION_LEN 12 -#define TSDB_LABEL_LEN 8 - -#define TSDB_CLUSTER_ID_LEN 40 -#define TSDB_FQDN_LEN 128 -#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6) -#define TSDB_IPv4ADDR_LEN 16 -#define TSDB_FILENAME_LEN 128 -#define TSDB_SHOW_SQL_LEN 512 -#define TSDB_SHOW_SUBQUERY_LEN 1000 -#define TSDB_SLOW_QUERY_SQL_LEN 512 - -#define TSDB_TRANS_STAGE_LEN 12 -#define TSDB_TRANS_TYPE_LEN 16 -#define TSDB_TRANS_ERROR_LEN 64 - -#define TSDB_STEP_NAME_LEN 32 -#define TSDB_STEP_DESC_LEN 128 - -#define TSDB_ERROR_MSG_LEN 1024 -#define TSDB_DNODE_CONFIG_LEN 128 -#define TSDB_DNODE_VALUE_LEN 256 - -#define TSDB_MQTT_HOSTNAME_LEN 64 -#define TSDB_MQTT_PORT_LEN 8 -#define TSDB_MQTT_USER_LEN 24 -#define TSDB_MQTT_PASS_LEN 24 -#define TSDB_MQTT_TOPIC_LEN 64 -#define TSDB_MQTT_CLIENT_ID_LEN 32 - -#define TSDB_DB_TYPE_DEFAULT 0 -#define TSDB_DB_TYPE_TOPIC 1 - -#define TSDB_DEFAULT_PKT_SIZE 65480 //same as RPC_MAX_UDP_SIZE +#define TSDB_ACCT_ID_LEN 11 + +#define TSDB_MAX_COLUMNS 4096 +#define TSDB_MIN_COLUMNS 2 // PRIMARY COLUMN(timestamp) + other columns + +#define TSDB_NODE_NAME_LEN 64 +#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string +#define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string +#define TSDB_DB_NAME_LEN 65 +#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN) + +#define TSDB_FUNC_NAME_LEN 65 +#define TSDB_FUNC_COMMENT_LEN 4096 +#define TSDB_FUNC_CODE_LEN (65535 - 512) +#define TSDB_FUNC_BUF_SIZE 512 +#define TSDB_FUNC_TYPE_SCALAR 1 +#define TSDB_FUNC_TYPE_AGGREGATE 2 +#define TSDB_FUNC_MAX_RETRIEVE 1024 + +#define TSDB_TYPE_STR_MAX_LEN 32 +#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN) +#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN +#define TSDB_CONSUMER_GROUP_LEN 192 +#define TSDB_SUBSCRIBE_KEY_LEN (TSDB_CONSUMER_GROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2) +#define TSDB_PARTITION_KEY_LEN (TSDB_CONSUMER_GROUP_LEN + TSDB_TOPIC_FNAME_LEN + 2) +#define TSDB_COL_NAME_LEN 65 +#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64 +#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE +#define TSDB_MAX_SQL_SHOW_LEN 1024 +#define TSDB_MAX_ALLOWED_SQL_LEN (1 * 1024 * 1024u) // sql length should be less than 1mb + +#define TSDB_APP_NAME_LEN TSDB_UNI_LEN +#define TSDB_STB_COMMENT_LEN 1024 +/** + * In some scenarios uint16_t (0~65535) is used to store the row len. + * - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header. + * - Secondly, if all cols are VarDataT type except primary key, we need 4 bits to store the offset, thus + * the final value is 65531-(4096-1)*4 = 49151. + */ +#define TSDB_MAX_BYTES_PER_ROW 49151 +#define TSDB_MAX_TAGS_LEN 16384 +#define TSDB_MAX_TAGS 128 +#define TSDB_MAX_TAG_CONDITIONS 1024 + +#define TSDB_AUTH_LEN 16 +#define TSDB_PASSWORD_LEN 32 +#define TSDB_USET_PASSWORD_LEN 129 +#define TSDB_VERSION_LEN 12 +#define TSDB_LABEL_LEN 8 + +#define TSDB_CLUSTER_ID_LEN 40 +#define TSDB_FQDN_LEN 128 +#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6) +#define TSDB_IPv4ADDR_LEN 16 +#define TSDB_FILENAME_LEN 128 +#define TSDB_SHOW_SQL_LEN 512 +#define TSDB_SHOW_SUBQUERY_LEN 1000 +#define TSDB_SLOW_QUERY_SQL_LEN 512 + +#define TSDB_TRANS_STAGE_LEN 12 +#define TSDB_TRANS_TYPE_LEN 16 +#define TSDB_TRANS_ERROR_LEN 64 + +#define TSDB_STEP_NAME_LEN 32 +#define TSDB_STEP_DESC_LEN 128 + +#define TSDB_ERROR_MSG_LEN 1024 +#define TSDB_DNODE_CONFIG_LEN 128 +#define TSDB_DNODE_VALUE_LEN 256 + +#define TSDB_MQTT_HOSTNAME_LEN 64 +#define TSDB_MQTT_PORT_LEN 8 +#define TSDB_MQTT_USER_LEN 24 +#define TSDB_MQTT_PASS_LEN 24 +#define TSDB_MQTT_TOPIC_LEN 64 +#define TSDB_MQTT_CLIENT_ID_LEN 32 + +#define TSDB_DB_TYPE_DEFAULT 0 +#define TSDB_DB_TYPE_TOPIC 1 + +#define TSDB_DEFAULT_PKT_SIZE 65480 // same as RPC_MAX_UDP_SIZE #define TSDB_PAYLOAD_SIZE TSDB_DEFAULT_PKT_SIZE -#define TSDB_DEFAULT_PAYLOAD_SIZE 5120 // default payload size, greater than PATH_MAX value -#define TSDB_EXTRA_PAYLOAD_SIZE 128 // extra bytes for auth +#define TSDB_DEFAULT_PAYLOAD_SIZE 5120 // default payload size, greater than PATH_MAX value +#define TSDB_EXTRA_PAYLOAD_SIZE 128 // extra bytes for auth #define TSDB_CQ_SQL_SIZE 1024 #define TSDB_MIN_VNODES 16 #define TSDB_MAX_VNODES 512 #define TSDB_MIN_VNODES_PER_DB 1 #define TSDB_MAX_VNODES_PER_DB 4096 -#define TSDB_DEFAULT_VN_PER_DB 2 - -#define TSDB_DNODE_ROLE_ANY 0 -#define TSDB_DNODE_ROLE_MGMT 1 -#define TSDB_DNODE_ROLE_VNODE 2 +#define TSDB_DEFAULT_VN_PER_DB 2 -#define TSDB_MAX_REPLICA 5 +#define TSDB_DNODE_ROLE_ANY 0 +#define TSDB_DNODE_ROLE_MGMT 1 +#define TSDB_DNODE_ROLE_VNODE 2 -#define TSDB_TBNAME_COLUMN_INDEX (-1) -#define TSDB_UD_COLUMN_INDEX (-1000) -#define TSDB_RES_COL_ID (-5000) +#define TSDB_MAX_REPLICA 5 -#define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta - -#define TSDB_MIN_CACHE_BLOCK_SIZE 1 -#define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode -#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16 +#define TSDB_TBNAME_COLUMN_INDEX (-1) +#define TSDB_UD_COLUMN_INDEX (-1000) +#define TSDB_RES_COL_ID (-5000) -#define TSDB_MIN_TOTAL_BLOCKS 3 -#define TSDB_MAX_TOTAL_BLOCKS 10000 -#define TSDB_DEFAULT_TOTAL_BLOCKS 6 +#define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta -#define TSDB_MIN_DAYS_PER_FILE 1 -#define TSDB_MAX_DAYS_PER_FILE 3650 -#define TSDB_DEFAULT_DAYS_PER_FILE 10 +#define TSDB_MIN_CACHE_BLOCK_SIZE 1 +#define TSDB_MAX_CACHE_BLOCK_SIZE 128 // 128MB for each vnode +#define TSDB_DEFAULT_CACHE_BLOCK_SIZE 16 -#define TSDB_MIN_KEEP 1 // data in db to be reserved. -#define TSDB_MAX_KEEP 365000 // data in db to be reserved. -#define TSDB_DEFAULT_KEEP 3650 // ten years +#define TSDB_MIN_TOTAL_BLOCKS 3 +#define TSDB_MAX_TOTAL_BLOCKS 10000 +#define TSDB_DEFAULT_TOTAL_BLOCKS 6 -#define TSDB_MIN_MIN_ROW_FBLOCK 10 -#define TSDB_MAX_MIN_ROW_FBLOCK 1000 -#define TSDB_DEFAULT_MIN_ROW_FBLOCK 100 +#define TSDB_MIN_DAYS_PER_FILE 1 +#define TSDB_MAX_DAYS_PER_FILE 3650 +#define TSDB_DEFAULT_DAYS_PER_FILE 10 -#define TSDB_MIN_MAX_ROW_FBLOCK 200 -#define TSDB_MAX_MAX_ROW_FBLOCK 10000 -#define TSDB_DEFAULT_MAX_ROW_FBLOCK 4096 +#define TSDB_MIN_KEEP 1 // data in db to be reserved. +#define TSDB_MAX_KEEP 365000 // data in db to be reserved. +#define TSDB_DEFAULT_KEEP 3650 // ten years -#define TSDB_MIN_COMMIT_TIME 30 -#define TSDB_MAX_COMMIT_TIME 40960 -#define TSDB_DEFAULT_COMMIT_TIME 3600 +#define TSDB_MIN_MIN_ROW_FBLOCK 10 +#define TSDB_MAX_MIN_ROW_FBLOCK 1000 +#define TSDB_DEFAULT_MIN_ROW_FBLOCK 100 -#define TSDB_MIN_FSYNC_PERIOD 0 -#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond -#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second +#define TSDB_MIN_MAX_ROW_FBLOCK 200 +#define TSDB_MAX_MAX_ROW_FBLOCK 10000 +#define TSDB_DEFAULT_MAX_ROW_FBLOCK 4096 -#define TSDB_MIN_WAL_LEVEL 0 -#define TSDB_MAX_WAL_LEVEL 2 -#define TSDB_DEFAULT_WAL_LEVEL 1 +#define TSDB_MIN_COMMIT_TIME 30 +#define TSDB_MAX_COMMIT_TIME 40960 +#define TSDB_DEFAULT_COMMIT_TIME 3600 -#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI -#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO -#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI +#define TSDB_MIN_FSYNC_PERIOD 0 +#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond +#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second -#define TSDB_MIN_COMP_LEVEL 0 -#define TSDB_MAX_COMP_LEVEL 2 -#define TSDB_DEFAULT_COMP_LEVEL 2 +#define TSDB_MIN_WAL_LEVEL 0 +#define TSDB_MAX_WAL_LEVEL 2 +#define TSDB_DEFAULT_WAL_LEVEL 1 -#define TSDB_MIN_DB_REPLICA_OPTION 1 -#define TSDB_MAX_DB_REPLICA_OPTION 3 -#define TSDB_DEFAULT_DB_REPLICA_OPTION 1 +#define TSDB_MIN_PRECISION TSDB_TIME_PRECISION_MILLI +#define TSDB_MAX_PRECISION TSDB_TIME_PRECISION_NANO +#define TSDB_DEFAULT_PRECISION TSDB_TIME_PRECISION_MILLI -#define TSDB_MIN_DB_QUORUM_OPTION 1 -#define TSDB_MAX_DB_QUORUM_OPTION 2 -#define TSDB_DEFAULT_DB_QUORUM_OPTION 1 +#define TSDB_MIN_COMP_LEVEL 0 +#define TSDB_MAX_COMP_LEVEL 2 +#define TSDB_DEFAULT_COMP_LEVEL 2 -#define TSDB_MIN_DB_UPDATE 0 -#define TSDB_MAX_DB_UPDATE 2 -#define TSDB_DEFAULT_DB_UPDATE_OPTION 0 +#define TSDB_MIN_DB_REPLICA_OPTION 1 +#define TSDB_MAX_DB_REPLICA_OPTION 3 +#define TSDB_DEFAULT_DB_REPLICA_OPTION 1 -#define TSDB_MIN_DB_CACHE_LAST_ROW 0 -#define TSDB_MAX_DB_CACHE_LAST_ROW 3 -#define TSDB_DEFAULT_CACHE_LAST_ROW 0 +#define TSDB_MIN_DB_QUORUM_OPTION 1 +#define TSDB_MAX_DB_QUORUM_OPTION 2 +#define TSDB_DEFAULT_DB_QUORUM_OPTION 1 -#define TSDB_MAX_JOIN_TABLE_NUM 10 -#define TSDB_MAX_UNION_CLAUSE 5 +#define TSDB_MIN_DB_UPDATE 0 +#define TSDB_MAX_DB_UPDATE 2 +#define TSDB_DEFAULT_DB_UPDATE_OPTION 0 -#define TSDB_MAX_FIELD_LEN 16384 -#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384 -#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384 -#define PRIMARYKEY_TIMESTAMP_COL_ID 1 -#define COL_REACH_END(colId, maxColId) ((colId) > (maxColId)) +#define TSDB_MIN_DB_CACHE_LAST_ROW 0 +#define TSDB_MAX_DB_CACHE_LAST_ROW 3 +#define TSDB_DEFAULT_CACHE_LAST_ROW 0 -#define TSDB_MAX_RPC_THREADS 5 +#define TSDB_MAX_JOIN_TABLE_NUM 10 +#define TSDB_MAX_UNION_CLAUSE 5 -#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type -#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode +#define TSDB_MAX_FIELD_LEN 16384 +#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN - TSDB_KEYSIZE) // keep 16384 +#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN - TSDB_KEYSIZE) // keep 16384 +#define PRIMARYKEY_TIMESTAMP_COL_ID 1 +#define COL_REACH_END(colId, maxColId) ((colId) > (maxColId)) -#define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default +#define TSDB_MAX_RPC_THREADS 5 +#define TSDB_QUERY_TYPE_NON_TYPE 0x00u // none type +#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01u // free qhandle at vnode +#define TSDB_META_COMPACT_RATIO 0 // disable tsdb meta compact by default /* * 1. ordinary sub query for select * from super_table * 2. all sqlobj generated by createSubqueryObj with this flag */ -#define TSDB_QUERY_TYPE_SUBQUERY 0x02u -#define TSDB_QUERY_TYPE_STABLE_SUBQUERY 0x04u // two-stage subquery for super table - -#define TSDB_QUERY_TYPE_TABLE_QUERY 0x08u // query ordinary table; below only apply to client side -#define TSDB_QUERY_TYPE_STABLE_QUERY 0x10u // query on super table -#define TSDB_QUERY_TYPE_JOIN_QUERY 0x20u // join query -#define TSDB_QUERY_TYPE_PROJECTION_QUERY 0x40u // select *,columns... query -#define TSDB_QUERY_TYPE_JOIN_SEC_STAGE 0x80u // join sub query at the second stage - -#define TSDB_QUERY_TYPE_TAG_FILTER_QUERY 0x400u -#define TSDB_QUERY_TYPE_INSERT 0x100u // insert type -#define TSDB_QUERY_TYPE_MULTITABLE_QUERY 0x200u -#define TSDB_QUERY_TYPE_FILE_INSERT 0x400u // insert data from file -#define TSDB_QUERY_TYPE_STMT_INSERT 0x800u // stmt insert type -#define TSDB_QUERY_TYPE_NEST_SUBQUERY 0x1000u // nested sub query - -#define TSDB_QUERY_HAS_TYPE(x, _type) (((x) & (_type)) != 0) -#define TSDB_QUERY_SET_TYPE(x, _type) ((x) |= (_type)) -#define TSDB_QUERY_CLEAR_TYPE(x, _type) ((x) &= (~_type)) -#define TSDB_QUERY_RESET_TYPE(x) ((x) = TSDB_QUERY_TYPE_NON_TYPE) - -#define TSDB_ORDER_ASC 1 -#define TSDB_ORDER_DESC 2 - -#define TSDB_DEFAULT_CLUSTER_HASH_SIZE 1 -#define TSDB_DEFAULT_MNODES_HASH_SIZE 5 -#define TSDB_DEFAULT_DNODES_HASH_SIZE 10 -#define TSDB_DEFAULT_ACCOUNTS_HASH_SIZE 10 -#define TSDB_DEFAULT_USERS_HASH_SIZE 20 -#define TSDB_DEFAULT_DBS_HASH_SIZE 100 -#define TSDB_DEFAULT_VGROUPS_HASH_SIZE 100 -#define TSDB_DEFAULT_STABLES_HASH_SIZE 100 -#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000 - -#define TSDB_MAX_WAL_SIZE (1024*1024*3) - -#define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P - -#define TFS_MAX_TIERS 3 +#define TSDB_QUERY_TYPE_SUBQUERY 0x02u +#define TSDB_QUERY_TYPE_STABLE_SUBQUERY 0x04u // two-stage subquery for super table + +#define TSDB_QUERY_TYPE_TABLE_QUERY 0x08u // query ordinary table; below only apply to client side +#define TSDB_QUERY_TYPE_STABLE_QUERY 0x10u // query on super table +#define TSDB_QUERY_TYPE_JOIN_QUERY 0x20u // join query +#define TSDB_QUERY_TYPE_PROJECTION_QUERY 0x40u // select *,columns... query +#define TSDB_QUERY_TYPE_JOIN_SEC_STAGE 0x80u // join sub query at the second stage + +#define TSDB_QUERY_TYPE_TAG_FILTER_QUERY 0x400u +#define TSDB_QUERY_TYPE_INSERT 0x100u // insert type +#define TSDB_QUERY_TYPE_MULTITABLE_QUERY 0x200u +#define TSDB_QUERY_TYPE_FILE_INSERT 0x400u // insert data from file +#define TSDB_QUERY_TYPE_STMT_INSERT 0x800u // stmt insert type +#define TSDB_QUERY_TYPE_NEST_SUBQUERY 0x1000u // nested sub query + +#define TSDB_QUERY_HAS_TYPE(x, _type) (((x) & (_type)) != 0) +#define TSDB_QUERY_SET_TYPE(x, _type) ((x) |= (_type)) +#define TSDB_QUERY_CLEAR_TYPE(x, _type) ((x) &= (~_type)) +#define TSDB_QUERY_RESET_TYPE(x) ((x) = TSDB_QUERY_TYPE_NON_TYPE) + +#define TSDB_ORDER_ASC 1 +#define TSDB_ORDER_DESC 2 + +#define TSDB_DEFAULT_CLUSTER_HASH_SIZE 1 +#define TSDB_DEFAULT_MNODES_HASH_SIZE 5 +#define TSDB_DEFAULT_DNODES_HASH_SIZE 10 +#define TSDB_DEFAULT_ACCOUNTS_HASH_SIZE 10 +#define TSDB_DEFAULT_USERS_HASH_SIZE 20 +#define TSDB_DEFAULT_DBS_HASH_SIZE 100 +#define TSDB_DEFAULT_VGROUPS_HASH_SIZE 100 +#define TSDB_DEFAULT_STABLES_HASH_SIZE 100 +#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000 + +#define TSDB_MAX_WAL_SIZE (1024 * 1024 * 3) + +#define TSDB_ARB_DUMMY_TIME 4765104000000 // 2121-01-01 00:00:00.000, :P + +#define TFS_MAX_TIERS 3 #define TFS_MAX_DISKS_PER_TIER 16 -#define TFS_MAX_DISKS (TFS_MAX_TIERS * TFS_MAX_DISKS_PER_TIER) -#define TFS_MIN_LEVEL 0 -#define TFS_MAX_LEVEL (TFS_MAX_TIERS - 1) -#define TFS_PRIMARY_LEVEL 0 -#define TFS_PRIMARY_ID 0 +#define TFS_MAX_DISKS (TFS_MAX_TIERS * TFS_MAX_DISKS_PER_TIER) +#define TFS_MIN_LEVEL 0 +#define TFS_MAX_LEVEL (TFS_MAX_TIERS - 1) +#define TFS_PRIMARY_LEVEL 0 +#define TFS_PRIMARY_ID 0 #define TFS_MIN_DISK_FREE_SIZE 50 * 1024 * 1024 enum { TRANS_STAT_INIT = 0, TRANS_STAT_EXECUTING, TRANS_STAT_EXECUTED, TRANS_STAT_ROLLBACKING, TRANS_STAT_ROLLBACKED }; diff --git a/include/util/tfile.h b/include/util/tfile.h deleted file mode 100644 index 59953de861f0f123dad05bf8cde1dd4ee70600f7..0000000000000000000000000000000000000000 --- a/include/util/tfile.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * 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 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef _TD_UTIL_FILE_H -#define _TD_UTIL_FILE_H - -#include "os.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// init taos file module -int32_t tfInit(); - -// clean up taos file module -void tfCleanup(); - -// the same syntax as UNIX standard open/close/read/write -// but FD is int64_t and will never be reused -// int64_t tfOpenRead(const char *pathname); -// int64_t tfOpenReadWrite(const char *pathname); -// int64_t tfOpenCreateWrite(const char *pathname); -// int64_t tfOpenCreateWriteAppend(const char *pathname); - -// int64_t tfClose(int64_t tfd); -// int64_t tfWrite(int64_t tfd, void *buf, int64_t count); -// int64_t tfRead(int64_t tfd, void *buf, int64_t count); -// int64_t tfPread(int64_t tfd, void *buf, int64_t count, int64_t offset); -// int32_t tfFsync(int64_t tfd); -// bool tfValid(int64_t tfd); -// int64_t tfLseek(int64_t tfd, int64_t offset, int32_t whence); -// int32_t tfFtruncate(int64_t tfd, int64_t length); -// void * tfMmapReadOnly(int64_t tfd, int64_t length); -#ifdef __cplusplus -} -#endif - -#endif /*_TD_UTIL_FILE_H*/ diff --git a/source/libs/index/inc/indexInt.h b/source/libs/index/inc/indexInt.h index 90ad1e15f4b2669620253e52269003abb0e4d1c7..e15075530c1e038f1e938ef03982b4f6c43b1603 100644 --- a/source/libs/index/inc/indexInt.h +++ b/source/libs/index/inc/indexInt.h @@ -16,9 +16,11 @@ #ifndef _TD_INDEX_INT_H_ #define _TD_INDEX_INT_H_ +#include "os.h" + #include "index.h" -#include "index_fst.h" #include "taos.h" +#include "tarray.h" #include "tchecksum.h" #include "thash.h" #include "tlog.h" diff --git a/source/libs/index/inc/index_cache.h b/source/libs/index/inc/index_cache.h index 9db913debfc06f3406aa4d9105709419e5314f1e..1445a1bc562cde1cf51fa3e6cb5df057eaa3cc88 100644 --- a/source/libs/index/inc/index_cache.h +++ b/source/libs/index/inc/index_cache.h @@ -15,10 +15,9 @@ #ifndef __INDEX_CACHE_H__ #define __INDEX_CACHE_H__ -#include "index.h" #include "indexInt.h" -#include "tlockfree.h" #include "tskiplist.h" + // ----------------- key structure in skiplist --------------------- /* A data row, the format is like below diff --git a/source/libs/index/inc/index_fst.h b/source/libs/index/inc/index_fst.h index 072ec93e4e648ae55c945f291e0c0d73dc51cbc0..5da0dc537bfbefbe79a430d0220cef3149eb7f7b 100644 --- a/source/libs/index/inc/index_fst.h +++ b/source/libs/index/inc/index_fst.h @@ -20,11 +20,12 @@ extern "C" { #endif +#include "indexInt.h" +#include "index_fst_node.h" #include "index_fst_automation.h" #include "index_fst_counting_writer.h" #include "index_fst_registry.h" #include "index_fst_util.h" -#include "tarray.h" #define OUTPUT_PREFIX(a, b) ((a) > (b) ? (b) : (a) diff --git a/source/libs/index/inc/index_fst_automation.h b/source/libs/index/inc/index_fst_automation.h index be056f38fa183e1460dac83c9fd90b70e69c40e9..786d3eb7d29b404dcbb1a20e4871c8661983e688 100644 --- a/source/libs/index/inc/index_fst_automation.h +++ b/source/libs/index/inc/index_fst_automation.h @@ -19,6 +19,7 @@ extern "C" { #endif +#include "indexInt.h" #include "index_fst_util.h" typedef struct AutomationCtx AutomationCtx; diff --git a/source/libs/index/inc/index_fst_counting_writer.h b/source/libs/index/inc/index_fst_counting_writer.h index 86e829aa95f7505537363cec65704e3d8d89e0b2..f8a62467239f55e8461fef562d25ee3cacaf20c1 100644 --- a/source/libs/index/inc/index_fst_counting_writer.h +++ b/source/libs/index/inc/index_fst_counting_writer.h @@ -16,12 +16,12 @@ #ifndef __INDEX_FST_COUNTING_WRITER_H__ #define __INDEX_FST_COUNTING_WRITER_H__ +#include "indexInt.h" + #ifdef __cplusplus extern "C" { #endif -#include "tfile.h" - //#define USE_MMAP 1 #define DefaultMem 1024 * 1024 diff --git a/source/libs/index/inc/index_fst_node.h b/source/libs/index/inc/index_fst_node.h index 32de7ea6211d4ab449fc6ef0d0fe8355ff380299..4dbf4cea04dcccc44b96d99709f3da287b05e1dd 100644 --- a/source/libs/index/inc/index_fst_node.h +++ b/source/libs/index/inc/index_fst_node.h @@ -20,6 +20,7 @@ extern "C" { #endif +#include "indexInt.h" #include "index_fst_counting_writer.h" #include "index_fst_util.h" diff --git a/source/libs/index/inc/index_fst_registry.h b/source/libs/index/inc/index_fst_registry.h index f94a21d8dd7fd6887f531793af74f2d5023f66b7..20b70e2866615a07c457fbfaa1919bbe1f17ef6c 100644 --- a/source/libs/index/inc/index_fst_registry.h +++ b/source/libs/index/inc/index_fst_registry.h @@ -19,9 +19,9 @@ extern "C" { #endif +#include "indexInt.h" #include "index_fst_node.h" #include "index_fst_util.h" -#include "tarray.h" typedef struct FstRegistryCell { CompiledAddr addr; diff --git a/source/libs/index/inc/index_fst_util.h b/source/libs/index/inc/index_fst_util.h index 71a378584d401e966d7b2966ff215916c40c8232..f173dd9a15553b9a1997ff5915fc1e50ea9658a7 100644 --- a/source/libs/index/inc/index_fst_util.h +++ b/source/libs/index/inc/index_fst_util.h @@ -20,8 +20,8 @@ extern "C" { #endif +#include "indexInt.h" #include "index_fst_common.h" -#include "tarray.h" typedef uint64_t FstType; typedef uint64_t CompiledAddr; diff --git a/source/libs/index/inc/index_tfile.h b/source/libs/index/inc/index_tfile.h index 4618a39197d1d87b1e9d50f895578e9d2dd8fb85..f676651e52262d80cd0c7c2f42ec0fa6c258e43b 100644 --- a/source/libs/index/inc/index_tfile.h +++ b/source/libs/index/inc/index_tfile.h @@ -15,7 +15,6 @@ #ifndef __INDEX_TFILE_H__ #define __INDEX_TFILE_H__ -#include "index.h" #include "indexInt.h" #include "index_fst.h" #include "index_fst_counting_writer.h" diff --git a/source/libs/index/inc/index_util.h b/source/libs/index/inc/index_util.h index 36830a68bcf8156eb2955ce999a444182de82908..985dd657d088c08b36ffac1f2f169420fe8e76b7 100644 --- a/source/libs/index/inc/index_util.h +++ b/source/libs/index/inc/index_util.h @@ -15,7 +15,7 @@ #ifndef __INDEX_UTIL_H__ #define __INDEX_UTIL_H__ -#include "tarray.h" +#include "indexInt.h" #ifdef __cplusplus extern "C" { diff --git a/source/libs/index/src/index_fst_counting_writer.c b/source/libs/index/src/index_fst_counting_writer.c index 78c7a8d1934ad30c88ca8ab2b7fffd97c266eb88..16d98937780d39e13e683b00818acd7f660d0c3f 100644 --- a/source/libs/index/src/index_fst_counting_writer.c +++ b/source/libs/index/src/index_fst_counting_writer.c @@ -12,6 +12,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ + +#include "os.h" #include "index_fst_counting_writer.h" #include "indexInt.h" #include "index_fst_util.h" diff --git a/source/libs/index/src/index_fst_registry.c b/source/libs/index/src/index_fst_registry.c index 07afc52ecf12bf515e32afca7fc50a44e0a422b3..b28b518fc156b5d7585a2e071b603a186bcd54e7 100644 --- a/source/libs/index/src/index_fst_registry.c +++ b/source/libs/index/src/index_fst_registry.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include "os.h" #include "index_fst_registry.h" uint64_t fstRegistryHash(FstRegistry* registry, FstBuilderNode* bNode) { diff --git a/source/libs/index/test/fstTest.cc b/source/libs/index/test/fstTest.cc index 65118a2bce043dc0e8725f0569a51e19c9bdebdc..698945ae14578d72377c3d30d942da3e7c8c5ec2 100644 --- a/source/libs/index/test/fstTest.cc +++ b/source/libs/index/test/fstTest.cc @@ -49,7 +49,6 @@ class FstWriter { class FstReadMemory { public: FstReadMemory(size_t size, const std::string& fileName = "/tmp/tindex.tindex") { - tfInit(); _wc = writerCtxCreate(TFile, fileName.c_str(), true, 64 * 1024); _w = fstCountingWriterCreate(_wc); _size = size; @@ -116,7 +115,6 @@ class FstReadMemory { fstDestroy(_fst); fstSliceDestroy(&_s); writerCtxDestroy(_wc, false); - tfCleanup(); } private: @@ -170,7 +168,6 @@ void Performance_fstReadRecords(FstReadMemory* m) { } void checkMillonWriteAndReadOfFst() { - tfInit(); FstWriter* fw = new FstWriter; Performance_fstWriteRecords(fw); delete fw; @@ -181,11 +178,9 @@ void checkMillonWriteAndReadOfFst() { } Performance_fstReadRecords(fr); - tfCleanup(); delete fr; } void checkFstLongTerm() { - tfInit(); FstWriter* fw = new FstWriter; // Performance_fstWriteRecords(fw); @@ -235,12 +230,10 @@ void checkFstLongTerm() { // for (int i = 0; i < result.size(); i++) { // assert(result[i] == i); // check result //} - tfCleanup(); // free(ctx); // delete m; } void checkFstCheckIterator() { - tfInit(); FstWriter* fw = new FstWriter; int64_t s = taosGetTimestampUs(); int count = 2; @@ -275,7 +268,6 @@ void checkFstCheckIterator() { free(ctx); delete m; - tfCleanup(); } void fst_get(Fst* fst) { @@ -294,8 +286,6 @@ void fst_get(Fst* fst) { #define NUM_OF_THREAD 10 void validateTFile(char* arg) { - tfInit(); - std::thread threads[NUM_OF_THREAD]; // std::vector threads; TFileReader* reader = tfileReaderOpen(arg, 0, 20000000, "tag1"); @@ -309,12 +299,9 @@ void validateTFile(char* arg) { // wait join threads[i].join(); } - tfCleanup(); } void iterTFileReader(char* path, char* ver) { - tfInit(); - int version = atoi(ver); TFileReader* reader = tfileReaderOpen(path, 0, version, "tag1"); Iterate* iter = tfileIteratorCreate(reader); @@ -331,7 +318,6 @@ void iterTFileReader(char* path, char* ver) { printf("total size: %d\n term count: %d\n", count, termCount); tfileIteratorDestroy(iter); - tfCleanup(); } int main(int argc, char* argv[]) { diff --git a/source/libs/index/test/fstUT.cc b/source/libs/index/test/fstUT.cc index 9665198b3b651698775c61753dc8473105649cd1..2d3d2f8894415236bb6e79849137fdc931b9bc94 100644 --- a/source/libs/index/test/fstUT.cc +++ b/source/libs/index/test/fstUT.cc @@ -24,8 +24,6 @@ static char tindex[PATH_MAX] = {0}; static char tindexDir[PATH_MAX] = {0}; static void EnvInit() { - tfInit(); - std::string path = dir; taosRemoveDir(path.c_str()); taosMkDir(path.c_str()); @@ -136,7 +134,6 @@ class FstReadMemory { fstDestroy(_fst); fstSliceDestroy(&_s); writerCtxDestroy(_wc, false); - // tfCleanup(); } private: diff --git a/source/libs/index/test/indexTests.cc b/source/libs/index/test/indexTests.cc index bbcc654ae26fe8b4ffbbf01072c893bbea067876..a50e91b0944870d4c658c5d51ec38028aa0d98a6 100644 --- a/source/libs/index/test/indexTests.cc +++ b/source/libs/index/test/indexTests.cc @@ -420,7 +420,6 @@ class IndexTFileEnv : public ::testing::Test { virtual void SetUp() { taosRemoveDir(dir.c_str()); taosMkDir(dir.c_str()); - tfInit(); fObj = new TFileObj(dir, colName); } @@ -428,7 +427,6 @@ class IndexTFileEnv : public ::testing::Test { // indexClose(index); // indexeptsDestroy(opts); delete fObj; - tfCleanup(); // tfileWriterDestroy(twrite); } TFileObj* fObj; @@ -800,13 +798,10 @@ class IndexObj { class IndexEnv2 : public ::testing::Test { protected: virtual void SetUp() { - tfInit(); index = new IndexObj(); - // } virtual void TearDown() { delete index; - tfCleanup(); } IndexObj* index; }; diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 4f17bf436ef48e58db114477a2a2ecd7214ceec0..b1caeab3b1396ae601326217c956133d776d54f8 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -17,7 +17,6 @@ #include "tcompare.h" #include "os.h" #include "taoserror.h" -#include "tfile.h" #include "tref.h" #include "walInt.h" @@ -40,15 +39,9 @@ int32_t walInit() { int8_t old = atomic_val_compare_exchange_8(&tsWal.inited, 0, 1); if (old == 1) return 0; - int code = tfInit(); - if (code != 0) { - wError("failed to init tfile since %s", tstrerror(code)); - atomic_store_8(&tsWal.inited, 0); - return code; - } tsWal.refSetId = taosOpenRef(TSDB_MIN_VNODES, walFreeObj); - code = walCreateThread(); + int32_t code = walCreateThread(); if (code != 0) { wError("failed to init wal module since %s", tstrerror(code)); atomic_store_8(&tsWal.inited, 0); diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 159d2817591900bb02f7071190f5b0651c5d2ebf..9e1ffeae7f83deb4692ba221ad3f334fcc6965a2 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -13,7 +13,6 @@ * along with this program. If not, see . */ -#include "tfile.h" #include "walInt.h" #include "taoserror.h" diff --git a/source/libs/wal/src/walSeek.c b/source/libs/wal/src/walSeek.c index 6b3abcd0f98ca15209f1fbeacab35ff8d83f14e8..140b7ddc32614662ceb86daae8f3beafb1ff8926 100644 --- a/source/libs/wal/src/walSeek.c +++ b/source/libs/wal/src/walSeek.c @@ -16,7 +16,6 @@ #define _DEFAULT_SOURCE #include "os.h" #include "taoserror.h" -#include "tfile.h" #include "tref.h" #include "walInt.h" diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index ba071340034bbae320e9940efbf5032d387614fd..4b1f0ba30637a01a78a01f9db5a4fd533e1c87dd 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -18,7 +18,6 @@ #include "os.h" #include "taoserror.h" #include "tchecksum.h" -#include "tfile.h" #include "walInt.h" int32_t walCommit(SWal *pWal, int64_t ver) { diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 1ea1d320554f6fe90c05bfce384b931c563ab0df..062d144933136891acc98b4ba07b43d09c8a9f69 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -16,14 +16,12 @@ #define _GNU_SOURCE #define _XOPEN_SOURCE #define _DEFAULT_SOURCE - #include "tcompare.h" #include "regex.h" +#include "tdef.h" #include "thash.h" -#include "types.h" #include "tlog.h" -#include "tdef.h" -#include "taos.h" +#include "types.h" int32_t setChkInBytes1(const void *pLeft, const void *pRight) { return NULL != taosHashGet((SHashObj *)pRight, pLeft, 1) ? 1 : 0; @@ -57,16 +55,14 @@ int32_t setChkNotInBytes8(const void *pLeft, const void *pRight) { return NULL == taosHashGet((SHashObj *)pRight, pLeft, 8) ? 1 : 0; } - -int32_t compareChkInString(const void *pLeft, const void* pRight) { +int32_t compareChkInString(const void *pLeft, const void *pRight) { return NULL != taosHashGet((SHashObj *)pRight, varDataVal(pLeft), varDataLen(pLeft)) ? 1 : 0; } -int32_t compareChkNotInString(const void *pLeft, const void* pRight) { +int32_t compareChkNotInString(const void *pLeft, const void *pRight) { return NULL == taosHashGet((SHashObj *)pRight, varDataVal(pLeft), varDataLen(pLeft)) ? 1 : 0; } - int32_t compareInt8Val(const void *pLeft, const void *pRight) { int8_t left = GET_INT8_VAL(pLeft), right = GET_INT8_VAL(pRight); if (left > right) return 1; @@ -74,9 +70,7 @@ int32_t compareInt8Val(const void *pLeft, const void *pRight) { return 0; } -int32_t compareInt8ValDesc(const void *pLeft, const void *pRight) { - return compareInt8Val(pRight, pLeft); -} +int32_t compareInt8ValDesc(const void *pLeft, const void *pRight) { return compareInt8Val(pRight, pLeft); } int32_t compareInt16Val(const void *pLeft, const void *pRight) { int16_t left = GET_INT16_VAL(pLeft), right = GET_INT16_VAL(pRight); @@ -85,9 +79,7 @@ int32_t compareInt16Val(const void *pLeft, const void *pRight) { return 0; } -int32_t compareInt16ValDesc(const void* pLeft, const void* pRight) { - return compareInt16Val(pRight, pLeft); -} +int32_t compareInt16ValDesc(const void *pLeft, const void *pRight) { return compareInt16Val(pRight, pLeft); } int32_t compareInt32Val(const void *pLeft, const void *pRight) { int32_t left = GET_INT32_VAL(pLeft), right = GET_INT32_VAL(pRight); @@ -96,9 +88,7 @@ int32_t compareInt32Val(const void *pLeft, const void *pRight) { return 0; } -int32_t compareInt32ValDesc(const void* pLeft, const void* pRight) { - return compareInt32Val(pRight, pLeft); -} +int32_t compareInt32ValDesc(const void *pLeft, const void *pRight) { return compareInt32Val(pRight, pLeft); } int32_t compareInt64Val(const void *pLeft, const void *pRight) { int64_t left = GET_INT64_VAL(pLeft), right = GET_INT64_VAL(pRight); @@ -107,9 +97,7 @@ int32_t compareInt64Val(const void *pLeft, const void *pRight) { return 0; } -int32_t compareInt64ValDesc(const void* pLeft, const void* pRight) { - return compareInt64Val(pRight, pLeft); -} +int32_t compareInt64ValDesc(const void *pLeft, const void *pRight) { return compareInt64Val(pRight, pLeft); } int32_t compareUint32Val(const void *pLeft, const void *pRight) { uint32_t left = GET_UINT32_VAL(pLeft), right = GET_UINT32_VAL(pRight); @@ -118,9 +106,7 @@ int32_t compareUint32Val(const void *pLeft, const void *pRight) { return 0; } -int32_t compareUint32ValDesc(const void* pLeft, const void* pRight) { - return compareUint32Val(pRight, pLeft); -} +int32_t compareUint32ValDesc(const void *pLeft, const void *pRight) { return compareUint32Val(pRight, pLeft); } int32_t compareUint64Val(const void *pLeft, const void *pRight) { uint64_t left = GET_UINT64_VAL(pLeft), right = GET_UINT64_VAL(pRight); @@ -129,9 +115,7 @@ int32_t compareUint64Val(const void *pLeft, const void *pRight) { return 0; } -int32_t compareUint64ValDesc(const void* pLeft, const void* pRight) { - return compareUint64Val(pRight, pLeft); -} +int32_t compareUint64ValDesc(const void *pLeft, const void *pRight) { return compareUint64Val(pRight, pLeft); } int32_t compareUint16Val(const void *pLeft, const void *pRight) { uint16_t left = GET_UINT16_VAL(pLeft), right = GET_UINT16_VAL(pRight); @@ -140,20 +124,16 @@ int32_t compareUint16Val(const void *pLeft, const void *pRight) { return 0; } -int32_t compareUint16ValDesc(const void* pLeft, const void* pRight) { - return compareUint16Val(pRight, pLeft); -} +int32_t compareUint16ValDesc(const void *pLeft, const void *pRight) { return compareUint16Val(pRight, pLeft); } -int32_t compareUint8Val(const void* pLeft, const void* pRight) { +int32_t compareUint8Val(const void *pLeft, const void *pRight) { uint8_t left = GET_UINT8_VAL(pLeft), right = GET_UINT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; } -int32_t compareUint8ValDesc(const void* pLeft, const void* pRight) { - return compareUint8Val(pRight, pLeft); -} +int32_t compareUint8ValDesc(const void *pLeft, const void *pRight) { return compareUint8Val(pRight, pLeft); } int32_t compareFloatVal(const void *pLeft, const void *pRight) { float p1 = GET_FLOAT_VAL(pLeft); @@ -173,12 +153,10 @@ int32_t compareFloatVal(const void *pLeft, const void *pRight) { if (FLT_EQUAL(p1, p2)) { return 0; } - return FLT_GREATER(p1, p2) ? 1: -1; + return FLT_GREATER(p1, p2) ? 1 : -1; } -int32_t compareFloatValDesc(const void* pLeft, const void* pRight) { - return compareFloatVal(pRight, pLeft); -} +int32_t compareFloatValDesc(const void *pLeft, const void *pRight) { return compareFloatVal(pRight, pLeft); } int32_t compareDoubleVal(const void *pLeft, const void *pRight) { double p1 = GET_DOUBLE_VAL(pLeft); @@ -198,30 +176,28 @@ int32_t compareDoubleVal(const void *pLeft, const void *pRight) { if (FLT_EQUAL(p1, p2)) { return 0; } - return FLT_GREATER(p1, p2) ? 1: -1; + return FLT_GREATER(p1, p2) ? 1 : -1; } -int32_t compareDoubleValDesc(const void* pLeft, const void* pRight) { - return compareDoubleVal(pRight, pLeft); -} +int32_t compareDoubleValDesc(const void *pLeft, const void *pRight) { return compareDoubleVal(pRight, pLeft); } int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight) { int32_t len1 = varDataLen(pLeft); int32_t len2 = varDataLen(pRight); if (len1 != len2) { - return len1 > len2? 1:-1; + return len1 > len2 ? 1 : -1; } else { int32_t ret = strncmp(varDataVal(pLeft), varDataVal(pRight), len1); if (ret == 0) { return 0; } else { - return ret > 0 ? 1:-1; + return ret > 0 ? 1 : -1; } } } -int32_t compareLenPrefixedStrDesc(const void* pLeft, const void* pRight) { +int32_t compareLenPrefixedStrDesc(const void *pLeft, const void *pRight) { return compareLenPrefixedStr(pRight, pLeft); } @@ -230,9 +206,9 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) { int32_t len2 = varDataLen(pRight); if (len1 != len2) { - return len1 > len2? 1:-1; + return len1 > len2 ? 1 : -1; } else { - int32_t ret = memcmp((wchar_t*) pLeft, (wchar_t*) pRight, len1); + int32_t ret = memcmp((wchar_t *)pLeft, (wchar_t *)pRight, len1); if (ret == 0) { return 0; } else { @@ -241,7 +217,7 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) { } } -int32_t compareLenPrefixedWStrDesc(const void* pLeft, const void* pRight) { +int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight) { return compareLenPrefixedWStr(pRight, pLeft); } @@ -301,10 +277,13 @@ int32_t patternMatch(const char *patterStr, const char *str, size_t size, const } c1 = str[j++]; - ++o; - + ++o; + if (j <= size) { - if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; } + if (c == '\\' && patterStr[i] == '_' && c1 == '_') { + i++; + continue; + } if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) { continue; } @@ -364,21 +343,19 @@ int32_t WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t siz return TSDB_PATTERN_NOMATCH; } - + return (str[j] == 0 || j >= size) ? TSDB_PATTERN_MATCH : TSDB_PATTERN_NOMATCH; } -int32_t compareStrRegexCompMatch(const void* pLeft, const void* pRight) { - return compareStrRegexComp(pLeft, pRight); -} +int32_t compareStrRegexCompMatch(const void *pLeft, const void *pRight) { return compareStrRegexComp(pLeft, pRight); } -int32_t compareStrRegexCompNMatch(const void* pLeft, const void* pRight) { +int32_t compareStrRegexCompNMatch(const void *pLeft, const void *pRight) { return compareStrRegexComp(pLeft, pRight) ? 0 : 1; } -int32_t compareStrRegexComp(const void* pLeft, const void* pRight) { +int32_t compareStrRegexComp(const void *pLeft, const void *pRight) { size_t sz = varDataLen(pRight); - char *pattern = malloc(sz + 1); + char *pattern = malloc(sz + 1); memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); pattern[sz] = 0; @@ -413,15 +390,14 @@ int32_t compareStrRegexComp(const void* pLeft, const void* pRight) { return result; } -int32_t taosArrayCompareString(const void* a, const void* b) { - const char* x = *(const char**)a; - const char* y = *(const char**)b; +int32_t taosArrayCompareString(const void *a, const void *b) { + const char *x = *(const char **)a; + const char *y = *(const char **)b; return compareLenPrefixedStr(x, y); } - -int32_t compareStrPatternMatch(const void* pLeft, const void* pRight) { +int32_t compareStrPatternMatch(const void *pLeft, const void *pRight) { SPatternCompareInfo pInfo = {'%', '_'}; assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN); @@ -429,7 +405,7 @@ int32_t compareStrPatternMatch(const void* pLeft, const void* pRight) { memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); size_t sz = varDataLen(pLeft); - char *buf = malloc(sz + 1); + char *buf = malloc(sz + 1); memcpy(buf, varDataVal(pLeft), sz); buf[sz] = 0; @@ -439,11 +415,11 @@ int32_t compareStrPatternMatch(const void* pLeft, const void* pRight) { return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } -int32_t compareStrPatternNotMatch(const void* pLeft, const void* pRight) { +int32_t compareStrPatternNotMatch(const void *pLeft, const void *pRight) { return compareStrPatternMatch(pLeft, pRight) ? 0 : 1; } -int32_t compareWStrPatternMatch(const void* pLeft, const void* pRight) { +int32_t compareWStrPatternMatch(const void *pLeft, const void *pRight) { SPatternCompareInfo pInfo = {'%', '_'}; assert(varDataLen(pRight) <= TSDB_MAX_FIELD_LEN * TSDB_NCHAR_SIZE); @@ -451,17 +427,16 @@ int32_t compareWStrPatternMatch(const void* pLeft, const void* pRight) { wchar_t *pattern = calloc(varDataLen(pRight) + 1, sizeof(wchar_t)); memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); - int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft)/TSDB_NCHAR_SIZE, &pInfo); + int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft) / TSDB_NCHAR_SIZE, &pInfo); free(pattern); return (ret == TSDB_PATTERN_MATCH) ? 0 : 1; } -int32_t compareWStrPatternNotMatch(const void* pLeft, const void* pRight) { +int32_t compareWStrPatternNotMatch(const void *pLeft, const void *pRight) { return compareWStrPatternMatch(pLeft, pRight) ? 0 : 1; } - __compar_fn_t getComparFunc(int32_t type, int32_t optr) { __compar_fn_t comparFn = NULL; @@ -513,13 +488,25 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { switch (type) { case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: comparFn = compareInt8Val; break; - case TSDB_DATA_TYPE_SMALLINT: comparFn = compareInt16Val; break; - case TSDB_DATA_TYPE_INT: comparFn = compareInt32Val; break; + case TSDB_DATA_TYPE_TINYINT: + comparFn = compareInt8Val; + break; + case TSDB_DATA_TYPE_SMALLINT: + comparFn = compareInt16Val; + break; + case TSDB_DATA_TYPE_INT: + comparFn = compareInt32Val; + break; case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_TIMESTAMP: comparFn = compareInt64Val; break; - case TSDB_DATA_TYPE_FLOAT: comparFn = compareFloatVal; break; - case TSDB_DATA_TYPE_DOUBLE: comparFn = compareDoubleVal; break; + case TSDB_DATA_TYPE_TIMESTAMP: + comparFn = compareInt64Val; + break; + case TSDB_DATA_TYPE_FLOAT: + comparFn = compareFloatVal; + break; + case TSDB_DATA_TYPE_DOUBLE: + comparFn = compareDoubleVal; + break; case TSDB_DATA_TYPE_BINARY: { if (optr == OP_TYPE_MATCH) { comparFn = compareStrRegexCompMatch; @@ -559,10 +546,18 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { break; } - case TSDB_DATA_TYPE_UTINYINT: comparFn = compareUint8Val; break; - case TSDB_DATA_TYPE_USMALLINT: comparFn = compareUint16Val;break; - case TSDB_DATA_TYPE_UINT: comparFn = compareUint32Val;break; - case TSDB_DATA_TYPE_UBIGINT: comparFn = compareUint64Val;break; + case TSDB_DATA_TYPE_UTINYINT: + comparFn = compareUint8Val; + break; + case TSDB_DATA_TYPE_USMALLINT: + comparFn = compareUint16Val; + break; + case TSDB_DATA_TYPE_UINT: + comparFn = compareUint32Val; + break; + case TSDB_DATA_TYPE_UBIGINT: + comparFn = compareUint64Val; + break; default: comparFn = compareInt32Val; @@ -572,99 +567,106 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { return comparFn; } - - __compar_fn_t getKeyComparFunc(int32_t keyType, int32_t order) { __compar_fn_t comparFn = NULL; switch (keyType) { case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_BOOL: - comparFn = (order == TSDB_ORDER_ASC)? compareInt8Val:compareInt8ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareInt8Val : compareInt8ValDesc; break; case TSDB_DATA_TYPE_SMALLINT: - comparFn = (order == TSDB_ORDER_ASC)? compareInt16Val:compareInt16ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareInt16Val : compareInt16ValDesc; break; case TSDB_DATA_TYPE_INT: - comparFn = (order == TSDB_ORDER_ASC)? compareInt32Val:compareInt32ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc; break; case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_TIMESTAMP: - comparFn = (order == TSDB_ORDER_ASC)? compareInt64Val:compareInt64ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareInt64Val : compareInt64ValDesc; break; case TSDB_DATA_TYPE_FLOAT: - comparFn = (order == TSDB_ORDER_ASC)? compareFloatVal:compareFloatValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareFloatVal : compareFloatValDesc; break; case TSDB_DATA_TYPE_DOUBLE: - comparFn = (order == TSDB_ORDER_ASC)? compareDoubleVal:compareDoubleValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareDoubleVal : compareDoubleValDesc; break; case TSDB_DATA_TYPE_UTINYINT: - comparFn = (order == TSDB_ORDER_ASC)? compareUint8Val:compareUint8ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareUint8Val : compareUint8ValDesc; break; case TSDB_DATA_TYPE_USMALLINT: - comparFn = (order == TSDB_ORDER_ASC)? compareUint16Val:compareUint16ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareUint16Val : compareUint16ValDesc; break; case TSDB_DATA_TYPE_UINT: - comparFn = (order == TSDB_ORDER_ASC)? compareUint32Val:compareUint32ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareUint32Val : compareUint32ValDesc; break; case TSDB_DATA_TYPE_UBIGINT: - comparFn = (order == TSDB_ORDER_ASC)? compareUint64Val:compareUint64ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareUint64Val : compareUint64ValDesc; break; case TSDB_DATA_TYPE_BINARY: - comparFn = (order == TSDB_ORDER_ASC)? compareLenPrefixedStr:compareLenPrefixedStrDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareLenPrefixedStr : compareLenPrefixedStrDesc; break; case TSDB_DATA_TYPE_NCHAR: - comparFn = (order == TSDB_ORDER_ASC)? compareLenPrefixedWStr:compareLenPrefixedWStrDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareLenPrefixedWStr : compareLenPrefixedWStrDesc; break; default: - comparFn = (order == TSDB_ORDER_ASC)? compareInt32Val:compareInt32ValDesc; + comparFn = (order == TSDB_ORDER_ASC) ? compareInt32Val : compareInt32ValDesc; break; } return comparFn; } -int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) { +int32_t doCompare(const char *f1, const char *f2, int32_t type, size_t size) { switch (type) { - case TSDB_DATA_TYPE_INT: DEFAULT_COMP(GET_INT32_VAL(f1), GET_INT32_VAL(f2)); - case TSDB_DATA_TYPE_DOUBLE: DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1), GET_DOUBLE_VAL(f2)); - case TSDB_DATA_TYPE_FLOAT: DEFAULT_FLOAT_COMP(GET_FLOAT_VAL(f1), GET_FLOAT_VAL(f2)); - case TSDB_DATA_TYPE_BIGINT: DEFAULT_COMP(GET_INT64_VAL(f1), GET_INT64_VAL(f2)); - case TSDB_DATA_TYPE_SMALLINT: DEFAULT_COMP(GET_INT16_VAL(f1), GET_INT16_VAL(f2)); + case TSDB_DATA_TYPE_INT: + DEFAULT_COMP(GET_INT32_VAL(f1), GET_INT32_VAL(f2)); + case TSDB_DATA_TYPE_DOUBLE: + DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(f1), GET_DOUBLE_VAL(f2)); + case TSDB_DATA_TYPE_FLOAT: + DEFAULT_FLOAT_COMP(GET_FLOAT_VAL(f1), GET_FLOAT_VAL(f2)); + case TSDB_DATA_TYPE_BIGINT: + DEFAULT_COMP(GET_INT64_VAL(f1), GET_INT64_VAL(f2)); + case TSDB_DATA_TYPE_SMALLINT: + DEFAULT_COMP(GET_INT16_VAL(f1), GET_INT16_VAL(f2)); case TSDB_DATA_TYPE_TINYINT: - case TSDB_DATA_TYPE_BOOL: DEFAULT_COMP(GET_INT8_VAL(f1), GET_INT8_VAL(f2)); - case TSDB_DATA_TYPE_UTINYINT: DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_VAL(f2)); - case TSDB_DATA_TYPE_USMALLINT: DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2)); - case TSDB_DATA_TYPE_UINT: DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2)); - case TSDB_DATA_TYPE_UBIGINT: DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2)); + case TSDB_DATA_TYPE_BOOL: + DEFAULT_COMP(GET_INT8_VAL(f1), GET_INT8_VAL(f2)); + case TSDB_DATA_TYPE_UTINYINT: + DEFAULT_COMP(GET_UINT8_VAL(f1), GET_UINT8_VAL(f2)); + case TSDB_DATA_TYPE_USMALLINT: + DEFAULT_COMP(GET_UINT16_VAL(f1), GET_UINT16_VAL(f2)); + case TSDB_DATA_TYPE_UINT: + DEFAULT_COMP(GET_UINT32_VAL(f1), GET_UINT32_VAL(f2)); + case TSDB_DATA_TYPE_UBIGINT: + DEFAULT_COMP(GET_UINT64_VAL(f1), GET_UINT64_VAL(f2)); case TSDB_DATA_TYPE_NCHAR: { - tstr* t1 = (tstr*) f1; - tstr* t2 = (tstr*) f2; + tstr *t1 = (tstr *)f1; + tstr *t2 = (tstr *)f2; if (t1->len != t2->len) { - return t1->len > t2->len? 1:-1; + return t1->len > t2->len ? 1 : -1; } - int32_t ret = memcmp((wchar_t*) t1, (wchar_t*) t2, t2->len); + int32_t ret = memcmp((wchar_t *)t1, (wchar_t *)t2, t2->len); if (ret == 0) { return ret; } return (ret < 0) ? -1 : 1; } default: { // todo refactor - tstr* t1 = (tstr*) f1; - tstr* t2 = (tstr*) f2; + tstr *t1 = (tstr *)f1; + tstr *t2 = (tstr *)f2; if (t1->len != t2->len) { - return t1->len > t2->len? 1:-1; + return t1->len > t2->len ? 1 : -1; } else { int32_t ret = strncmp(t1->data, t2->data, t1->len); if (ret == 0) { return 0; } else { - return ret < 0? -1:1; + return ret < 0 ? -1 : 1; } } } } } - diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index bb86c9389c764d71a0b5c1999b167e09ed49196f..5ea745d924b63d039d23d7241df51bed27e583bc 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -17,8 +17,8 @@ #include "tconfig.h" #include "taoserror.h" #include "thash.h" -#include "tutil.h" #include "tlog.h" +#include "tutil.h" #define CFG_NAME_PRINT_LEN 24 #define CFG_SRC_PRINT_LEN 12 diff --git a/source/util/src/tfile.c b/source/util/src/tfile.c deleted file mode 100644 index ef9708df0ccf61852e1e5f465a9670a72916efac..0000000000000000000000000000000000000000 --- a/source/util/src/tfile.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * 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 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "os.h" -#include "taoserror.h" -#include "tref.h" -#include "tutil.h" -#include "tlog.h" - -static int32_t tsFileRsetId = -1; - -static int8_t tfInited = 0; - -// static void tfCloseFile(void *p) { taosCloseFile((TdFilePtr)(uintptr_t)p); } - -int32_t tfInit() { - // int8_t old = atomic_val_compare_exchange_8(&tfInited, 0, 1); - // if (old == 1) return 0; - // tsFileRsetId = taosOpenRef(2000, tfCloseFile); - // if (tsFileRsetId > 0) { - // return 0; - // } else { - // atomic_store_8(&tfInited, 0); - // return -1; - // } -} - -void tfCleanup() { - // atomic_store_8(&tfInited, 0); - // if (tsFileRsetId >= 0) taosCloseRef(tsFileRsetId); - // tsFileRsetId = -1; -} - -// static int64_t tfOpenImp(TdFilePtr pFile) { -// if (pFile == NULL) { -// terrno = TAOS_SYSTEM_ERROR(errno); -// return -1; -// } - -// void * p = (void *)(int64_t)pFile; -// int64_t rid = taosAddRef(tsFileRsetId, p); -// if (rid < 0) taosCloseFile(&pFile); - -// return rid; -// } - -// int64_t tfOpenRead(const char *pathname, int32_t flags) { -// int32_t pFile = taosOpenFile(pathname, TD_FILE_READ); -// return tfOpenImp(fd); -// } - -// int64_t tfOpenReadWrite(const char *pathname, int32_t flags) { -// int32_t pFile = taosOpenFile(pathname, TD_FILE_READ | TD_FILE_WRITE); -// return tfOpenImp(fd); -// } - -// int64_t tfOpenCreateWrite(const char *pathname, int32_t flags, mode_t mode) { -// int32_t pFile = taosOpenFile(pathname, TD_FILE_CTEATE | TD_FILE_WRITE); -// return tfOpenImp(fd); -// } - -// int64_t tfOpenCreateWriteAppend(const char *pathname, int32_t flags, mode_t mode) { -// int32_t pFile = taosOpenFile(pathname, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); -// return tfOpenImp(fd); -// } - -// int64_t tfClose(int64_t tfd) { return taosRemoveRef(tsFileRsetId, tfd); } - -// int64_t tfWrite(int64_t tfd, void *buf, int64_t count) { -// void *p = taosAcquireRef(tsFileRsetId, tfd); -// if (p == NULL) return -1; - -// int32_t pFile = (TdFilePtr)(uintptr_t)p; - -// int64_t ret = taosWriteFile(pFile, buf, count); -// if (ret < 0) terrno = TAOS_SYSTEM_ERROR(errno); - -// taosReleaseRef(tsFileRsetId, tfd); -// return ret; -// } - -// int64_t tfRead(int64_t tfd, void *buf, int64_t count) { -// void *p = taosAcquireRef(tsFileRsetId, tfd); -// if (p == NULL) return -1; - -// int32_t pFile = (TdFilePtr)(uintptr_t)p; - -// int64_t ret = taosReadFile(pFile, buf, count); -// if (ret < 0) terrno = TAOS_SYSTEM_ERROR(errno); - -// taosReleaseRef(tsFileRsetId, tfd); -// return ret; -// } - -// int64_t tfPread(int64_t tfd, void *buf, int64_t count, int32_t offset) { -// void *p = taosAcquireRef(tsFileRsetId, tfd); -// if (p == NULL) return -1; - -// int32_t pFile = (TdFilePtr)(uintptr_t)p; - -// int64_t ret = pread(fd, buf, count, offset); -// if (ret < 0) terrno = TAOS_SYSTEM_ERROR(errno); - -// taosReleaseRef(tsFileRsetId, tfd); -// return ret; -// } - -// int32_t tfFsync(int64_t tfd) { -// void *p = taosAcquireRef(tsFileRsetId, tfd); -// if (p == NULL) return -1; - -// int32_t pFile = (TdFilePtr)(uintptr_t)p; -// int32_t code = taosFsyncFile(pFile); - -// taosReleaseRef(tsFileRsetId, tfd); -// return code; -// } - -// bool tfValid(int64_t tfd) { -// void *p = taosAcquireRef(tsFileRsetId, tfd); -// if (p == NULL) return false; - -// taosReleaseRef(tsFileRsetId, tfd); -// return true; -// } - -// int64_t tfLseek(int64_t tfd, int64_t offset, int32_t whence) { -// void *p = taosAcquireRef(tsFileRsetId, tfd); -// if (p == NULL) return -1; - -// int32_t pFile = (TdFilePtr)(uintptr_t)p; -// int64_t ret = taosLSeekFile(fd, offset, whence); - -// taosReleaseRef(tsFileRsetId, tfd); -// return ret; -// } - -// int32_t tfFtruncate(int64_t tfd, int64_t length) { -// void *p = taosAcquireRef(tsFileRsetId, tfd); -// if (p == NULL) return -1; - -// int32_t pFile = (TdFilePtr)(uintptr_t)p; -// int32_t code = taosFtruncateFile(fd, length); - -// taosReleaseRef(tsFileRsetId, tfd); -// return code; -// } - -// void *tfMmapReadOnly(int64_t tfd, int64_t length) { -// void *p = taosAcquireRef(tsFileRsetId, tfd); -// if (p == NULL) return NULL; -// int32_t pFile = (TdFilePtr)(uintptr_t)p; - -// void *ptr = mmap(NULL, length, PROT_READ, MAP_SHARED, fd, 0); -// taosReleaseRef(tsFileRsetId, tfd); -// return ptr; -// }