@@ -32,7 +32,8 @@ namespace test {
3232// PELOTON CODEGEN TEST
3333// ===----------------------------------------------------------------------===//
3434
35- PelotonCodeGenTest::PelotonCodeGenTest (oid_t tuples_per_tilegroup) {
35+ PelotonCodeGenTest::PelotonCodeGenTest (oid_t tuples_per_tilegroup,
36+ peloton::LayoutType layout_type) {
3637 auto *catalog = catalog::Catalog::GetInstance ();
3738 auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance ();
3839 auto txn = txn_manager.BeginTransaction ();
@@ -41,9 +42,10 @@ PelotonCodeGenTest::PelotonCodeGenTest(oid_t tuples_per_tilegroup) {
4142 catalog->CreateDatabase (test_db_name, txn);
4243 test_db = catalog->GetDatabaseWithName (test_db_name, txn);
4344 // Create test table
44- CreateTestTables (txn, tuples_per_tilegroup);
45+ CreateTestTables (txn, tuples_per_tilegroup, layout_type );
4546
4647 txn_manager.CommitTransaction (txn);
48+ layout_table = nullptr ;
4749}
4850
4951PelotonCodeGenTest::~PelotonCodeGenTest () {
@@ -103,13 +105,14 @@ std::unique_ptr<catalog::Schema> PelotonCodeGenTest::CreateTestSchema(
103105
104106// Create all the test tables, but don't load any data
105107void PelotonCodeGenTest::CreateTestTables (concurrency::TransactionContext *txn,
106- oid_t tuples_per_tilegroup) {
108+ oid_t tuples_per_tilegroup,
109+ peloton::LayoutType layout_type) {
107110 auto *catalog = catalog::Catalog::GetInstance ();
108111 for (int i = 0 ; i < 4 ; i++) {
109112 auto table_schema = CreateTestSchema ();
110113 catalog->CreateTable (test_db_name, DEFAULT_SCHEMA_NAME, test_table_names[i],
111114 std::move (table_schema), txn, false ,
112- tuples_per_tilegroup);
115+ tuples_per_tilegroup, layout_type );
113116 test_table_oids.push_back (catalog
114117 ->GetTableObject (test_db_name,
115118 DEFAULT_SCHEMA_NAME,
@@ -120,7 +123,7 @@ void PelotonCodeGenTest::CreateTestTables(concurrency::TransactionContext *txn,
120123 auto table_schema = CreateTestSchema (true );
121124 catalog->CreateTable (test_db_name, DEFAULT_SCHEMA_NAME, test_table_names[i],
122125 std::move (table_schema), txn, false ,
123- tuples_per_tilegroup);
126+ tuples_per_tilegroup, layout_type );
124127 test_table_oids.push_back (catalog
125128 ->GetTableObject (test_db_name,
126129 DEFAULT_SCHEMA_NAME,
@@ -175,6 +178,80 @@ void PelotonCodeGenTest::LoadTestTable(oid_t table_id, uint32_t num_rows,
175178 txn_manager.CommitTransaction (txn);
176179}
177180
181+ void PelotonCodeGenTest::CreateAndLoadTableWithLayout (
182+ peloton::LayoutType layout_type, oid_t tuples_per_tilegroup,
183+ oid_t tile_group_count, oid_t column_count, bool is_inlined) {
184+ oid_t tuple_count = tuples_per_tilegroup * tile_group_count;
185+ // ///////////////////////////////////////////////////////
186+ // Define the schema.
187+ // ///////////////////////////////////////////////////////
188+
189+ std::vector<catalog::Column> columns;
190+
191+ for (oid_t col_itr = 0 ; col_itr <= column_count; col_itr++) {
192+ auto column = catalog::Column (
193+ type::TypeId::INTEGER, type::Type::GetTypeSize (type::TypeId::INTEGER),
194+ " FIELD" + std::to_string (col_itr), is_inlined);
195+
196+ columns.push_back (column);
197+ }
198+
199+ std::unique_ptr<catalog::Schema> table_schema =
200+ std::unique_ptr<catalog::Schema>(new catalog::Schema (columns));
201+ std::string table_name (" LAYOUT_TABLE" );
202+
203+ // ///////////////////////////////////////////////////////
204+ // Create table.
205+ // ///////////////////////////////////////////////////////
206+
207+ bool is_catalog = false ;
208+ auto *catalog = catalog::Catalog::GetInstance ();
209+ auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance ();
210+ const bool allocate = true ;
211+ auto txn = txn_manager.BeginTransaction ();
212+
213+ // Insert table in catalog
214+ catalog->CreateTable (test_db_name, DEFAULT_SCHEMA_NAME, table_name,
215+ std::move (table_schema), txn, is_catalog,
216+ tuples_per_tilegroup, layout_type);
217+ // Get table reference
218+ layout_table = catalog->GetTableWithName (test_db_name, DEFAULT_SCHEMA_NAME,
219+ table_name, txn);
220+ txn_manager.EndTransaction (txn);
221+
222+ // ///////////////////////////////////////////////////////
223+ // Load in the data
224+ // ///////////////////////////////////////////////////////
225+
226+ // Insert tuples into tile_group.
227+
228+ txn = txn_manager.BeginTransaction ();
229+ auto table_schema_ptr = layout_table->GetSchema ();
230+ auto testing_pool = TestingHarness::GetInstance ().GetTestingPool ();
231+
232+ for (oid_t row_id = 0 ; row_id < tuple_count; row_id++) {
233+ int populate_value = row_id;
234+
235+ storage::Tuple tuple (table_schema_ptr, allocate);
236+
237+ for (oid_t col_id = 0 ; col_id <= column_count; col_id++) {
238+ auto value = type::ValueFactory::GetIntegerValue (populate_value + col_id);
239+ tuple.SetValue (col_id, value, testing_pool);
240+ }
241+
242+ ItemPointer *index_entry_ptr = nullptr ;
243+ ItemPointer tuple_slot_id =
244+ layout_table->InsertTuple (&tuple, txn, &index_entry_ptr);
245+
246+ EXPECT_TRUE (tuple_slot_id.block != INVALID_OID);
247+ EXPECT_TRUE (tuple_slot_id.offset != INVALID_OID);
248+
249+ txn_manager.PerformInsert (txn, tuple_slot_id, index_entry_ptr);
250+ }
251+
252+ txn_manager.CommitTransaction (txn);
253+ }
254+
178255void PelotonCodeGenTest::ExecuteSync (
179256 codegen::Query &query,
180257 std::unique_ptr<executor::ExecutorContext> executor_context,
0 commit comments