[TD-3591] <fix>: rework limit and offset logic. (#5618)
Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
78e67ebe7c
commit
c13f335fcf
|
@ -3118,7 +3118,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
||||||
g_args.interlace_rows, g_args.num_of_RPR);
|
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",
|
printf(" interlace rows value will be set to num_of_records_per_request %d\n\n",
|
||||||
g_args.num_of_RPR);
|
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();
|
(void)getchar();
|
||||||
g_args.interlace_rows = g_args.num_of_RPR;
|
g_args.interlace_rows = g_args.num_of_RPR;
|
||||||
}
|
}
|
||||||
|
@ -3621,7 +3621,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
|
||||||
i, j, g_Dbs.db[i].superTbls[j].interlaceRows, g_args.num_of_RPR);
|
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",
|
printf(" interlace rows value will be set to num_of_records_per_request %d\n\n",
|
||||||
g_args.num_of_RPR);
|
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();
|
(void)getchar();
|
||||||
g_Dbs.db[i].superTbls[j].interlaceRows = g_args.num_of_RPR;
|
g_Dbs.db[i].superTbls[j].interlaceRows = g_args.num_of_RPR;
|
||||||
}
|
}
|
||||||
|
@ -5008,39 +5008,14 @@ static void *asyncWrite(void *sarg) {
|
||||||
static void startMultiThreadInsertData(int threads, char* db_name,
|
static void startMultiThreadInsertData(int threads, char* db_name,
|
||||||
char* precision,SSuperTable* superTblInfo) {
|
char* precision,SSuperTable* superTblInfo) {
|
||||||
|
|
||||||
pthread_t *pids = malloc(threads * sizeof(pthread_t));
|
pthread_t *pids = malloc(threads * sizeof(pthread_t));
|
||||||
assert(pids != NULL);
|
assert(pids != NULL);
|
||||||
|
|
||||||
threadInfo *infos = malloc(threads * sizeof(threadInfo));
|
threadInfo *infos = malloc(threads * sizeof(threadInfo));
|
||||||
assert(infos != NULL);
|
assert(infos != NULL);
|
||||||
|
|
||||||
memset(pids, 0, threads * sizeof(pthread_t));
|
memset(pids, 0, threads * sizeof(pthread_t));
|
||||||
memset(infos, 0, threads * sizeof(threadInfo));
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int a = ntables / threads;
|
|
||||||
if (a < 1) {
|
|
||||||
threads = ntables;
|
|
||||||
a = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int b = 0;
|
|
||||||
if (threads != 0) {
|
|
||||||
b = ntables % threads;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TAOS* taos;
|
//TAOS* taos;
|
||||||
//if (0 == strncasecmp(superTblInfo->insertMode, "taosc", 5)) {
|
//if (0 == strncasecmp(superTblInfo->insertMode, "taosc", 5)) {
|
||||||
|
@ -5082,13 +5057,6 @@ static void startMultiThreadInsertData(int threads, char* db_name,
|
||||||
|
|
||||||
double start = getCurrentTime();
|
double start = getCurrentTime();
|
||||||
|
|
||||||
int startFrom;
|
|
||||||
|
|
||||||
if ((superTblInfo) && (superTblInfo->childTblOffset >= 0))
|
|
||||||
startFrom = superTblInfo->childTblOffset;
|
|
||||||
else
|
|
||||||
startFrom = 0;
|
|
||||||
|
|
||||||
// read sample data from file first
|
// read sample data from file first
|
||||||
if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource,
|
if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource,
|
||||||
"sample", strlen("sample")))) {
|
"sample", strlen("sample")))) {
|
||||||
|
@ -5118,18 +5086,36 @@ static void startMultiThreadInsertData(int threads, char* db_name,
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (superTblInfo) {
|
int ntables = 0;
|
||||||
|
int startFrom;
|
||||||
|
|
||||||
|
if (superTblInfo) {
|
||||||
int limit, offset;
|
int limit, offset;
|
||||||
if (superTblInfo && (superTblInfo->childTblOffset >= 0)
|
|
||||||
&& (superTblInfo->childTblLimit > 0)) {
|
if (superTblInfo->childTblOffset >= superTblInfo->childTblCount) {
|
||||||
limit = superTblInfo->childTblLimit;
|
printf("WARNING: specified offset >= child table count! \n");
|
||||||
offset = superTblInfo->childTblOffset;
|
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 {
|
} else {
|
||||||
limit = superTblInfo->childTblCount;
|
limit = superTblInfo->childTblCount;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ntables = limit;
|
||||||
|
startFrom = offset;
|
||||||
|
|
||||||
superTblInfo->childTblName = (char*)calloc(1,
|
superTblInfo->childTblName = (char*)calloc(1,
|
||||||
limit * TSDB_TABLE_NAME_LEN);
|
limit * TSDB_TABLE_NAME_LEN);
|
||||||
if (superTblInfo->childTblName == NULL) {
|
if (superTblInfo->childTblName == NULL) {
|
||||||
|
@ -5145,9 +5131,24 @@ static void startMultiThreadInsertData(int threads, char* db_name,
|
||||||
&superTblInfo->childTblName, &childTblCount,
|
&superTblInfo->childTblName, &childTblCount,
|
||||||
limit,
|
limit,
|
||||||
offset);
|
offset);
|
||||||
|
} else {
|
||||||
|
ntables = g_args.num_of_tables;
|
||||||
|
startFrom = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_close(taos);
|
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++) {
|
for (int i = 0; i < threads; i++) {
|
||||||
threadInfo *t_info = infos + i;
|
threadInfo *t_info = infos + i;
|
||||||
t_info->threadID = i;
|
t_info->threadID = i;
|
||||||
|
|
Loading…
Reference in New Issue