add a common directory
This commit is contained in:
parent
54a84475f1
commit
ec55211264
|
@ -1,8 +1,12 @@
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
PROJECT(TDengine)
|
PROJECT(TDengine)
|
||||||
|
|
||||||
|
# Base compile
|
||||||
ADD_SUBDIRECTORY(os)
|
ADD_SUBDIRECTORY(os)
|
||||||
ADD_SUBDIRECTORY(thirdparty)
|
ADD_SUBDIRECTORY(thirdparty)
|
||||||
|
|
||||||
|
ADD_SUBDIRECTORY(common)
|
||||||
|
|
||||||
# ADD_SUBDIRECTORY(util)
|
# ADD_SUBDIRECTORY(util)
|
||||||
# ADD_SUBDIRECTORY(rpc)
|
# ADD_SUBDIRECTORY(rpc)
|
||||||
# ADD_SUBDIRECTORY(client)
|
# ADD_SUBDIRECTORY(client)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
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)
|
|
@ -17,8 +17,9 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "schema.h"
|
// #include "schema.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -43,9 +44,9 @@ typedef void *SDataRow;
|
||||||
#define dataRowCpy(dst, r) memcpy((dst), (r), dataRowLen(r))
|
#define dataRowCpy(dst, r) memcpy((dst), (r), dataRowLen(r))
|
||||||
|
|
||||||
SDataRow tdNewDataRow(int32_t bytes);
|
SDataRow tdNewDataRow(int32_t bytes);
|
||||||
SDataRow tdNewDdataFromSchema(SSchema *pSchema);
|
// SDataRow tdNewDdataFromSchema(SSchema *pSchema);
|
||||||
void tdFreeDataRow(SDataRow row);
|
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 tdDataRowCpy(void *dst, SDataRow row);
|
||||||
void tdDataRowReset(SDataRow row);
|
void tdDataRowReset(SDataRow row);
|
||||||
SDataRow tdDataRowDup(SDataRow row);
|
SDataRow tdDataRowDup(SDataRow row);
|
|
@ -21,10 +21,10 @@ SDataRow tdNewDataRow(int32_t bytes) {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDataRow tdNewDdataFromSchema(SSchema *pSchema) {
|
// SDataRow tdNewDdataFromSchema(SSchema *pSchema) {
|
||||||
int32_t bytes = tdMaxRowDataBytes(pSchema);
|
// int32_t bytes = tdMaxRowDataBytes(pSchema);
|
||||||
return tdNewDataRow(bytes);
|
// return tdNewDataRow(bytes);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the SDataRow object
|
* Free the SDataRow object
|
||||||
|
@ -45,34 +45,34 @@ void tdFreeDataRow(SDataRow row) {
|
||||||
*
|
*
|
||||||
* @return 0 for success and -1 for failure
|
* @return 0 for success and -1 for failure
|
||||||
*/
|
*/
|
||||||
int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixOffset) {
|
// int32_t tdAppendColVal(SDataRow row, void *value, SColumn *pCol, int32_t suffixOffset) {
|
||||||
int32_t offset;
|
// int32_t offset;
|
||||||
|
|
||||||
switch (pCol->type) {
|
// switch (pCol->type) {
|
||||||
case TD_DATATYPE_BOOL:
|
// case TD_DATATYPE_BOOL:
|
||||||
case TD_DATATYPE_TINYINT:
|
// case TD_DATATYPE_TINYINT:
|
||||||
case TD_DATATYPE_SMALLINT:
|
// case TD_DATATYPE_SMALLINT:
|
||||||
case TD_DATATYPE_INT:
|
// case TD_DATATYPE_INT:
|
||||||
case TD_DATATYPE_BIGINT:
|
// case TD_DATATYPE_BIGINT:
|
||||||
case TD_DATATYPE_FLOAT:
|
// case TD_DATATYPE_FLOAT:
|
||||||
case TD_DATATYPE_DOUBLE:
|
// case TD_DATATYPE_DOUBLE:
|
||||||
case TD_DATATYPE_TIMESTAMP:
|
// case TD_DATATYPE_TIMESTAMP:
|
||||||
memcpy(dataRowIdx(row, pCol->offset + sizeof(int32_t)), value, rowDataLen[pCol->type]);
|
// memcpy(dataRowIdx(row, pCol->offset + sizeof(int32_t)), value, rowDataLen[pCol->type]);
|
||||||
if (dataRowLen(row) < suffixOffset + sizeof(int32_t))
|
// if (dataRowLen(row) < suffixOffset + sizeof(int32_t))
|
||||||
dataRowSetLen(row, dataRowLen(row) + rowDataLen[pCol->type]);
|
// dataRowSetLen(row, dataRowLen(row) + rowDataLen[pCol->type]);
|
||||||
break;
|
// break;
|
||||||
case TD_DATATYPE_VARCHAR:
|
// case TD_DATATYPE_VARCHAR:
|
||||||
offset = dataRowLen(row) > suffixOffset ? dataRowLen(row) : suffixOffset;
|
// offset = dataRowLen(row) > suffixOffset ? dataRowLen(row) : suffixOffset;
|
||||||
memcpy(dataRowIdx(row, pCol->offset+sizeof(int32_t)), (void *)(&offset), sizeof(offset));
|
// memcpy(dataRowIdx(row, pCol->offset+sizeof(int32_t)), (void *)(&offset), sizeof(offset));
|
||||||
case TD_DATATYPE_NCHAR:
|
// case TD_DATATYPE_NCHAR:
|
||||||
case TD_DATATYPE_BINARY:
|
// case TD_DATATYPE_BINARY:
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
return -1;
|
// return -1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a data row to a destination
|
* Copy a data row to a destination
|
|
@ -29,18 +29,6 @@ typedef void TAOS_SUB;
|
||||||
typedef void TAOS_STREAM;
|
typedef void TAOS_STREAM;
|
||||||
typedef void TAOS_STMT;
|
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 {
|
typedef enum {
|
||||||
TSDB_OPTION_LOCALE,
|
TSDB_OPTION_LOCALE,
|
||||||
TSDB_OPTION_CHARSET,
|
TSDB_OPTION_CHARSET,
|
||||||
|
|
Loading…
Reference in New Issue