Пример #1
0
/*
* 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);
}
Пример #2
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);
}
Пример #3
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);
}
Пример #4
0
bool CCPlayer::load(const QString &path)
{
	set_files(path);
	return load();
}
Пример #5
0
bool CCPlayer::play(const QString& path)
{
	set_files(path);
	plays();
	return true;
}