use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.floatTypeInfo in project hive by apache.
the class TestMapJoinOperator method doTestString1.
public boolean doTestString1(long seed, int hiveConfVariation, VectorMapJoinVariation vectorMapJoinVariation, MapJoinPlanVariation mapJoinPlanVariation) throws Exception {
int rowCount = 10;
HiveConf hiveConf = new HiveConf();
if (!addNonLongHiveConfVariation(hiveConfVariation, hiveConf)) {
return true;
}
TypeInfo[] bigTableTypeInfos = null;
int[] bigTableKeyColumnNums = null;
TypeInfo[] smallTableValueTypeInfos = null;
int[] smallTableRetainKeyColumnNums = null;
SmallTableGenerationParameters smallTableGenerationParameters = new SmallTableGenerationParameters();
MapJoinTestDescription testDesc = null;
MapJoinTestData testData = null;
// One BINARY key column.
bigTableTypeInfos = new TypeInfo[] { TypeInfoFactory.binaryTypeInfo };
bigTableKeyColumnNums = new int[] { 0 };
smallTableRetainKeyColumnNums = new int[] { 0 };
smallTableValueTypeInfos = new TypeInfo[] { TypeInfoFactory.shortTypeInfo, TypeInfoFactory.floatTypeInfo, new DecimalTypeInfo(38, 18) };
smallTableGenerationParameters = new SmallTableGenerationParameters();
// ----------------------------------------------------------------------------------------------
testDesc = new MapJoinTestDescription(hiveConf, vectorMapJoinVariation, bigTableTypeInfos, bigTableKeyColumnNums, smallTableValueTypeInfos, smallTableRetainKeyColumnNums, smallTableGenerationParameters, mapJoinPlanVariation);
if (!goodTestVariation(testDesc)) {
return false;
}
// Prepare data. Good for ANY implementation variation.
testData = new MapJoinTestData(rowCount, testDesc, seed);
executeTest(testDesc, testData, "testString1");
return false;
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.floatTypeInfo in project hive by apache.
the class TestGenericUDFOPNegative method testFloat.
@Test
public void testFloat() throws HiveException {
GenericUDFOPNegative udf = new GenericUDFOPNegative();
FloatWritable input = new FloatWritable(323.4747f);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableFloatObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.floatTypeInfo, oi.getTypeInfo());
FloatWritable res = (FloatWritable) udf.evaluate(args);
Assert.assertEquals(-323.4747f, res.get(), EPSILON);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.floatTypeInfo in project hive by apache.
the class TestGenericUDFOPPlus method testFloatPlusFloat.
@Test
public void testFloatPlusFloat() throws HiveException {
GenericUDFOPPlus udf = new GenericUDFOPPlus();
// Float
FloatWritable f1 = new FloatWritable(4.5f);
FloatWritable f2 = new FloatWritable(0.0f);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableFloatObjectInspector, PrimitiveObjectInspectorFactory.writableFloatObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(f1), new DeferredJavaObject(f2) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.floatTypeInfo);
FloatWritable res = (FloatWritable) udf.evaluate(args);
Assert.assertEquals(4.5, res.get(), EPSILON);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.floatTypeInfo in project hive by apache.
the class TestGenericUDFOPMultiply method testFloatTimesFloat.
@Test
public void testFloatTimesFloat() throws HiveException {
GenericUDFOPMultiply udf = new GenericUDFOPMultiply();
FloatWritable f1 = new FloatWritable(4.5f);
FloatWritable f2 = new FloatWritable(0.0f);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableFloatObjectInspector, PrimitiveObjectInspectorFactory.writableFloatObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(f1), new DeferredJavaObject(f2) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(oi.getTypeInfo(), TypeInfoFactory.floatTypeInfo);
FloatWritable res = (FloatWritable) udf.evaluate(args);
Assert.assertEquals(0.0, res.get(), EPSILON);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.floatTypeInfo in project hive by apache.
the class TestGenericUDFOPPositive method testFloat.
@Test
public void testFloat() throws HiveException {
GenericUDFOPPositive udf = new GenericUDFOPPositive();
FloatWritable input = new FloatWritable(323.4747f);
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableFloatObjectInspector };
DeferredObject[] args = { new DeferredJavaObject(input) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(TypeInfoFactory.floatTypeInfo, oi.getTypeInfo());
FloatWritable res = (FloatWritable) udf.evaluate(args);
Assert.assertEquals(323.4747, res.get(), EPSILON);
}
Aggregations