예제 #1
0
BaseQuery * TPCCQueryGenerator::gen_new_order(uint64_t home_partition) {
  TPCCQuery * query = new TPCCQuery;
	set<uint64_t> partitions_accessed;

	query->txn_type = TPCC_NEW_ORDER;
  query->items.init(g_max_items_per_txn);
	if (FIRST_PART_LOCAL) {
    while(wh_to_part(query->w_id = URand(1, g_num_wh)) != home_partition) {}
  }
	else
		query->w_id = URand(1, g_num_wh);

	query->d_id = URand(1, g_dist_per_wh);
	query->c_id = NURand(1023, 1, g_cust_per_dist);
  // FIXME: No rollback
	//rbk = URand(1, 100) == 1 ? true : false;
	query->rbk = false;
	query->ol_cnt = URand(5, g_max_items_per_txn);
	query->o_entry_d = 2013;

  partitions_accessed.insert(wh_to_part(query->w_id));

  double r_mpr = (double)(rand() % 10000) / 10000;
  uint64_t part_limit;
  if(r_mpr < g_mpr)
    part_limit = g_part_per_txn;
  else
    part_limit = 1;

  std::set<uint64_t> ol_i_ids;
  while(query->items.size() < query->ol_cnt) {
      Item_no * item = new Item_no;

    while(ol_i_ids.count( item->ol_i_id = NURand(8191, 1, g_max_items)) > 0) {}
    ol_i_ids.insert(item->ol_i_id);
    item->ol_quantity = URand(1, 10);
    double r_rem = (double)(rand() % 100000) / 100000;
		if (r_rem > 0.01 || r_mpr > g_mpr || g_num_wh == 1) {
			// home warehouse
			item->ol_supply_w_id = query->w_id;
    } else {
      if(partitions_accessed.size() < part_limit) {
        item->ol_supply_w_id = URand(1, g_num_wh);
        partitions_accessed.insert(wh_to_part(item->ol_supply_w_id));
      } else {
        // select warehouse from among those already selected
        while( partitions_accessed.count(wh_to_part(item->ol_supply_w_id = URand(1, g_num_wh))) == 0) {}
      }
    }

    query->items.add(item);
  }

  query->partitions.init(partitions_accessed.size());
  for(auto it = partitions_accessed.begin(); it != partitions_accessed.end(); ++it) {
    query->partitions.add(*it);
  }
  return query;

}
예제 #2
0
BaseQuery * TPCCQueryGenerator::gen_payment(uint64_t home_partition) {
  TPCCQuery * query = new TPCCQuery;
	set<uint64_t> partitions_accessed;

	query->txn_type = TPCC_PAYMENT;
  uint64_t home_warehouse;
	if (FIRST_PART_LOCAL) {
    while(wh_to_part(home_warehouse = URand(1, g_num_wh)) != home_partition) {}
  }
	else
		home_warehouse = URand(1, g_num_wh);
  query->w_id =  home_warehouse;
	query->d_w_id = home_warehouse;

  partitions_accessed.insert(wh_to_part(query->w_id));

	query->d_id = URand(1, g_dist_per_wh);
	query->h_amount = URand(1, 5000);
  query->rbk = false;
	double x = (double)(rand() % 10000) / 10000;
	int y = URand(1, 100);

	//if(x > g_mpr) { 
	if(x > 0.15) { 
		// home warehouse
		query->c_d_id = query->d_id;
		query->c_w_id = query->w_id;
	} else {	
		// remote warehouse
		query->c_d_id = URand(1, g_dist_per_wh);
		if(g_num_wh > 1) {
			while((query->c_w_id = URand(1, g_num_wh)) == query->w_id) {}
			if (wh_to_part(query->w_id) != wh_to_part(query->c_w_id)) {
        partitions_accessed.insert(wh_to_part(query->c_w_id));
			}
		} else 
      query->c_w_id = query->w_id;
	}
	if(y <= 60) {
		// by last name
		query->by_last_name = true;
		Lastname(NURand(255,0,999),query->c_last);
	} else {
		// by cust id
		query->by_last_name = false;
		query->c_id = NURand(1023, 1, g_cust_per_dist);
	}

  query->partitions.init(partitions_accessed.size());
  for(auto it = partitions_accessed.begin(); it != partitions_accessed.end(); ++it) {
    query->partitions.add(*it);
  }
  return query;
}
예제 #3
0
void tpcc_query::gen_new_order(uint64_t thd_id) {
	type = TPCC_NEW_ORDER;
	if (FIRST_PART_LOCAL)
		w_id = thd_id % g_num_wh + 1;
	else
		w_id = URand(1, g_num_wh);
	d_id = URand(1, DIST_PER_WARE);
	c_id = NURand(1023, 1, g_cust_per_dist);
	rbk = URand(1, 100);
	ol_cnt = URand(5, 15);
	o_entry_d = 2013;
	items = (Item_no *) mem_allocator.alloc(sizeof(Item_no) * ol_cnt, thd_id);
	remote = false;
	part_to_access[0] = wh_to_part(w_id);
	part_num = 1;

	for (UInt32 oid = 0; oid < ol_cnt; oid ++) {
		items[oid].ol_i_id = NURand(8191, 1, g_max_items);
		UInt32 x = URand(1, 100);
		if (x > 1 || g_num_wh == 1)
			items[oid].ol_supply_w_id = w_id;
		else  {
			while((items[oid].ol_supply_w_id = URand(1, g_num_wh)) == w_id) {}
			remote = true;
		}
		items[oid].ol_quantity = URand(1, 10);
	}
	// Remove duplicate items
	for (UInt32 i = 0; i < ol_cnt; i ++) {
		for (UInt32 j = 0; j < i; j++) {
			if (items[i].ol_i_id == items[j].ol_i_id) {
				for (UInt32 k = i; k < ol_cnt - 1; k++)
					items[k] = items[k + 1];
				ol_cnt --;
				i--;
			}
		}
	}
	for (UInt32 i = 0; i < ol_cnt; i ++) 
		for (UInt32 j = 0; j < i; j++) 
			assert(items[i].ol_i_id != items[j].ol_i_id);
	// update part_to_access
	for (UInt32 i = 0; i < ol_cnt; i ++) {
		UInt32 j;
		for (j = 0; j < part_num; j++ ) 
			if (part_to_access[j] == wh_to_part(items[i].ol_supply_w_id))
				break;
		if (j == part_num) // not found! add to it.
		part_to_access[part_num ++] = wh_to_part( items[i].ol_supply_w_id );
	}
}
예제 #4
0
mbench_cust_input_t create_mbench_cust_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf > 0);

    mbench_cust_input_t mcin;

