|
@@ -1,12 +1,17 @@
|
|
|
package examples.utils;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyun.odps.data.Record;
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
public class AdUtil {
|
|
|
|
|
|
+ public static final String IS_API_FLAG = "1";
|
|
|
+
|
|
|
/**
|
|
|
* 将线上metaFeature中的Key替换为大数据表中的Key,用于定位问题
|
|
|
*/
|
|
@@ -37,4 +42,26 @@ public class AdUtil {
|
|
|
|
|
|
return newJson;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 是否有回传,用于生产数据时的过滤
|
|
|
+ */
|
|
|
+ public static boolean isApi(Record record) {
|
|
|
+
|
|
|
+ if (record.isNull("extend_alg")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject extendAlgJson = JSON.parseObject(record.getString("extend_alg"));
|
|
|
+ if (MapUtils.isEmpty(extendAlgJson)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (extendAlgJson.containsKey("extinfo")) {
|
|
|
+ return IS_API_FLAG.equals(extendAlgJson.getJSONObject("extinfo").getString("isApi"));
|
|
|
+ }
|
|
|
+ if (extendAlgJson.containsKey("is_api")) {
|
|
|
+ return IS_API_FLAG.equals(extendAlgJson.getString("is_api"));
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|