void InsertTuple(storage::DataTable *table, common::VarlenPool *pool, oid_t tilegroup_count_per_loader, UNUSED_ATTRIBUTE uint64_t thread_itr) { auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); oid_t tuple_count = tilegroup_count_per_loader * TEST_TUPLES_PER_TILEGROUP; // Start a txn for each insert auto txn = txn_manager.BeginTransaction(); std::unique_ptr<storage::Tuple> tuple( ExecutorTestsUtil::GetTuple(table, ++loader_tuple_id, pool)); std::unique_ptr<executor::ExecutorContext> context( new executor::ExecutorContext(txn)); auto project_info = MakeProjectInfoFromTuple(tuple.get()); planner::InsertPlan node(table, std::move(project_info)); // Insert the desired # of tuples for (oid_t tuple_itr = 0; tuple_itr < tuple_count; tuple_itr++) { executor::InsertExecutor executor(&node, context.get()); executor.Execute(); } txn_manager.CommitTransaction(txn); }
void InsertTuple(storage::DataTable *table, VarlenPool *pool) { auto &txn_manager = concurrency::OptimisticTxnManager::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr<executor::ExecutorContext> context( new executor::ExecutorContext(txn)); for (oid_t tuple_itr = 0; tuple_itr < 10; tuple_itr++) { auto tuple = ExecutorTestsUtil::GetTuple(table, ++tuple_id, pool); auto project_info = MakeProjectInfoFromTuple(tuple); planner::InsertPlan node(table, project_info); executor::InsertExecutor executor(&node, context.get()); executor.Execute(); delete tuple; } txn_manager.CommitTransaction(); }
bool TransactionTestsUtil::ExecuteInsert(concurrency::Transaction *transaction, storage::DataTable *table, int id, int value) { std::unique_ptr<executor::ExecutorContext> context( new executor::ExecutorContext(transaction)); // Make tuple std::unique_ptr<storage::Tuple> tuple( new storage::Tuple(table->GetSchema(), true)); auto testing_pool = TestingHarness::GetInstance().GetTestingPool(); tuple->SetValue(0, ValueFactory::GetIntegerValue(id), testing_pool); tuple->SetValue(1, ValueFactory::GetIntegerValue(value), testing_pool); std::unique_ptr<const planner::ProjectInfo> project_info{ MakeProjectInfoFromTuple(tuple.get())}; // Insert planner::InsertPlan node(table, std::move(project_info)); executor::InsertExecutor executor(&node, context.get()); return executor.Execute(); }
bool ConstraintsTestsUtil::ExecuteInsert(concurrency::Transaction *transaction, storage::DataTable *table, const Value &col1, const Value &col2, const Value &col3, const Value &col4) { std::unique_ptr<executor::ExecutorContext> context( new executor::ExecutorContext(transaction)); // Make tuple std::unique_ptr<storage::Tuple> tuple( new storage::Tuple(table->GetSchema(), true)); auto testing_pool = TestingHarness::GetInstance().GetTestingPool(); tuple->SetValue(0, col1, testing_pool); tuple->SetValue(1, col2, testing_pool); tuple->SetValue(2, col3, testing_pool); tuple->SetValue(3, col4, testing_pool); auto project_info = MakeProjectInfoFromTuple(tuple.get()); // Insert planner::InsertPlan node(table, std::move(project_info)); executor::InsertExecutor executor(&node, context.get()); return executor.Execute(); }
TEST_F(MutateTests, StressTests) { auto &txn_manager = concurrency::OptimisticTxnManager::GetInstance(); auto txn = txn_manager.BeginTransaction(); std::unique_ptr<executor::ExecutorContext> context( new executor::ExecutorContext(txn)); auto testing_pool = TestingHarness::GetInstance().GetTestingPool(); // Create insert node for this test. storage::DataTable *table = ExecutorTestsUtil::CreateTable(); // Pass through insert executor. storage::Tuple *tuple; tuple = ExecutorTestsUtil::GetNullTuple(table, testing_pool); auto project_info = MakeProjectInfoFromTuple(tuple); planner::InsertPlan node(table, project_info); executor::InsertExecutor executor(&node, context.get()); try { executor.Execute(); } catch (ConstraintException &ce) { LOG_ERROR("%s", ce.what()); } delete tuple; tuple = ExecutorTestsUtil::GetTuple(table, ++tuple_id, testing_pool); project_info = MakeProjectInfoFromTuple(tuple); planner::InsertPlan node2(table, project_info); executor::InsertExecutor executor2(&node2, context.get()); executor2.Execute(); try { executor2.Execute(); } catch (ConstraintException &ce) { LOG_ERROR("%s", ce.what()); } delete tuple; txn_manager.CommitTransaction(); LaunchParallelTest(1, InsertTuple, table, testing_pool); LOG_TRACE(table->GetInfo().c_str()); LOG_INFO("---------------------------------------------"); // LaunchParallelTest(1, UpdateTuple, table); // LOG_TRACE(table->GetInfo().c_str()); LOG_INFO("---------------------------------------------"); LaunchParallelTest(1, DeleteTuple, table); LOG_TRACE(table->GetInfo().c_str()); // PRIMARY KEY std::vector<catalog::Column> columns; columns.push_back(ExecutorTestsUtil::GetColumnInfo(0)); catalog::Schema *key_schema = new catalog::Schema(columns); storage::Tuple *key1 = new storage::Tuple(key_schema, true); storage::Tuple *key2 = new storage::Tuple(key_schema, true); key1->SetValue(0, ValueFactory::GetIntegerValue(10), nullptr); key2->SetValue(0, ValueFactory::GetIntegerValue(100), nullptr); delete key1; delete key2; delete key_schema; // SEC KEY columns.clear(); columns.push_back(ExecutorTestsUtil::GetColumnInfo(0)); columns.push_back(ExecutorTestsUtil::GetColumnInfo(1)); key_schema = new catalog::Schema(columns); storage::Tuple *key3 = new storage::Tuple(key_schema, true); storage::Tuple *key4 = new storage::Tuple(key_schema, true); key3->SetValue(0, ValueFactory::GetIntegerValue(10), nullptr); key3->SetValue(1, ValueFactory::GetIntegerValue(11), nullptr); key4->SetValue(0, ValueFactory::GetIntegerValue(100), nullptr); key4->SetValue(1, ValueFactory::GetIntegerValue(101), nullptr); delete key3; delete key4; delete key_schema; delete table; tuple_id = 0; }