throw new RuntimeException("Expected LazyInteger"); int value = ((LazyInteger) primitiveObject).getWritableObject().get(); int expected = ((IntWritable) expectedObject).get(); if (value != expected) {
@Test public void testLazy() throws HiveException { GenericUDFNullif udf = new GenericUDFNullif(); ObjectInspector[] inputOIs = { LazyPrimitiveObjectInspectorFactory.LAZY_INT_OBJECT_INSPECTOR, LazyPrimitiveObjectInspectorFactory.LAZY_INT_OBJECT_INSPECTOR }; LazyInteger a1 = new LazyInteger(LazyPrimitiveObjectInspectorFactory.LAZY_INT_OBJECT_INSPECTOR); LazyInteger a2 = new LazyInteger(LazyPrimitiveObjectInspectorFactory.LAZY_INT_OBJECT_INSPECTOR); a1.getWritableObject().set(1); a2.getWritableObject().set(1); DeferredObject[] args = { new DeferredJavaObject(a1), new DeferredJavaObject(a2) }; PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs); Assert.assertEquals(TypeInfoFactory.intTypeInfo, oi.getTypeInfo()); Assert.assertEquals(null, udf.evaluate(args)); } }
public static int asJavaInt(@Nullable final Object o) { if (o == null) { throw new IllegalArgumentException(); } if (o instanceof Integer) { return ((Integer) o).intValue(); } if (o instanceof LazyInteger) { IntWritable i = ((LazyInteger) o).getWritableObject(); return i.get(); } if (o instanceof IntWritable) { return ((IntWritable) o).get(); } String s = o.toString(); return Integer.parseInt(s); }
public static int asJavaInt(@Nullable final Object o) { if(o == null) { throw new IllegalArgumentException(); } if(o instanceof Integer) { return ((Integer) o).intValue(); } if(o instanceof LazyInteger) { IntWritable i = ((LazyInteger) o).getWritableObject(); return i.get(); } if(o instanceof IntWritable) { return ((IntWritable) o).get(); } String s = o.toString(); return Integer.parseInt(s); }
public static int asJavaInt(@Nullable final Object o) { if (o == null) { throw new IllegalArgumentException(); } if (o instanceof Integer) { return ((Integer) o).intValue(); } if (o instanceof LazyInteger) { IntWritable i = ((LazyInteger) o).getWritableObject(); return i.get(); } if (o instanceof IntWritable) { return ((IntWritable) o).get(); } String s = o.toString(); return Integer.parseInt(s); }
@Nonnull public static LazyInteger lazyInteger(@Nonnull final int v) { LazyInteger lazy = new LazyInteger(LazyPrimitiveObjectInspectorFactory.LAZY_INT_OBJECT_INSPECTOR); lazy.getWritableObject().set(v); return lazy; }
throw new RuntimeException("Expected LazyInteger"); int value = ((LazyInteger) primitiveObject).getWritableObject().get(); int expected = ((IntWritable) expectedObject).get(); if (value != expected) {