|  | @@ -1,46 +1,32 @@
 | 
											
												
													
														|  |  package com.tzld.piaoquan.recommend.server.dataloader;
 |  |  package com.tzld.piaoquan.recommend.server.dataloader;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -import com.aliyun.odps.Instance;
 |  | 
 | 
											
												
													
														|  | -import com.aliyun.odps.Odps;
 |  | 
 | 
											
												
													
														|  | -import com.aliyun.odps.OdpsException;
 |  | 
 | 
											
												
													
														|  | -import com.aliyun.odps.account.Account;
 |  | 
 | 
											
												
													
														|  | -import com.aliyun.odps.account.AliyunAccount;
 |  | 
 | 
											
												
													
														|  |  import com.aliyun.odps.data.Record;
 |  |  import com.aliyun.odps.data.Record;
 | 
											
												
													
														|  | -import com.aliyun.odps.task.SQLTask;
 |  | 
 | 
											
												
													
														|  |  import com.aliyun.odps.tunnel.io.TunnelRecordReader;
 |  |  import com.aliyun.odps.tunnel.io.TunnelRecordReader;
 | 
											
												
													
														|  | -import com.google.common.collect.ListMultimap;
 |  | 
 | 
											
												
													
														|  |  import com.tzld.piaoquan.recommend.server.common.ThreadPoolFactory;
 |  |  import com.tzld.piaoquan.recommend.server.common.ThreadPoolFactory;
 | 
											
												
													
														|  |  import com.tzld.piaoquan.recommend.server.common.base.*;
 |  |  import com.tzld.piaoquan.recommend.server.common.base.*;
 | 
											
												
													
														|  | -import com.tzld.piaoquan.recommend.server.dataloader.OfflineSamplesLoader;
 |  | 
 | 
											
												
													
														|  | -import com.tzld.piaoquan.recommend.server.util.JSONUtils;
 |  | 
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Autowired;
 |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.data.redis.core.RedisTemplate;
 |  |  import org.springframework.data.redis.core.RedisTemplate;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Component;
 |  |  import org.springframework.stereotype.Component;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import java.io.IOException;
 |  |  import java.io.IOException;
 | 
											
												
													
														|  | -import java.util.ArrayList;
 |  | 
 | 
											
												
													
														|  |  import java.util.HashMap;
 |  |  import java.util.HashMap;
 | 
											
												
													
														|  | -import java.util.List;
 |  | 
 | 
											
												
													
														|  |  import java.util.Map;
 |  |  import java.util.Map;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import java.util.concurrent.ExecutorService;
 |  |  import java.util.concurrent.ExecutorService;
 | 
											
												
													
														|  | -import java.util.concurrent.Executors;
 |  | 
 | 
											
												
													
														|  | -import java.util.stream.Collectors;
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  @Component
 |  |  @Component
 | 
											
												
													
														|  | -public class FeatureToRedisLoader {
 |  | 
 | 
											
												
													
														|  | 
 |  | +public class UserFeatureToRedisLoader {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private RedisTemplate<String, String> redisTemplate;
 |  |      private RedisTemplate<String, String> redisTemplate;
 | 
											
												
													
														|  |      private final String userKeyFormat = "user:%s";
 |  |      private final String userKeyFormat = "user:%s";
 | 
											
												
													
														|  | -    private final String videoKeyFormat = "video:%s";
 |  | 
 | 
											
												
													
														|  |      private ExecutorService pool = ThreadPoolFactory.defaultPool();
 |  |      private ExecutorService pool = ThreadPoolFactory.defaultPool();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |      public void loadFeatureToRedis(String userTable, String dt) {
 |  |      public void loadFeatureToRedis(String userTable, String dt) {
 | 
											
												
													
														|  | -        TunnelRecordReader reader = FeatureConstructor.loadDataFromOSSSession(userTable, dt);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        String sql = String.format("select * from %s where dt ='%s';", userTable, dt);
 | 
											
												
													
														|  | 
 |  | +        TunnelRecordReader reader = FeatureConstructor.loadDataFromOSSSession(sql, userTable, dt);
 | 
											
												
													
														|  |          Record record;
 |  |          Record record;
 | 
											
												
													
														|  |          Map<String, String> userFeaRedisFormat = new HashMap<String, String>();
 |  |          Map<String, String> userFeaRedisFormat = new HashMap<String, String>();
 | 
											
												
													
														|  |          int count = 0;
 |  |          int count = 0;
 | 
											
										
											
												
													
														|  | @@ -64,8 +50,14 @@ public class FeatureToRedisLoader {
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    public static void main(String[] args) {
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +    public static void main(String[] args) {
 | 
											
												
													
														|  | 
 |  | +        if(args.length < 2){
 | 
											
												
													
														|  | 
 |  | +            System.out.println("--------args 缺失---------");
 | 
											
												
													
														|  | 
 |  | +            return;
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        UserFeatureToRedisLoader userFeatureToRedisLoader = new UserFeatureToRedisLoader();
 | 
											
												
													
														|  | 
 |  | +        userFeatureToRedisLoader.loadFeatureToRedis(args[0], args[1]);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  }
 |  |  }
 |