Skip to content

Commit

Permalink
feat: support geometry (not include schemaless)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiShunGang committed Sep 15, 2023
1 parent 3f8a5dd commit fb60784
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ static int generateRandDataSQL(SSuperTable *stbInfo, char *sampleDataBuf,
break;
}
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: {
case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_GEOMETRY: {
char *tmp = benchCalloc(1, field->length + 1, false);
if (0 != tmpStr(tmp, stbInfo->iface, field, i)) {
free(tmp);
Expand Down
8 changes: 5 additions & 3 deletions src/benchInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ static int createSuperTable(SDataBase* database, SSuperTable* stbInfo) {
Field * col = benchArrayGet(stbInfo->cols, colIndex);
int n;
if (col->type == TSDB_DATA_TYPE_BINARY ||
col->type == TSDB_DATA_TYPE_NCHAR) {
col->type == TSDB_DATA_TYPE_NCHAR ||
col->type == TSDB_DATA_TYPE_GEOMETRY) {
n = snprintf(colsBuf + len, col_buffer_len - len,
",%s %s(%d)", col->name,
convertDatatypeToString(col->type), col->length);
Expand Down Expand Up @@ -282,7 +283,8 @@ static int createSuperTable(SDataBase* database, SSuperTable* stbInfo) {
for (tagIndex = 0; tagIndex < stbInfo->tags->size; tagIndex++) {
Field *tag = benchArrayGet(stbInfo->tags, tagIndex);
if (tag->type == TSDB_DATA_TYPE_BINARY ||
tag->type == TSDB_DATA_TYPE_NCHAR) {
tag->type == TSDB_DATA_TYPE_NCHAR ||
tag->type == TSDB_DATA_TYPE_GEOMETRY) {
n = snprintf(tagsBuf + len, tag_buffer_len - len,
"%s %s(%d),", tag->name,
convertDatatypeToString(tag->type), tag->length);
Expand Down Expand Up @@ -1738,7 +1740,7 @@ static void *syncWriteInterlace(void *sarg) {
infoPrint(
"thread[%d] has currently inserted rows: %" PRIu64
", peroid insert rate: %.3f rows/s \n",
pThreadInfo->threadID, pThreadInfo->totalInsertRows,
pThreadInfo->threadID, pThreadInfo->totalInsertRows,
(double)(pThreadInfo->totalInsertRows - lastTotalInsertRows) * 1000.0/(currentPrintTime - lastPrintTime));
lastPrintTime = currentPrintTime;
lastTotalInsertRows = pThreadInfo->totalInsertRows;
Expand Down
5 changes: 3 additions & 2 deletions src/benchJsonOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ static int getColumnAndTagTypeFromInsertJsonFile(
} else {
if (type == TSDB_DATA_TYPE_BINARY
|| type == TSDB_DATA_TYPE_JSON
|| type == TSDB_DATA_TYPE_NCHAR) {
|| type == TSDB_DATA_TYPE_NCHAR
|| type == TSDB_DATA_TYPE_GEOMETRY) {
length = g_arguments->binwidth;
} else {
length = convertTypeToLength(type);
Expand Down Expand Up @@ -1748,7 +1749,7 @@ static int getMetaFromTmqJsonFile(tools_cJSON *json) {
if (tools_cJSON_IsString(groupMode)) {
g_tmqInfo.consumerInfo.groupMode = groupMode->valuestring;
}


tools_cJSON *pollDelay = tools_cJSON_GetObjectItem(tmqInfo, "poll_delay");
if (tools_cJSON_IsNumber(pollDelay)) {
Expand Down
10 changes: 8 additions & 2 deletions src/benchUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void closeBenchConn(SBenchConn* conn) {
if(conn->taos) {
taos_close(conn->taos);
conn->taos = NULL;
}
}
if (conn->ctaos) {
taos_close(conn->ctaos);
conn->ctaos = NULL;
Expand Down Expand Up @@ -833,6 +833,8 @@ char *convertDatatypeToString(int type) {
return "double";
case TSDB_DATA_TYPE_JSON:
return "json";
case TSDB_DATA_TYPE_GEOMETRY:
return "geometry";
default:
break;
}
Expand Down Expand Up @@ -965,6 +967,8 @@ int convertStringToDatatype(char *type, int length) {
return TSDB_DATA_TYPE_JSON;
} else if (0 == strcasecmp(type, "varchar")) {
return TSDB_DATA_TYPE_BINARY;
} else if (0 == strcasecmp(type, "geometry")) {
return TSDB_DATA_TYPE_GEOMETRY;
} else {
errorPrint("unknown data type: %s\n", type);
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -1002,6 +1006,8 @@ int convertStringToDatatype(char *type, int length) {
return TSDB_DATA_TYPE_JSON;
} else if (0 == strncasecmp(type, "varchar", length)) {
return TSDB_DATA_TYPE_BINARY;
} else if (0 == strcasecmp(type, "geometry")) {
return TSDB_DATA_TYPE_GEOMETRY;
} else {
errorPrint("unknown data type: %s\n", type);
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -1184,7 +1190,7 @@ void destroySockFd(int sockfd) {
if (sockfd < 0) {
return;
}

// shutdown the connection since no more data will be sent
int result;
result = shutdown(sockfd, SHUT_WR);
Expand Down

0 comments on commit fb60784

Please sign in to comment.