Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsff committed Nov 6, 2024
1 parent 8d98289 commit f967fea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.antgroup.openspg.reasoner.common.constants;

import com.google.common.collect.Sets;

import java.util.Set;

public class Constants {
Expand Down Expand Up @@ -87,8 +86,6 @@ public class Constants {

public static final String CONCEPT_EDGE_EXPAND_FUNC_NAME = "concept_edge_expand";

/**
* allow throw exception in udf
*/
/** allow throw exception in udf */
public static final String ALLOW_UDF_EXCEPTION = "allowUDFThrowException";
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
import com.antgroup.openspg.reasoner.common.constants.Constants;
import com.antgroup.openspg.reasoner.udf.impl.UdfMngImpl;
import com.antgroup.openspg.reasoner.udf.model.UdfDefine;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import org.apache.commons.lang3.StringUtils;

public class ContainsAny {

Expand Down Expand Up @@ -60,7 +59,8 @@ public boolean containsAny(String toCheckedStr, String[] keywords) {
@UdfDefine(name = "contains_any", compatibleName = "contains")
public boolean contains(String toCheckedStr, String keyword) {
Map<String, Object> configMap = UdfMngImpl.sceneConfigMap.get();
Boolean allowUDFThrowException = (Boolean) configMap.getOrDefault(Constants.ALLOW_UDF_EXCEPTION, false);
Boolean allowUDFThrowException =
(Boolean) configMap.getOrDefault(Constants.ALLOW_UDF_EXCEPTION, false);
if ((toCheckedStr == null || keyword == null) && allowUDFThrowException) {
throw new RuntimeException("contains_any arguments is null");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package com.antgroup.openspg.reasoner.udf.impl;

import static com.antgroup.openspg.reasoner.common.Utils.javaType2KgType;

import com.antgroup.openspg.reasoner.common.exception.UdfExistsException;
import com.antgroup.openspg.reasoner.common.types.KgType;
import com.antgroup.openspg.reasoner.udf.UdfMng;
Expand All @@ -29,10 +31,6 @@
import com.antgroup.openspg.reasoner.udf.utils.UdfUtils;
import com.google.common.collect.Lists;
import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import scala.Tuple2;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
Expand All @@ -43,8 +41,9 @@
import java.util.List;
import java.util.Map;
import java.util.Set;

import static com.antgroup.openspg.reasoner.common.Utils.javaType2KgType;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import scala.Tuple2;

@Slf4j(topic = "userlogger")
public class UdfMngImpl implements UdfMng {
Expand All @@ -55,7 +54,8 @@ public class UdfMngImpl implements UdfMng {

private static volatile UdfMngImpl instance = null;

public static ThreadLocal<Map<String, Object>> sceneConfigMap = ThreadLocal.withInitial(HashMap::new);
public static ThreadLocal<Map<String, Object>> sceneConfigMap =
ThreadLocal.withInitial(HashMap::new);

/** 单例 */
public static UdfMngImpl getInstance() {
Expand Down

0 comments on commit f967fea

Please sign in to comment.