xueyiming 1 ماه پیش
والد
کامیت
4c31580b59
1فایلهای تغییر یافته به همراه9 افزوده شده و 6 حذف شده
  1. 9 6
      src/main/scala/com/aliyun/odps/spark/examples/makedata_ad/v20240718/diff_data_20250319.scala

+ 9 - 6
src/main/scala/com/aliyun/odps/spark/examples/makedata_ad/v20240718/diff_data_20250319.scala

@@ -172,14 +172,16 @@ object diff_data_20250319 {
               val diff = math.abs(num1.doubleValue() - num2.doubleValue())
               if (diff > 0) {
                 if (countJsonObject1.containsKey(key)) {
-                  countJsonObject1.put(key, diff)
-                } else {
                   countJsonObject1.put(key, countJsonObject1.getDouble(key) + diff)
+                } else {
+                  countJsonObject1.put(key, diff)
+
                 }
                 if (countJsonObject2.containsKey(key)) {
-                  countJsonObject2.put(key, 1)
-                } else {
                   countJsonObject2.put(key, countJsonObject2.getIntValue(key) + 1)
+                } else {
+                  countJsonObject2.put(key, 1)
+
                 }
 
                 featureDiffSum(key) = featureDiffSum.getOrElse(key, 0.0) + diff
@@ -190,9 +192,10 @@ object diff_data_20250319 {
               val str2 = if (value2 != null) value2 else ""
               if (str1 != str2) {
                 if (countJsonObject2.containsKey(key)) {
-                  countJsonObject2.put(key, 1)
-                } else {
                   countJsonObject2.put(key, countJsonObject2.getIntValue(key) + 1)
+                } else {
+                  countJsonObject2.put(key, 1)
+
                 }
                 featureCount(key) = featureCount.getOrElse(key, 0) + 1
               }