@@ -102,38 +102,38 @@ void RuntimeFunctions::FillPredicateArray(
102102// to skip over to find successive values of the column.
103103// ===----------------------------------------------------------------------===//
104104void RuntimeFunctions::GetTileGroupLayout (const storage::TileGroup *tile_group,
105- const catalog::Schema *schema,
106105 ColumnLayoutInfo *infos,
107106 uint32_t num_cols) {
108107 const auto &layout = tile_group->GetLayout ();
109- // For LayoutType::ROW, the tile group contains a single tile
110- // and all the columns are in the same order as the table schema.
111- if (layout.IsRowStore ()) {
112- auto tuple_location = tile_group->GetTile (0 )->GetTupleLocation (0 );
113- auto stride = schema->GetLength ();
114- for (uint32_t col_idx = 0 ; col_idx < num_cols; col_idx++) {
115- infos[col_idx].column = tuple_location + schema->GetOffset (col_idx);
116- infos[col_idx].stride = stride;
117- infos[col_idx].is_columnar = false ;
118- }
119- return ;
120- }
121- for (uint32_t col_idx = 0 ; col_idx < num_cols; col_idx++) {
122- // Map the current column to a tile and a column offset in the tile
123- oid_t tile_offset, tile_column_offset;
124- layout.LocateTileAndColumn (col_idx, tile_offset, tile_column_offset);
108+ UNUSED_ATTRIBUTE oid_t last_col_idx = INVALID_OID;
125109
126- // Now grab the column information
127- auto *tile = tile_group->GetTile (tile_offset);
128- auto *tile_schema = tile->GetSchema ();
129- infos[col_idx].column =
130- tile->GetTupleLocation (0 ) + tile_schema->GetOffset (tile_column_offset);
131- infos[col_idx].stride = tile_schema->GetLength ();
132- infos[col_idx].is_columnar = tile_schema->GetColumnCount () == 1 ;
133- LOG_TRACE (" Col [%u] start: %p, stride: %u, columnar: %s" , col_idx,
134- infos[col_idx].column , infos[col_idx].stride ,
135- infos[col_idx].is_columnar ? " true" : " false" );
110+ auto tile_map = layout.GetTileMap ();
111+ // Find the mapping for each tile in the layout.
112+ for (auto tile_entry : tile_map) {
113+ // Get the tile schema.
114+ auto tile_idx = tile_entry.first ;
115+ auto *tile = tile_group->GetTile (tile_idx);
116+ auto tile_schema = tile->GetSchema ();
117+ // Map the current column to a tile and a column offset in the tile.
118+ for (auto column_entry : tile_entry.second ) {
119+ // Now grab the column information
120+ oid_t col_idx = column_entry.first ;
121+ oid_t tile_col_offset = column_entry.second ;
122+ // Ensure that the col_idx is within the num_cols range
123+ PELOTON_ASSERT (col_idx < num_cols);
124+ infos[col_idx].column =
125+ tile->GetTupleLocation (0 ) + tile_schema->GetOffset (tile_col_offset);
126+ infos[col_idx].stride = tile_schema->GetLength ();
127+ infos[col_idx].is_columnar = tile_schema->GetColumnCount () == 1 ;
128+ last_col_idx = col_idx;
129+ LOG_TRACE (" Col [%u] start: %p, stride: %u, columnar: %s" , col_idx,
130+ infos[col_idx].column , infos[col_idx].stride ,
131+ infos[col_idx].is_columnar ? " true" : " false" );
132+ }
136133 }
134+ // Ensure that ColumnLayoutInfo for each column has been populated.
135+ PELOTON_ASSERT ((last_col_idx != INVALID_OID) &&
136+ (last_col_idx == (num_cols - 1 )));
137137}
138138
139139void RuntimeFunctions::ThrowDivideByZeroException () {
0 commit comments