// Generate a scan over all tile groups. // // @code // column_layouts := alloca<peloton::ColumnLayoutInfo>( // table.GetSchema().GetColumnCount()) // // oid_t tile_group_idx := 0 // num_tile_groups = GetTileGroupCount(table_ptr) // // for (; tile_group_idx < num_tile_groups; ++tile_group_idx) { // tile_group_ptr := GetTileGroup(table_ptr, tile_group_idx) // consumer.TileGroupStart(tile_group_ptr); // tile_group.TidScan(tile_group_ptr, column_layouts, vector_size, consumer); // consumer.TileGroupEnd(tile_group_ptr); // } // // @endcode void Table::GenerateScan(CodeGen &codegen, llvm::Value *table_ptr, uint32_t batch_size, ScanCallback &consumer) const { // First get the columns from the table the consumer needs. For every column, // we'll need to have a ColumnInfoLayout struct const uint32_t num_columns = static_cast<uint32_t>(table_.GetSchema()->GetColumnCount()); llvm::Value *column_layouts = codegen->CreateAlloca( RuntimeFunctionsProxy::_ColumnLayoutInfo::GetType(codegen), codegen.Const32(num_columns)); // Get the number of tile groups in the given table llvm::Value *tile_group_idx = codegen.Const64(0); llvm::Value *num_tile_groups = GetTileGroupCount(codegen, table_ptr); // Iterate over all tile groups in the table lang::Loop loop{codegen, codegen->CreateICmpULT(tile_group_idx, num_tile_groups), {{"tileGroupIdx", tile_group_idx}}}; { // Get the tile group with the given tile group ID tile_group_idx = loop.GetLoopVar(0); llvm::Value *tile_group_ptr = GetTileGroup(codegen, table_ptr, tile_group_idx); llvm::Value *tile_group_id = tile_group_.GetTileGroupId(codegen, tile_group_ptr); // Invoke the consumer to let her know that we're starting to iterate over // the tile group now consumer.TileGroupStart(codegen, tile_group_id, tile_group_ptr); // Generate the scan cover over the given tile group tile_group_.GenerateTidScan(codegen, tile_group_ptr, column_layouts, batch_size, consumer); // Invoke the consumer to let her know that we're done with this tile group consumer.TileGroupFinish(codegen, tile_group_ptr); // Move to next tile group in the table tile_group_idx = codegen->CreateAdd(tile_group_idx, codegen.Const64(1)); loop.LoopEnd(codegen->CreateICmpULT(tile_group_idx, num_tile_groups), {tile_group_idx}); } }