Beispiel #1
0
void tpcc_wl::init_tab_dist(uint64_t wid) {
	for (uint64_t did = 1; did <= DIST_PER_WARE; did++) {
		row_t * row;
		uint64_t row_id;
		t_district->get_new_row(row, 0, row_id);
		row->set_primary_key(did);
		
		row->set_value(D_ID, did);
		row->set_value(D_W_ID, wid);
		char name[10];
		MakeAlphaString(6, 10, name, wid-1);
		row->set_value(D_NAME, name);
		char street[20];
        MakeAlphaString(10, 20, street, wid-1);
		row->set_value(D_STREET_1, street);
        MakeAlphaString(10, 20, street, wid-1);
		row->set_value(D_STREET_2, street);
        MakeAlphaString(10, 20, street, wid-1);
		row->set_value(D_CITY, street);
		char state[2];
		MakeAlphaString(2, 2, state, wid-1); /* State */
		row->set_value(D_STATE, state);
		char zip[9];
    	MakeNumberString(9, 9, zip, wid-1); /* Zip */
		row->set_value(D_ZIP, zip);
    	double tax = (double)URand(0L,200L,wid-1)/1000.0;
    	double w_ytd=30000.00;
		row->set_value(D_TAX, tax);
		row->set_value(D_YTD, w_ytd);
		row->set_value(D_NEXT_O_ID, 3001);
		
		index_insert(i_district, distKey(did, wid), row, wh_to_part(wid));
	}
}
Beispiel #2
0
void tpcc_wl::init_tab_wh(uint32_t wid) {
	assert(wid >= 1 && wid <= g_num_wh);
	row_t * row;
	uint64_t row_id;
	t_warehouse->get_new_row(row, 0, row_id);
	row->set_primary_key(wid);

	row->set_value(W_ID, wid);
	char name[10];
    MakeAlphaString(6, 10, name, wid-1);
	row->set_value(W_NAME, name);
	char street[20];
    MakeAlphaString(10, 20, street, wid-1);
	row->set_value(W_STREET_1, street);
    MakeAlphaString(10, 20, street, wid-1);
	row->set_value(W_STREET_2, street);
    MakeAlphaString(10, 20, street, wid-1);
	row->set_value(W_CITY, street);
	char state[2];
	MakeAlphaString(2, 2, state, wid-1); /* State */
	row->set_value(W_STATE, state);
	char zip[9];
   	MakeNumberString(9, 9, zip, wid-1); /* Zip */
	row->set_value(W_ZIP, zip);
   	double tax = (double)URand(0L,200L,wid-1)/1000.0;
   	double w_ytd=300000.00;
	row->set_value(W_TAX, tax);
	row->set_value(W_YTD, w_ytd);
	
	index_insert(i_warehouse, wid, row, wh_to_part(wid));
	return;
}
Beispiel #3
0
void
URandFillStrNumbx(char* dest, const int sz)
{
    assert (dest);
    for (int i=0; i<sz; i++) {
        dest[i] = NUMBERS_CHAR_ARRAY[URand(0,sizeof(NUMBERS_CHAR_ARRAY)-1)];
    }
}
Beispiel #4
0
update_input_t create_update_input(int sf, int specificPrefix, int tspread)
{
    update_input_t input;
    input.key = get_key(sf, specificPrefix, tspread);
    input.field_number = URand(1, 10);
    fill_value(input.value);
    return input;
}
Beispiel #5
0
static void gen_cid_array(int* cid_array) {
    for(int i=0; i < ORDERS_PER_DIST; i++)
	cid_array[i] = i+1;
    for(int i=0; i < ORDERS_PER_DIST; i++) {
	std::swap(cid_array[i], cid_array[i+URand(0,ORDERS_PER_DIST-i-1)]);
                  //sthread_t::randn(ORDERS_PER_DIST-i)]);
    }
}
Beispiel #6
0
void
URandFillStrCaps(char* dest, const int sz)
{
    assert (dest);
    for (int i=0; i<sz; i++) {
        dest[i] = CAPS_CHAR_ARRAY[URand(0,sizeof(CAPS_CHAR_ARRAY)-1)];
    }
}
Beispiel #7
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;

}
Beispiel #8
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
Beispiel #9
0
void ShoreYCSBEnv::start_load_imbalance()
{
    if(y_skewer.is_used()) {
	_change_load = false;
	y_skewer.reset(_skew_type);
    }
    if(_skew_type != SKEW_CHAOTIC || URand(1,100) > 30) {
	_change_load = true;
    }
    ShoreEnv::start_load_imbalance();
}
Beispiel #10
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);
	}
}
Beispiel #11
0
/********************************************************************
 *
 *  @fn:    start_load_imbalance()
 *
 *  @brief: sets the flag that triggers load imbalance for TPC-C
 *          resets the intervals if necessary (depending on the skew type)
 *
 ********************************************************************/
