/** * Initializes the {@link StreamInvokable} for input and output handling * * @param taskContext StreamTaskContext representing the vertex */ public void setup(StreamTaskContext<OUT> taskContext) { this.collector = taskContext.getOutputCollector(); this.recordIterator = taskContext.getIndexedInput(0); this.inSerializer = taskContext.getInputSerializer(0); if (this.inSerializer != null) { this.nextRecord = inSerializer.createInstance(); this.objectSerializer = inSerializer.getObjectSerializer(); } this.taskContext = taskContext; this.executionConfig = taskContext.getExecutionConfig(); }
/* * Reads the next record from the reader iterator and stores it in the * nextRecord variable */ protected StreamRecord<IN> readNext() { this.nextRecord = inSerializer.createInstance(); try { nextRecord = recordIterator.next(nextRecord); try { nextObject = nextRecord.getObject(); } catch (NullPointerException e) { // end of stream } return nextRecord; } catch (IOException e) { throw new RuntimeException("Could not read next record."); } }
void setSerializers() { outTypeInfo = configuration.getTypeInfoOut1(); outSerializer = new StreamRecordSerializer<OUT>(outTypeInfo); outSerializationDelegate = new SerializationDelegate<StreamRecord<OUT>>(outSerializer); outSerializationDelegate.setInstance(outSerializer.createInstance()); }