#ifndef USE_SAME_INPUT

    if (specificWH>0)
        mcin._wh_id = specificWH;
    else
        mcin._wh_id = URand(1, sf);

    mcin._d_id = URand(1,10);
    mcin._c_id = NURand(1023,1,3000);
    mcin._amount = (double)URand(1,1000);

#else
    // same input
    mcin._wh_id  = 1;
    mcin._d_id   = 2;
    mcin._c_id   = 3;
    mcin._amount = 15;
#endif

    return (mcin);

}; // EOF: mbench_cust
예제 #5
0
void create_customer(){
  FD fd;
  int c_load = uniform(0, 255);

  /* validate C-Run by using this value(C-Load) */
  fd.open(CLOADFILENAME, O_CREAT | O_TRUNC | O_WRONLY, 0644);
  fd.write(&c_load, sizeof(c_load));
  fd.close();

  int n = W*10*3000;
  std::vector<PageCustomer> pages(n);

  for(int i=0; i<W; i++){
    for(int j=0; j<10; j++){
      for(int k=0; k<3000; k++){
	int idx = i*10*3000 + j*3000 + k;

	pages[idx].page_id = idx+1;
	pages[idx].c_id   = k+1; // p-key
	pages[idx].c_d_id = j+1; // p-key
	pages[idx].c_w_id = i+1; // p-key
	if(pages[idx].c_id < 1000){
	  gen_c_last(pages[idx].c_last, pages[idx].c_id);
	} else {
	  gen_c_last(pages[idx].c_last, NURand(255, 0, 999, c_load));
	}
	strncpy(pages[idx].c_middle, "OE", 3);
	gen_rand_astring(pages[idx].c_first, 8, 16);
	gen_rand_astring(pages[idx].c_street_1, 10, 20);
	gen_rand_astring(pages[idx].c_street_2, 10, 20);
	gen_rand_astring(pages[idx].c_city, 10, 20);
	gen_rand_astring(pages[idx].c_state, 2, 2);
	gen_rand_zip(pages[idx].c_zip);
	gen_rand_nstring(pages[idx].c_phone, 16, 16);
	gen_date_and_time(pages[idx].c_since);
	if(uniform(0,9)!=0){
	  strncpy(pages[idx].c_credit, "GC", 3);
	} else {
	  strncpy(pages[idx].c_credit, "BC", 3);
	}
	pages[idx].c_credit_lim = 50000.00;
	gen_rand_decimal(&pages[idx].c_discount, 0, 5000, 4);
	pages[idx].c_balance = -10.00;
	pages[idx].c_ytd_payment = 10.00;
	pages[idx].c_payment_cnt = 1;
	pages[idx].c_delivery_cnt = 0;
	gen_rand_astring(pages[idx].c_data, 300, 500);
      }
    }
  }

  fd.open(CFILENAME, O_CREAT | O_TRUNC | O_WRONLY, 0644);
  fd.write(&pages[0], pages.size()*sizeof(PageCustomer));

  std::cerr << "create customer " << pages.size() << "records: " << CFILENAME << std::endl;
}
예제 #6
0
void tpcc_query::gen_payment(uint64_t thd_id) {
	type = TPCC_PAYMENT;
	if (FIRST_PART_LOCAL)
		w_id = thd_id % g_num_wh + 1;
	else
		w_id = URand(1, g_num_wh);
	d_w_id = w_id;
	uint64_t part_id = wh_to_part(w_id);
	part_to_access[0] = part_id;
	part_num = 1;

	d_id = URand(1, DIST_PER_WARE);
	h_amount = URand(1, 5000);
	int x = URand(1, 100);
	int y = URand(1, 100);


	if(x <= 85) { 
		// home warehouse
		c_d_id = d_id;
		c_w_id = w_id;
	} else {	
		// remote warehouse
		c_d_id = URand(1, DIST_PER_WARE);
		if(g_num_wh > 1) {
			while((c_w_id = URand(1, g_num_wh)) == w_id) {}
			if (wh_to_part(w_id) != wh_to_part(c_w_id)) {
				part_to_access[1] = wh_to_part(c_w_id);
				part_num = 2;
			}
		} else 
			c_w_id = w_id;
	}
	if(y <= 60) {
		// by last name
		by_last_name = true;
		Lastname(NURand(255,0,999),c_last);
	} else {
		// by cust id
		by_last_name = false;
		c_id = NURand(1023, 1, g_cust_per_dist);
	}
}
예제 #7
0
order_status_input_t create_order_status_input(int sf, int specificWH)
{
    // check scaling factor
    assert (sf > 0);

    // produce PAYMENT params according to tpcc spec v.5.4
    order_status_input_t osin;

#ifndef USE_SAME_INPUT    

    if (specificWH>0)
        osin._wh_id = specificWH;
    else
        osin._wh_id    = URand(1, sf);

    osin._d_id     = URand(1, 10);

#ifdef USE_SAFE_PATHS
    osin._c_select = URand(61, 100);
#else
    osin._c_select = URand(1, 100); /* 60% - 40% */
#endif

    if (osin._c_select <= 60) {
        // Calls the function that returns the correct cust_last
        generate_cust_last(NURand(255,0,999), osin._c_last);    
    }
    else {
        osin._c_id = NURand(1023, 1, 3000);
    }

#else
    // same input
    osin._wh_id    = 1;
    osin._d_id     = 2;
    osin._c_select = 80;
    osin._c_id     = 3;
    //osin._c_last   = NULL;
#endif

    return (osin);

}; // EOF: create_order_status
예제 #8
0
void 
tpcc_query::gen_order_status(uint64_t thd_id) {
	type = TPCC_ORDER_STATUS;
	if (FIRST_PART_LOCAL)
		w_id = thd_id % g_num_wh + 1;
	else
		w_id = URand(1, g_num_wh);
	d_id = URand(1, DIST_PER_WARE);
	c_w_id = w_id;
	c_d_id = d_id;
	int y = URand(1, 100);
	if(y <= 60) {
		// by last name
		by_last_name = true;
		Lastname(NURand(255,0,999),c_last);
	} else {
		// by cust id
		by_last_name = false;
		c_id = NURand(1023, 1, g_cust_per_dist);
	}
}
예제 #9
0
파일: driver.c 프로젝트: Percona-QA/toku-qa
/*
 * prepare data and execute order status transaction
 */