void ShoreTPCCEnv::start_load_imbalance()
{
    if(w_skewer.is_used()) {
	_change_load = false;
	// for warehouses
	w_skewer.reset(_skew_type);
    }
    if(_skew_type != SKEW_CHAOTIC || URand(1,100) > 30) {
	_change_load = true;
    }
    ShoreEnv::start_load_imbalance();
}
Beispiel #12
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;
}
Beispiel #13
0
int get_wh(int sf, int specificWH, int tspread)
{
    int wh = _change_load ? w_skewer.get_input() : URand(1, sf);
    if (specificWH > 0) {
        w_assert0(tspread > 0);
        w_assert0(specificWH <= tspread);
        wh = (wh / tspread) * tspread + specificWH;
        if (wh > sf) { wh -= tspread; }
        w_assert0(wh <= sf);
        w_assert0(wh > 0);
    }
    return wh;
}
Beispiel #14
0
void tpcc_wl::init_tab_stock(uint64_t wid) {
	
	for (UInt32 sid = 1; sid <= g_max_items; sid++) {
		row_t * row;
		uint64_t row_id;
		t_stock->get_new_row(row, 0, row_id);
		row->set_primary_key(sid);
		row->set_value(S_I_ID, sid);
		row->set_value(S_W_ID, wid);
		row->set_value(S_QUANTITY, URand(10, 100));
		row->set_value(S_REMOTE_CNT, 0);
#if !TPCC_SMALL
		char s_dist[25];
		char row_name[10] = "S_DIST_";
		for (int i = 1; i <= 10; i++) {
			if (i < 10) {
				row_name[7] = '0';
				row_name[8] = i + '0';
			} else {
				row_name[7] = '1';
				row_name[8] = '0';
			}
			row_name[9] = '\0';
			MakeAlphaString(24, 24, s_dist);
			row->set_value(row_name, s_dist);
		}
		row->set_value(S_YTD, 0);
		row->set_value(S_ORDER_CNT, 0);
		char s_data[50];
		int len = MakeAlphaString(26, 50, s_data);
		if (rand() % 100 < 10) {
			int idx = URand(0, len - 8);
			strcpy(&s_data[idx], "original");
		}
		row->set_value(S_DATA, s_data);
#endif
		index_insert(i_stock, stockKey(sid, wid), row, wh_to_part(wid));
	}
}
Beispiel #15
0
// TODO ITEM table is assumed to be in partition 0
void tpcc_wl::init_tab_item() {
	for (UInt32 i = 1; i <= g_max_items; i++) {
		row_t * row;
		uint64_t row_id;
		t_item->get_new_row(row, 0, row_id);
		row->set_primary_key(i);
		row->set_value(I_ID, i);
		row->set_value(I_IM_ID, URand(1L,10000L, 0));
		char name[24];
		MakeAlphaString(14, 24, name, 0);
		row->set_value(I_NAME, name);
		row->set_value(I_PRICE, URand(1, 100, 0));
		char data[50];
    	MakeAlphaString(26, 50, data, 0);
		// TODO in TPCC, "original" should start at a random position
		if (RAND(10, 0) == 0) 
			strcpy(data, "original");		
		row->set_value(I_DATA, data);
		
		index_insert(i_item, i, row, 0);
	}
}
Beispiel #16
0
void 
tpcc_wl::init_permutation(uint64_t * perm_c_id, uint64_t wid) {
	uint32_t i;
	// Init with consecutive values
	for(i = 0; i < g_cust_per_dist; i++) 
		perm_c_id[i] = i+1;

	// shuffle
	for(i=0; i < g_cust_per_dist-1; i++) {
		uint64_t j = URand(i+1, g_cust_per_dist-1, wid-1);
		uint64_t tmp = perm_c_id[i];
		perm_c_id[i] = perm_c_id[j];
		perm_c_id[j] = tmp;
	}
}
Beispiel #17
0
// This is similar to get_wh() used in tpcc_input.cpp
uint64_t get_key(int sf, int specificPrefix, int tspread)
{
    // 10-byte key has 2 parts: prefix and user
    // - Prefix (2 bytes) is determined by the sf, like the warehouse of TPC-C
    // - User (8 bytes) is picked randomly with a uniform distribution
    // Skew only applies to the prefix. A "90-10" type of skew should use at least SF=10.
    // Within a prefix, static chunks are partitioned to worker threads just like the
    // warehouses in TPC-C, according to the tspread argument.
    int prefix = _change_load ? y_skewer.get_input() : URand(1, sf);
    if (specificPrefix > 0) {
        // If prefix is given, it is essentially the worker thread number
        w_assert1(tspread > 0);
        w_assert1(specificPrefix <= tspread);
        prefix = (prefix / tspread) * tspread + specificPrefix;
        if (prefix > sf) { prefix -= tspread; }
        w_assert1(prefix <= sf);
        w_assert1(prefix > 0);
    }
    w_assert1(prefix < std::numeric_limits<uint16_t>::max());
    uint64_t user = URand(0, RecordsPerSF-1);
    uint64_t key = (static_cast<uint64_t>(prefix) << 48) | static_cast<uint64_t>(user);
    // cout << "probing prefix " << prefix << " user " << user << " key " << key <<endl;
    return key;
}
Beispiel #18
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 );
	}
}
Beispiel #19
0
stock_level_input_t create_stock_level_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf > 0);

    // produce PAYMENT params according to tpcc spec v.5.4
    stock_level_input_t slin;

