Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: init csv module #743

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
958b2bb
feat: init csv moudle
DuanKuanJun May 21, 2024
14d2d68
fix: read json file error
DuanKuanJun May 21, 2024
bb8eea8
fix: timestamp now with toolsFormatTimestamp replace
DuanKuanJun May 21, 2024
feac5b1
fix: add source benchCsv.c
DuanKuanJun May 21, 2024
589991f
feat : basic function finished
DuanKuanJun May 21, 2024
28a3ddc
fix: test passed version
DuanKuanJun May 21, 2024
1437945
fix: add batch size
DuanKuanJun May 21, 2024
d4b9557
feat: add progress tips
DuanKuanJun May 21, 2024
a176e1f
feat: add progress tips
DuanKuanJun May 21, 2024
3faa6b1
fix: move addbatch to exec
DuanKuanJun May 22, 2024
221fb7b
fix: build error
DuanKuanJun May 22, 2024
4f2bc5f
fix: output path
DuanKuanJun May 22, 2024
44137d8
fix: replace null with blank
DuanKuanJun May 22, 2024
9bf9d78
fix: build error
DuanKuanJun May 22, 2024
d792756
fix: build error
DuanKuanJun May 22, 2024
864ccef
fix: build error for nowts
DuanKuanJun May 25, 2024
166b32a
fix: case passed
DuanKuanJun May 25, 2024
50a1074
feat: add newtype varbinary
DuanKuanJun May 25, 2024
34f700e
fix: build error
DuanKuanJun May 25, 2024
9bb1cf5
feat: support thread bind vgroup
DuanKuanJun May 27, 2024
28ad4c5
feat: add bind vgroup new function
DuanKuanJun May 27, 2024
d290350
Merge branch 'feat/TD-30092' into feat/TD-30077
DuanKuanJun May 28, 2024
f3ee2a1
feat: create table add speed
DuanKuanJun May 29, 2024
b105aa3
feat: create table add speed
DuanKuanJun May 29, 2024
dc8f52e
fix: with limit thread frame build ok
DuanKuanJun May 31, 2024
24dbb78
fix: limit thread is finish
DuanKuanJun May 31, 2024
8c7dee2
fix: remove old auto_thread variant
DuanKuanJun Jun 1, 2024
64e57a7
fix: ci case pass
DuanKuanJun Jun 1, 2024
4f8ef78
fix: modify check methon
DuanKuanJun Jun 1, 2024
1398ccc
fix: case error for commandline.py
DuanKuanJun Jun 1, 2024
4eb2937
fix: zero div
DuanKuanJun Jun 1, 2024
16f0cdb
fix: window build add benchCsv.c
DuanKuanJun Jun 1, 2024
c0d63d9
fix: ci case default_json.py
DuanKuanJun Jun 1, 2024
91f1286
fix: from and to argument valid
DuanKuanJun Jun 1, 2024
e8c1536
fix: stmt set columns data only once
DuanKuanJun Jun 5, 2024
dbfa467
fix: add stbInsert support
dapan1121 Jun 7, 2024
28f95e9
fix: taos_stmt_init_with_options
DuanKuanJun Jun 7, 2024
e00fba3
fix: diff stmt_init with auto create table
DuanKuanJun Jun 7, 2024
0b4fb8f
fix: conflicts benchData.c
DuanKuanJun Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions case/exportCsv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"filetype": "csvfile",
"csvPath": "/root/csv/",
"num_of_records_per_req": 10000,
"databases": [
{
"dbinfo": {
"name": "csvdb"
},
"super_tables": [
{
"name": "batchTable",
"childtable_count": 10,
"insert_rows": 50,
"childtable_prefix": "d",
"timestamp_step": 10,
"start_timestamp":1600000000000,
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc", "min": 1},
{ "type": "double", "name": "dc", "min":10, "max":10},
{ "type": "tinyint", "name": "ti"},
{ "type": "smallint", "name": "si"},
{ "type": "int", "name": "ic", "fillNull":"false"},
{ "type": "bigint", "name": "bi"},
{ "type": "utinyint", "name": "uti"},
{ "type": "usmallint", "name": "usi", "min":100, "max":120},
{ "type": "uint", "name": "ui"},
{ "type": "ubigint", "name": "ubi"},
{ "type": "binary", "name": "bin", "len": 16},
{ "type": "nchar", "name": "nch", "len": 16}
],
"tags": [
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
{"type": "binary", "name": "location", "len": 16,
"values": ["San Francisco", "Los Angles", "San Diego",
"San Jose", "Palo Alto", "Campbell", "Mountain View",
"Sunnyvale", "Santa Clara", "Cupertino"]
}
]
},
{
"name": "interlaceTable",
"childtable_count": 5,
"insert_rows": 100,
"interlace_rows": 10,
"childtable_prefix": "e",
"timestamp_step": 1000,
"start_timestamp":1700000000000,
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc", "min":16},
{ "type": "double", "name": "dc", "min":16},
{ "type": "tinyint", "name": "ti"},
{ "type": "smallint", "name": "si"},
{ "type": "int", "name": "ic", "fillNull":"false"},
{ "type": "bigint", "name": "bi"},
{ "type": "utinyint", "name": "uti"},
{ "type": "usmallint", "name": "usi"},
{ "type": "uint", "name": "ui"},
{ "type": "ubigint", "name": "ubi"},
{ "type": "binary", "name": "bin", "len": 32},
{ "type": "nchar", "name": "nch", "len": 64}
],
"tags": [
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
{"type": "binary", "name": "location", "len": 16,
"values": ["San Francisco", "Los Angles", "San Diego",
"San Jose", "Palo Alto", "Campbell", "Mountain View",
"Sunnyvale", "Santa Clara", "Cupertino"]
}
]
}
]
}
]
}
58 changes: 58 additions & 0 deletions case/insertBindVGroup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"num_of_records_per_req": 200,
"thread_count": 20,
"thread_bind_vgroup": "yes",
"create_table_thread_count": 1,
"confirm_parameter_prompt": "no",
"databases": [
{
"dbinfo": {
"name": "binddb",
"drop": "yes",
"vgroups": 2
},
"super_tables": [
{
"name": "meters",
"child_table_exists": "no",
"childtable_count": 4,
"insert_rows": 100,
"interlace_rows": 10,
"childtable_prefix": "d",
"insert_mode": "taosc",
"timestamp_step": 1000,
"start_timestamp":1500000000000,
"columns": [
{ "type": "bool", "name": "bc"},
{ "type": "float", "name": "fc", "max": 1, "min": 0 },
{ "type": "double", "name": "dc", "max": 1, "min": 0 },
{ "type": "tinyint", "name": "ti", "max": 100, "min": 0 },
{ "type": "smallint", "name": "si", "max": 100, "min": 0 },
{ "type": "int", "name": "ic", "max": 100, "min": 0 },
{ "type": "bigint", "name": "bi", "max": 100, "min": 0 },
{ "type": "utinyint", "name": "uti", "max": 100, "min": 0 },
{ "type": "usmallint", "name": "usi", "max": 100, "min": 0 },
{ "type": "uint", "name": "ui", "max": 100, "min": 0 },
{ "type": "ubigint", "name": "ubi", "max": 100, "min": 0 },
{ "type": "binary", "name": "bin", "len": 32},
{ "type": "nchar", "name": "nch", "len": 64}
],
"tags": [
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
{"type": "binary", "name": "location", "len": 16,
"values": ["San Francisco", "Los Angles", "San Diego",
"San Jose", "Palo Alto", "Campbell", "Mountain View",
"Sunnyvale", "Santa Clara", "Cupertino"]
}
]
}
]
}
]
}
11 changes: 7 additions & 4 deletions inc/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ enum TEST_MODE {
INSERT_TEST, // 0
QUERY_TEST, // 1
SUBSCRIBE_TEST, // 2
CSVFILE_TEST // 3
};

