zhangbo 1 ano atrás
pai
commit
7809bc87ae

+ 1 - 0
MyFirstUDF/.gitignore

@@ -0,0 +1 @@
+.idea/*

+ 37 - 0
MyFirstUDF/src/main/java/com/alidata/odps/udtf/examples/jiebafenci.java

@@ -0,0 +1,37 @@
+package com.alidata.odps.udtf.examples;
+import com.aliyun.odps.udf.ExecutionContext;
+import com.aliyun.odps.udf.UDFException;
+import com.aliyun.odps.udf.UDTF;
+import com.aliyun.odps.udf.annotation.Resolve;
+import com.huaban.analysis.jieba.JiebaSegmenter;
+import java.util.*;
+
+// TODO define input and output types, e.g. "string,string->string,bigint".
+@Resolve({"string,string->string,string"})
+public class jiebafenci extends UDTF {
+
+    @Override
+    public void setup(ExecutionContext ctx) throws UDFException {
+
+    }
+
+    @Override
+    public void process(Object[] args) throws UDFException {
+        // TODO
+        String a = (String) args[0];
+        String content = (String) args[1];
+        JiebaSegmenter segmenter = new JiebaSegmenter();
+        List<String> result = segmenter.sentenceProcess(content);
+
+
+        for (String t: result) {
+            forward(a, t);
+        }
+    }
+
+    @Override
+    public void close() throws UDFException {
+
+    }
+
+}