//package examples.dataloader;
//
//
//import com.aliyun.odps.account.Account;
//import com.aliyun.odps.account.AliyunAccount;
//import com.aliyun.odps.data.Record;
//import com.tzld.piaoquan.ad.engine.commons.base.AdActionFeature;
//import com.tzld.piaoquan.ad.engine.commons.base.AdRequestContext;
//import com.tzld.piaoquan.ad.engine.commons.base.UserAdFeature;
//import com.tzld.piaoquan.ad.engine.commons.base.AdItemFeature;
//
//
//import java.util.HashMap;
//import java.util.Map;
//
//public class AdSampleConstructor {
//
//    private static final String BUCKET_NAME = "ali-recommend";
//    private static final Map<String, String> ODPS_CONFIG = new HashMap<String, String>();
//
//    static {
//        ODPS_CONFIG.put("ENDPOINT", "http://service.cn.maxcompute.aliyun.com/api");
//        ODPS_CONFIG.put("ACCESSID", "LTAIWYUujJAm7CbH");
//        ODPS_CONFIG.put("ACCESSKEY", "RfSjdiWwED1sGFlsjXv0DlfTnZTG1P");
//    }
//
//    private static final Account account = new AliyunAccount(ODPS_CONFIG.get("ACCESSID"), ODPS_CONFIG.get("ACCESSKEY"));
//
//
//    public static AdRequestContext constructRequestContext(Record record) {
//        AdRequestContext requestContext = new AdRequestContext();
//        requestContext.setApptype(record.getString("apptype"));
//        requestContext.setMachineinfoBrand(record.getString("machineinfo_brand"));
//        requestContext.setMachineinfoModel(record.getString("machineinfo_model"));
//        requestContext.setMachineinfoSdkversion(record.getString("machineinfo_sdkversion"));
//        requestContext.setMachineinfoWchatversion(record.getString("machineinfo_wechatversion"));
//
//
//        requestContext.setDay(record.getString("ctx_day"));
//        requestContext.setWeek(record.getString("ctx_week"));
//        requestContext.setHour(record.getString("ctx_hour"));
//        requestContext.setRegion(record.getString("province"));
//        requestContext.setCity(record.getString("city"));
//        return requestContext;
//    }
//
//
//    public static UserAdFeature constructUserFeature(Record record) {
//        UserAdFeature userFeature = new UserAdFeature();
//        userFeature.setMid(record.get("machinecode").toString());
//
//        // 1day features
//        AdActionFeature user1dayActionFeature = new AdActionFeature();
//        user1dayActionFeature.setAdView(record.getString("user_view_1day"));
//        user1dayActionFeature.setAdClick(record.getString("user_click_1day"));
//        user1dayActionFeature.setAdConversion(record.getString("user_conversion_1day"));
//        user1dayActionFeature.setCtr(record.getString("user_ctr_1day"));
//        user1dayActionFeature.setCvr(record.getString("user_cvr_1day"));
//        userFeature.setDay1_cnt_features(user1dayActionFeature);
//
//        // 3day features
//        AdActionFeature user3dayActionFeature = new AdActionFeature();
//        user3dayActionFeature.setAdView(record.getString("user_view_3day"));
//        user3dayActionFeature.setAdClick(record.getString("user_click_3day"));
//        user3dayActionFeature.setAdConversion(record.getString("user_conversion_3day"));
//        user3dayActionFeature.setCtr(record.getString("user_ctr_3day"));
//        user3dayActionFeature.setCvr(record.getString("user_cvr_3day"));
//        userFeature.setDay3_cnt_features(user3dayActionFeature);
//
//
//        // 7day features
//        AdActionFeature user7dayActionFeature = new AdActionFeature();
//        user7dayActionFeature.setAdView(record.getString("user_view_7day"));
//        user7dayActionFeature.setAdClick(record.getString("user_click7day"));
//        user7dayActionFeature.setAdConversion(record.getString("user_conversion_7day"));
//        user7dayActionFeature.setCtr(record.getString("user_ctr_7day"));
//        user7dayActionFeature.setCvr(record.getString("user_cvr_7day"));
//        userFeature.setDay7_cnt_features(user7dayActionFeature);
//
//        // 3month features
//        AdActionFeature user3MonthActionFeature = new AdActionFeature();
//        user3MonthActionFeature.setAdView(record.getString("user_view_3month"));
//        user3MonthActionFeature.setAdClick(record.getString("user_click_3month"));
//        user3MonthActionFeature.setAdConversion(record.getString("user_conversion_3month"));
//        user3MonthActionFeature.setCtr(record.getString("user_ctr_3month"));
//        user3MonthActionFeature.setCvr(record.getString("user_cvr_3month"));
//        userFeature.setMonth3_cnt_features(user3MonthActionFeature);
//
//        return userFeature;
//    }
//
//
//    public static AdItemFeature constructItemFeature(Record record) {
//        AdItemFeature itemFeature = new AdItemFeature();
//
//
//        itemFeature.setAdId(record.getString("adid"));
//        // itemFeature.setAdCode(record.getString("adcode"));
//        itemFeature.setAdvertiserId(record.getString("advertiserid"));
//        itemFeature.setCampaignId(record.getString("campaignid"));
//        itemFeature.setCreativeId(record.getString("creativeid"));
//
//        // 1day features
//        AdActionFeature user1dayActionFeature = new AdActionFeature();
//        user1dayActionFeature.setAdView(record.getString("ad_view_1day"));
//        user1dayActionFeature.setAdClick(record.getString("ad_click_1day"));
//        user1dayActionFeature.setAdConversion(record.getString("ad_conversion_1day"));
//        user1dayActionFeature.setCtr(record.getString("ad_ctr_1day"));
//        user1dayActionFeature.setCvr(record.getString("ad_cvr_1day"));
//        itemFeature.setDay1_cnt_features(user1dayActionFeature);
//
//        // 3day features
//        AdActionFeature user3dayActionFeature = new AdActionFeature();
//        user3dayActionFeature.setAdView(record.getString("ad_view_3day"));
//        user3dayActionFeature.setAdClick(record.getString("ad_click_3day"));
//        user3dayActionFeature.setAdConversion(record.getString("ad_conversion_3day"));
//        user3dayActionFeature.setCtr(record.getString("ad_ctr_3day"));
//        user3dayActionFeature.setCvr(record.getString("ad_cvr_3day"));
//        itemFeature.setDay3_cnt_features(user3dayActionFeature);
//
//
//        // 7day features
//        AdActionFeature user7dayActionFeature = new AdActionFeature();
//        user7dayActionFeature.setAdView(record.getString("ad_view_7day"));
//        user7dayActionFeature.setAdClick(record.getString("ad_click_7day"));
//        user7dayActionFeature.setAdConversion(record.getString("ad_conversion_7day"));
//        user7dayActionFeature.setCtr(record.getString("ad_ctr_7day"));
//        user7dayActionFeature.setCvr(record.getString("ad_cvr_7day"));
//        itemFeature.setDay7_cnt_features(user7dayActionFeature);
//
//        // 3month features
//        AdActionFeature user3MonthActionFeature = new AdActionFeature();
//        user3MonthActionFeature.setAdView(record.getString("ad_view_3month"));
//        user3MonthActionFeature.setAdClick(record.getString("ad_click_3month"));
//        user3MonthActionFeature.setAdConversion(record.getString("ad_conversion_3month"));
//        user3MonthActionFeature.setCtr(record.getString("ad_ctr_3month"));
//        user3MonthActionFeature.setCvr(record.getString("ad_cvr_3month"));
//        itemFeature.setMonth3_cnt_features(user3MonthActionFeature);
//
//
//        //TODO  CREATIVE 维度  需要在样本中补齐
//        AdActionFeature creative1dayFeature = new AdActionFeature();
//        creative1dayFeature.setAdView(record.getString("view_creative_1day"));
//        creative1dayFeature.setAdClick(record.getString("click_creative_1day"));
//        creative1dayFeature.setAdConversion(record.getString("conversion_creative_1day"));
//        creative1dayFeature.setCtr(record.getString("ctr_creative_1day"));
//        creative1dayFeature.setCvr(record.getString("cvr_creative_1day"));
//        itemFeature.setCreative_1day_cnt_features(creative1dayFeature);
//
//        // 3day features
//        AdActionFeature creative3dayFeature = new AdActionFeature();
//        creative3dayFeature.setAdView(record.getString("view_creative_3day"));
//        creative3dayFeature.setAdClick(record.getString("click_creative_3day"));
//        creative3dayFeature.setAdConversion(record.getString("conversion_creative_3day"));
//        creative3dayFeature.setCtr(record.getString("ctr_creative_3day"));
//        creative3dayFeature.setCvr(record.getString("cvr_creative_3day"));
//        itemFeature.setCreative_3day_cnt_features(creative3dayFeature);
//
//
//        // 7day features
//        AdActionFeature creative7dayFeature = new AdActionFeature();
//        creative7dayFeature.setAdView(record.getString("view_creative_7day"));
//        creative7dayFeature.setAdClick(record.getString("click_creative_7day"));
//        creative7dayFeature.setAdConversion(record.getString("conversion_creative_7day"));
//        creative7dayFeature.setCtr(record.getString("ctr_creative_7day"));
//        creative7dayFeature.setCvr(record.getString("cvr_creative_7day"));
//        itemFeature.setCreative_7day_cnt_features(creative7dayFeature);
//
//        // 3month features
//        AdActionFeature creative3MonthFeature = new AdActionFeature();
//        creative3MonthFeature.setAdView(record.getString("view_creative_3month"));
//        creative3MonthFeature.setAdClick(record.getString("click_creative_3month"));
//        creative3MonthFeature.setAdConversion(record.getString("conversion_creative_3month"));
//        creative3MonthFeature.setCtr(record.getString("ctr_creative_3month"));
//        creative3MonthFeature.setCvr(record.getString("cvr_creative_3month"));
//        itemFeature.setCreative_3month_cnt_features(creative3MonthFeature);
//
//
//        // advertiser id
//        // 1day features
//        AdActionFeature advertiser1dayFeature = new AdActionFeature();
//        advertiser1dayFeature.setAdView(record.getString("advertiser_view_1day"));
//        advertiser1dayFeature.setAdClick(record.getString("advertiser_click_1day"));
//        advertiser1dayFeature.setAdConversion(record.getString("advertiser_conversion_1day"));
//        advertiser1dayFeature.setCtr(record.getString("advertiser_ctr_1day"));
//        advertiser1dayFeature.setCvr(record.getString("advertiser_cvr_1day"));
//        itemFeature.setAdvertiser_1day_cnt_features(advertiser1dayFeature);
//
//        // 3day features
//        AdActionFeature advertiser3dayFeature = new AdActionFeature();
//        advertiser3dayFeature.setAdView(record.getString("advertiser_view_3day"));
//        advertiser3dayFeature.setAdClick(record.getString("advertiser_click_3day"));
//        advertiser3dayFeature.setAdConversion(record.getString("advertiser_conversion_3day"));
//        advertiser3dayFeature.setCtr(record.getString("advertiser_ctr_3day"));
//        advertiser3dayFeature.setCvr(record.getString("advertiser_cvr_3day"));
//        itemFeature.setAdvertiser_3day_cnt_features(advertiser3dayFeature);
//
//
//        // 7day features
//        AdActionFeature advertiser7dayFeature = new AdActionFeature();
//        advertiser7dayFeature.setAdView(record.getString("advertiser_view_7day"));
//        advertiser7dayFeature.setAdClick(record.getString("advertiser_click_7day"));
//        advertiser7dayFeature.setAdConversion(record.getString("advertiser_conversion_7day"));
//        advertiser7dayFeature.setCtr(record.getString("advertiser_ctr_7day"));
//        advertiser7dayFeature.setCvr(record.getString("advertiser_cvr_7day"));
//        itemFeature.setAdvertiser_7day_cnt_features(advertiser7dayFeature);
//
//        // 3month features
//        AdActionFeature advertiser3monthFeature = new AdActionFeature();
//        advertiser3monthFeature.setAdView(record.getString("advertiser_view_3month"));
//        advertiser3monthFeature.setAdClick(record.getString("advertiser_view_3month"));
//        advertiser3monthFeature.setAdConversion(record.getString("advertiser_conversion_3month"));
//        advertiser3monthFeature.setCtr(record.getString("advertiser_ctr_3month"));
//        advertiser3monthFeature.setCvr(record.getString("advertiser_cvr_3month"));
//        itemFeature.setAdvertiser_3month_cnt_features(advertiser3monthFeature);
//
//
//
//        return itemFeature;
//    }
//
//
//}