enum enumSYNC_MODE { SYNC_MODE, ASYNC_MODE, MODE_BUT };
Expand Down Expand Up @@ -646,6 +647,8 @@ typedef struct STSMA {
#define SUIT_DATAPOS_MUL_FILE 4
#define SUIT_DATAPOS_MIX 5

#define VAL_NULL "NULL"

enum CONTINUE_IF_FAIL_MODE {
NO_IF_FAILED, // 0
YES_IF_FAILED, // 1
Expand Down Expand Up @@ -788,14 +791,12 @@ typedef struct SSTREAM_S {
bool drop;
} SSTREAM;

#ifdef TD_VER_COMPATIBLE_3_0_0_0
typedef struct SVGroup_S {
int32_t vgId;
uint64_t tbCountPerVgId;
SChildTable **childTblArray;
uint64_t tbOffset; // internal use
} SVGroup;
#endif // TD_VER_COMPATIBLE_3_0_0_0
//
typedef struct SDataBase_S {
char * dbName;
Expand Down Expand Up @@ -923,7 +924,6 @@ typedef struct SArguments_S {
uint32_t binwidth;
uint32_t intColumnCount;
uint32_t nthreads;
bool nthreads_auto;
uint32_t table_threads;
uint64_t prepared_rand;
uint32_t reqPerReq;
Expand Down Expand Up @@ -965,6 +965,9 @@ typedef struct SArguments_S {
bool mistMode;
bool escape_character;
bool pre_load_tb_meta;
char csvPath[MAX_FILE_NAME_LEN];

bool bind_vgroup;
} SArguments;

typedef struct SBenchConn {
Expand Down Expand Up @@ -1160,7 +1163,7 @@ int32_t benchGetTotalMemory(int64_t *totalKB);
int32_t benchParseArgsNoArgp(int argc, char* argv[]);
#endif

int32_t execInsert(threadInfo *pThreadInfo, uint32_t k);
int32_t execInsert(threadInfo *pThreadInfo, uint32_t k, int64_t* delay3);
// if return true, timestmap must add timestap_step, else timestamp no need changed
bool needChangeTs(SSuperTable * stbInfo, int32_t *pkCur, int32_t *pkCnt);

Expand Down
36 changes: 36 additions & 0 deletions inc/benchCsv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <[email protected]>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the MIT license 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 INC_BENCHCSV_H_
#define INC_BENCHCSV_H_

#include <bench.h>

int csvTestProcess();

int genWithSTable(SDataBase* db, SSuperTable* stb, char* outDir);

char * genTagData(char* buf, SSuperTable* stb, int64_t i, int64_t *k);

char * genColumnData(char* colData, SSuperTable* stb, int64_t ts, int32_t precision, int64_t *k);

int32_t genRowByField(char* buf, BArray* fields, int16_t fieldCnt, char* binanryPrefix, char* ncharPrefix, int64_t *k);

void obtainCsvFile(char * outFile, SDataBase* db, SSuperTable* stb, char* outDir);

int interlaceWriteCsv(SDataBase* db, SSuperTable* stb, FILE* fs, char* buf, int bufLen, int minRemain);
int batchWriteCsv(SDataBase* db, SSuperTable* stb, FILE* fs, char* buf, int bufLen, int minRemain);

#endif // INC_BENCHCSV_H_
2 changes: 1 addition & 1 deletion inc/benchDataMix.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define __BENCHDATAMIX_H_


uint32_t dataGenByField(Field* fd, char* pstr, uint32_t len, char* prefix, int64_t *k);
uint32_t dataGenByField(Field* fd, char* pstr, uint32_t len, char* prefix, int64_t *k, char* nullVal);

// data generate by calc ts
uint32_t dataGenByCalcTs(Field* fd, char* pstr, uint32_t len, int64_t ts);
Expand Down
12 changes: 6 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin
ADD_DEPENDENCIES(taosdump deps-jansson)
ADD_DEPENDENCIES(taosdump deps-snappy)
IF (${TD_VER_COMPATIBLE} STRGREATER_EQUAL "3.0.0.0")
ADD_EXECUTABLE(taosBenchmark benchMain.c benchTmq.c benchQuery.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ADD_EXECUTABLE(taosBenchmark benchMain.c benchTmq.c benchQuery.c benchCsv.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ELSE()
ADD_EXECUTABLE(taosBenchmark benchMain.c benchSubscribe.c benchQuery.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ADD_EXECUTABLE(taosBenchmark benchMain.c benchSubscribe.c benchQuery.c benchCsv.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ENDIF()
ELSE ()
INCLUDE_DIRECTORIES(/usr/local/include)
Expand All @@ -246,9 +246,9 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin
SET(OS_ID "Darwin")

IF (${TD_VER_COMPATIBLE} STRGREATER_EQUAL "3.0.0.0")
ADD_EXECUTABLE(taosBenchmark benchMain.c benchTmq.c benchQuery.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ADD_EXECUTABLE(taosBenchmark benchMain.c benchTmq.c benchQuery.c benchCsv.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ELSE()
ADD_EXECUTABLE(taosBenchmark benchMain.c benchSubscribe.c benchQuery.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ADD_EXECUTABLE(taosBenchmark benchMain.c benchSubscribe.c benchQuery.c benchCsv.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ENDIF()
ENDIF ()

Expand Down Expand Up @@ -441,9 +441,9 @@ ELSE ()
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /utf-8")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /utf-8")
IF (${TD_VER_COMPATIBLE} STRGREATER_EQUAL "3.0.0.0")
ADD_EXECUTABLE(taosBenchmark benchMain.c benchTmq.c benchQuery.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsString.c toolsSys.c toolsString.c)
ADD_EXECUTABLE(taosBenchmark benchMain.c benchTmq.c benchQuery.c benchCsv.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsString.c toolsSys.c toolsString.c)
ELSE ()
ADD_EXECUTABLE(taosBenchmark benchMain.c benchSubscribe.c benchQuery.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ADD_EXECUTABLE(taosBenchmark benchMain.c benchSubscribe.c benchQuery.c benchCsv.c benchJsonOpt.c benchInsert.c benchInsertMix.c benchDataMix.c wrapDb.c benchData.c benchCommandOpt.c benchUtil.c benchUtilDs.c benchSys.c toolstime.c toolsSys.c toolsString.c)
ENDIF ()

ADD_EXECUTABLE(taosdump taosdump.c toolsSys.c toolstime.c toolsDir.c toolsString.c)
Expand Down
1 change: 0 additions & 1 deletion src/benchCommandOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ void initArgument() {
g_arguments->performance_print = 0;
g_arguments->output_file = DEFAULT_OUTPUT;
g_arguments->nthreads = DEFAULT_NTHREADS;
g_arguments->nthreads_auto = true;
g_arguments->table_threads = DEFAULT_NTHREADS;
g_arguments->prepared_rand = DEFAULT_PREPARED_RAND;
g_arguments->reqPerReq = DEFAULT_REQ_PER_REQ;
Expand Down
Loading
Loading