| 
					
				 | 
			
			
				@@ -3,10 +3,12 @@ package com.tzld.piaoquan.recommend.server.dataloader; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.aliyun.odps.data.Record; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.aliyun.odps.tunnel.io.TunnelRecordReader; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.common.ThreadPoolFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.tzld.piaoquan.recommend.server.common.base.ItemFeature; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.tzld.piaoquan.recommend.server.common.base.UserFeature; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.tzld.piaoquan.recommend.server.common.base.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.data.redis.connection.RedisStandaloneConfiguration; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.redis.core.RedisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.data.redis.serializer.StringRedisSerializer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Component; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.IOException; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -15,15 +17,28 @@ import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.concurrent.ExecutorService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-@Component 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class ItemFeatureToRedisLoader { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private RedisTemplate<String, String> redisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final String videoKeyFormat = "video:%s"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ExecutorService pool = ThreadPoolFactory.defaultPool(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static RedisTemplate<String, String> buildRedisTemplate() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RedisStandaloneConfiguration rsc = new RedisStandaloneConfiguration(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        rsc.setPort(6379); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        rsc.setPassword("Wqsd@2019"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        rsc.setHostName("r-bp1ps6my7lzg8rdhwx682.redis.rds.aliyuncs.com"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RedisTemplate<String, String> template = new RedisTemplate<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        JedisConnectionFactory fac = new JedisConnectionFactory(rsc); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        fac.afterPropertiesSet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        template.setDefaultSerializer(new StringRedisSerializer()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        template.setConnectionFactory(fac); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        template.afterPropertiesSet(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return template; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void loadFeatureToRedis(String table, String dt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RedisTemplate<String, String> redisTemplate = buildRedisTemplate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String sql = String.format("select * from %s where dt ='%s';", table, dt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         TunnelRecordReader reader = FeatureConstructor.loadDataFromOSSSession(sql, table, dt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Record record; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -35,12 +50,14 @@ public class ItemFeatureToRedisLoader { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 String key = String.format(videoKeyFormat, itemFeature.getKey()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 String value = itemFeature.getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 userFeaRedisFormat.put(key, value); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (count < 10000) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (count < 200) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     count++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else if (count == 10000) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else if (count == 200) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     redisTemplate.opsForValue().multiSet(userFeaRedisFormat); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    System.out.println("------succes add 2000-----"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     userFeaRedisFormat = new HashMap<String, String>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     count = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (IOException e) { 
			 |