Ver código fonte

feat:redis store optimize

zhaohaipeng 6 dias atrás
pai
commit
c336252e2c

+ 2 - 9
recommend-server-service/src/main/java/com/tzld/piaoquan/recommend/server/service/FeatureService.java

@@ -414,22 +414,15 @@ public class FeatureService {
                 Map<String, String> colMap = JSONUtils.fromJson(value, new TypeToken<Map<String, String>>() {
                 }, Collections.emptyMap());
 
-                Map<String, String> featureMap = new HashMap<>();
-                if (Boolean.TRUE.equals(featureServiceOptimizeSwtich)) {
-                    featureMap = colMap;
-                } else {
-                    featureMap = JSONUtils.fromJson(colMap.get("feature"), new TypeToken<Map<String, String>>() {
-                    }, Collections.emptyMap());
-                }
                 switch (prefix) {
                     case "v":
                         String vid = uk[2];
                         Map<String, Map<String, String>> tableFeatureMap = feature.getVideoFeature().getOrDefault(vid, new HashMap<>());
-                        tableFeatureMap.put(table, featureMap);
+                        tableFeatureMap.put(table, colMap);
                         feature.getVideoFeature().put(vid, tableFeatureMap);
                         break;
                     case "u":
-                        feature.getUserFeature().put(table, featureMap);
+                        feature.getUserFeature().put(table, colMap);
                         break;
                     default:
                         break;

+ 27 - 22
recommend-server-service/src/test/java/com/tzld/piaoquan/recommend/server/service/FeatureServiceTest.java

@@ -1,22 +1,27 @@
-package com.tzld.piaoquan.recommend.server.service;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-public class FeatureServiceTest {
-
-    @Autowired
-    private FeatureService featureService;
-
-    @Test
-    public void featureV3OptimizeTest() {
-
-        // List<FeatureKeyProto> protos = new ArrayList<>();
-        // protos.add(featureService.genWithKeyMap("alg_videoid_feature", "10035427", ImmutableMap.of("videoid", "68781839")));
-        //
-        // System.out.println(featureService.getFeatureByProto(protos));
-    }
-
-}
+// package com.tzld.piaoquan.recommend.server.service;
+//
+// import com.google.common.collect.ImmutableMap;
+// import com.tzld.piaoquan.recommend.feature.model.feature.FeatureKeyProto;
+// import org.junit.jupiter.api.Test;
+// import org.springframework.beans.factory.annotation.Autowired;
+// import org.springframework.boot.test.context.SpringBootTest;
+//
+// import java.util.ArrayList;
+// import java.util.List;
+//
+// @SpringBootTest
+// public class FeatureServiceTest {
+//
+//     @Autowired
+//     private FeatureService featureService;
+//
+//     @Test
+//     public void featureV3OptimizeTest() {
+//
+//         List<FeatureKeyProto> protos = new ArrayList<>();
+//         protos.add(featureService.genWithKeyMap("alg_videoid_feature", "10035427", ImmutableMap.of("videoid", "68781839")));
+//
+//         System.out.println(featureService.getFeatureByProto(protos));
+//     }
+//
+// }