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

support primary key order generator #738

Merged
merged 9 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 28 additions & 22 deletions case/insertPrimaryKey.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,52 @@
"num_of_records_per_req": 1000,
"create_table_thread_count": 2,
"thread_count": 10,
"prepared_rand": 1000,
"confirm_parameter_prompt": "no",
"databases": [
{
"dbinfo": {
"name": "primary",
"name": "primarydb",
"drop": "yes",
"vgroups": 6,
"replica": 3,
"vgroups": 2,
"replica": 1,
"precision": "ms"
},
"super_tables": [
{
"name": "meters",
"child_table_exists": "no",
"childtable_count": 1000,
"insert_rows": 10000000,
"childtable_count": 100,
"insert_rows": 100000,
"childtable_prefix": "d",
"insert_mode": "taosc",
"insert_interval": 0,
"timestamp_step": 10,
"start_timestamp":1500000000000,
"primary_key":1,
"repeat_ts_min": 0,
"repeat_ts_min": 10,
"repeat_ts_max": 10,
"disorder_ratio":0,
"update_ratio": 0,
"delete_ratio": 0,
"disorder_fill_interval": 100,
"update_fill_interval": 25,
"generate_row_rule": 2,
"columns": [
{ "type": "int", "name": "pk", "max": 100, "min": 0 },
{ "type": "int", "name": "pk", "max": 100000, "min": 0, "gen":"order","fillNull":"false"},
{ "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}
{ "type": "float", "name": "fc", "min": 1, "gen":"order"},
{ "type": "double", "name": "dc", "min":10, "gen":"order"},
{ "type": "tinyint", "name": "ti", "gen":"order"},
{ "type": "smallint", "name": "si", "gen":"order"},
{ "type": "int", "name": "ic", "gen":"order", "fillNull":"false"},
{ "type": "bigint", "name": "bi", "gen":"order"},
{ "type": "utinyint", "name": "uti", "gen":"order"},
{ "type": "usmallint", "name": "usi", "gen":"order"},
{ "type": "uint", "name": "ui", "gen":"order"},
{ "type": "ubigint", "name": "ubi", "gen":"order"},
{ "type": "binary", "name": "bin", "len": 32, "gen":"order"},
{ "type": "nchar", "name": "nch", "len": 64, "gen":"order"}
],
"tags": [
{"type": "tinyint", "name": "groupid","max": 10,"min": 1},
Expand All @@ -58,9 +65,8 @@
}
],
"sqls" : [
"select count(*) from primary.meters",
"select max(pk) from primary.meters",
"create topic tp1 as * from primary.meters"
"create tmsa tmsa1 on test.meters ...",
"create recursive tsma tmsa2 on test.tmsa1 ..."
]
}
]
Expand Down
36 changes: 35 additions & 1 deletion inc/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,24 @@ typedef struct SChildField {

#define TAG_BATCH_COUNT 100

#define GEN_RANDOM 0
#define GEN_ORDER 1

#define COL_GEN (field->gen == GEN_ORDER ? k : taosRandom())

#define tmpInt8(field) tmpInt8Impl(field, 0)
#define tmpUint8(field) tmpUint8Impl(field, 0)
#define tmpInt16(field) tmpInt16Impl(field, 0)
#define tmpUint16(field) tmpUint16Impl(field, 0)

#define tmpInt32(field) tmpInt32Impl (field,0,0,0)
#define tmpUint32(field) tmpUint32Impl(field,0,0,0)
#define tmpInt64(field) tmpInt64Impl (field,0,0)
#define tmpUint64(field) tmpUint64Impl(field,0,0)
#define tmpFloat(field) tmpFloatImpl (field,0,0,0)
#define tmpDouble(field) tmpDoubleImpl(field,0,0)


typedef struct SField {
uint8_t type;
char name[TSDB_COL_NAME_LEN + 1];
Expand All @@ -592,8 +610,10 @@ typedef struct SField {
int32_t offset;
int32_t step;


bool sma;
bool fillNull;
uint8_t gen; // see GEN_ define

} Field;

typedef struct STSMA {
Expand Down Expand Up @@ -632,6 +652,7 @@ typedef struct SChildTable_S {
char *sampleDataBuf;
uint64_t insertRows;
BArray *childCols;
int64_t ts; // record child table ts
int32_t pkCur;
int32_t pkCnt;
} SChildTable;
Expand Down Expand Up @@ -1130,5 +1151,18 @@ int32_t execInsert(threadInfo *pThreadInfo, uint32_t k);
// if return true, timestmap must add timestap_step, else timestamp no need changed
bool needChangeTs(SSuperTable * stbInfo, int32_t *pkCur, int32_t *pkCnt);

// tmp function
bool tmpBool(Field *field);
int8_t tmpInt8Impl(Field *field, int64_t k);
uint8_t tmpUint8Impl(Field *field, int64_t k);
int16_t tmpInt16Impl(Field *field, int64_t k);
uint16_t tmpUint16Impl(Field *field, int64_t k);
int tmpInt32Impl(Field *field, int i, int angle, int32_t k);
uint32_t tmpUint32Impl(Field *field, int i, int angle, int64_t k);
int64_t tmpInt64Impl(Field *field, int32_t angle, int32_t k);
uint64_t tmpUint64Impl(Field *field, int32_t angle, int64_t k);
float tmpFloatImpl(Field *field, int i, int32_t angle, int32_t k);
double tmpDoubleImpl(Field *field, int32_t angle, int32_t k);
int tmpStr(char *tmp, int iface, Field *field, int64_t k);

#endif // INC_BENCH_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);
uint32_t dataGenByField(Field* fd, char* pstr, uint32_t len, char* prefix, int64_t *k);

// data generate by calc ts
uint32_t dataGenByCalcTs(Field* fd, char* pstr, uint32_t len, int64_t ts);
Expand Down
Loading
Loading