static int do_ordstat (int t_num)
{
    int c_num;
    int byname,i,ret;
    clock_t clk1,clk2;
    double rt;
    struct timespec tbuf1;
    struct timespec tbuf2;
    int  w_id, d_id, c_id;
    char c_last[16];

    if(num_node==0){
	w_id = RandomNumber(1, num_ware);
    }else{
	c_num = ((num_node * t_num)/num_conn); /* drop moduls */
	w_id = RandomNumber(1 + (num_ware * c_num)/num_node,
			    (num_ware * (c_num + 1))/num_node);
    }
    d_id = RandomNumber(1, DIST_PER_WARE);
    c_id = NURand(1023, 1, CUST_PER_DIST); 
    Lastname(NURand(255,0,999), c_last); 
    if (RandomNumber(1, 100) <= 60) {
        byname = 1; /* select by last name */
    }else{
        byname = 0; /* select by customer id */
    }

      clk1 = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tbuf1 );
    for (i = 0; i < MAX_RETRY; i++) {
      ret = ordstat(t_num, w_id, d_id, byname, c_id, c_last);
      clk2 = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tbuf2 );

      if(ret){

	rt = (double)(tbuf2.tv_sec * 1000.0 + tbuf2.tv_nsec/1000000.0-tbuf1.tv_sec * 1000.0 - tbuf1.tv_nsec/1000000.0);
	if(rt > max_rt[2])
	  max_rt[2]=rt;
	hist_inc(2, rt);
	if(counting_on){
	  if( rt < RTIME_ORDSTAT ){
	    success[2]++;
	    success2[2][t_num]++;
	  }else{
	    late[2]++;
	    late2[2][t_num]++;
	  }
	}

	return (1); /* end */
      }else{

	if(counting_on){
	  retry[2]++;
	  retry2[2][t_num]++;
	}

      }
    }

    if(counting_on){
      retry[2]--;
      retry2[2][t_num]--;
      failure[2]++;
      failure2[2][t_num]++;
    }

    return (0);

}
예제 #10
0
파일: driver.c 프로젝트: Percona-QA/toku-qa
/*
 * prepare data and execute the new order transaction for one order
 * officially, this is supposed to be simulated terminal I/O
 */
