Browse Source

new feature

jch 2 months ago
parent
commit
6b1e432aec

+ 1 - 1
src/main/scala/com/aliyun/odps/spark/examples/makedata_recsys_r_rate/makedata_recsys_82_originData_20250221.scala

@@ -45,7 +45,7 @@ object makedata_recsys_82_originData_20250221 {
       .flatMap(raw => {
         val result = new ArrayBuffer[(String, String)]
         for (hVid <- ConvertUtils.getVidList(raw._2.getString("c9_feature"))) {
-          result += (hVid, raw._1) // (vid, mid)
+          result += ((hVid, raw._1)) // (vid, mid)
         }
         result
       })

+ 9 - 6
src/main/scala/com/aliyun/odps/spark/examples/myUtils/ConvertUtils.java

@@ -122,14 +122,17 @@ public class ConvertUtils {
     public static Map<String, String> getRecordCol(Record record, String col) {
         Map<String, String> colMap = new HashMap<>();
         if (null != record && !record.isNull(col)) {
-            JSONObject json = JSON.parseObject(record.getString(col));
-            if (null != json) {
-                for (Map.Entry<String, Object> entry : json.entrySet()) {
-                    Object obj = entry.getValue();
-                    if (null != obj) {
-                        colMap.put(entry.getKey(), obj.toString());
+            try {
+                JSONObject json = JSON.parseObject(record.getString(col));
+                if (null != json) {
+                    for (Map.Entry<String, Object> entry : json.entrySet()) {
+                        Object obj = entry.getValue();
+                        if (null != obj) {
+                            colMap.put(entry.getKey(), obj.toString());
+                        }
                     }
                 }
+            } catch (Exception ignored) {
             }
         }
         return colMap;