提交 ec552112 编写于 作者: H hzcheng

add a common directory

上级 54a84475
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)
......
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)
\ No newline at end of file
......@@ -17,8 +17,9 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#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);
......
......@@ -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
......
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册