static int do_neword (int t_num)
{
    int c_num;
    int i,ret;
    clock_t clk1,clk2;
    double rt;
    struct timespec tbuf1;
    struct timespec tbuf2;
    int  w_id, d_id, c_id, ol_cnt;
    int  all_local = 1;
    int  notfound = MAXITEMS+1;  /* valid item ids are numbered consecutively
				    [1..MAXITEMS] */
    int rbk;
    int  itemid[MAX_NUM_ITEMS];
    int  supware[MAX_NUM_ITEMS];
    int  qty[MAX_NUM_ITEMS];

    if(num_node==0){
	w_id = RandomNumber(1, num_ware);
    }else{
	c_num = ((num_node * t_num)/num_conn); /* drop moduls */
	w_id = RandomNumber(1 + (num_ware * c_num)/num_node,
			    (num_ware * (c_num + 1))/num_node);
    }
    d_id = RandomNumber(1, DIST_PER_WARE);
    c_id = NURand(1023, 1, CUST_PER_DIST);

    ol_cnt = RandomNumber(5, 15);
    rbk = RandomNumber(1, 100);

    for (i = 0; i < ol_cnt; i++) {
	itemid[i] = NURand(8191, 1, MAXITEMS);
	if ((i == ol_cnt - 1) && (rbk == 1)) {
	    itemid[i] = notfound;
	}
	if (RandomNumber(1, 100) != 1) {
	    supware[i] = w_id;
	}
	else {
	    supware[i] = other_ware(w_id);
	    all_local = 0;
	}
	qty[i] = RandomNumber(1, 10);
    }

    clk1 = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tbuf1 );
    for (i = 0; i < MAX_RETRY; i++) {
      ret = neword(t_num, w_id, d_id, c_id, ol_cnt, all_local, itemid, supware, qty);
      clk2 = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tbuf2 );

      if(ret){

	rt = (double)(tbuf2.tv_sec * 1000.0 + tbuf2.tv_nsec/1000000.0-tbuf1.tv_sec * 1000.0 - tbuf1.tv_nsec/1000000.0);
        //printf("NOT : %.3f\n", rt);
        if (freport_file != NULL) {
          fprintf(freport_file,"%d %.3f\n", time_count, rt);
        }

	if(rt > max_rt[0])
	  max_rt[0]=rt;
	hist_inc(0, rt);
	if(counting_on){
	  if( rt < RTIME_NEWORD ){
	    success[0]++;
	    success2[0][t_num]++;
	  }else{
	    late[0]++;
	    late2[0][t_num]++;
	  }
	}

	return (1); /* end */
      }else{

	if(counting_on){
	  retry[0]++;
	  retry2[0][t_num]++;
	}

      }
    }

    if(counting_on){
      retry[0]--;
      retry2[0][t_num]--;
      failure[0]++;
      failure2[0][t_num]++;
    }

    return (0);
}
예제 #11
0
/*
 * Loads Customer Table
 * Also inserts corresponding history record
 *
 * id   - customer id
 * d_id - district id
 * w_id - warehouse id
 */
