//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.AdItemFeature;
//import com.tzld.piaoquan.ad.engine.commons.base.UserAdFeature;
//
//
//import java.util.HashMap;
//import java.util.Map;
//
//public class AdRedisFeatureConstructor {
//
//    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 UserAdFeature constructUserFeature(Record record) {
//        UserAdFeature userFeature = new UserAdFeature();
//        userFeature.setMid(record.getString("mids"));
//
//        // 1day features
//        AdActionFeature userAd1dayActionFeature = new AdActionFeature();
//        userAd1dayActionFeature.setOriginAdView(record.getString("ad_view_1day"));
//        userAd1dayActionFeature.setOriginAdClick(record.getString("ad_click_1day"));
//        userAd1dayActionFeature.setOriginAdConversion(record.getString("ad_conversion_1day"));
//        userAd1dayActionFeature.setOriginCtr(record.getString("ad_ctr_1day"));
//        userAd1dayActionFeature.setOriginCvr(record.getString("ad_cvr_1day"));
//        userFeature.setDay1_cnt_features(userAd1dayActionFeature);
//
//
//        // 3day features
//        AdActionFeature userAd3dayActionFeature = new AdActionFeature();
//        userAd1dayActionFeature.setOriginAdView(record.getString("ad_view_3day"));
//        userAd1dayActionFeature.setOriginAdClick(record.getString("ad_click_3day"));
//        userAd1dayActionFeature.setOriginAdConversion(record.getString("ad_conversion_3day"));
//        userAd1dayActionFeature.setOriginCtr(record.getString("ad_ctr_3day"));
//        userAd1dayActionFeature.setOriginCvr(record.getString("ad_cvr_3day"));
//        userFeature.setDay3_cnt_features(userAd3dayActionFeature);
//
//
//        // 7day features
//        AdActionFeature userAd7dayActionFeature = new AdActionFeature();
//        userAd1dayActionFeature.setOriginAdView(record.getString("ad_view_7day"));
//        userAd1dayActionFeature.setOriginAdClick(record.getString("ad_click7day"));
//        userAd1dayActionFeature.setOriginAdConversion(record.getString("ad_conversion_7day"));
//        userAd1dayActionFeature.setOriginCtr(record.getString("ad_ctr_7day"));
//        userAd1dayActionFeature.setOriginCvr(record.getString("ad_cvr_7day"));
//        userFeature.setDay7_cnt_features(userAd7dayActionFeature);
//
//
//        // 3month features
//        AdActionFeature userAd3MonthActionFeature = new AdActionFeature();
//        userAd3MonthActionFeature.setOriginAdView(record.getString("ad_view_3month"));
//        userAd3MonthActionFeature.setOriginAdClick(record.getString("ad_click_3month"));
//        userAd3MonthActionFeature.setOriginAdConversion(record.getString("ad_conversion_3month"));
//        userAd3MonthActionFeature.setOriginCtr(record.getString("ad_ctr_3month"));
//        userAd3MonthActionFeature.setOriginCvr(record.getString("ad_cvr_3month"));
//        userFeature.setMonth3_cnt_features(userAd3MonthActionFeature);
//
//
//        return userFeature;
//    }
//
//
//    public static AdItemFeature constructItemFeature(Record record) {
//        AdItemFeature itemFeature = new AdItemFeature();
//        itemFeature.setAdId(record.getString("creativeid"));
//        // itemFeature.setAdCode(record.getString("adcode"));
//        itemFeature.setCampaignId(record.getString("campaignid"));
//        itemFeature.setAdvertiserId(record.getString("advertiserid"));
//        itemFeature.setCreativeId(record.getString("creativeid"));
//
//        // ad 维度特征
//        AdActionFeature adIdActionFeature1day = new AdActionFeature();
//        adIdActionFeature1day.setOriginAdView(record.getString("view_ad_1day"));
//        adIdActionFeature1day.setOriginAdClick(record.getString("click_ad_1day"));
//        adIdActionFeature1day.setOriginAdConversion(record.getString("conversion_ad_1day"));
//        adIdActionFeature1day.setOriginCtr(record.getString("ctr_ad_1day"));
//        adIdActionFeature1day.setOriginCvr(record.getString("cvr_ad_1day"));
//        itemFeature.setDay1_cnt_features(adIdActionFeature1day);
//
//        AdActionFeature adIdActionFeature3day = new AdActionFeature();
//        adIdActionFeature3day.setOriginAdView(record.getString("view_ad_3day"));
//        adIdActionFeature3day.setOriginAdClick(record.getString("click_ad_3day"));
//        adIdActionFeature3day.setOriginAdConversion(record.getString("conversion_ad_3day"));
//        adIdActionFeature3day.setOriginCtr(record.getString("ctr_ad_3day"));
//        adIdActionFeature3day.setOriginCvr(record.getString("cvr_ad_3day"));
//        itemFeature.setDay3_cnt_features(adIdActionFeature3day);
//
//        AdActionFeature adIdActionFeature7day = new AdActionFeature();
//        adIdActionFeature7day.setOriginAdView(record.getString("view_ad_7day"));
//        adIdActionFeature7day.setOriginAdClick(record.getString("click_ad_7day"));
//        adIdActionFeature7day.setOriginAdConversion(record.getString("conversion_ad_7day"));
//        adIdActionFeature7day.setOriginCtr(record.getString("ctr_ad_7day"));
//        adIdActionFeature7day.setOriginCvr(record.getString("cvr_ad_7day"));
//        itemFeature.setDay7_cnt_features(adIdActionFeature7day);
//
//        AdActionFeature adIdActionFeature3month = new AdActionFeature();
//        adIdActionFeature3month.setOriginAdView(record.getString("view_ad_3month"));
//        adIdActionFeature3month.setOriginAdClick(record.getString("click_ad_3month"));
//        adIdActionFeature3month.setOriginAdConversion(record.getString("conversion_ad_3month"));
//        adIdActionFeature3month.setOriginCtr(record.getString("ctr_ad_3month"));
//        adIdActionFeature3month.setOriginCvr(record.getString("cvr_ad_3month"));
//        itemFeature.setMonth3_cnt_features(adIdActionFeature3month);
//
//        // TODO creativeId等维度特征
//        // creative 维度特征
//        AdActionFeature creativeActionFeature1day = new AdActionFeature();
//        creativeActionFeature1day.setOriginAdView(record.getString("view_creative_1day"));
//        creativeActionFeature1day.setOriginAdClick(record.getString("click_creative_1day"));
//        creativeActionFeature1day.setOriginAdConversion(record.getString("conversion_creative_1day"));
//        creativeActionFeature1day.setOriginCtr(record.getString("ctr_creative_1day"));
//        creativeActionFeature1day.setOriginCvr(record.getString("cvr_creative_1day"));
//        itemFeature.setCreative_1day_cnt_features(creativeActionFeature1day);
//
//        AdActionFeature creativeActionFeature3day = new AdActionFeature();
//        creativeActionFeature3day.setOriginAdView(record.getString("view_creative_3day"));
//        creativeActionFeature3day.setOriginAdClick(record.getString("click_creative_3day"));
//        creativeActionFeature3day.setOriginAdConversion(record.getString("conversion_creative_3day"));
//        creativeActionFeature3day.setOriginCtr(record.getString("ctr_creative_3day"));
//        creativeActionFeature3day.setOriginCvr(record.getString("cvr_creative_3day"));
//        itemFeature.setCreative_3day_cnt_features(creativeActionFeature3day);
//
//        AdActionFeature creativeActionFeature7day = new AdActionFeature();
//        creativeActionFeature7day.setOriginAdView(record.getString("view_creative_7day"));
//        creativeActionFeature7day.setOriginAdClick(record.getString("click_creative_7day"));
//        creativeActionFeature7day.setOriginAdConversion(record.getString("conversion_creative_7day"));
//        creativeActionFeature7day.setOriginCtr(record.getString("ctr_creative_7day"));
//        creativeActionFeature7day.setOriginCvr(record.getString("cvr_creative_7day"));
//        itemFeature.setCreative_7day_cnt_features(creativeActionFeature7day);
//
//
//        AdActionFeature creativeActionFeature3month = new AdActionFeature();
//        creativeActionFeature3month.setOriginAdView(record.getString("view_creative_3month"));
//        creativeActionFeature3month.setOriginAdClick(record.getString("click_creative_3month"));
//        creativeActionFeature3month.setOriginAdConversion(record.getString("conversion_creative_3month"));
//        creativeActionFeature3month.setOriginCtr(record.getString("ctr_creative_3month"));
//        creativeActionFeature3month.setOriginCvr(record.getString("cvr_creative_3month"));
//        itemFeature.setCreative_3month_cnt_features(creativeActionFeature3month);
//
//
//
//        // TODO advertiser维度
//        // advertiser 维度特征
//        AdActionFeature advidActionFeature1day = new AdActionFeature();
//        advidActionFeature1day.setOriginAdView(record.getString("view_advertiser_1day"));
//        advidActionFeature1day.setOriginAdClick(record.getString("click_advertiser_1day"));
//        advidActionFeature1day.setOriginAdConversion(record.getString("conversion_advertiser_1day"));
//        advidActionFeature1day.setOriginCtr(record.getString("ctr_advertiser_1day"));
//        advidActionFeature1day.setOriginCvr(record.getString("cvr_advertiser_1day"));
//        itemFeature.setAdvertiser_1day_cnt_features(advidActionFeature1day);
//
//        AdActionFeature advidActionFeature3day = new AdActionFeature();
//        advidActionFeature3day.setOriginAdView(record.getString("view_advertiser_3day"));
//        advidActionFeature3day.setOriginAdClick(record.getString("click_advertiser_3day"));
//        advidActionFeature3day.setOriginAdConversion(record.getString("conversion_advertiser_3day"));
//        advidActionFeature3day.setOriginCtr(record.getString("ctr_advertiser_3day"));
//        advidActionFeature3day.setOriginCvr(record.getString("cvr_advertiser_3day"));
//        itemFeature.setAdvertiser_3day_cnt_features(advidActionFeature3day);
//
//        AdActionFeature advidActionFeature7day = new AdActionFeature();
//        advidActionFeature7day.setOriginAdView(record.getString("view_advertiser_7day"));
//        advidActionFeature7day.setOriginAdClick(record.getString("click_advertiser_7day"));
//        advidActionFeature7day.setOriginAdConversion(record.getString("conversion_advertiser_7day"));
//        advidActionFeature7day.setOriginCtr(record.getString("ctr_advertiser_7day"));
//        advidActionFeature7day.setOriginCvr(record.getString("cvr_advertiser_7day"));
//        itemFeature.setAdvertiser_7day_cnt_features(advidActionFeature7day);
//
//
//        AdActionFeature advidActionFeature3month = new AdActionFeature();
//        advidActionFeature3month.setOriginAdView(record.getString("view_advertiser_3month"));
//        advidActionFeature3month.setOriginAdClick(record.getString("click_advertiser_3month"));
//        advidActionFeature3month.setOriginAdConversion(record.getString("conversion_advertiser_3month"));
//        advidActionFeature3month.setOriginCtr(record.getString("ctr_advertiser_3month"));
//        advidActionFeature3month.setOriginCvr(record.getString("cvr_advertiser_3month"));
//        itemFeature.setAdvertiser_3month_cnt_features(advidActionFeature3month);
//
//
//
//        return itemFeature;
//    }
//
//
//}