#ifndef USE_SAME_INPUT

    slin._wh_id = get_wh(sf, specificWH, tspread);
    slin._d_id      = URand(1, 10);
    slin._threshold = URand(10, 20);

#else
    // same input
    slin._wh_id     = 1;
    slin._d_id      = 2;
    slin._threshold = 15;
#endif

    return (slin);

}; // EOF: create_stock_level
Beispiel #20
0
/********************************************************************
 *
 *  @fn:    start_load_imbalance()
 *
 *  @brief: sets the flag that triggers load imbalance for TPC-B
 *          resets the intervals if necessary (depending on the skew type)
 *
 ********************************************************************/
void ShoreTPCBEnv::start_load_imbalance()
{
    if(b_skewer.is_used()) {
	_change_load = false;
	// for branches
	b_skewer.reset(_skew_type);
	// for tellers
	t_skewer.reset(_skew_type);
	// for accounts
	a_skewer.reset(_skew_type);
    }
    if(_skew_type != SKEW_CHAOTIC || URand(1,100) > 30) {
	_change_load = true;
    }
    ShoreEnv::start_load_imbalance();
}
Beispiel #21
0
void tpcc_wl::init_permutation() {
	UInt32 i;
	perm_count = 0;
	perm_c_id = new uint64_t[g_cust_per_dist];
	// Init with consecutive values
	for(i = 0; i < g_cust_per_dist; i++) {
		perm_c_id[i] = i+1;
	}

	// shuffle
	for(i=0; i < g_cust_per_dist-1; i++) {
		uint64_t j = URand(i+1, g_cust_per_dist-1);
		uint64_t tmp = perm_c_id[i];
		perm_c_id[i] = perm_c_id[j];
		perm_c_id[j] = tmp;
	}
	return;
}
Beispiel #22
0
void PPSWorkload::init_tab_supplies() {
  for (UInt32 id = 1; id <= g_max_supplier_key; id++) {
    std::set<uint64_t> parts_set;
    for (UInt32 i = 0; i < g_max_parts_per; i++) {
      parts_set.insert(URand(1,g_max_part_key));
    }
    for(auto it = parts_set.begin(); it != parts_set.end();it++) {
      row_t * row;
      uint64_t row_id;
      uint64_t part_id = *it;
      t_supplies->get_new_row(row, 0, row_id);
      row->set_primary_key(id);
      //row->set_value(SUPPLIER_KEY,id);
      //row->set_value(PART_KEY,part_id);
      row->set_value(0,id);
      row->set_value(1,part_id);
      index_insert_nonunique(i_supplies, id, row, suppliers_to_partition(id));
    }
  }

}
Beispiel #23
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);
	}
}
Beispiel #24
0
delivery_input_t create_delivery_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf > 0);

    // produce PAYMENT params according to tpcc spec v.5.9
    delivery_input_t din;