int 
Customer(long d_id, long w_id )
{
    long    c_id;
    long    c_d_id;
    long    c_w_id;
    char    c_first[17];
    char    c_middle[3];
    char    c_last[17];
    char    c_street_1[21];
    char    c_street_2[21];
    char    c_city[21];
    char    c_state[3];
    char    c_zip[10];
    char    c_phone[17];
    char    c_since[12];
    char    c_credit[3];
    long    c_credit_lim;
    float   c_discount;
    float   c_balance;
    char    c_data[501];
    float   h_amount;
    char    h_data[25];
    int     err;

    
    printf("Loading Customer for DID=%ld, WID=%ld\n",d_id,w_id);

    for (c_id=1; c_id<=CUST_PER_DIST; c_id++) 
    {
	DBT     key, data;
	CUSTOMER_PRIMARY_KEY  c_key;
	CUSTOMER_PRIMARY_DATA c_primdata;
	HISTORY_PRIMARY_KEY  h_key;

	memset(&c_key, 0, sizeof(CUSTOMER_PRIMARY_KEY));
	memset(&c_primdata, 0, sizeof(CUSTOMER_PRIMARY_DATA));
	
	memset(&h_key, 0, sizeof(HISTORY_PRIMARY_KEY));

	/* Generate Customer Data */
	c_d_id=d_id;
	c_w_id=w_id;
	
	MakeAlphaString( 8, 16, c_first );
	
	c_middle[0]='O'; c_middle[1]='E'; c_middle[2] = '\0';
	
	if (c_id <= 1000)
	    Lastname(c_id-1,c_last);
	else
	    Lastname(NURand(255,0,999),c_last);
	
	MakeAddress( c_street_1, c_street_2, c_city, c_state, c_zip );
	MakeNumberString( 16, 16, c_phone );
	
	if (random1(0L,1L)) 
	    c_credit[0]='G';
	else 
	    c_credit[0]='B';
	
	c_credit[1]='C'; c_credit[2]='\0'; 
	c_credit_lim=50000;
	c_discount=((float)random1(0L,50L))/100.0; 
	c_balance= -10.0;
	MakeAlphaString(300,500,c_data);
	
	/* Prepare for putting into the database */
	c_key.C_W_ID = c_w_id;
	c_key.C_D_ID = c_d_id;
	c_key.C_ID = c_id;
	
	memcpy(&c_primdata.C_FIRST, &c_first, 17);
	memcpy(&c_primdata.C_MIDDLE, &c_middle, 3);
	memcpy(&c_primdata.C_LAST, &c_last, 17);
	memcpy(&c_primdata.C_STREET_1, &c_street_1, 21);
	memcpy(&c_primdata.C_STREET_2, &c_street_2, 21);
	memcpy(&c_primdata.C_CITY, &c_city, 21);
	memcpy(&c_primdata.C_STATE, &c_state, 3);
	memcpy(&c_primdata.C_ZIP, &c_zip, 10);
	memcpy(&c_primdata.C_PHONE, &c_phone, 17);
	memcpy(&c_primdata.C_DATA, &c_data, 501);
	memcpy(&c_primdata.C_CREDIT, &c_credit, 3);
	
	memcpy(c_primdata.C_CREDIT, &c_credit, 3);	
	c_primdata.C_DISCOUNT = c_discount;
	c_primdata.C_BALANCE = c_balance;

	memset(&key, 0, sizeof(DBT));
	key.data = &c_key;
	key.size = sizeof(CUSTOMER_PRIMARY_KEY);

	memset(&data, 0, sizeof(DBT));
	data.data = &c_primdata;
	data.size = sizeof(CUSTOMER_PRIMARY_DATA);
	
	if((err=dbp_customer->put(dbp_customer, 0, &key, &data, 0)))
	{
	    db_error("DB->put", err);
	    return -1;
	}
  
	h_amount = 10.0;
	MakeAlphaString(12,24,h_data);

	memset(&key, 0, sizeof(DBT));
	key.data = &h_key;
	key.size = sizeof(HISTORY_PRIMARY_KEY);
	memset(&data, 0, sizeof(DBT));

	h_key.H_C_ID = c_id;
	h_key.H_C_D_ID = c_d_id;
	h_key.H_C_W_ID = c_w_id;
	h_key.H_W_ID = c_w_id;
	h_key.H_D_ID = c_d_id;
	h_key.H_AMOUNT = h_amount;
	memcpy(&h_key.H_DATE, &timestamp, 26);
	memcpy(&h_key.H_DATA, &h_data, 24);

	if((err=dbp_history->put(dbp_history, 0, &key, &data, 0)))
	{
	    db_error("DB->put", err);
	    return -1;
	}
	
	if ( option_debug )
	    printf( "CID = %ld, LST = %s, P# = %s\n",
		    c_id, c_last, c_phone );
	if ( !(c_id % 100) ) 
	{
	    printf(".");
	    if ( !(c_id % 1000) ) printf(" %ld\n",c_id);
	}
    }  
    printf("Customer Done.\n");

  return 0;

}
예제 #12
0
payment_input_t create_payment_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf>0);

    // produce PAYMENT params according to tpcc spec v.5.9
    payment_input_t pin;

