/* * MAIN * * assumes the existance of getopt() to clean up the command * line handling */ int dbgen_init () { table = (1 << CUST) | (1 << SUPP) | (1 << NATION) | (1 << REGION) | (1 << PART_PSUPP) | (1 << ORDER_LINE); force = 0; insert_segments=0; delete_segments=0; insert_orders_segment=0; insert_lineitem_segment=0; delete_segment=0; verbose = 0; columnar = 0; set_seeds = 0; header = 0; direct = 0; scale = 1; flt_scale = 1.0; updates = 0; arefresh = UPD_PCT; step = -1; tdefs[ORDER].base *= ORDERS_PER_CUST; /* have to do this after init */ tdefs[LINE].base *= ORDERS_PER_CUST; /* have to do this after init */ tdefs[ORDER_LINE].base *= ORDERS_PER_CUST; /* have to do this after init */ fnames = 0; db_name = NULL; gen_sql = 0; gen_rng = 0; children = 1; d_path = NULL; load_dists (); #ifdef RNG_TEST for (DSS_HUGE i=0; i <= MAX_STREAM; i++) Seed[i].nCalls = 0; #endif // have to do this after init tdefs[NATION].base = nations.count; tdefs[REGION].base = regions.count; return (0); }
/* * MAIN * * assumes the existance of getopt() to clean up the command * line handling */ int main (int ac, char **av) { DSS_HUGE i; table = (1 << CUST) | (1 << SUPP) | (1 << NATION) | (1 << REGION) | (1 << PART_PSUPP) | (1 << ORDER_LINE); force = 0; insert_segments=0; delete_segments=0; insert_orders_segment=0; insert_lineitem_segment=0; delete_segment=0; verbose = 0; set_seeds = 0; scale = 1; flt_scale = 1.0; updates = 0; step = -1; tdefs[ORDER].base *= ORDERS_PER_CUST; /* have to do this after init */ tdefs[LINE].base *= ORDERS_PER_CUST; /* have to do this after init */ tdefs[ORDER_LINE].base *= ORDERS_PER_CUST; /* have to do this after init */ children = 1; d_path = NULL; #ifdef NO_SUPPORT signal (SIGINT, exit); #endif /* NO_SUPPORT */ process_options (ac, av); validate_options(); #if (defined(WIN32)&&!defined(_POSIX_)) for (i = 0; i < ac; i++) { spawn_args[i] = malloc (((int)strlen (av[i]) + 1) * sizeof (char)); MALLOC_CHECK (spawn_args[i]); strcpy (spawn_args[i], av[i]); } spawn_args[ac] = NULL; #endif if (verbose >= 0) { fprintf (stderr, "%s Population Generator (Version %d.%d.%d)\n", NAME, VERSION, RELEASE, PATCH); fprintf (stderr, "Copyright %s %s\n", TPC, C_DATES); } load_dists (); #ifdef RNG_TEST for (i=0; i <= MAX_STREAM; i++) Seed[i].nCalls = 0; #endif /* have to do this after init */ tdefs[NATION].base = nations.count; tdefs[REGION].base = regions.count; /* * updates are never parallelized */ if (updates) { /* * set RNG to start generating rows beyond SF=scale */ set_state (ORDER, scale, 100, 101, &i); rowcnt = (int)(tdefs[ORDER_LINE].base / 10000 * scale * UPD_PCT); if (step > 0) { /* * adjust RNG for any prior update generation */ for (i=1; i < step; i++) { sd_order(0, rowcnt); sd_line(0, rowcnt); } upd_num = step - 1; } else upd_num = 0; while (upd_num < updates) { if (verbose > 0) fprintf (stderr, "Generating update pair #%ld for %s", upd_num + 1, tdefs[ORDER_LINE].comment); insert_orders_segment=0; insert_lineitem_segment=0; delete_segment=0; minrow = upd_num * rowcnt + 1; gen_tbl (ORDER_LINE, minrow, rowcnt, upd_num + 1); if (verbose > 0) fprintf (stderr, "done.\n"); pr_drange (ORDER_LINE, minrow, rowcnt, upd_num + 1); upd_num++; } exit (0); } /** ** actual data generation section starts here **/ /* * traverse the tables, invoking the appropriate data generation routine for any to be built */ for (i = PART; i <= REGION; i++) if (table & (1 << i)) { if (children > 1 && i < NATION) { partial ((int)i, step); } else { minrow = 1; if (i < NATION) rowcnt = tdefs[i].base * scale; else rowcnt = tdefs[i].base; if (verbose > 0) fprintf (stderr, "Generating data for %s", tdefs[i].comment); gen_tbl ((int)i, minrow, rowcnt, upd_num); if (verbose > 0) fprintf (stderr, "done.\n"); } } return (0); }
/* * MAIN * * assumes the existance of getopt() to clean up the command * line handling */ int main (int ac, char **av) { DSS_HUGE i; o_table = 0; o_force = 0; insert_segments=0; delete_segments=0; insert_orders_segment=0; insert_lineitem_segment=0; delete_segment=0; o_verbose = 0; o_columnar = 0; o_set_seeds = 0; o_header = 0; o_direct = 0; o_scale = 1; flt_scale = 1.0; o_updates = 0; o_refresh = UPD_PCT; tdefs[ORDER].base *= ORDERS_PER_CUST; /* have to do this after init */ tdefs[LINE].base *= ORDERS_PER_CUST; /* have to do this after init */ tdefs[ORDER_LINE].base *= ORDERS_PER_CUST; /* have to do this after init */ o_fnames = 0; o_db_name = NULL; o_schema_name = NULL; o_gen_sql = 0; o_gen_rng = 0; o_d_path = NULL; o_step = 1; o_stepmax = 1; #ifdef NO_SUPPORT signal (SIGINT, exit); #endif /* NO_SUPPORT */ process_options (ac, av); if (o_table == 0) { usage(); fprintf(stderr, "Error: please specify -T option\n"); exit(1); } if (o_stepmax <= 0) { usage(); fprintf(stderr, "Error: invalid -N option\n"); exit(1); } if (! (0 < o_step && o_step <= o_stepmax)) { usage(); fprintf(stderr, "Error: invalid -n option\n"); exit(1); } if (o_verbose >= 0) { fprintf (stderr, "%s Population Generator (Version %d.%d.%d build %d)\n", NAME, VERSION, RELEASE, PATCH, BUILD); fprintf (stderr, "Copyright %s %s\n", TPC, C_DATES); } load_dists (); /* have to do this after init */ tdefs[NATION].base = nations.count; tdefs[REGION].base = regions.count; /* * updates are never parallelized */ if (o_updates) { /* * set RNG to start generating rows beyond SF=scale */ set_state (ORDER, o_scale, o_stepmax, o_stepmax + 1, &i); rowcnt = (int)(tdefs[ORDER_LINE].base / 10000 * o_scale * o_refresh); if (o_step > 0) { /* * adjust RNG for any prior update generation */ for (i=1; i < o_step; i++) { sd_order(0, rowcnt); sd_line(0, rowcnt); } upd_num = o_step - 1; } else upd_num = 0; while (upd_num < o_updates) { if (o_verbose > 0) fprintf (stderr, "Generating update pair #%ld for %s [pid: %d]", upd_num + 1, tdefs[ORDER_LINE].comment, (int)DSS_PROC); insert_orders_segment=0; insert_lineitem_segment=0; delete_segment=0; minrow = upd_num * rowcnt + 1; gen_tbl (ORDER_LINE, minrow, rowcnt, upd_num + 1); if (o_verbose > 0) fprintf (stderr, "done.\n"); pr_drange (ORDER_LINE, minrow, rowcnt, upd_num + 1); upd_num++; } exit (0); } /** ** actual data generation section starts here **/ /* * open database connection or set all the file names, as appropriate */ if (o_fnames) for (i = PART; i <= REGION; i++) { if (o_table & (1 << i)) if (set_files ((int)i, -1)) { fprintf (stderr, "Load aborted!\n"); exit (1); } } /* * traverse the tables, invoking the appropriate data generation routine for any to be built */ for (i = PART; i <= REGION; i++) { if (0 == (o_table & (1 << i))) continue; minrow = 1; if (i < NATION) rowcnt = tdefs[i].base * o_scale; else rowcnt = tdefs[i].base; if (o_verbose > 0) fprintf (stderr, "%s data for %s [pid: %ld, step: %d]", (o_validate)?"Validating":"Generating", tdefs[i].comment, (long)DSS_PROC, o_step); if (i < NATION) { partial(i, o_step); } else { gen_tbl ((int)i, minrow, rowcnt, upd_num); } if (o_verbose > 0) fprintf (stderr, "done.\n"); if (o_validate) printf("Validation checksum for %s at %ld GB: %0x\n", tdefs[i].name, o_scale, (unsigned int) tdefs[i].vtotal); } return (0); }
int main(int argc, char *argv[]) { FILE *sequence_sql; FILE *p; char pwd[256]; char cmd[256]; path[0] = '\0'; if (process_options(argc, argv) == 0) { usage(); return 1; } if (rdbms == SAPDB) { strcpy(field_deco, "\""); delimiter = ','; strcpy(sequence_file, "../scripts/sapdb/create_sequence.sql"); strcpy(exec_sql, "sql_execute"); } else if (rdbms == PGSQL) { strcpy(field_deco, ""); delimiter = '\\'; strcpy(sequence_file, "../scripts/pgsql/create_sequence.sql"); strcpy(exec_sql, ""); } if (items != 1000 && items != 10000 && items != 100000 && items != 1000000 && items != 10000000) { printf("%d is an invalid item scale factor:\n", items); printf("\t1000\n"); printf("\t10000\n"); printf("\t100000\n"); printf("\t1000000\n"); printf("\t10000000\n"); return 2; } p = popen("pwd", "r"); fscanf(p, "%s", pwd); printf("%s\n", pwd); if (strcmp(path, ".") == 0 || path[0] == '\0' ) { strcpy(path, pwd); } printf("item scale factor %10d\n", items); printf("user scale factor %10d\n", ebs); printf("data files are in %10s\n", path); printf("generating sequence creation file: %s\n", sequence_file); sequence_sql = fopen(sequence_file, "w"); if (sequence_sql == NULL) { printf("cannot open %s\n", sequence_file); return 3; } if (rdbms == SAPDB) { fprintf(sequence_sql, "sql_connect dbt,dbt\n"); fprintf(sequence_sql, "%s CREATE SEQUENCE custid INCREMENT BY 1 START WITH %d\n", exec_sql, 2880 * ebs + 1); fprintf(sequence_sql, "%s CREATE SEQUENCE addrid INCREMENT BY 1 START WITH %d\n", exec_sql, ebs * 2880 * 2 + 1); fprintf(sequence_sql, "%s CREATE SEQUENCE scid INCREMENT BY 1 START WITH %d\n", exec_sql, (int) ((double) ebs * 2880.0 * 0.9 + 1.0)); } else { fprintf(sequence_sql, "%s CREATE SEQUENCE custid INCREMENT 1 START %d;\n", exec_sql, 2880 * ebs + 1); fprintf(sequence_sql, "commit;"); fprintf(sequence_sql, "%s CREATE SEQUENCE addrid INCREMENT 1 START %d;\n", exec_sql, ebs * 2880 * 2 + 1); fprintf(sequence_sql, "commit;"); fprintf(sequence_sql, "%s CREATE SEQUENCE scid INCREMENT 1 START %d;\n", exec_sql, (int) ((double) ebs * 2880.0 * 0.9 + 1.0)); fprintf(sequence_sql, "commit;"); } fclose(sequence_sql); dpath = (char *) malloc(sizeof(char) * 64); strcpy(dpath, "../wgen/grammar.tpcw"); init_common(); load_dists(); printf("generating data files...\n"); if (flag_item == 1) { gen_items(); sprintf(cmd, "ln -fs %s/item.data /tmp/item.data\n", path); popen(cmd, "r"); } if (flag_cust == 1) { gen_customers(); sprintf(cmd, "ln -fs %s/customer.data /tmp/customer.data", path); popen(cmd, "r"); } if (flag_author == 1) { gen_authors(); sprintf(cmd, "ln -fs %s/author.data /tmp/author.data", path); popen(cmd, "r"); } if (flag_address == 1) { gen_addresses(); sprintf(cmd, "ln -fs %s/address.data /tmp/address.data", path); popen(cmd, "r"); } if (flag_order == 1) { gen_orders(); sprintf(cmd, "ln -fs %s/orders.data /tmp/orders.data", path); popen(cmd, "r"); sprintf(cmd, "ln -fs %s/order_line.data /tmp/order_line.data", path); popen(cmd, "r"); sprintf(cmd, "ln -fs %s/cc_xacts.data /tmp/cc_xacts.data", path); popen(cmd, "r"); } if (rdbms == SAPDB) { sprintf(cmd, "ln -fs %s/country.data /tmp/country.data", pwd); } else if (rdbms == PGSQL) { sprintf(cmd, "ln -fs %s/country.data.pgsql /tmp/country.data", pwd); } popen(cmd, "r"); free(dpath); return 0; }