// ############################################## } END_PIE BEGIN_PIE(TPCC_DELIVERY, TPCC_DELIVERY_3, // W customer DF_REAL) { Log::debug("TPCC_DELIVERY, piece: %d", TPCC_DELIVERY_3); verify(input_size == 4); i32 oi = 0; Value buf; mdb::Txn *txn = DTxnMgr::get_sole_mgr()->get_mdb_txn(header); mdb::Row *r = NULL; mdb::MultiBlob mb(3); //cell_locator_t cl(TPCC_TB_CUSTOMER, 3); mb[0] = input[0].get_blob(); mb[1] = input[2].get_blob(); mb[2] = input[1].get_blob(); if (!(IS_MODE_RCC || IS_MODE_RO6) || ((IS_MODE_RCC || IS_MODE_RO6) && IN_PHASE_1)) { // non-rcc || rcc start request r = txn->query(txn->get_table(TPCC_TB_CUSTOMER), mb, output_size, header.pid).next(); } TPL_KISS( mdb::column_lock_t(r, 16, ALock::WLOCK), mdb::column_lock_t(r, 19, ALock::WLOCK) ); RCC_KISS(r, 16, false); RCC_KISS(r, 19, false); RCC_SAVE_ROW(r, TPCC_DELIVERY_3); RCC_PHASE1_RET; RCC_LOAD_ROW(r, TPCC_DELIVERY_3); txn->read_column(r, 16, &buf); buf.set_double(buf.get_double() + input[3].get_double()); txn->write_column(r, 16, buf); txn->read_column(r, 19, &buf); buf.set_i32(buf.get_i32() + (i32) 1); txn->write_column(r, 19, buf); // ############################################## verify(*output_size >= oi); *res = SUCCESS; Log::debug("TPCC_DELIVERY, piece: %d end", TPCC_DELIVERY_3); // ############################################## *output_size = oi; } END_PIE
// ############################################################ } END_PIE BEGIN_PIE(TPCC_PAYMENT, // txn TPCC_PAYMENT_2, // piece 1, Ri & W district DF_REAL) { // ############################################################ verify(input_size == 3); Log::debug("TPCC_PAYMENT, piece: %d", TPCC_PAYMENT_2); i32 output_index = 0; // ############################################################ Value buf; mdb::Row *r = NULL; mdb::MultiBlob mb(2); //cell_locator_t cl(TPCC_TB_DISTRICT, 2); mb[0] = input[1].get_blob(); mb[1] = input[0].get_blob(); if (!(IS_MODE_RCC || IS_MODE_RO6) || ((IS_MODE_RCC || IS_MODE_RO6) && IN_PHASE_1)) { // non-rcc || rcc start request r = dtxn->query(dtxn->get_table(TPCC_TB_DISTRICT), mb, output_size, header.pid).next(); verify(r->schema_ != nullptr); } TPL_KISS(mdb::column_lock_t(r, 9, ALock::WLOCK)); RCC_KISS(r, 9, false); RCC_SAVE_ROW(r, TPCC_PAYMENT_2); RCC_PHASE1_RET; RCC_LOAD_ROW(r, TPCC_PAYMENT_2); verify(r->schema_ != nullptr); dtxn->read_column(r, 9, &buf); // W district buf.set_double(buf.get_double() + input[2].get_double()); dtxn->write_column(r, 9, buf); // ############################################################ verify(*output_size >= output_index); *output_size = output_index; *res = SUCCESS; Log::debug("TPCC_PAYMENT, piece: %d end", TPCC_PAYMENT_2); // ############################################################ } END_PIE
}END_PIE BEGIN_PIE(TPCC_STOCK_LEVEL, TPCC_STOCK_LEVEL_2, // R stock DF_NO) { verify(row_map == NULL); verify(input_size == 3); i32 output_index = 0; Value buf; mdb::MultiBlob mb(2); //cell_locator_t cl(TPCC_TB_STOCK, 2); mb[0] = input[0].get_blob(); mb[1] = input[1].get_blob(); mdb::Row *r = dtxn->query(dtxn->get_table(TPCC_TB_STOCK), mb, output_size, header.pid).next(); TPL_KISS(mdb::column_lock_t(r, 2, ALock::RLOCK)); if ((IS_MODE_RCC || IS_MODE_RO6) && IN_PHASE_1) { ((RCCDTxn *) dtxn)->kiss(r, 2, false); } if (RO6_RO_PHASE_1) return; if (!dtxn->read_column(r, 2, &buf)) { *res = REJECT; *output_size = output_index; return; } if (buf.get_i32() < input[2].get_i32()) output[output_index++] = Value((i32) 1); else output[output_index++] = Value((i32) 0); verify(*output_size >= output_index); *output_size = output_index; *res = SUCCESS; }END_PIE
// ############################################################ } END_PIE BEGIN_PIE(TPCC_PAYMENT, // txn TPCC_PAYMENT_4, // piece 4, R & W customer DF_REAL) { // ############################################################ verify(input_size == 6); Log::debug("TPCC_PAYMENT, piece: %d", TPCC_PAYMENT_4); i32 output_index = 0; // ############################################################ mdb::Row *r = NULL; std::vector<Value> buf; mdb::MultiBlob mb(3); //cell_locator_t cl(TPCC_TB_CUSTOMER, 3); mb[0] = input[0].get_blob(); mb[1] = input[2].get_blob(); mb[2] = input[1].get_blob(); // R customer if (!(IS_MODE_RCC || IS_MODE_RO6) || ((IS_MODE_RCC || IS_MODE_RO6) && IN_PHASE_1)) { // non-rcc || rcc start request r = dtxn->query(dtxn->get_table(TPCC_TB_CUSTOMER), mb, output_size, header.pid).next(); } ALock::type_t lock_20_type = ALock::RLOCK; if (input[0].get_i32() % 10 == 0) lock_20_type = ALock::WLOCK; // ############################################################ TPL_KISS( mdb::column_lock_t(r, 3, ALock::RLOCK), mdb::column_lock_t(r, 4, ALock::RLOCK), mdb::column_lock_t(r, 5, ALock::RLOCK), mdb::column_lock_t(r, 6, ALock::RLOCK), mdb::column_lock_t(r, 7, ALock::RLOCK), mdb::column_lock_t(r, 8, ALock::RLOCK), mdb::column_lock_t(r, 9, ALock::RLOCK), mdb::column_lock_t(r, 10, ALock::RLOCK), mdb::column_lock_t(r, 11, ALock::RLOCK), mdb::column_lock_t(r, 12, ALock::RLOCK), mdb::column_lock_t(r, 13, ALock::RLOCK), mdb::column_lock_t(r, 14, ALock::RLOCK), mdb::column_lock_t(r, 15, ALock::RLOCK), mdb::column_lock_t(r, 16, ALock::WLOCK), mdb::column_lock_t(r, 17, ALock::WLOCK), mdb::column_lock_t(r, 20, lock_20_type) ) // ############################################################ RCC_KISS(r, 16, false); RCC_KISS(r, 17, false); RCC_KISS(r, 20, false); RCC_SAVE_ROW(r, TPCC_PAYMENT_4); RCC_PHASE1_RET; RCC_LOAD_ROW(r, TPCC_PAYMENT_4); if (!dtxn->read_columns(r, std::vector<mdb::column_id_t>({ 3, // c_first buf[0] 4, // c_middle buf[1] 5, // c_last buf[2] 6, // c_street_1 buf[3] 7, // c_street_2 buf[4] 8, // c_city buf[5] 9, // c_state buf[6] 10, // c_zip buf[7] 11, // c_phone buf[8] 12, // c_since buf[9] 13, // c_credit buf[10] 14, // c_credit_lim buf[11] 15, // c_discount buf[12] 16, // c_balance buf[13] 17, // c_ytd_payment buf[14] 20 // c_data buf[15] }), &buf)) { *res = REJECT; *output_size = output_index; return; } // if c_credit == "BC" (bad) 10% // here we use c_id to pick up 10% instead of c_credit if (input[0].get_i32() % 10 == 0) { Value c_data(( to_string(input[0]) + to_string(input[2]) + to_string(input[1]) + to_string(input[5]) + to_string(input[4]) + to_string(input[3]) + buf[15].get_str() ).substr(0, 500)); std::vector<mdb::column_id_t> col_ids({ 16, // c_balance 17, // c_ytd_payment 20 // c_data }); std::vector<Value> col_data({ Value(buf[13].get_double() - input[3].get_double()), Value(buf[14].get_double() + input[3].get_double()), c_data }); dtxn->write_columns(r, col_ids, col_data); } else { std::vector<mdb::column_id_t> col_ids({ 16, // c_balance 17 // c_ytd_payment }); std::vector<Value> col_data({ Value(buf[13].get_double() - input[3].get_double()), Value(buf[14].get_double() + input[3].get_double()) }); dtxn->write_columns(r, col_ids, col_data); } output[output_index++] = input[0]; // output[0] => c_id output[output_index++] = buf[0]; // output[1] => c_first output[output_index++] = buf[1]; // output[2] => c_middle output[output_index++] = buf[2]; // output[3] => c_last output[output_index++] = buf[3]; // output[4] => c_street_1 output[output_index++] = buf[4]; // output[5] => c_street_2 output[output_index++] = buf[5]; // output[6] => c_city output[output_index++] = buf[6]; // output[7] => c_state output[output_index++] = buf[7]; // output[8] => c_zip output[output_index++] = buf[8]; // output[9] => c_phone output[output_index++] = buf[9]; // output[10] => c_since output[output_index++] = buf[10]; // output[11] => c_credit output[output_index++] = buf[11]; // output[12] => c_credit_lim output[output_index++] = buf[12]; // output[13] => c_discount output[output_index++] = Value(buf[13].get_double() - input[3].get_double()); // output[14] => c_balance // ############################################################ verify(*output_size >= output_index); *res = SUCCESS; Log::debug("TPCC_PAYMENT, piece: %d end", TPCC_PAYMENT_4); // ############################################################ *output_size = output_index; } END_PIE