org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject Java Examples
The following examples show how to use
org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject.
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: TestParseUserAgent.java From yauaa with Apache License 2.0 | 6 votes |
@Test public void testBasic() throws HiveException { // This is an edge case where the webview fields are calulcated AND wiped again. String userAgent = "Mozilla/5.0 (Linux; Android 5.1.1; KFFOWI Build/LMY47O) AppleWebKit/537.36 (KHTML, like Gecko) " + "Version/4.0 Chrome/41.51020.2250.0246 Mobile Safari/537.36 cordova-amazon-fireos/3.4.0 AmazonWebAppPlatform/3.4.0;2.0"; ParseUserAgent parseUserAgent = new ParseUserAgent(); StandardStructObjectInspector resultInspector = (StandardStructObjectInspector) parseUserAgent .initialize(new ObjectInspector[]{ PrimitiveObjectInspectorFactory.javaStringObjectInspector }); for (int i = 0; i < 100000; i++) { Object row = parseUserAgent.evaluate(new DeferredObject[]{new DeferredJavaObject(userAgent)}); checkField(resultInspector, row, "DeviceClass", "Tablet"); checkField(resultInspector, row, "OperatingSystemNameVersion", "FireOS 3.4.0"); checkField(resultInspector, row, "WebviewAppName", "Unknown"); } }
Example #2
Source File: ToLibSVMFormatUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testFeatureAndFloatLabel() throws IOException, HiveException { ToLibSVMFormatUDF udf = new ToLibSVMFormatUDF(); udf.initialize( new ObjectInspector[] { ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector), PrimitiveObjectInspectorFactory.javaFloatObjectInspector, ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-features 10")}); Assert.assertEquals("5.0 3:2.1 7:3.4", udf.evaluate( new DeferredObject[] {new DeferredJavaObject(Arrays.asList("7:3.4", "3:2.1")), new DeferredJavaObject(5.f)})); udf.close(); }
Example #3
Source File: ToLibSVMFormatUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testFeatureAndIntLabel() throws IOException, HiveException { ToLibSVMFormatUDF udf = new ToLibSVMFormatUDF(); udf.initialize( new ObjectInspector[] { ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector), PrimitiveObjectInspectorFactory.javaIntObjectInspector, ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-features 10")}); Assert.assertEquals("5 3:2.1 7:3.4", udf.evaluate(new DeferredObject[] { new DeferredJavaObject(Arrays.asList("apple:3.4", "orange:2.1")), new DeferredJavaObject(5)})); udf.close(); }
Example #4
Source File: ToLibSVMFormatUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testFeatureOnly() throws IOException, HiveException { ToLibSVMFormatUDF udf = new ToLibSVMFormatUDF(); udf.initialize(new ObjectInspector[] { ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector), ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, "-features 10")}); Assert.assertEquals("3:2.1 7:3.4", udf.evaluate(new DeferredObject[] { new DeferredJavaObject(Arrays.asList("apple:3.4", "orange:2.1"))})); Assert.assertEquals("3:2.1 7:3.4", udf.evaluate( new DeferredObject[] {new DeferredJavaObject(Arrays.asList("7:3.4", "3:2.1"))})); udf.close(); }
Example #5
Source File: VectorizeFeaturesUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testAvoidZeroWeight() throws HiveException, IOException { VectorizeFeaturesUDF udf = new VectorizeFeaturesUDF(); ObjectInspector[] argOIs = new ObjectInspector[3]; List<String> featureNames = Arrays.asList("a", "b"); argOIs[0] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, featureNames); argOIs[1] = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; argOIs[2] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; udf.initialize(argOIs); DeferredObject[] arguments = new DeferredObject[3]; arguments[1] = new DeferredJavaObject(new Double(0.1)); arguments[2] = new DeferredJavaObject("0"); List<Text> actuals = udf.evaluate(arguments); //System.out.println(actuals); List<Text> expected = WritableUtils.val(new String[] {"a:0.1"}); Assert.assertEquals(expected, actuals); udf.close(); }
Example #6
Source File: VectorizeFeaturesUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testTwoArguments() throws HiveException, IOException { VectorizeFeaturesUDF udf = new VectorizeFeaturesUDF(); ObjectInspector[] argOIs = new ObjectInspector[3]; List<String> featureNames = Arrays.asList("a", "b"); argOIs[0] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, featureNames); argOIs[1] = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; argOIs[2] = PrimitiveObjectInspectorFactory.javaStringObjectInspector; udf.initialize(argOIs); DeferredObject[] arguments = new DeferredObject[3]; arguments[1] = new DeferredJavaObject(new Double(0.1)); arguments[2] = new DeferredJavaObject("1.1"); List<Text> actuals = udf.evaluate(arguments); //System.out.println(actuals); List<Text> expected = WritableUtils.val("a:0.1", "b:1.1"); Assert.assertEquals(expected, actuals); udf.close(); }
Example #7
Source File: VectorizeFeaturesUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testOneArgument() throws HiveException, IOException { VectorizeFeaturesUDF udf = new VectorizeFeaturesUDF(); ObjectInspector[] argOIs = new ObjectInspector[2]; List<String> featureNames = Arrays.asList("a"); argOIs[0] = ObjectInspectorFactory.getStandardConstantListObjectInspector( PrimitiveObjectInspectorFactory.javaStringObjectInspector, featureNames); argOIs[1] = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; udf.initialize(argOIs); DeferredObject[] arguments = new DeferredObject[2]; arguments[1] = new DeferredJavaObject(new Double(0.1)); List<Text> actuals = udf.evaluate(arguments); //System.out.println(actuals); List<Text> expected = WritableUtils.val(new String[] {"a:0.1"}); Assert.assertEquals(expected, actuals); udf.close(); }
Example #8
Source File: TreePredictUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
private static double evalPredict(RegressionTree tree, double[] x) throws HiveException, IOException { byte[] b = tree.serialize(true); byte[] encoded = Base91.encode(b); Text model = new Text(encoded); TreePredictUDF udf = new TreePredictUDF(); udf.initialize( new ObjectInspector[] {PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.writableStringObjectInspector, ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.javaDoubleObjectInspector), ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaBooleanObjectInspector, false)}); DeferredObject[] arguments = new DeferredObject[] {new DeferredJavaObject("model_id#1"), new DeferredJavaObject(model), new DeferredJavaObject(ArrayUtils.toList(x)), new DeferredJavaObject(false)}; DoubleWritable result = (DoubleWritable) udf.evaluate(arguments); udf.close(); return result.get(); }
Example #9
Source File: TreePredictUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
private static int evalPredict(DecisionTree tree, double[] x) throws HiveException, IOException { byte[] b = tree.serialize(true); byte[] encoded = Base91.encode(b); Text model = new Text(encoded); TreePredictUDF udf = new TreePredictUDF(); udf.initialize( new ObjectInspector[] {PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.writableStringObjectInspector, ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.javaDoubleObjectInspector), ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaBooleanObjectInspector, true)}); DeferredObject[] arguments = new DeferredObject[] {new DeferredJavaObject("model_id#1"), new DeferredJavaObject(model), new DeferredJavaObject(ArrayUtils.toList(x)), new DeferredJavaObject(true)}; Object[] result = (Object[]) udf.evaluate(arguments); udf.close(); return ((IntWritable) result[0]).get(); }
Example #10
Source File: TreePredictUDFv1Test.java From incubator-hivemall with Apache License 2.0 | 6 votes |
private static double evalPredict(RegressionTree tree, double[] x) throws HiveException, IOException { String opScript = tree.predictOpCodegen(StackMachine.SEP); debugPrint(opScript); TreePredictUDFv1 udf = new TreePredictUDFv1(); udf.initialize( new ObjectInspector[] {PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.javaIntObjectInspector, PrimitiveObjectInspectorFactory.javaStringObjectInspector, ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.javaDoubleObjectInspector), ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaBooleanObjectInspector, false)}); DeferredObject[] arguments = new DeferredObject[] {new DeferredJavaObject("model_id#1"), new DeferredJavaObject(ModelType.opscode.getId()), new DeferredJavaObject(opScript), new DeferredJavaObject(ArrayUtils.toList(x)), new DeferredJavaObject(false)}; DoubleWritable result = (DoubleWritable) udf.evaluate(arguments); udf.close(); return result.get(); }
Example #11
Source File: TreePredictUDFv1Test.java From incubator-hivemall with Apache License 2.0 | 6 votes |
private static int evalPredict(DecisionTree tree, double[] x) throws HiveException, IOException { String opScript = tree.predictOpCodegen(StackMachine.SEP); debugPrint(opScript); TreePredictUDFv1 udf = new TreePredictUDFv1(); udf.initialize( new ObjectInspector[] {PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.javaIntObjectInspector, PrimitiveObjectInspectorFactory.javaStringObjectInspector, ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.javaDoubleObjectInspector), ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaBooleanObjectInspector, true)}); DeferredObject[] arguments = new DeferredObject[] {new DeferredJavaObject("model_id#1"), new DeferredJavaObject(ModelType.opscode.getId()), new DeferredJavaObject(opScript), new DeferredJavaObject(ArrayUtils.toList(x)), new DeferredJavaObject(true)}; IntWritable result = (IntWritable) udf.evaluate(arguments); udf.close(); return result.get(); }
Example #12
Source File: HaversineDistanceUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testMiles() throws HiveException, IOException { HaversineDistanceUDF udf = new HaversineDistanceUDF(); udf.initialize( new ObjectInspector[] {PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaBooleanObjectInspector, true)}); // Tokyo double lat1 = 35.6833d, lon1 = 139.7667d; // Osaka double lat2 = 34.6603d, lon2 = 135.5232d; DoubleWritable result1 = udf.evaluate(new DeferredObject[] {new DeferredJavaObject(lat1), new DeferredJavaObject(lon1), new DeferredJavaObject(lat2), new DeferredJavaObject(lon2), new DeferredJavaObject(true)}); Assert.assertEquals(249.84d, result1.get(), 0.1d); udf.close(); }
Example #13
Source File: HaversineDistanceUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testKilometers2() throws HiveException, IOException { HaversineDistanceUDF udf = new HaversineDistanceUDF(); udf.initialize( new ObjectInspector[] {PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, ObjectInspectorUtils.getConstantObjectInspector( PrimitiveObjectInspectorFactory.javaBooleanObjectInspector, false)}); // Tokyo double lat1 = 35.6833d, lon1 = 139.7667d; // Osaka double lat2 = 34.6603d, lon2 = 135.5232d; DoubleWritable result1 = udf.evaluate( new DeferredObject[] {new DeferredJavaObject(lat1), new DeferredJavaObject(lon1), new DeferredJavaObject(lat2), new DeferredJavaObject(lon2)}); Assert.assertEquals(402.092d, result1.get(), 0.001d); udf.close(); }
Example #14
Source File: HaversineDistanceUDFTest.java From incubator-hivemall with Apache License 2.0 | 6 votes |
@Test public void testKilometers1() throws HiveException, IOException { HaversineDistanceUDF udf = new HaversineDistanceUDF(); udf.initialize( new ObjectInspector[] {PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector}); // Tokyo double lat1 = 35.6833d, lon1 = 139.7667d; // Osaka double lat2 = 34.6603d, lon2 = 135.5232d; DoubleWritable result1 = udf.evaluate( new DeferredObject[] {new DeferredJavaObject(lat1), new DeferredJavaObject(lon1), new DeferredJavaObject(lat2), new DeferredJavaObject(lon2)}); Assert.assertEquals(402.092d, result1.get(), 0.001d); udf.close(); }
Example #15
Source File: UDFMapConcatTest.java From hive-third-functions with Apache License 2.0 | 6 votes |
@Test public void testMapConcat() throws Exception { UDFMapConcat udf = new UDFMapConcat(); ObjectInspector leftMapOI = ObjectInspectorFactory.getStandardMapObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.javaStringObjectInspector); ObjectInspector rightMapOI = ObjectInspectorFactory.getStandardMapObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.javaStringObjectInspector); ObjectInspector[] arguments = {leftMapOI, rightMapOI}; udf.initialize(arguments); LinkedHashMap<String, String> leftMap = Maps.newLinkedHashMap(); leftMap.putAll(ImmutableMap.<String, String>of("key1", "11", "key2", "12", "key3", "13")); LinkedHashMap<String, String> rightMap = Maps.newLinkedHashMap(); rightMap.putAll(ImmutableMap.<String, String>of("key3", "21", "key4", "22", "key5", "23")); DeferredObject leftMapObj = new DeferredJavaObject(leftMap); DeferredObject rightMapObj = new DeferredJavaObject(rightMap); DeferredObject[] args = {leftMapObj, rightMapObj}; LinkedHashMap<String, String> output = (LinkedHashMap<String, String>) udf.evaluate(args); LinkedHashMap<String, String> expect = Maps.newLinkedHashMap(); expect.putAll(ImmutableMap.<String, String>of("key1", "11", "key2", "12", "key3", "21", "key4", "22", "key5", "23")); Assert.assertEquals("map_concat() test", true, MapUtils.mapEquals(output, expect)); }
Example #16
Source File: UDFMapBuildTest.java From hive-third-functions with Apache License 2.0 | 6 votes |
@Test public void testMapBuild() throws Exception { UDFMapBuild udf = new UDFMapBuild(); ObjectInspector keyArrayOI = ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector); ObjectInspector valueArrayOI = ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector); ObjectInspector[] arguments = {keyArrayOI, valueArrayOI}; udf.initialize(arguments); List<String> keyArray = ImmutableList.of("key1", "key2", "key3"); List<String> valueArray = ImmutableList.of("value1", "value2", "value3"); DeferredObject keyArrayObj = new DeferredJavaObject(keyArray); DeferredObject valueArrayObj = new DeferredJavaObject(valueArray); DeferredObject[] args = {keyArrayObj, valueArrayObj}; LinkedHashMap<String, String> output = (LinkedHashMap<String, String>) udf.evaluate(args); LinkedHashMap<String, String> expect = Maps.newLinkedHashMap(); expect.putAll(ImmutableMap.<String, String>of("key1", "value1", "key2", "value2", "key3", "value3")); Assert.assertEquals("map_build() test", true, MapUtils.mapEquals(output, expect)); }
Example #17
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testStringFloat() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaFloatObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject("f1"), new DeferredJavaObject(2.5f)}); Assert.assertEquals("f1:2.5", ret.toString()); }
Example #18
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testLongLong() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(1L), new DeferredJavaObject(2L)}); Assert.assertEquals("1:2", ret.toString()); }
Example #19
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testLongFloat() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaFloatObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(1L), new DeferredJavaObject(2.5f)}); Assert.assertEquals("1:2.5", ret.toString()); }
Example #20
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testLongDouble() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(1L), new DeferredJavaObject(2.5d)}); Assert.assertEquals("1:2.5", ret.toString()); }
Example #21
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testStringInt() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject("f1"), new DeferredJavaObject(2)}); Assert.assertEquals("f1:2", ret.toString()); }
Example #22
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testStringLong() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject("f1"), new DeferredJavaObject(2L)}); Assert.assertEquals("f1:2", ret.toString()); }
Example #23
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test(expected = UDFArgumentException.class) public void testInvalidFeatureName() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(new Text("f:1")), new DeferredJavaObject(new DoubleWritable(2.5d))}); Assert.fail(); }
Example #24
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testTextDouble() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] { new DeferredJavaObject(new Text("f1")), new DeferredJavaObject(2.5d)}); Assert.assertEquals("f1:2.5", ret.toString()); }
Example #25
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testStringDouble() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject("f1"), new DeferredJavaObject(2.5d)}); Assert.assertEquals("f1:2.5", ret.toString()); }
Example #26
Source File: TestParseUserAgentBadInput.java From yauaa with Apache License 2.0 | 5 votes |
@Test public void testBadInputNull() throws HiveException { parseUserAgent .initialize(new ObjectInspector[]{ PrimitiveObjectInspectorFactory.javaStringObjectInspector }); assertNull(parseUserAgent.evaluate(new DeferredObject[]{new DeferredJavaObject(null)})); }
Example #27
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testNullWeight() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject("f1"), new DeferredJavaObject(null)}); Assert.assertNull(ret); }
Example #28
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testTextDoubleWritable() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.writableDoubleObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate( new GenericUDF.DeferredObject[] {new DeferredJavaObject(new Text("f1")), new DeferredJavaObject(new DoubleWritable(2.5d))}); Assert.assertEquals("f1:2.5", ret.toString()); }
Example #29
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testLongInt() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaLongObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(1L), new DeferredJavaObject(2)}); Assert.assertEquals("1:2", ret.toString()); }
Example #30
Source File: FeatureUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testIntDouble() throws Exception { ObjectInspector featureOI = PrimitiveObjectInspectorFactory.javaIntObjectInspector; ObjectInspector weightOI = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; udf.initialize(new ObjectInspector[] {featureOI, weightOI}); Text ret = udf.evaluate(new GenericUDF.DeferredObject[] {new DeferredJavaObject(1), new DeferredJavaObject(2.5d)}); Assert.assertEquals("1:2.5", ret.toString()); }