示例#1
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
示例#2
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