public Vertex<K, VV> map(Tuple1<K> value) throws Exception { output.f0 = value.f0; output.f1 = vertexValueInitializer.map(value.f0); return output; } }).returns(returnType).withForwardedFields("f0").name("Initialize vertex values");
public Edge<K, NV> map(Edge<K, EV> value) throws Exception { output.f0 = value.f0; output.f1 = value.f1; output.f2 = mapper.map(value); return output; } })
public Vertex<K, NV> map(Vertex<K, VV> value) throws Exception { output.f0 = value.f0; output.f1 = mapper.map(value); return output; } })
@Override public OUT map(IN value) throws Exception { return mapFunction.map(value); }
@Override public OUT map(IN value) throws Exception { for (ArtificialStateBuilder<IN> stateBuilder : artificialStateBuilders) { stateBuilder.artificialStateForElement(value); } return mapFunction.map(value); }
@Override public PyObject map(PyObject value) throws Exception { try { return AdapterMap.adapt(fun.map(value)); } catch (PyException pe) { throw createAndLogException(pe); } } }
@Override public void processElement(StreamRecord<IN> element) throws Exception { output.collect(element.replace(userFunction.map(element.getValue()))); } }
@Override protected List<OUT> executeOnCollections(List<IN> inputData, RuntimeContext ctx, ExecutionConfig executionConfig) throws Exception { MapFunction<IN, OUT> function = this.userFunction.getUserCodeObject(); FunctionUtils.setFunctionRuntimeContext(function, ctx); FunctionUtils.openFunction(function, this.parameters); ArrayList<OUT> result = new ArrayList<OUT>(inputData.size()); TypeSerializer<IN> inSerializer = getOperatorInfo().getInputType().createSerializer(executionConfig); TypeSerializer<OUT> outSerializer = getOperatorInfo().getOutputType().createSerializer(executionConfig); for (IN element : inputData) { IN inCopy = inSerializer.copy(element); OUT out = function.map(inCopy); result.add(outSerializer.copy(out)); } FunctionUtils.closeFunction(function); return result; } }
@Test public void testCleanedNonSerializable() throws Exception { MapCreator creator = new NonSerializableMapCreator(); MapFunction<Integer, Integer> map = creator.getMap(); ClosureCleaner.clean(map, true); int result = map.map(3); Assert.assertEquals(result, 4); }
@Test(expected = InvalidProgramException.class) public void testNonSerializable() throws Exception { MapCreator creator = new NonSerializableMapCreator(); MapFunction<Integer, Integer> map = creator.getMap(); ClosureCleaner.ensureSerializable(map); int result = map.map(3); Assert.assertEquals(result, 4); }
@Test public void testSerializable() throws Exception { MapCreator creator = new SerializableMapCreator(1); MapFunction<Integer, Integer> map = creator.getMap(); ClosureCleaner.clean(map, true); int result = map.map(3); Assert.assertEquals(result, 4); }
@Test public void testNestedSerializable() throws Exception { MapCreator creator = new NestedSerializableMapCreator(1); MapFunction<Integer, Integer> map = creator.getMap(); ClosureCleaner.clean(map, true); ClosureCleaner.ensureSerializable(map); int result = map.map(3); Assert.assertEquals(result, 4); }
@Test(expected = InvalidProgramException.class) public void testNestedNonSerializable() throws Exception { MapCreator creator = new NestedNonSerializableMapCreator(1); MapFunction<Integer, Integer> map = creator.getMap(); ClosureCleaner.clean(map, true); ClosureCleaner.ensureSerializable(map); int result = map.map(3); Assert.assertEquals(result, 4); } }
public Edge<K, NV> map(Edge<K, EV> value) throws Exception { output.f0 = value.f0; output.f1 = value.f1; output.f2 = mapper.map(value); return output; } })
public Vertex<K, VV> map(Tuple1<K> value) throws Exception { output.f0 = value.f0; output.f1 = vertexValueInitializer.map(value.f0); return output; } }).returns(returnType).withForwardedFields("f0").name("Initialize vertex values");
public Edge<K, NV> map(Edge<K, EV> value) throws Exception { output.f0 = value.f0; output.f1 = value.f1; output.f2 = mapper.map(value); return output; } })
@Override public void collect(IT record) { try { this.numRecordsIn.inc(); this.outputCollector.collect(this.mapper.map(record)); } catch (Exception ex) { throw new ExceptionInChainedStubException(this.taskName, ex); } }
@Override public void collect(IT record) { try { this.numRecordsIn.inc(); this.outputCollector.collect(this.mapper.map(record)); } catch (Exception ex) { throw new ExceptionInChainedStubException(this.taskName, ex); } }
@Override public void processElement(StreamRecord<IN> element) throws Exception { output.collect(element.replace(userFunction.map(element.getValue()))); } }
@Override public void processElement(StreamRecord<IN> element) throws Exception { output.collect(element.replace(userFunction.map(element.getValue()))); } }