jch 3 päivää sitten
vanhempi
commit
6c7bf4a603

+ 5 - 0
src/main/scala/com/aliyun/odps/spark/examples/myUtils/FeatureTransformV2.java

@@ -174,6 +174,11 @@ public class FeatureTransformV2 {
             String resolution = String.format("%s@%s@%s_%s", prefix, "wh", videoInfo.get("width"), videoInfo.get("height"));
             featMap.put(resolution, 1.0);
         }
+        String resolution = FeatureUtils.getResolution(videoInfo);
+        if (!resolution.isEmpty()) {
+            String resKey = String.format("%s@%s@%s", prefix, "res", resolution);
+            featMap.put(resKey, 1.0);
+        }
 
         // cate
         getVideoCateFeature(prefix, videoInfo, featMap);

+ 12 - 0
src/main/scala/com/aliyun/odps/spark/examples/myUtils/FeatureUtils.java

@@ -172,4 +172,16 @@ public class FeatureUtils {
         }
         return "";
     }
+
+    public static String getResolution(Map<String, String> videoInfo) {
+        try {
+            if (null != videoInfo && videoInfo.containsKey("width") && videoInfo.containsKey("height")) {
+                int width = Integer.parseInt(videoInfo.get("width")) / 100;
+                int height = Integer.parseInt(videoInfo.get("height")) / 100;
+                return String.format("%d_%d", width, height);
+            }
+        } catch (Exception ignore) {
+        }
+        return "";
+    }
 }