#ifndef USE_SAME_INPUT

    din._wh_id = get_wh(sf, specificWH, tspread);
    din._carrier_id = URand(1, 10);

#else
    // same input
    din._wh_id      = 1;
    din._carrier_id = 1;
#endif

    return (din);

}; // EOF: create_delivery
Beispiel #25
0
void PPSWorkload::init_tab_uses() {
  for (UInt32 id = 1; id <= g_max_product_key; id++) {
    std::set<uint64_t> parts_set;
    for (UInt32 i = 0; i < g_max_parts_per; i++) {
      parts_set.insert(URand(1,g_max_part_key));
    }
    for(auto it = parts_set.begin(); it != parts_set.end();it++) {
      row_t * row;
      uint64_t row_id;
      uint64_t part_id = *it;
      t_uses->get_new_row(row, 0, row_id);
      row->set_primary_key(id);
      //row->set_value(PRODUCT_KEY,id);
      //row->set_value(PART_KEY,part_id);
      row->set_value(0,id);
      row->set_value(1,part_id);
      index_insert_nonunique(i_uses, id, row, products_to_partition(id));
      DEBUG("USES added (%d, %ld) -- %lx\n",id,part_id,(uint64_t)row);
    }
  }

}
Beispiel #26
0
void tpcc_wl::init_tab_wh() {
	if (WL_VERB)
		printf("[init] workload table.\n");
	for (UInt32 wid = 1; wid <= g_num_wh; wid ++) {
		row_t * row;
		uint64_t row_id;
		t_warehouse->get_new_row(row, 0, row_id);
		row->set_primary_key(wid);

		row->set_value(W_ID, wid);
		char name[10];
        MakeAlphaString(6, 10, name);
		row->set_value(W_NAME, name);
		char street[20];
        MakeAlphaString(10, 20, street);
		row->set_value(W_STREET_1, street);
        MakeAlphaString(10, 20, street);
		row->set_value(W_STREET_2, street);
        MakeAlphaString(10, 20, street);
		row->set_value(W_CITY, street);
		char state[2];
		MakeAlphaString(2, 2, state); /* State */
		row->set_value(W_STATE, state);
		char zip[9];
    	MakeNumberString(9, 9, zip); /* Zip */
		row->set_value(W_ZIP, zip);
    	double tax = (double)URand(0L,200L)/1000.0;
    	double w_ytd=300000.00;
		row->set_value(W_TAX, tax);
		row->set_value(W_YTD, w_ytd);

		index_insert(i_warehouse, wid, row, wh_to_part(wid));
	}
	
	return;
}
Beispiel #27
0
rc_t ShoreYCSBEnv::run_one_xct(Request* prequest)
{
    assert (prequest);

    if(_start_imbalance > 0 && !_bAlarmSet) {
	CRITICAL_SECTION(alarm_cs, _alarm_lock);
	if(!_bAlarmSet) {
	    alarm(_start_imbalance);
	    _bAlarmSet = true;
	}
    }

    // Only one xct type for now
    prequest->set_type(XCT_YCSB_SIMPLE);

    switch (prequest->type()) {
    case XCT_YCSB_SIMPLE:
        if (URand(1,100) <= _update_freq) { return (run_update(prequest)); }
        else { return (run_read(prequest)); }
     default:
	 assert (0); // UNKNOWN TRX-ID
     }
    return (RCOK);
}
Beispiel #28
0
bool
URandBool()
{
    return (URand(0,1) ? true : false);
}
Beispiel #29
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
Beispiel #30
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