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

Hotfix/sangshuduo/td 3591 taosdemo get tbname after create #5618

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
91 changes: 46 additions & 45 deletions src/kit/taosdemo/taosdemo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3118,7 +3118,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
g_args.interlace_rows, g_args.num_of_RPR);
printf(" interlace rows value will be set to num_of_records_per_request %d\n\n",
g_args.num_of_RPR);
printf(" press Enter key to continue or Ctrl+C to stop.");
printf(" press Enter key to continue or Ctrl-C to stop.");
(void)getchar();
g_args.interlace_rows = g_args.num_of_RPR;
}
Expand Down Expand Up @@ -3621,7 +3621,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
i, j, g_Dbs.db[i].superTbls[j].interlaceRows, g_args.num_of_RPR);
printf(" interlace rows value will be set to num_of_records_per_request %d\n\n",
g_args.num_of_RPR);
printf(" press Enter key to continue or Ctrl+C to stop.");
printf(" press Enter key to continue or Ctrl-C to stop.");
(void)getchar();
g_Dbs.db[i].superTbls[j].interlaceRows = g_args.num_of_RPR;
}
Expand Down Expand Up @@ -5008,39 +5008,14 @@ static void *asyncWrite(void *sarg) {
static void startMultiThreadInsertData(int threads, char* db_name,
char* precision,SSuperTable* superTblInfo) {

pthread_t *pids = malloc(threads * sizeof(pthread_t));
assert(pids != NULL);

threadInfo *infos = malloc(threads * sizeof(threadInfo));
assert(infos != NULL);

memset(pids, 0, threads * sizeof(pthread_t));
memset(infos, 0, threads * sizeof(threadInfo));

int ntables = 0;
if (superTblInfo) {

if ((superTblInfo->childTblOffset >= 0)
&& (superTblInfo->childTblLimit > 0)) {

ntables = superTblInfo->childTblLimit;
} else {
ntables = superTblInfo->childTblCount;
}
} else {
ntables = g_args.num_of_tables;
}
pthread_t *pids = malloc(threads * sizeof(pthread_t));
assert(pids != NULL);

int a = ntables / threads;
if (a < 1) {
threads = ntables;
a = 1;
}
threadInfo *infos = malloc(threads * sizeof(threadInfo));
assert(infos != NULL);

int b = 0;
if (threads != 0) {
b = ntables % threads;
}
memset(pids, 0, threads * sizeof(pthread_t));
memset(infos, 0, threads * sizeof(threadInfo));

//TAOS* taos;
//if (0 == strncasecmp(superTblInfo->insertMode, "taosc", 5)) {
Expand Down Expand Up @@ -5082,13 +5057,6 @@ static void startMultiThreadInsertData(int threads, char* db_name,

double start = getCurrentTime();

int startFrom;

if ((superTblInfo) && (superTblInfo->childTblOffset >= 0))
startFrom = superTblInfo->childTblOffset;
else
startFrom = 0;

// read sample data from file first
if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource,
"sample", strlen("sample")))) {
Expand Down Expand Up @@ -5118,18 +5086,36 @@ static void startMultiThreadInsertData(int threads, char* db_name,
exit(-1);
}

if (superTblInfo) {
int ntables = 0;
int startFrom;

if (superTblInfo) {
int limit, offset;
if (superTblInfo && (superTblInfo->childTblOffset >= 0)
&& (superTblInfo->childTblLimit > 0)) {
limit = superTblInfo->childTblLimit;
offset = superTblInfo->childTblOffset;

if (superTblInfo->childTblOffset >= superTblInfo->childTblCount) {
printf("WARNING: specified offset >= child table count! \n");
if (!g_args.answer_yes) {
printf(" Press enter key to continue or Ctrl-C to stop\n\n");
(void)getchar();
}
}

if (superTblInfo->childTblOffset >= 0) {
if (superTblInfo->childTblLimit <= 0) {
superTblInfo->childTblLimit =
superTblInfo->childTblCount - superTblInfo->childTblOffset;
}

offset = superTblInfo->childTblOffset;
limit = superTblInfo->childTblLimit;
} else {
limit = superTblInfo->childTblCount;
offset = 0;
}

ntables = limit;
startFrom = offset;

superTblInfo->childTblName = (char*)calloc(1,
limit * TSDB_TABLE_NAME_LEN);
if (superTblInfo->childTblName == NULL) {
Expand All @@ -5145,9 +5131,24 @@ static void startMultiThreadInsertData(int threads, char* db_name,
&superTblInfo->childTblName, &childTblCount,
limit,
offset);
} else {
ntables = g_args.num_of_tables;
startFrom = 0;
}

taos_close(taos);

int a = ntables / threads;
if (a < 1) {
threads = ntables;
a = 1;
}

int b = 0;
if (threads != 0) {
b = ntables % threads;
}

for (int i = 0; i < threads; i++) {
threadInfo *t_info = infos + i;
t_info->threadID = i;
Expand Down