@Override public byte get(Object o) { // Accept int writables and convert them. if (o instanceof IntWritable) { return (byte) ((IntWritable) o).get(); } return ((ByteWritable) o).get(); } }
public ByteWritable evaluate(ByteWritable a) { if (a == null) { return null; } byteWritable.set((byte) (~a.get())); return byteWritable; }
public IntWritable evaluate(ByteWritable a, IntWritable b) { if (a == null || b == null) { return null; } intWritable.set(a.get() >>> b.get()); return intWritable; }
public IntWritable evaluate(ByteWritable a, IntWritable b) { if (a == null || b == null) { return null; } intWritable.set(a.get() >> b.get()); return intWritable; }
@Override public int precision() { if (value == null) { return super.precision(); } return BigDecimal.valueOf(value.get()).precision(); }
public IntWritable evaluate(ByteWritable a, IntWritable b) { if (a == null || b == null) { return null; } intWritable.set(a.get() << b.get()); return intWritable; }
LazyBinaryByte(LazyBinaryByte copy) { super(copy); data = new ByteWritable(copy.data.get()); }
@Override public byte get(Object o) { return getPrimitiveWritableObject(o).get(); }
public LazyByte(LazyByte copy) { super(copy); data = new ByteWritable(copy.data.get()); }
public void writeByte(ByteWritable bw) throws IOException { out.writeByte(bw.get()); }
@Override public void assignObjectValue(Object val, int destIndex) throws HiveException { if (val == null) { assignNull(destIndex); } else { ByteWritable bw = (ByteWritable) val; assignLong(bw.get(), destIndex); } } }.init(outputBatch, (LongColumnVector) destCol);
@Test public void testByteNeq() throws HiveException { GenericUDFNullif udf = new GenericUDFNullif(); ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableByteObjectInspector, PrimitiveObjectInspectorFactory.writableByteObjectInspector }; DeferredObject[] args = { new DeferredJavaObject(new ByteWritable((byte) 4)), new DeferredJavaObject(new ByteWritable((byte) 1)) }; PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs); Assert.assertEquals(TypeInfoFactory.byteTypeInfo, oi.getTypeInfo()); ByteWritable res = (ByteWritable) udf.evaluate(args); Assert.assertEquals(4, res.get()); }