hadoop udf

public class StringContain extends UDF

{public static String evaluate(String im,String drugs)

{String rltString="";List drugList = Arrays.asList(drugs.trim().split(","));

for(String idString : drugList){

if(im.contains(idString)){

if(rltString.isEmpty()){

rltString=idString;

}else{

rltString=rltString+","+idString;

}

}

}

System.out.println(rltString);

return rltString.trim();

}

public static void main(String[] args){

String c1="生理性海水鼻腔护理喷雾器(儿童),盐酸金霉素眼膏 硝呋太尔制霉素阴道软胶囊";

String c2="徐峰";

String aString = evaluate(c1,c2);

System.out.println("=="+aString);

}

}

你可能感兴趣的:(hadoop udf)