|
@@ -222,47 +222,22 @@ object makedata_ad_33_bucketDataFromOriginToHive_20250522 {
|
|
|
featureMap.put("abcode_" + extend.getString("abcode"), idDefaultValue)
|
|
|
}
|
|
|
|
|
|
- if (reqFeature.containsKey("cid") && reqFeature.getString("cid").nonEmpty) {
|
|
|
- featureMap.put("cid", reqFeature.getString("cid"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("adid") && reqFeature.getString("adid").nonEmpty) {
|
|
|
- featureMap.put("adid", reqFeature.getString("adid"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("adverid") && reqFeature.getString("adverid").nonEmpty) {
|
|
|
- featureMap.put("adverid", reqFeature.getString("adverid"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("profession") && reqFeature.getString("profession").nonEmpty) {
|
|
|
- featureMap.put("profession", reqFeature.getString("profession"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("region") && reqFeature.getString("region").nonEmpty) {
|
|
|
- featureMap.put("region", reqFeature.getString("region"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("city") && reqFeature.getString("city").nonEmpty) {
|
|
|
- featureMap.put("city", reqFeature.getString("city"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("is_first_layer") && reqFeature.getString("is_first_layer").nonEmpty) {
|
|
|
- featureMap.put("is_first_layer", reqFeature.getString("is_first_layer"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("root_source_scene") && reqFeature.getString("root_source_scene").nonEmpty) {
|
|
|
- featureMap.put("root_source_scene", reqFeature.getString("root_source_scene"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("root_source_channel") && reqFeature.getString("root_source_channel").nonEmpty) {
|
|
|
- featureMap.put("root_source_channel", reqFeature.getString("root_source_channel"))
|
|
|
- }
|
|
|
-
|
|
|
- if (reqFeature.containsKey("brand") && reqFeature.getString("brand").nonEmpty) {
|
|
|
- featureMap.put("brand", reqFeature.getString("brand"))
|
|
|
+ // 定义需要处理的键名列表
|
|
|
+ val reqFeatureKeys = List(
|
|
|
+ "cid", "adid", "adverid", "profession", "region",
|
|
|
+ "city", "is_first_layer", "root_source_scene",
|
|
|
+ "root_source_channel", "brand", "vid"
|
|
|
+ )
|
|
|
+
|
|
|
+ // 使用函数式方式处理所有键
|
|
|
+ reqFeatureKeys.foreach { key =>
|
|
|
+ reqFeature.get(key) match {
|
|
|
+ case Some(value) if value != null && value.toString.nonEmpty =>
|
|
|
+ featureMap.put(key, value.toString)
|
|
|
+ case _ => // 不做任何操作
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (b1.containsKey("cpa")) {
|
|
|
featureMap.put("cpa", b1.getString("cpa").toDouble)
|
|
|
}
|
|
@@ -583,7 +558,6 @@ object makedata_ad_33_bucketDataFromOriginToHive_20250522 {
|
|
|
featureMap.put("cate2", d3.getOrDefault("merge_second_level_cate", ""))
|
|
|
featureMap.put("title_split", d3.getOrDefault("title_split", ""))
|
|
|
}
|
|
|
- featureMap.put("vid", reqFeature.getString("vid"))
|
|
|
|
|
|
// 随机mask部分特征供模型训练
|
|
|
if (Random.nextDouble() < maskFeatureRate) {
|