/* * int partial(int tbl, int s) -- generate the s-th part of the named tables data */ int partial (int tbl, int s) { long rowcnt; long extra; if (verbose > 0) { fprintf (stderr, "\tStarting to load stage %d of %d for %s...", s, children, tdefs[tbl].comment); } if (direct == 0) set_files (tbl, s); rowcnt = set_state(tbl, scale, children, s, &extra); if (s == children) gen_tbl (tbl, rowcnt * (s - 1) + 1, rowcnt + extra, upd_num); else gen_tbl (tbl, rowcnt * (s - 1) + 1, rowcnt, upd_num); if (verbose > 0) fprintf (stderr, "done.\n"); return (0); }
/* * int partial(int tbl, int s) -- generate the s-th part of the named tables data */ int partial (int tbl, int s) { DSS_HUGE rowcnt; DSS_HUGE extra; if (o_verbose > 0) { fprintf (stderr, "\tStarting to load stage %d of %ld for %s...", s, o_stepmax, tdefs[tbl].comment); } if (o_direct == 0) set_files (tbl, s); rowcnt = set_state(tbl, o_scale, o_stepmax, s, &extra); if (s == o_stepmax) gen_tbl (tbl, rowcnt * (s - 1) + 1, rowcnt + extra, upd_num); else gen_tbl (tbl, rowcnt * (s - 1) + 1, rowcnt, upd_num); if (o_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; 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); }