@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { super.init(m, parameters); return ObjectInspectorFactory .getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { super.init(m, parameters); return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableDoubleObjectInspector); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { super.init(m, parameters); return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableDoubleObjectInspector); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { super.init(m, parameters); return ObjectInspectorFactory .getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector); }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length < 1 || arguments.length > 3) { throw new UDFArgumentLengthException( "The function sentences takes between 1 and 3 arguments."); } converters = new ObjectInspectorConverters.Converter[arguments.length]; for (int i = 0; i < arguments.length; i++) { converters[i] = ObjectInspectorConverters.getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector); } return ObjectInspectorFactory.getStandardListObjectInspector( ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableStringObjectInspector)); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { super.init(m, parameters); if (m != Mode.COMPLETE) { throw new HiveException("Only COMPLETE mode supported for row_number function"); } return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableIntObjectInspector); }
private ObjectInspector convertList(ObjectInspector inspector, AtomicBoolean foundUnion) { ListObjectInspector listOI = (ListObjectInspector) inspector; ObjectInspector elementOI = convert(listOI.getListElementObjectInspector(), foundUnion); return ObjectInspectorFactory.getStandardListObjectInspector(elementOI); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { assert (parameters.length == 1); super.init(m, parameters); if (m != Mode.COMPLETE) { throw new HiveException("Only COMPLETE mode supported for NTile function"); } inputOI = (PrimitiveObjectInspector) parameters[0]; return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableIntObjectInspector); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { super.init(m, parameters); if (m != Mode.COMPLETE) { throw new HiveException("Only COMPLETE mode supported for row_number function"); } return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableIntObjectInspector); }
private ObjectInspector convertList(ObjectInspector inspector, AtomicBoolean foundUnion) { ListObjectInspector listOI = (ListObjectInspector) inspector; ObjectInspector elementOI = convert(listOI.getListElementObjectInspector(), foundUnion); return ObjectInspectorFactory.getStandardListObjectInspector(elementOI); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { assert (parameters.length == 1); super.init(m, parameters); if (m != Mode.COMPLETE) { throw new HiveException("Only COMPLETE mode supported for NTile function"); } inputOI = (PrimitiveObjectInspector) parameters[0]; return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableIntObjectInspector); }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 2) { throw new UDFArgumentException("Invalid number of arguments."); } converterArg0 = ObjectInspectorConverters.getConverter(arguments[0], PrimitiveObjectInspectorFactory.writableStringObjectInspector); converterArg1 = ObjectInspectorConverters.getConverter(arguments[1], PrimitiveObjectInspectorFactory.writableStringObjectInspector); return ObjectInspectorFactory .getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableStringObjectInspector); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { super.init(m, parameters); if (m != Mode.COMPLETE) { throw new HiveException("Only COMPLETE mode supported for Rank function"); } inputOI = parameters; outputOI = new ObjectInspector[inputOI.length]; for (int i = 0; i < inputOI.length; i++) { outputOI[i] = ObjectInspectorUtils.getStandardObjectInspector(inputOI[i], ObjectInspectorCopyOption.JAVA); } return ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableIntObjectInspector); }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { if (arguments.length != 1) { throw new UDFArgumentLengthException("The function MAP_VALUES only accepts 1 argument."); } else if (!(arguments[0] instanceof MapObjectInspector)) { throw new UDFArgumentTypeException(0, "\"" + Category.MAP.toString().toLowerCase() + "\" is expected at function MAP_VALUES, " + "but \"" + arguments[0].getTypeName() + "\" is found"); } mapOI = (MapObjectInspector) arguments[0]; ObjectInspector mapValueOI = mapOI.getMapValueObjectInspector(); return ObjectInspectorFactory.getStandardListObjectInspector(mapValueOI); }
@Test public void testSortPrimitive() throws HiveException { ObjectInspector[] inputOIs = { ObjectInspectorFactory.getStandardListObjectInspector( PrimitiveObjectInspectorFactory.writableIntObjectInspector) }; udf.initialize(inputOIs); Object i1 = new IntWritable(3); Object i2 = new IntWritable(4); Object i3 = new IntWritable(2); Object i4 = new IntWritable(1); runAndVerify(asList(i1,i2,i3,i4), asList(i4,i3,i1,i2)); }
@Override public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException { super.init(m, parameters); if (m != Mode.COMPLETE) { throw new HiveException("Only COMPLETE mode supported for " + fnName + " function"); } inputOI = parameters; if (parameters.length == 3) { defaultValueConverter = ObjectInspectorConverters .getConverter(parameters[2], parameters[0]); } return ObjectInspectorFactory.getStandardListObjectInspector(ObjectInspectorUtils .getStandardObjectInspector(parameters[0])); }
@Test public void convertList() { ObjectInspector inspector = ObjectInspectorFactory.getStandardListObjectInspector(unionObjectInspector); Object value = Arrays.asList(union); @SuppressWarnings("unchecked") List<Object> result = (List<Object>) underTest.convert(value, inspector); assertThat(result.size(), is(1)); assertThat(result.get(0), is((Object) Arrays.asList("foo", null))); }
@Test public void convertList() { ObjectInspector inspector = ObjectInspectorFactory.getStandardListObjectInspector(unionObjectInspector); ObjectInspector result = underTest.convert(inspector); assertThat( result.getTypeName(), is(ObjectInspectorFactory.getStandardListObjectInspector(structObjectInspector).getTypeName())); }
@Test public void testArrayOfMaps() throws Exception { Iterable<Map<String, Long>> maps = createNullableTestMaps(transform(intsBetween(0, 10), Object::toString), longsBetween(0, 10)); List<List<Map<String, Long>>> values = createTestArrays(maps); tester.testRoundTrip(getStandardListObjectInspector(getStandardMapObjectInspector(javaStringObjectInspector, javaLongObjectInspector)), values, values, new ArrayType(mapType(VARCHAR, BIGINT))); }
@Test public void testSingleLevelSchemaArrayOfMaps() throws Exception { Iterable<Map<String, Long>> maps = createTestMaps(transform(intsBetween(0, 10), Object::toString), longsBetween(0, 10)); List<List<Map<String, Long>>> values = createTestArrays(maps); ObjectInspector objectInspector = getStandardListObjectInspector(getStandardMapObjectInspector(javaStringObjectInspector, javaLongObjectInspector)); tester.testSingleLevelArraySchemaRoundTrip(objectInspector, values, values, new ArrayType(mapType(VARCHAR, BIGINT))); }