adjust code
This commit is contained in:
parent
ec55211264
commit
722abe2f43
|
@ -6,8 +6,7 @@ ADD_SUBDIRECTORY(os)
|
||||||
ADD_SUBDIRECTORY(thirdparty)
|
ADD_SUBDIRECTORY(thirdparty)
|
||||||
|
|
||||||
ADD_SUBDIRECTORY(common)
|
ADD_SUBDIRECTORY(common)
|
||||||
|
ADD_SUBDIRECTORY(util)
|
||||||
# ADD_SUBDIRECTORY(util)
|
|
||||||
# ADD_SUBDIRECTORY(rpc)
|
# ADD_SUBDIRECTORY(rpc)
|
||||||
# ADD_SUBDIRECTORY(client)
|
# ADD_SUBDIRECTORY(client)
|
||||||
# ADD_SUBDIRECTORY(kit)
|
# ADD_SUBDIRECTORY(kit)
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST)
|
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST)
|
||||||
|
|
||||||
add_library(common ${SOURCE_LIST})
|
add_library(common ${SOURCE_LIST})
|
||||||
target_include_directories(common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc)
|
target_include_directories(
|
||||||
|
common
|
||||||
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc
|
||||||
|
PUBLIC ${CMAKE_SOURCE_DIR}/src/inc
|
||||||
|
PUBLIC ${CMAKE_SOURCE_DIR}/src/os/linux/inc
|
||||||
|
)
|
|
@ -12,12 +12,11 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "ttypes.h"
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taos.h"
|
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "ttokendef.h"
|
#include "ttokendef.h"
|
||||||
#include "tutil.h"
|
// #include "tutil.h"
|
||||||
|
|
||||||
tDataTypeDescriptor tDataTypeDesc[11] = {
|
tDataTypeDescriptor tDataTypeDesc[11] = {
|
||||||
{TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE"},
|
{TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE"},
|
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "tglobalcfg.h"
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define TSDB__packed
|
#define TSDB__packed
|
||||||
|
|
||||||
|
@ -31,6 +31,42 @@ extern "C" {
|
||||||
#define TSKEY int64_t
|
#define TSKEY int64_t
|
||||||
#endif
|
#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_TRUE 1
|
||||||
#define TSDB_FALSE 0
|
#define TSDB_FALSE 0
|
||||||
#define TSDB_OK 0
|
#define TSDB_OK 0
|
||||||
|
@ -44,16 +80,6 @@ extern "C" {
|
||||||
#define TSDB_TIME_PRECISION_MILLI_STR "ms"
|
#define TSDB_TIME_PRECISION_MILLI_STR "ms"
|
||||||
#define TSDB_TIME_PRECISION_MICRO_STR "us"
|
#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)
|
#define TSDB_KEYSIZE sizeof(TSKEY)
|
||||||
|
|
||||||
|
@ -64,6 +90,48 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
//#define TSDB_CHAR_TERMINATED_SPACE 1
|
//#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_INVALID 0
|
||||||
#define TSDB_RELATION_LESS 1
|
#define TSDB_RELATION_LESS 1
|
||||||
#define TSDB_RELATION_LARGE 2
|
#define TSDB_RELATION_LARGE 2
|
||||||
|
|
|
@ -8,7 +8,7 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc)
|
||||||
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
|
||||||
AUX_SOURCE_DIRECTORY(src SRC)
|
AUX_SOURCE_DIRECTORY(src SRC)
|
||||||
ADD_LIBRARY(tutil ${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)
|
IF (TD_CLUSTER)
|
||||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||||
TARGET_LINK_LIBRARIES(tutil iconv)
|
TARGET_LINK_LIBRARIES(tutil iconv)
|
||||||
|
@ -68,7 +68,7 @@ ELSEIF (TD_WINDOWS_64)
|
||||||
LIST(APPEND SRC ./src/tutil.c)
|
LIST(APPEND SRC ./src/tutil.c)
|
||||||
LIST(APPEND SRC ./src/version.c)
|
LIST(APPEND SRC ./src/version.c)
|
||||||
ADD_LIBRARY(tutil ${SRC})
|
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)
|
ELSEIF(TD_DARWIN_64)
|
||||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||||
LIST(APPEND SRC ./src/hash.c)
|
LIST(APPEND SRC ./src/hash.c)
|
||||||
|
@ -105,7 +105,7 @@ ELSEIF(TD_DARWIN_64)
|
||||||
LIST(APPEND SRC ./src/version.c)
|
LIST(APPEND SRC ./src/version.c)
|
||||||
LIST(APPEND SRC ./src/hash.c)
|
LIST(APPEND SRC ./src/hash.c)
|
||||||
ADD_LIBRARY(tutil ${SRC})
|
ADD_LIBRARY(tutil ${SRC})
|
||||||
TARGET_LINK_LIBRARIES(tutil iconv pthread os)
|
TARGET_LINK_LIBRARIES(tutil thirdparty iconv pthread os)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
#IF (TD_CLUSTER)
|
#IF (TD_CLUSTER)
|
||||||
|
|
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "ttypes.h"
|
#include "taosdef.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TDENGINE_TTYPES_H
|
|
||||||
#define TDENGINE_TTYPES_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#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
|
|
|
@ -93,29 +93,6 @@ extern "C" {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} 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)))
|
#define ALIGN_NUM(n, align) (((n) + ((align)-1)) & (~((align)-1)))
|
||||||
|
|
||||||
// align to 8bytes
|
// align to 8bytes
|
||||||
|
|
|
@ -51,7 +51,6 @@
|
||||||
#include "lz4.h"
|
#include "lz4.h"
|
||||||
#include "tscompression.h"
|
#include "tscompression.h"
|
||||||
#include "taosdef.h"
|
#include "taosdef.h"
|
||||||
#include "ttypes.h"
|
|
||||||
|
|
||||||
const int TEST_NUMBER = 1;
|
const int TEST_NUMBER = 1;
|
||||||
#define is_bigendian() ((*(char *)&TEST_NUMBER) == 0)
|
#define is_bigendian() ((*(char *)&TEST_NUMBER) == 0)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "tcrc32c.h"
|
#include "tcrc32c.h"
|
||||||
#include "tglobalcfg.h"
|
#include "tglobalcfg.h"
|
||||||
#include "ttime.h"
|
#include "ttime.h"
|
||||||
#include "ttypes.h"
|
#include "taosdef.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
|
Loading…
Reference in New Issue