use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBooleanObjectInspector in project hive by apache.
the class TestGenericUDFOPOr method testFalseOrFalse.
@Test
public void testFalseOrFalse() throws HiveException, IOException {
GenericUDFOPOr udf = new GenericUDFOPOr();
BooleanWritable left = new BooleanWritable(false);
BooleanWritable right = new BooleanWritable(false);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableBooleanObjectInspector, PrimitiveObjectInspectorFactory.writableBooleanObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.booleanTypeInfo);
BooleanWritable res = (BooleanWritable) udf.evaluate(args);
Assert.assertEquals(false, res.get());
udf.close();
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBooleanObjectInspector in project hive by apache.
the class TestGenericUDFOPAnd method testFalseAndNull.
@Test
public void testFalseAndNull() throws HiveException, IOException {
GenericUDFOPAnd udf = new GenericUDFOPAnd();
BooleanWritable left = new BooleanWritable(false);
Writable right = null;
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableBooleanObjectInspector, PrimitiveObjectInspectorFactory.writableVoidObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.booleanTypeInfo);
BooleanWritable res = (BooleanWritable) udf.evaluate(args);
Assert.assertEquals(false, res.get());
udf.close();
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBooleanObjectInspector in project hive by apache.
the class TestObjectInspectorConverters method convertBoolean.
private void convertBoolean() {
Converter booleanConverter = ObjectInspectorConverters.getConverter(PrimitiveObjectInspectorFactory.javaIntObjectInspector, PrimitiveObjectInspectorFactory.writableBooleanObjectInspector);
assertEquals("BooleanConverter", new BooleanWritable(false), booleanConverter.convert(Integer.valueOf(0)));
assertEquals("BooleanConverter", new BooleanWritable(true), booleanConverter.convert(Integer.valueOf(1)));
assertEquals("BooleanConverter", null, booleanConverter.convert(null));
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBooleanObjectInspector in project hive by apache.
the class TestGenericUDFOPAnd method testFalseAndFalse.
@Test
public void testFalseAndFalse() throws HiveException, IOException {
GenericUDFOPAnd udf = new GenericUDFOPAnd();
BooleanWritable left = new BooleanWritable(false);
BooleanWritable right = new BooleanWritable(false);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableBooleanObjectInspector, PrimitiveObjectInspectorFactory.writableBooleanObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.booleanTypeInfo);
BooleanWritable res = (BooleanWritable) udf.evaluate(args);
Assert.assertEquals(false, res.get());
udf.close();
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBooleanObjectInspector in project hive by apache.
the class TestGenericUDFOPAnd method testTrueAndNull.
@Test
public void testTrueAndNull() throws HiveException, IOException {
GenericUDFOPAnd udf = new GenericUDFOPAnd();
BooleanWritable left = new BooleanWritable(true);
Writable right = null;
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableBooleanObjectInspector, PrimitiveObjectInspectorFactory.writableVoidObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(left), new DeferredJavaObject(right) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.booleanTypeInfo);
BooleanWritable res = (BooleanWritable) udf.evaluate(args);
Assert.assertEquals(null, res);
udf.close();
}
Aggregations