diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81df1196f9b1c8378e5ca2bcacd5032725a4406d..7eba0cd7369705ad7d424c0b0026751cee7de23c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,15 +1,19 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) +# Base compile ADD_SUBDIRECTORY(os) +ADD_SUBDIRECTORY(thirdparty) + +ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(util) ADD_SUBDIRECTORY(rpc) ADD_SUBDIRECTORY(client) +ADD_SUBDIRECTORY(query) ADD_SUBDIRECTORY(kit) ADD_SUBDIRECTORY(plugins) ADD_SUBDIRECTORY(sdb) ADD_SUBDIRECTORY(mnode) -ADD_SUBDIRECTORY(vnode) -ADD_SUBDIRECTORY(dnode) -ADD_SUBDIRECTORY(query) +# ADD_SUBDIRECTORY(vnode) +# ADD_SUBDIRECTORY(dnode) #ADD_SUBDIRECTORY(connector/jdbc) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 827c65435dc7e7c2267d2448b6e59aab753171b7..a64f0581fb01ee6093e3fdc284030e0303f59060 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -15,13 +15,13 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) # set the static lib name ADD_LIBRARY(taos_static STATIC ${SRC}) - TARGET_LINK_LIBRARIES(taos_static query trpc tutil pthread m rt) + TARGET_LINK_LIBRARIES(taos_static common query trpc tutil pthread m rt) SET_TARGET_PROPERTIES(taos_static PROPERTIES OUTPUT_NAME "taos_static") SET_TARGET_PROPERTIES(taos_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) # generate dynamic library (*.so) ADD_LIBRARY(taos SHARED ${SRC}) - TARGET_LINK_LIBRARIES(taos trpc tutil pthread m rt) + TARGET_LINK_LIBRARIES(taos common trpc tutil pthread m rt) SET_TARGET_PROPERTIES(taos PROPERTIES CLEAN_DIRECT_OUTPUT 1) #set version of .so diff --git a/src/client/inc/tscSQLParser.h b/src/client/inc/tscSQLParser.h index 87c193de75a81c690a2580c220e13212b3b4b384..c7f8ba06e8fc20ea4be57784861ad86b4089aad2 100644 --- a/src/client/inc/tscSQLParser.h +++ b/src/client/inc/tscSQLParser.h @@ -23,7 +23,7 @@ extern "C" { #include "taos.h" #include "taosmsg.h" #include "ttokendef.h" -#include "ttypes.h" +#include "taosdef.h" #include "tvariant.h" #include "qsqlparser.h" diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 88b1fc0c28157f9023a3fbef62dabc05802cf05c..9c4f7e9c55b315263edaa4bbcadef11b6089593f 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -25,7 +25,7 @@ #include "tscompression.h" #include "tsqlfunction.h" #include "ttime.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" #include "tpercentile.h" diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index ab57719d0979d4994e2c5ee913f21d320ca21561..89b43816c86db232b2d48de86a839bc958296b38 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -19,7 +19,7 @@ #include "tcache.h" #include "tscUtil.h" #include "tsclient.h" -#include "ttypes.h" +#include "taosdef.h" #include "textbuffer.h" #include "tscSecondaryMerge.h" diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index b54600f6412f84c67b892fd228d10d0380e5f948..4c9f99b93235f38cfd995dc822e2ceef2ee1a325 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -25,7 +25,7 @@ #include "tschemautil.h" #include "tsclient.h" #include "ttokendef.h" -#include "ttypes.h" +#include "taosdef.h" #include "tlog.h" #include "tstoken.h" diff --git a/src/client/src/tscSchemaUtil.c b/src/client/src/tscSchemaUtil.c index 250e296e5345845152534c692f5a28020e22748f..d412ac18c86988665a2f5a1e1dad688d4bc45700 100644 --- a/src/client/src/tscSchemaUtil.c +++ b/src/client/src/tscSchemaUtil.c @@ -17,7 +17,7 @@ #include "taosmsg.h" #include "tschemautil.h" #include "ttokendef.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) { diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5c5366c53f825f6b302abc2579bc6e31dd3d1e29 --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1,9 @@ +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) + +add_library(common ${SOURCE_LIST}) +target_include_directories( + common + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc + PUBLIC ${CMAKE_SOURCE_DIR}/src/inc + PUBLIC ${CMAKE_SOURCE_DIR}/src/os/linux/inc + ) \ No newline at end of file diff --git a/src/vnode/common/inc/dataformat.h b/src/common/inc/dataformat.h similarity index 94% rename from src/vnode/common/inc/dataformat.h rename to src/common/inc/dataformat.h index 43eb1ad103afac0ea75f94a04238a30d5269d361..f004380336c4e4d8ce5112a2516b4be7cc6a8e3f 100644 --- a/src/vnode/common/inc/dataformat.h +++ b/src/common/inc/dataformat.h @@ -17,8 +17,9 @@ #include #include +#include -#include "schema.h" +// #include "schema.h" #ifdef __cplusplus extern "C" { @@ -43,9 +44,9 @@ typedef void *SDataRow; #define dataRowCpy(dst, r) memcpy((dst), (r), dataRowLen(r)) SDataRow tdNewDataRow(int32_t bytes); -SDataRow tdNewDdataFromSchema(SSchema *pSchema); +// SDataRow tdNewDdataFromSchema(SSchema *pSchema); void tdFreeDataRow(SDataRow row); -int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixOffset); +// int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixOffset); void tdDataRowCpy(void *dst, SDataRow row); void tdDataRowReset(SDataRow row); SDataRow tdDataRowDup(SDataRow row); diff --git a/src/vnode/common/src/dataformat.c b/src/common/src/dataformat.c similarity index 66% rename from src/vnode/common/src/dataformat.c rename to src/common/src/dataformat.c index f8f794e882fe174bac658a8e8e4a97bba4eb5b2d..fe868f91d522fb308da52aeb06a0f02a0af6a0a4 100644 --- a/src/vnode/common/src/dataformat.c +++ b/src/common/src/dataformat.c @@ -21,10 +21,10 @@ SDataRow tdNewDataRow(int32_t bytes) { return row; } -SDataRow tdNewDdataFromSchema(SSchema *pSchema) { - int32_t bytes = tdMaxRowDataBytes(pSchema); - return tdNewDataRow(bytes); -} +// SDataRow tdNewDdataFromSchema(SSchema *pSchema) { +// int32_t bytes = tdMaxRowDataBytes(pSchema); +// return tdNewDataRow(bytes); +// } /** * Free the SDataRow object @@ -45,34 +45,34 @@ void tdFreeDataRow(SDataRow row) { * * @return 0 for success and -1 for failure */ -int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixOffset) { - int32_t offset; - - switch (pCol->type) { - case TD_DATATYPE_BOOL: - case TD_DATATYPE_TINYINT: - case TD_DATATYPE_SMALLINT: - case TD_DATATYPE_INT: - case TD_DATATYPE_BIGINT: - case TD_DATATYPE_FLOAT: - case TD_DATATYPE_DOUBLE: - case TD_DATATYPE_TIMESTAMP: - memcpy(dataRowIdx(row, pCol->offset + sizeof(int32_t)), value, rowDataLen[pCol->type]); - if (dataRowLen(row) < suffixOffset + sizeof(int32_t)) - dataRowSetLen(row, dataRowLen(row) + rowDataLen[pCol->type]); - break; - case TD_DATATYPE_VARCHAR: - offset = dataRowLen(row) > suffixOffset ? dataRowLen(row) : suffixOffset; - memcpy(dataRowIdx(row, pCol->offset+sizeof(int32_t)), (void *)(&offset), sizeof(offset)); - case TD_DATATYPE_NCHAR: - case TD_DATATYPE_BINARY: - break; - default: - return -1; - } - - return 0; -} +// int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixOffset) { +// int32_t offset; + +// switch (pCol->type) { +// case TD_DATATYPE_BOOL: +// case TD_DATATYPE_TINYINT: +// case TD_DATATYPE_SMALLINT: +// case TD_DATATYPE_INT: +// case TD_DATATYPE_BIGINT: +// case TD_DATATYPE_FLOAT: +// case TD_DATATYPE_DOUBLE: +// case TD_DATATYPE_TIMESTAMP: +// memcpy(dataRowIdx(row, pCol->offset + sizeof(int32_t)), value, rowDataLen[pCol->type]); +// if (dataRowLen(row) < suffixOffset + sizeof(int32_t)) +// dataRowSetLen(row, dataRowLen(row) + rowDataLen[pCol->type]); +// break; +// case TD_DATATYPE_VARCHAR: +// offset = dataRowLen(row) > suffixOffset ? dataRowLen(row) : suffixOffset; +// memcpy(dataRowIdx(row, pCol->offset+sizeof(int32_t)), (void *)(&offset), sizeof(offset)); +// case TD_DATATYPE_NCHAR: +// case TD_DATATYPE_BINARY: +// break; +// default: +// return -1; +// } + +// return 0; +// } /** * Copy a data row to a destination diff --git a/src/util/src/ttypes.c b/src/common/src/ttypes.c similarity index 99% rename from src/util/src/ttypes.c rename to src/common/src/ttypes.c index 5fd679dccfc7673133880b6c86b3b630b18e436d..0d4ca30e357b684c1710ba630a61321b27a5d7de 100644 --- a/src/util/src/ttypes.c +++ b/src/common/src/ttypes.c @@ -12,12 +12,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "ttypes.h" #include "os.h" -#include "taos.h" + #include "taosdef.h" #include "ttokendef.h" -#include "tutil.h" +// #include "tutil.h" tDataTypeDescriptor tDataTypeDesc[11] = { {TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE"}, diff --git a/src/inc/taos.h b/src/inc/taos.h index d9db79fbcb74e6935ab052c702b72129cd4cc132..4a815d8ee53cef379454965b38330c356186fdd4 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -29,18 +29,6 @@ typedef void TAOS_SUB; typedef void TAOS_STREAM; typedef void TAOS_STMT; -#define TSDB_DATA_TYPE_NULL 0 -#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes -#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte -#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes -#define TSDB_DATA_TYPE_INT 4 // 4 bytes -#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes -#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes -#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes -#define TSDB_DATA_TYPE_BINARY 8 // string -#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes -#define TSDB_DATA_TYPE_NCHAR 10 // multibyte string - typedef enum { TSDB_OPTION_LOCALE, TSDB_OPTION_CHARSET, diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 7a8cd28428fa0e4ad7a8aa4207c0f728803a09ab..8147f6b9bc25d8d5bd772eeb6641c1149a92b9c6 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -21,7 +21,7 @@ extern "C" { #endif #include -#include "tglobalcfg.h" +#include #define TSDB__packed @@ -31,6 +31,42 @@ extern "C" { #define TSKEY int64_t #endif +// Data type definition +#define TSDB_DATA_TYPE_NULL 0 // 1 bytes +#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes +#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte +#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes +#define TSDB_DATA_TYPE_INT 4 // 4 bytes +#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes +#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes +#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes +#define TSDB_DATA_TYPE_BINARY 8 // string +#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes +#define TSDB_DATA_TYPE_NCHAR 10 // unicode string + +// Bytes for each type. +#define CHAR_BYTES sizeof(char) +#define SHORT_BYTES sizeof(short) +#define INT_BYTES sizeof(int) +#define LONG_BYTES sizeof(int64_t) +#define FLOAT_BYTES sizeof(float) +#define DOUBLE_BYTES sizeof(double) + +// 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 0x80000000 +#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L + +#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_NULL_STR "NULL" +#define TSDB_DATA_NULL_STR_L "null" + #define TSDB_TRUE 1 #define TSDB_FALSE 0 #define TSDB_OK 0 @@ -44,16 +80,6 @@ extern "C" { #define TSDB_TIME_PRECISION_MILLI_STR "ms" #define TSDB_TIME_PRECISION_MICRO_STR "us" -#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes -#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte -#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes -#define TSDB_DATA_TYPE_INT 4 // 4 bytes -#define TSDB_DATA_TYPE_BIGINT 5 // 8 bytes -#define TSDB_DATA_TYPE_FLOAT 6 // 4 bytes -#define TSDB_DATA_TYPE_DOUBLE 7 // 8 bytes -#define TSDB_DATA_TYPE_BINARY 8 // string -#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes -#define TSDB_DATA_TYPE_NCHAR 10 // unicode string #define TSDB_KEYSIZE sizeof(TSKEY) @@ -64,6 +90,48 @@ extern "C" { #endif //#define TSDB_CHAR_TERMINATED_SPACE 1 +#define GET_INT8_VAL(x) (*(int8_t *)(x)) +#define GET_INT16_VAL(x) (*(int16_t *)(x)) +#define GET_INT32_VAL(x) (*(int32_t *)(x)) +#define GET_INT64_VAL(x) (*(int64_t *)(x)) +#ifdef _TD_ARM_32_ + #define GET_FLOAT_VAL(x) taos_align_get_float(x) + #define GET_DOUBLE_VAL(x) taos_align_get_double(x) + + float taos_align_get_float(const char* pBuf); + double taos_align_get_double(const char* pBuf); + + //#define __float_align_declear() float __underlyFloat = 0.0; + //#define __float_align_declear() + //#define GET_FLOAT_VAL_ALIGN(x) (*(int32_t*)&(__underlyFloat) = *(int32_t*)(x); __underlyFloat); + // notes: src must be float or double type variable !!! + #define SET_FLOAT_VAL_ALIGN(dst, src) (*(int32_t*) dst = *(int32_t*)src); + #define SET_DOUBLE_VAL_ALIGN(dst, src) (*(int64_t*) dst = *(int64_t*)src); +#else + #define GET_FLOAT_VAL(x) (*(float *)(x)) + #define GET_DOUBLE_VAL(x) (*(double *)(x)) +#endif + +typedef struct tDataTypeDescriptor { + int16_t nType; + int16_t nameLen; + int32_t nSize; + char * aName; +} tDataTypeDescriptor; + +extern tDataTypeDescriptor tDataTypeDesc[11]; +#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*) + +bool isValidDataType(int32_t type, int32_t length); +bool isNull(const char *val, int32_t type); + +void setNull(char *val, int32_t type, int32_t bytes); +void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems); + +void assignVal(char *val, const char *src, int32_t len, int32_t type); +void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); + +// TODO: check if below is necessary #define TSDB_RELATION_INVALID 0 #define TSDB_RELATION_LESS 1 #define TSDB_RELATION_LARGE 2 diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index a4a589d55ccd77d61e389efddcb4a6f7e80b7302..61fdb424e54435ce7dfa04b71219093d97e89bc7 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -21,7 +21,7 @@ #include "shellCommand.h" #include "ttime.h" #include "tutil.h" -#include "ttypes.h" +#include "taosdef.h" #include "taoserror.h" #include diff --git a/src/query/inc/tast.h b/src/query/inc/tast.h index 3cb483a91b134fe3301533d0360174d250fba578..1e89ffb49dbc0667dd25d7d8b32646a155bcb016 100644 --- a/src/query/inc/tast.h +++ b/src/query/inc/tast.h @@ -23,7 +23,7 @@ extern "C" { #include "os.h" #include "taosmsg.h" -#include "ttypes.h" +#include "taosdef.h" #include "tvariant.h" struct tSQLBinaryExpr; diff --git a/src/query/inc/tsqlfunction.h b/src/query/inc/tsqlfunction.h index dc5f284efab09c0b54e2366e7b11ed055fa14cc4..27bce71300ccf17743eaa50d64a975b624bde5d2 100644 --- a/src/query/inc/tsqlfunction.h +++ b/src/query/inc/tsqlfunction.h @@ -24,7 +24,7 @@ extern "C" { #include #include "trpc.h" -#include "ttypes.h" +#include "taosdef.h" #include "tvariant.h" #define TSDB_FUNC_INVALID_ID -1 diff --git a/src/query/inc/tvariant.h b/src/query/inc/tvariant.h index f54a3a434827aea2e4b0685bb0b4df345d263dae..7ed5aa8dbe1243633e3b256a173dd61f217038fb 100644 --- a/src/query/inc/tvariant.h +++ b/src/query/inc/tvariant.h @@ -16,6 +16,8 @@ #ifndef TDENGINE_TVARIANT_H #define TDENGINE_TVARIANT_H +#include "tstoken.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/src/query/src/textbuffer.c b/src/query/src/textbuffer.c index 8ce090d335ea8105d22d2342de9d9a3e61b4592f..056fe808588e673126081355ca31020f672ab368 100644 --- a/src/query/src/textbuffer.c +++ b/src/query/src/textbuffer.c @@ -19,7 +19,7 @@ #include "tlog.h" #include "tsqlfunction.h" #include "ttime.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" #define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \ diff --git a/src/query/src/tinterpolation.c b/src/query/src/tinterpolation.c index cb7c8854ce914d22680db5429871857ac445f1fe..1a9da44788f5c9bc5a066bd927beaefd0f58ea34 100644 --- a/src/query/src/tinterpolation.c +++ b/src/query/src/tinterpolation.c @@ -18,7 +18,7 @@ #include "textbuffer.h" #include "tinterpolation.h" #include "tsqlfunction.h" -#include "ttypes.h" +#include "taosdef.h" #define INTERPOL_IS_ASC_INTERPOL(interp) ((interp)->order == TSQL_SO_ASC) diff --git a/src/query/src/tpercentile.c b/src/query/src/tpercentile.c index a5c074839cf540da206d987daaab248e1b911e7c..6e1c28c516ce08e233b7c9afa418e571bd94e051 100644 --- a/src/query/src/tpercentile.c +++ b/src/query/src/tpercentile.c @@ -18,7 +18,7 @@ #include "taosmsg.h" #include "taosdef.h" #include "tlog.h" -#include "ttypes.h" +#include "taosdef.h" #include "tpercentile.h" tExtMemBuffer *releaseBucketsExceptFor(tMemBucket *pMemBucket, int16_t segIdx, int16_t slotIdx) { diff --git a/src/query/src/tscAst.c b/src/query/src/tscAst.c index 70fda9bd9360a1d9715fac5b904a72078610762e..7be583a5ea1c59bae4065185e39e22b2d0d75dd1 100644 --- a/src/query/src/tscAst.c +++ b/src/query/src/tscAst.c @@ -24,7 +24,7 @@ #include "tsqlfunction.h" #include "tstoken.h" #include "ttokendef.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" #include "qsqlparser.h" diff --git a/src/query/src/tscSQLParserImpl.c b/src/query/src/tscSQLParserImpl.c index 0a76b867f29780a7af3f381237c28ced03d9354d..e4067d470fc93617f93623aafc7a59138090d7c0 100644 --- a/src/query/src/tscSQLParserImpl.c +++ b/src/query/src/tscSQLParserImpl.c @@ -22,7 +22,7 @@ #include "tstoken.h" #include "ttime.h" #include "ttokendef.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) { diff --git a/src/query/src/tscSyntaxtreefunction.c b/src/query/src/tscSyntaxtreefunction.c index 3fe43d9c1ef35e9f073c67b72047ef932d256c11..e3c00ed59d1da9ee6e042f748a6bf6f586f8bd2f 100644 --- a/src/query/src/tscSyntaxtreefunction.c +++ b/src/query/src/tscSyntaxtreefunction.c @@ -16,7 +16,7 @@ #include "os.h" #include "tscSyntaxtreefunction.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" #define ARRAY_LIST_OP(left, right, _left_type, _right_type, len1, len2, out, op, _res_type, _ord) \ diff --git a/src/query/src/ttokenizer.c b/src/query/src/ttokenizer.c index c53debcb455d05cf8852769e4cac5f0e7be30ebb..f43d344ca3aeb82b45c15d6eea399f22c12392c1 100644 --- a/src/query/src/ttokenizer.c +++ b/src/query/src/ttokenizer.c @@ -19,7 +19,7 @@ #include "shash.h" #include "tstoken.h" #include "ttokendef.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" // All the keywords of the SQL language are stored in a hash table diff --git a/src/query/src/tvariant.c b/src/query/src/tvariant.c index 8c8887ca2ec7da2c956a2ec883a147d61bf4db71..c9168ab252bd39f58ddcf0e09f676ff585c27c56 100644 --- a/src/query/src/tvariant.c +++ b/src/query/src/tvariant.c @@ -19,10 +19,10 @@ #include "shash.h" #include "tstoken.h" #include "ttokendef.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" #include "tvariant.h" -#include "ttypes.h" +#include "taosdef.h" #include "taos.h" // todo support scientific expression number and oct number diff --git a/src/thirdparty/CMakeLists.txt b/src/thirdparty/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9958e1e28c0a963a18021a0e449e389583bc5698 --- /dev/null +++ b/src/thirdparty/CMakeLists.txt @@ -0,0 +1,4 @@ +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) + +add_library(thirdparty ${SOURCE_LIST}) +target_include_directories(thirdparty PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) \ No newline at end of file diff --git a/src/util/inc/lz4.h b/src/thirdparty/inc/lz4.h similarity index 100% rename from src/util/inc/lz4.h rename to src/thirdparty/inc/lz4.h diff --git a/src/util/src/lz4.c b/src/thirdparty/src/lz4.c similarity index 100% rename from src/util/src/lz4.c rename to src/thirdparty/src/lz4.c diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 9cca2f2db11f0cb01ff036257aaf9dc8b372a3bb..67ecf39f1b2a0564e8f2bcdc0cb39360652a3965 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -8,7 +8,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM)) AUX_SOURCE_DIRECTORY(src SRC) ADD_LIBRARY(tutil ${SRC}) - TARGET_LINK_LIBRARIES(tutil pthread os m rt) + TARGET_LINK_LIBRARIES(tutil thirdparty pthread os m rt) IF (TD_CLUSTER) ADD_DEFINITIONS(-DUSE_LIBICONV) TARGET_LINK_LIBRARIES(tutil iconv) @@ -68,7 +68,7 @@ ELSEIF (TD_WINDOWS_64) LIST(APPEND SRC ./src/tutil.c) LIST(APPEND SRC ./src/version.c) ADD_LIBRARY(tutil ${SRC}) - TARGET_LINK_LIBRARIES(tutil iconv regex pthread os winmm IPHLPAPI ws2_32) + TARGET_LINK_LIBRARIES(tutil thirdparty iconv regex pthread os winmm IPHLPAPI ws2_32) ELSEIF(TD_DARWIN_64) ADD_DEFINITIONS(-DUSE_LIBICONV) LIST(APPEND SRC ./src/hash.c) @@ -105,7 +105,7 @@ ELSEIF(TD_DARWIN_64) LIST(APPEND SRC ./src/version.c) LIST(APPEND SRC ./src/hash.c) ADD_LIBRARY(tutil ${SRC}) - TARGET_LINK_LIBRARIES(tutil iconv pthread os) + TARGET_LINK_LIBRARIES(tutil thirdparty iconv pthread os) ENDIF() #IF (TD_CLUSTER) diff --git a/src/util/inc/sskiplist.h b/src/util/inc/sskiplist.h index 2f300fa4ea0765ae81e06d560172dbec2c672a16..f2ae2efc54342a1aa0fd1298b8868132d65e246d 100644 --- a/src/util/inc/sskiplist.h +++ b/src/util/inc/sskiplist.h @@ -28,7 +28,7 @@ extern "C" { #include #include "os.h" -#include "ttypes.h" +#include "taosdef.h" /* * key of each node diff --git a/src/util/inc/tskiplist.h b/src/util/inc/tskiplist.h index ecdbc38a0573678303f834545c9677ef9e7e1b4e..2ebb9bf5f2cd48f67f4c044a2764d0b3ff449c40 100644 --- a/src/util/inc/tskiplist.h +++ b/src/util/inc/tskiplist.h @@ -21,7 +21,7 @@ extern "C" { #endif #include "os.h" -#include "ttypes.h" +#include "taosdef.h" #include "tarray.h" /* diff --git a/src/util/inc/ttypes.h b/src/util/inc/ttypes.h deleted file mode 100644 index a099f3fa7cf14e7321b3dcfef4dec2a1c4efe74a..0000000000000000000000000000000000000000 --- a/src/util/inc/ttypes.h +++ /dev/null @@ -1,74 +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 TDENGINE_TTYPES_H -#define TDENGINE_TTYPES_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include "tstoken.h" - -// Bytes for each type. -#define CHAR_BYTES sizeof(char) -#define SHORT_BYTES sizeof(short) -#define INT_BYTES sizeof(int) -#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_DATA_BOOL_NULL 0x02 -#define TSDB_DATA_TINYINT_NULL 0x80 -#define TSDB_DATA_SMALLINT_NULL 0x8000 -#define TSDB_DATA_INT_NULL 0x80000000 -#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L - -#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_NULL_STR "NULL" -#define TSDB_DATA_NULL_STR_L "null" - -typedef struct tDataTypeDescriptor { - int16_t nType; - int16_t nameLen; - int32_t nSize; - char * aName; -} tDataTypeDescriptor; - -extern tDataTypeDescriptor tDataTypeDesc[11]; - -bool isValidDataType(int32_t type, int32_t length); -bool isNull(const char *val, int32_t type); - -void setNull(char *val, int32_t type, int32_t bytes); -void setNullN(char *val, int32_t type, int32_t bytes, int32_t numOfElems); - -void assignVal(char *val, const char *src, int32_t len, int32_t type); -void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size); - -#ifdef __cplusplus -} -#endif - -#endif // TDENGINE_TTYPES_H diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index 04b2b32f69eec01dde55e4631c4998bf4be83c11..cb311ed19361bad442e312732d8e499893e1556e 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -93,29 +93,6 @@ extern "C" { } \ } while (0) -#define GET_INT8_VAL(x) (*(int8_t *)(x)) -#define GET_INT16_VAL(x) (*(int16_t *)(x)) -#define GET_INT32_VAL(x) (*(int32_t *)(x)) -#define GET_INT64_VAL(x) (*(int64_t *)(x)) - -#ifdef _TD_ARM_32_ - #define GET_FLOAT_VAL(x) taos_align_get_float(x) - #define GET_DOUBLE_VAL(x) taos_align_get_double(x) - - float taos_align_get_float(const char* pBuf); - double taos_align_get_double(const char* pBuf); - - //#define __float_align_declear() float __underlyFloat = 0.0; - //#define __float_align_declear() - //#define GET_FLOAT_VAL_ALIGN(x) (*(int32_t*)&(__underlyFloat) = *(int32_t*)(x); __underlyFloat); - // notes: src must be float or double type variable !!! - #define SET_FLOAT_VAL_ALIGN(dst, src) (*(int32_t*) dst = *(int32_t*)src); - #define SET_DOUBLE_VAL_ALIGN(dst, src) (*(int64_t*) dst = *(int64_t*)src); -#else - #define GET_FLOAT_VAL(x) (*(float *)(x)) - #define GET_DOUBLE_VAL(x) (*(double *)(x)) -#endif - #define ALIGN_NUM(n, align) (((n) + ((align)-1)) & (~((align)-1))) // align to 8bytes diff --git a/src/util/src/tcompression.c b/src/util/src/tcompression.c index 1592a47c1597c53336d46d65e946b1a400b447f0..24a53b3fe49a555cf24c605cda4e7c4041086ce8 100644 --- a/src/util/src/tcompression.c +++ b/src/util/src/tcompression.c @@ -51,7 +51,6 @@ #include "lz4.h" #include "tscompression.h" #include "taosdef.h" -#include "ttypes.h" const int TEST_NUMBER = 1; #define is_bigendian() ((*(char *)&TEST_NUMBER) == 0) diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index efe1defa57dfdf447b265e7e9f83383f6f54bd2a..d5e67adff693b427633908b39e862e1993812c5f 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -22,7 +22,7 @@ #include "tcrc32c.h" #include "tglobalcfg.h" #include "ttime.h" -#include "ttypes.h" +#include "taosdef.h" #include "tutil.h" #include "tlog.h" #include "taoserror.h" diff --git a/src/vnode/CMakeLists.txt b/src/vnode/CMakeLists.txt index 8549fa478c2ce26080f544d80f5ebc4353222c0b..4631c4046b80780083fb91535e6405a93eb00011 100644 --- a/src/vnode/CMakeLists.txt +++ b/src/vnode/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) PROJECT(TDengine) -ADD_SUBDIRECTORY(common) +# ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(tsdb) # ENABLE_TESTING() # ADD_SUBDIRECTORY(tests)