#ifndef USE_SAME_INPUT

    pin._home_wh_id  = get_wh(sf, specificWH, tspread);
    pin._home_d_id = URand(1, 10);
    pin._h_amount = (long)URand(100, 500000)/(long)100.00;
    pin._h_date = time(nullptr);

#ifndef USE_ONLY_LOCAL_WHS
    pin._v_cust_wh_selection = URand(1, 100); // 85 - 15
    if (pin._v_cust_wh_selection <= 85) {
        // all local payment
        pin._remote_wh_id = pin._home_wh_id;
        pin._remote_d_id = pin._home_d_id;
    }
    else {
        // remote warehouse
        if (sf == 1) {
            pin._remote_wh_id = 1;
        }
        else {
            // pick a remote wh (different from the home_wh)
            do {
                pin._remote_wh_id = URand(1, sf);
            } while (pin._home_wh_id == pin._remote_wh_id);
        }
        pin._remote_d_id = URand(1, 10);
    }
#else
    pin._v_cust_wh_selection = 50;
    pin._remote_wh_id = pin._home_wh_id;
    pin._remote_d_id = pin._home_d_id;
#endif


#ifdef USE_SAFE_PATHS
    pin._v_cust_ident_selection = URand(61, 100); // 60 - 40
#else
    pin._v_cust_ident_selection = URand(1, 100); // 60 - 40
#endif

    if (pin._v_cust_ident_selection <= 60) {
        // Calls the function that returns the correct cust_last
        generate_cust_last(NURand(255,0,999), pin._c_last);
    }
    else {
        pin._c_id = NURand(1023, 1, 3000);
    }

#else
    // Same input
    pin._home_wh_id = 1;
    pin._home_d_id =  2;
    pin._v_cust_wh_selection = 80;
    pin._remote_wh_id = 1;
    pin._remote_d_id =  3;
    pin._v_cust_ident_selection = 50;
    pin._c_id =  1500;
    //pin._c_last = nullptr;
    pin._h_amount = 1000.00;
    pin._h_date = time(nullptr);
#endif

    return (pin);

}; // EOF: create_payment
예제 #13
0
new_order_input_t create_new_order_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf>0);

    // produce NEW_ORDER params according to tpcc spec v.5.9
    new_order_input_t noin;

