Java Code Examples for org.apache.hadoop.hive.ql.udf.generic.GenericUDF#close()
The following examples show how to use
org.apache.hadoop.hive.ql.udf.generic.GenericUDF#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test(expected = UDFArgumentException.class) public void testInvalidMode() throws IOException, HiveException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[2]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // mode PrimitiveTypeInfo stringType = new PrimitiveTypeInfo(); stringType.setTypeName("string"); argOIs[1] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( stringType, new Text("unsupported mode")); udf.initialize(argOIs); DeferredObject[] args = new DeferredObject[1]; args[0] = new DeferredObject() { public Text get() throws HiveException { return new Text("クロモジのJapaneseAnalyzerを使ってみる。テスト。"); } @Override public void prepare(int arg) throws HiveException {} }; udf.evaluate(args); udf.close(); }
Example 2
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testThreeArgument() throws UDFArgumentException, IOException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[3]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // mode PrimitiveTypeInfo stringType = new PrimitiveTypeInfo(); stringType.setTypeName("string"); argOIs[1] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( stringType, null); // stopWords argOIs[2] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); udf.initialize(argOIs); udf.close(); }
Example 3
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testFourArgument() throws UDFArgumentException, IOException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[4]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // mode PrimitiveTypeInfo stringType = new PrimitiveTypeInfo(); stringType.setTypeName("string"); argOIs[1] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( stringType, null); // stopWords argOIs[2] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); // stopTags argOIs[3] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); udf.initialize(argOIs); udf.close(); }
Example 4
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testFiveArgumentArray() throws UDFArgumentException, IOException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[5]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // mode PrimitiveTypeInfo stringType = new PrimitiveTypeInfo(); stringType.setTypeName("string"); argOIs[1] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( stringType, null); // stopWords argOIs[2] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); // stopTags argOIs[3] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); // userDictUrl argOIs[4] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); udf.initialize(argOIs); udf.close(); }
Example 5
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testFiveArgumenString() throws UDFArgumentException, IOException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[5]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // mode PrimitiveTypeInfo stringType = new PrimitiveTypeInfo(); stringType.setTypeName("string"); argOIs[1] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( stringType, null); // stopWords argOIs[2] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); // stopTags argOIs[3] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); // userDictUrl argOIs[4] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( stringType, null); udf.initialize(argOIs); udf.close(); }
Example 6
Source File: SmartcnUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testOneArgument() throws UDFArgumentException, IOException { GenericUDF udf = new SmartcnUDF(); ObjectInspector[] argOIs = new ObjectInspector[1]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; udf.initialize(argOIs); udf.close(); }
Example 7
Source File: SmartcnUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testTwoArgument() throws UDFArgumentException, IOException { GenericUDF udf = new SmartcnUDF(); ObjectInspector[] argOIs = new ObjectInspector[2]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // stopWords argOIs[1] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, null); udf.initialize(argOIs); udf.close(); }
Example 8
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testOneArgument() throws UDFArgumentException, IOException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[1]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; udf.initialize(argOIs); udf.close(); }
Example 9
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testTwoArgument() throws UDFArgumentException, IOException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[2]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // mode PrimitiveTypeInfo stringType = new PrimitiveTypeInfo(); stringType.setTypeName("string"); argOIs[1] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( stringType, null); udf.initialize(argOIs); udf.close(); }
Example 10
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
public void testExpectedMode() throws UDFArgumentException, IOException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[2]; // line argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // mode PrimitiveTypeInfo stringType = new PrimitiveTypeInfo(); stringType.setTypeName("string"); argOIs[1] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( stringType, new Text("normal")); udf.initialize(argOIs); udf.close(); }
Example 11
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testNormalModeWithOption() throws IOException, HiveException, IllegalAccessException, NoSuchFieldException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[2]; argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // line argOIs[1] = HiveUtils.getConstStringObjectInspector("-mode normal"); // mode udf.initialize(argOIs); Object mode = PrivilegedAccessor.getValue(udf, "_mode"); Assert.assertEquals(Mode.NORMAL, mode); DeferredObject[] args = new DeferredObject[1]; args[0] = new DeferredObject() { public Text get() throws HiveException { return new Text("クロモジのJapaneseAnalyzerを使ってみる。テスト。"); } @Override public void prepare(int arg) throws HiveException {} }; Object result = udf.evaluate(args); Assert.assertThat(Arrays.asList(new Text("クロモジ"), new Text("japaneseanalyzer"), new Text("使う"), new Text("みる"), new Text("テスト")), CoreMatchers.is(result)); udf.close(); }
Example 12
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testNormalModeWithPosOptions() throws IOException, HiveException, IllegalAccessException, NoSuchFieldException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[2]; argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // line argOIs[1] = HiveUtils.getConstStringObjectInspector("-mode normal -pos"); // mode udf.initialize(argOIs); Object mode = PrivilegedAccessor.getValue(udf, "_mode"); Assert.assertEquals(Mode.NORMAL, mode); DeferredObject[] args = new DeferredObject[1]; args[0] = new DeferredObject() { public Text get() throws HiveException { return new Text("クロモジのJapaneseAnalyzerを使ってみる。テスト。"); } @Override public void prepare(int arg) throws HiveException {} }; Object[] result = (Object[]) udf.evaluate(args); Assert.assertEquals(2, result.length); Assert.assertEquals(Arrays.asList(new Text("クロモジ"), new Text("japaneseanalyzer"), new Text("使う"), new Text("みる"), new Text("テスト")), result[0]); Assert.assertEquals(Arrays.asList(new Text("名詞-一般"), new Text("名詞-一般"), new Text("動詞-自立"), new Text("動詞-非自立"), new Text("名詞-サ変接続")), result[1]); udf.close(); }
Example 13
Source File: KuromojiUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test(expected = UDFArgumentException.class) public void testUnsupportedOptionArgs() throws IOException, HiveException, IllegalAccessException, NoSuchFieldException { GenericUDF udf = new KuromojiUDF(); ObjectInspector[] argOIs = new ObjectInspector[2]; argOIs[0] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; // line argOIs[1] = HiveUtils.getConstStringObjectInspector("-mode normal -unsupported_option"); // mode udf.initialize(argOIs); udf.close(); }