@PublicEvolving public static <IN, OUT> TypeInformation<OUT> getMapPartitionReturnTypes(MapPartitionFunction<IN, OUT> mapPartitionInterface, TypeInformation<IN> inType) { return getMapPartitionReturnTypes(mapPartitionInterface, inType, null, false); }
/** * Applies a Map-style operation to the entire partition of the data. * The function is called once per parallel partition of the data, * and the entire partition is available through the given Iterator. * The number of elements that each instance of the MapPartition function * sees is non deterministic and depends on the parallelism of the operation. * * <p>This function is intended for operations that cannot transform individual elements, * requires no grouping of elements. To transform individual elements, * the use of {@code map()} and {@code flatMap()} is preferable. * * @param mapPartition The MapPartitionFunction that is called for the full DataSet. * @return A MapPartitionOperator that represents the transformed DataSet. * * @see MapPartitionFunction * @see MapPartitionOperator */ public <R> MapPartitionOperator<T, R> mapPartition(MapPartitionFunction<T, R> mapPartition) { if (mapPartition == null) { throw new NullPointerException("MapPartition function must not be null."); } String callLocation = Utils.getCallLocationName(); TypeInformation<R> resultType = TypeExtractor.getMapPartitionReturnTypes(mapPartition, getType(), callLocation, true); return new MapPartitionOperator<>(this, resultType, clean(mapPartition), callLocation); }
@Test public void testMapPartitionLambda() { MapPartitionFunction<Tuple2<Tuple1<Integer>, Boolean>, Tuple2<Tuple1<Integer>, String>> f = (i, o) -> {}; TypeInformation<?> ti = TypeExtractor.getMapPartitionReturnTypes(f, NESTED_TUPLE_BOOLEAN_TYPE, null, true); if (!(ti instanceof MissingTypeInfo)) { assertTrue(ti.isTupleType()); assertEquals(2, ti.getArity()); assertTrue(((TupleTypeInfo<?>) ti).getTypeAt(0).isTupleType()); assertEquals(((TupleTypeInfo<?>) ti).getTypeAt(1), BasicTypeInfo.STRING_TYPE_INFO); } }
@PublicEvolving public static <IN, OUT> TypeInformation<OUT> getMapPartitionReturnTypes(MapPartitionFunction<IN, OUT> mapPartitionInterface, TypeInformation<IN> inType) { return getMapPartitionReturnTypes(mapPartitionInterface, inType, null, false); }
@PublicEvolving public static <IN, OUT> TypeInformation<OUT> getMapPartitionReturnTypes(MapPartitionFunction<IN, OUT> mapPartitionInterface, TypeInformation<IN> inType) { return getMapPartitionReturnTypes(mapPartitionInterface, inType, null, false); }
/** * Applies a Map-style operation to the entire partition of the data. * The function is called once per parallel partition of the data, * and the entire partition is available through the given Iterator. * The number of elements that each instance of the MapPartition function * sees is non deterministic and depends on the parallelism of the operation. * * <p>This function is intended for operations that cannot transform individual elements, * requires no grouping of elements. To transform individual elements, * the use of {@code map()} and {@code flatMap()} is preferable. * * @param mapPartition The MapPartitionFunction that is called for the full DataSet. * @return A MapPartitionOperator that represents the transformed DataSet. * * @see MapPartitionFunction * @see MapPartitionOperator */ public <R> MapPartitionOperator<T, R> mapPartition(MapPartitionFunction<T, R> mapPartition) { if (mapPartition == null) { throw new NullPointerException("MapPartition function must not be null."); } String callLocation = Utils.getCallLocationName(); TypeInformation<R> resultType = TypeExtractor.getMapPartitionReturnTypes(mapPartition, getType(), callLocation, true); return new MapPartitionOperator<>(this, resultType, clean(mapPartition), callLocation); }
/** * Applies a Map-style operation to the entire partition of the data. * The function is called once per parallel partition of the data, * and the entire partition is available through the given Iterator. * The number of elements that each instance of the MapPartition function * sees is non deterministic and depends on the parallelism of the operation. * * <p>This function is intended for operations that cannot transform individual elements, * requires no grouping of elements. To transform individual elements, * the use of {@code map()} and {@code flatMap()} is preferable. * * @param mapPartition The MapPartitionFunction that is called for the full DataSet. * @return A MapPartitionOperator that represents the transformed DataSet. * * @see MapPartitionFunction * @see MapPartitionOperator */ public <R> MapPartitionOperator<T, R> mapPartition(MapPartitionFunction<T, R> mapPartition) { if (mapPartition == null) { throw new NullPointerException("MapPartition function must not be null."); } String callLocation = Utils.getCallLocationName(); TypeInformation<R> resultType = TypeExtractor.getMapPartitionReturnTypes(mapPartition, getType(), callLocation, true); return new MapPartitionOperator<>(this, resultType, clean(mapPartition), callLocation); }