[TD-6442]<feature>: Support OpenTSDB telnet style data import format
This commit is contained in:
parent
ea7ca9b241
commit
9c1813dca7
|
@ -53,13 +53,11 @@ typedef struct {
|
||||||
} SSmlLinesInfo;
|
} SSmlLinesInfo;
|
||||||
|
|
||||||
int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLinesInfo* info);
|
int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLinesInfo* info);
|
||||||
int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint);
|
|
||||||
bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info);
|
bool checkDuplicateKey(char *key, SHashObj *pHash, SSmlLinesInfo* info);
|
||||||
int32_t isValidChildTableName(const char *pTbName, int16_t len);
|
int32_t isValidChildTableName(const char *pTbName, int16_t len);
|
||||||
|
|
||||||
bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
bool convertSmlValueType(TAOS_SML_KV *pVal, char *value,
|
||||||
uint16_t len, SSmlLinesInfo* info);
|
uint16_t len, SSmlLinesInfo* info);
|
||||||
|
|
||||||
int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
|
int32_t convertSmlTimeStamp(TAOS_SML_KV *pVal, char *value,
|
||||||
uint16_t len, SSmlLinesInfo* info);
|
uint16_t len, SSmlLinesInfo* info);
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
#include "tscLog.h"
|
#include "tscLog.h"
|
||||||
|
|
||||||
#include "tscParseLine.h"
|
#include "tscParseLine.h"
|
||||||
//=========================================================================
|
|
||||||
// telnet style API parser
|
/* telnet style API parser */
|
||||||
static uint64_t HandleId = 0;
|
static uint64_t HandleId = 0;
|
||||||
|
|
||||||
uint64_t genUID() {
|
uint64_t genUID() {
|
||||||
|
@ -221,6 +221,7 @@ static bool parseTelnetTagValue(TAOS_SML_KV *pKV, const char **index,
|
||||||
}
|
}
|
||||||
free(value);
|
free(value);
|
||||||
|
|
||||||
|
*index = (*cur == '\0') ? cur : cur + 1;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,19 +267,16 @@ static int32_t parseTelnetTagKvs(TAOS_SML_KV **pKVs, int *num_kvs,
|
||||||
}
|
}
|
||||||
|
|
||||||
//reallocate addtional memory for more kvs
|
//reallocate addtional memory for more kvs
|
||||||
TAOS_SML_KV *more_kvs = NULL;
|
|
||||||
|
|
||||||
if ((*num_kvs + 1) > capacity) {
|
if ((*num_kvs + 1) > capacity) {
|
||||||
|
TAOS_SML_KV *more_kvs = NULL;
|
||||||
capacity *= 3; capacity /= 2;
|
capacity *= 3; capacity /= 2;
|
||||||
more_kvs = realloc(*pKVs, capacity * sizeof(TAOS_SML_KV));
|
more_kvs = realloc(*pKVs, capacity * sizeof(TAOS_SML_KV));
|
||||||
} else {
|
|
||||||
more_kvs = *pKVs;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!more_kvs) {
|
if (!more_kvs) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
*pKVs = more_kvs;
|
*pKVs = more_kvs;
|
||||||
|
}
|
||||||
|
|
||||||
//move pKV points to next TAOS_SML_KV block
|
//move pKV points to next TAOS_SML_KV block
|
||||||
pkv = *pKVs + *num_kvs;
|
pkv = *pKVs + *num_kvs;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +314,7 @@ int32_t tscParseTelnetLine(const char* line, TAOS_SML_DATA_POINT* smlData, SSmlL
|
||||||
|
|
||||||
//Parse tagKVs
|
//Parse tagKVs
|
||||||
SHashObj *keyHashTable = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
|
SHashObj *keyHashTable = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, false);
|
||||||
ret = parseTelnetTagKvs(&smlData->fields, &smlData->fieldNum, &index, smlData->childTableName, keyHashTable, info);
|
ret = parseTelnetTagKvs(&smlData->tags, &smlData->tagNum, &index, smlData->childTableName, keyHashTable, info);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tscError("SML:0x%"PRIx64" Unable to parse tags", info->id);
|
tscError("SML:0x%"PRIx64" Unable to parse tags", info->id);
|
||||||
taosHashCleanup(keyHashTable);
|
taosHashCleanup(keyHashTable);
|
||||||
|
@ -401,3 +399,11 @@ cleanup:
|
||||||
free(info);
|
free(info);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int taos_telnet_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
|
||||||
|
SSmlLinesInfo* info = calloc(1, sizeof(SSmlLinesInfo));
|
||||||
|
info->id = genUID();
|
||||||
|
int code = tscSmlInsert(taos, points, numPoint, info);
|
||||||
|
free(info);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
|
@ -172,6 +172,8 @@ DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList);
|
||||||
|
|
||||||
DLL_EXPORT int taos_insert_lines(TAOS* taos, char* lines[], int numLines);
|
DLL_EXPORT int taos_insert_lines(TAOS* taos, char* lines[], int numLines);
|
||||||
|
|
||||||
|
DLL_EXPORT int taos_insert_telnet_lines(TAOS* taos, char* lines[], int numLines);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,6 +11,8 @@ IF (TD_LINUX)
|
||||||
TARGET_LINK_LIBRARIES(subscribe taos_static trpc tutil pthread )
|
TARGET_LINK_LIBRARIES(subscribe taos_static trpc tutil pthread )
|
||||||
ADD_EXECUTABLE(epoll epoll.c)
|
ADD_EXECUTABLE(epoll epoll.c)
|
||||||
TARGET_LINK_LIBRARIES(epoll taos_static trpc tutil pthread lua)
|
TARGET_LINK_LIBRARIES(epoll taos_static trpc tutil pthread lua)
|
||||||
|
ADD_EXECUTABLE(opentsdb opentsdb.c)
|
||||||
|
TARGET_LINK_LIBRARIES(opentsdb taos_static trpc tutil pthread lua)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
IF (TD_DARWIN)
|
IF (TD_DARWIN)
|
||||||
INCLUDE_DIRECTORIES(. ${TD_COMMUNITY_DIR}/src/inc ${TD_COMMUNITY_DIR}/src/client/inc ${TD_COMMUNITY_DIR}/inc)
|
INCLUDE_DIRECTORIES(. ${TD_COMMUNITY_DIR}/src/inc ${TD_COMMUNITY_DIR}/src/client/inc ${TD_COMMUNITY_DIR}/inc)
|
||||||
|
|
Loading…
Reference in New Issue