#ifndef USE_SAME_INPUT

    noin._wh_id = get_wh(sf, specificWH, tspread);
    noin._d_id   = URand(1, 10);
    noin._c_id   = NURand(1023, 1, 3000);
    noin._ol_cnt = URand(5, 15);
    noin._rbk    = URand(1, 100); // if rbk == 1 - ROLLBACK

    noin._tstamp = time(nullptr);

    // generate the items order
    for (int i=0; i<noin._ol_cnt; i++) {
        noin.items[i]._ol_i_id = NURand(8191, 1, 100000);
        noin.items[i]._ol_supply_wh_select = URand(1, 100); // 1 - 99
        noin.items[i]._ol_quantity = URand(1, 10);

#ifndef USE_ONLY_LOCAL_WHS
        if (noin.items[i]._ol_supply_wh_select == 1) {
            // remote new_order
            noin.items[i]._ol_supply_wh_id = URand(1, sf);
            if (noin.items[i]._ol_supply_wh_id != noin._wh_id)
                noin._all_local = 0; // if indeed remote WH, then update all_local flag
        }
        else {
            // home new_order
            noin.items[i]._ol_supply_wh_id = noin._wh_id;
        }
#else
        noin.items[i]._ol_supply_wh_id = noin._wh_id;
#endif
    }

#ifndef USE_NO_NORD_INPUTS_FOR_ROLLBACK
    if (noin._rbk == 1) {
        // generate an input that it will cause a rollback
        noin.items[noin._ol_cnt-1]._ol_i_id = -1;
        // TRACE( TRACE_TRX_FLOW, "Bad input...\n");
    }
#endif


#else
    // same input
    noin._wh_id  = 1;
    noin._d_id   = 2;
    noin._c_id   = 3;
    noin._ol_cnt = 10;
    noin._rbk    = 50;

    // generate the items order
    for (int i=0; i<noin._ol_cnt; i++) {
        noin.items[i]._ol_i_id = 1;
        noin.items[i]._ol_supply_wh_select = 50;
        noin.items[i]._ol_supply_wh_id = noin._wh_id; /* home new_order */
        noin.items[i]._ol_quantity = 5;
    }
#endif

    return (noin);

}; // EOF: create_new_order
예제 #14
0
void tpcc_wl::init_tab_cust(uint64_t did, uint64_t wid) {
	assert(g_cust_per_dist >= 1000);
	for (UInt32 cid = 1; cid <= g_cust_per_dist; cid++) {
		row_t * row;
		uint64_t row_id;
		t_customer->get_new_row(row, 0, row_id);
		row->set_primary_key(cid);

		row->set_value(C_ID, cid);		
		row->set_value(C_D_ID, did);
		row->set_value(C_W_ID, wid);
		char c_last[LASTNAME_LEN];
		if (cid <= 1000)
			Lastname(cid - 1, c_last);
		else
			Lastname(NURand(255,0,999), c_last);
		row->set_value(C_LAST, c_last);
#if !TPCC_SMALL
		char * tmp = "OE";
		row->set_value(C_MIDDLE, tmp);
		char c_first[FIRSTNAME_LEN];
		MakeAlphaString(FIRSTNAME_MINLEN, sizeof(c_first), c_first);
		row->set_value(C_FIRST, c_first);
		char street[20];
        MakeAlphaString(10, 20, street);
		row->set_value(C_STREET_1, street);
        MakeAlphaString(10, 20, street);
		row->set_value(C_STREET_2, street);
        MakeAlphaString(10, 20, street);
		row->set_value(C_CITY, street); 
		char state[2];
		MakeAlphaString(2, 2, state); /* State */
		row->set_value(C_STATE, state);
		char zip[9];
    	MakeNumberString(9, 9, zip); /* Zip */
		row->set_value(C_ZIP, zip);
		char phone[16];
  		MakeNumberString(16, 16, phone); /* Zip */
		row->set_value(C_PHONE, phone);
		row->set_value(C_SINCE, 0);
		row->set_value(C_CREDIT_LIM, 50000);
		row->set_value(C_DELIVERY_CNT, 0);
		char c_data[500];
        MakeAlphaString(300, 500, c_data);
		row->set_value(C_DATA, c_data);

#endif
		if (RAND(10) == 0) {
			char tmp[] = "GC";
			row->set_value(C_CREDIT, tmp);
		} else {
			char tmp[] = "BC";
			row->set_value(C_CREDIT, tmp);
		}
		row->set_value(C_DISCOUNT, (double)RAND(5000) / 10000);
		row->set_value(C_BALANCE, -10.0);
		row->set_value(C_YTD_PAYMENT, 10.0);
		row->set_value(C_PAYMENT_CNT, 1);
		uint64_t key;
		key = custNPKey(c_last, did, wid);
		index_insert(i_customer_last, key, row, wh_to_part(wid));
		key = custKey(cid, did, wid);
		index_insert(i_customer_id, key, row, wh_to_part(wid));
	}
}