|
@@ -1,5 +1,6 @@
|
|
package com.tzld.piaoquan.ad.engine.service.predict.container;
|
|
package com.tzld.piaoquan.ad.engine.service.predict.container;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.aliyun.odps.Instance;
|
|
import com.aliyun.odps.Instance;
|
|
import com.aliyun.odps.Odps;
|
|
import com.aliyun.odps.Odps;
|
|
import com.aliyun.odps.OdpsException;
|
|
import com.aliyun.odps.OdpsException;
|
|
@@ -25,7 +26,7 @@ public class TopOneVideoContainer {
|
|
@Value("${ad.odps.access.id:LTAIWYUujJAm7CbH}")
|
|
@Value("${ad.odps.access.id:LTAIWYUujJAm7CbH}")
|
|
public String odpsAccessId;
|
|
public String odpsAccessId;
|
|
@Value("${ad.odps.access.key:RfSjdiWwED1sGFlsjXv0DlfTnZTG1P}")
|
|
@Value("${ad.odps.access.key:RfSjdiWwED1sGFlsjXv0DlfTnZTG1P}")
|
|
- public String odpsAAccessKey;
|
|
|
|
|
|
+ public String odpsAccessKey;
|
|
@Value("${ad.odps.endpoint:http://service.cn.maxcompute.aliyun.com/api}")
|
|
@Value("${ad.odps.endpoint:http://service.cn.maxcompute.aliyun.com/api}")
|
|
public String odpsEndpoint;
|
|
public String odpsEndpoint;
|
|
public static final String sqlExp="select * from top_return_videolist_hh where dt={dt};";
|
|
public static final String sqlExp="select * from top_return_videolist_hh where dt={dt};";
|
|
@@ -51,7 +52,7 @@ public class TopOneVideoContainer {
|
|
}, delay, 60 * 60 * 1000);
|
|
}, delay, 60 * 60 * 1000);
|
|
}
|
|
}
|
|
public void refreshTopVideoIdCache(){
|
|
public void refreshTopVideoIdCache(){
|
|
- Account account = new AliyunAccount(odpsAccessId, odpsAAccessKey);
|
|
|
|
|
|
+ Account account = new AliyunAccount(odpsAccessId, odpsAccessKey);
|
|
Odps odps = new Odps(account);
|
|
Odps odps = new Odps(account);
|
|
odps.setEndpoint(odpsEndpoint);
|
|
odps.setEndpoint(odpsEndpoint);
|
|
odps.setDefaultProject("loghubods");
|
|
odps.setDefaultProject("loghubods");
|
|
@@ -92,4 +93,30 @@ public class TopOneVideoContainer {
|
|
long delay = (secondsUntilNextHour + secondsUntilNextQuarterHour) * 1000;
|
|
long delay = (secondsUntilNextHour + secondsUntilNextQuarterHour) * 1000;
|
|
return delay;
|
|
return delay;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args){
|
|
|
|
+ Account account = new AliyunAccount("LTAIWYUujJAm7CbH", "RfSjdiWwED1sGFlsjXv0DlfTnZTG1P");
|
|
|
|
+ Odps odps = new Odps(account);
|
|
|
|
+ odps.setEndpoint("http://service.cn.maxcompute.aliyun.com/api");
|
|
|
|
+ odps.setDefaultProject("loghubods");
|
|
|
|
+ List<Record> recordList=new ArrayList<>();
|
|
|
|
+ Instance i;
|
|
|
|
+ try {
|
|
|
|
+ i = SQLTask.run(odps, sqlExp.replace("{dt}", DateUtils.getCurrentDateStr("yyyyMMddHH")));
|
|
|
|
+ i.waitForSuccess();
|
|
|
|
+ recordList = SQLTask.getResult(i);
|
|
|
|
+ } catch (OdpsException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ Map<Long,List<Long>> tempMap=new HashMap<>();
|
|
|
|
+ for(Record record:recordList){
|
|
|
|
+ List<Long> idList=tempMap.getOrDefault(Long.parseLong(record.get("apptype").toString()),new ArrayList<>());
|
|
|
|
+ if(idList.size()==0){
|
|
|
|
+ tempMap.put(Long.parseLong(record.get("apptype").toString()),idList);
|
|
|
|
+ }
|
|
|
|
+ idList.add(Long.parseLong(record.get("videoid").toString()));
|
|
|
|
+ }
|
|
|
|
+ System.out.println(JSONObject.toJSONString(tempMap));
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|