org.apache.flink.runtime.plugable.DeserializationDelegate Java Examples

The following examples show how to use org.apache.flink.runtime.plugable.DeserializationDelegate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StreamTaskNetworkInput.java    From flink with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
StreamTaskNetworkInput(
	CheckpointedInputGate checkpointedInputGate,
	TypeSerializer<?> inputSerializer,
	StatusWatermarkValve statusWatermarkValve,
	int inputIndex,
	RecordDeserializer<DeserializationDelegate<StreamElement>>[] recordDeserializers) {

	this.checkpointedInputGate = checkpointedInputGate;
	this.deserializationDelegate = new NonReusingDeserializationDelegate<>(
		new StreamElementSerializer<>(inputSerializer));
	this.recordDeserializers = recordDeserializers;
	this.statusWatermarkValve = statusWatermarkValve;
	this.inputIndex = inputIndex;
	this.channelIndexes = getChannelIndexes(checkpointedInputGate);
}
 
Example #2
Source File: BatchTask.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
protected MutableObjectIterator<?> createInputIterator(MutableReader<?> inputReader, TypeSerializerFactory<?> serializerFactory) {
	@SuppressWarnings("unchecked")
	MutableReader<DeserializationDelegate<?>> reader = (MutableReader<DeserializationDelegate<?>>) inputReader;
	@SuppressWarnings({ "unchecked", "rawtypes" })
	final MutableObjectIterator<?> iter = new ReaderIterator(reader, serializerFactory.getSerializer());
	return iter;
}
 
Example #3
Source File: DataSinkTask.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the input readers of the DataSinkTask.
 * 
 * @throws RuntimeException
 *         Thrown in case of invalid task input configuration.
 */
@SuppressWarnings("unchecked")
private void initInputReaders() throws Exception {
	int numGates = 0;
	//  ---------------- create the input readers ---------------------
	// in case where a logical input unions multiple physical inputs, create a union reader
	final int groupSize = this.config.getGroupSize(0);
	numGates += groupSize;
	if (groupSize == 1) {
		// non-union case
		inputReader = new MutableRecordReader<DeserializationDelegate<IT>>(
				getEnvironment().getInputGate(0),
				getEnvironment().getTaskManagerInfo().getTmpDirectories());
	} else if (groupSize > 1){
		// union case
		inputReader = new MutableRecordReader<IOReadableWritable>(
				new UnionInputGate(getEnvironment().getAllInputGates()),
				getEnvironment().getTaskManagerInfo().getTmpDirectories());
	} else {
		throw new Exception("Illegal input group size in task configuration: " + groupSize);
	}
	
	this.inputTypeSerializerFactory = this.config.getInputSerializer(0, getUserCodeClassLoader());
	@SuppressWarnings({ "rawtypes" })
	final MutableObjectIterator<?> iter = new ReaderIterator(inputReader, this.inputTypeSerializerFactory.getSerializer());
	this.reader = (MutableObjectIterator<IT>)iter;

	// final sanity check
	if (numGates != this.config.getNumInputs()) {
		throw new Exception("Illegal configuration: Number of input gates and group sizes are not consistent.");
	}
}
 
Example #4
Source File: BatchTask.java    From flink with Apache License 2.0 5 votes vote down vote up
protected MutableObjectIterator<?> createInputIterator(MutableReader<?> inputReader, TypeSerializerFactory<?> serializerFactory) {
	@SuppressWarnings("unchecked")
	MutableReader<DeserializationDelegate<?>> reader = (MutableReader<DeserializationDelegate<?>>) inputReader;
	@SuppressWarnings({ "unchecked", "rawtypes" })
	final MutableObjectIterator<?> iter = new ReaderIterator(reader, serializerFactory.getSerializer());
	return iter;
}
 
Example #5
Source File: DataSinkTask.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the input readers of the DataSinkTask.
 * 
 * @throws RuntimeException
 *         Thrown in case of invalid task input configuration.
 */
@SuppressWarnings("unchecked")
private void initInputReaders() throws Exception {
	int numGates = 0;
	//  ---------------- create the input readers ---------------------
	// in case where a logical input unions multiple physical inputs, create a union reader
	final int groupSize = this.config.getGroupSize(0);
	numGates += groupSize;
	if (groupSize == 1) {
		// non-union case
		inputReader = new MutableRecordReader<DeserializationDelegate<IT>>(
				getEnvironment().getInputGate(0),
				getEnvironment().getTaskManagerInfo().getTmpDirectories());
	} else if (groupSize > 1){
		// union case
		inputReader = new MutableRecordReader<IOReadableWritable>(
				new UnionInputGate(getEnvironment().getAllInputGates()),
				getEnvironment().getTaskManagerInfo().getTmpDirectories());
	} else {
		throw new Exception("Illegal input group size in task configuration: " + groupSize);
	}
	
	this.inputTypeSerializerFactory = this.config.getInputSerializer(0, getUserCodeClassLoader());
	@SuppressWarnings({ "rawtypes" })
	final MutableObjectIterator<?> iter = new ReaderIterator(inputReader, this.inputTypeSerializerFactory.getSerializer());
	this.reader = (MutableObjectIterator<IT>)iter;

	// final sanity check
	if (numGates != this.config.getNumInputs()) {
		throw new Exception("Illegal configuration: Number of input gates and group sizes are not consistent.");
	}
}
 
Example #6
Source File: BatchTask.java    From flink with Apache License 2.0 5 votes vote down vote up
protected MutableObjectIterator<?> createInputIterator(MutableReader<?> inputReader, TypeSerializerFactory<?> serializerFactory) {
	@SuppressWarnings("unchecked")
	MutableReader<DeserializationDelegate<?>> reader = (MutableReader<DeserializationDelegate<?>>) inputReader;
	@SuppressWarnings({ "unchecked", "rawtypes" })
	final MutableObjectIterator<?> iter = new ReaderIterator(reader, serializerFactory.getSerializer());
	return iter;
}
 
Example #7
Source File: DataSinkTask.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the input readers of the DataSinkTask.
 * 
 * @throws RuntimeException
 *         Thrown in case of invalid task input configuration.
 */
@SuppressWarnings("unchecked")
private void initInputReaders() throws Exception {
	int numGates = 0;
	//  ---------------- create the input readers ---------------------
	// in case where a logical input unions multiple physical inputs, create a union reader
	final int groupSize = this.config.getGroupSize(0);
	numGates += groupSize;
	if (groupSize == 1) {
		// non-union case
		inputReader = new MutableRecordReader<DeserializationDelegate<IT>>(
				getEnvironment().getInputGate(0),
				getEnvironment().getTaskManagerInfo().getTmpDirectories());
	} else if (groupSize > 1){
		// union case
		inputReader = new MutableRecordReader<IOReadableWritable>(
				new UnionInputGate(getEnvironment().getAllInputGates()),
				getEnvironment().getTaskManagerInfo().getTmpDirectories());
	} else {
		throw new Exception("Illegal input group size in task configuration: " + groupSize);
	}
	
	this.inputTypeSerializerFactory = this.config.getInputSerializer(0, getUserCodeClassLoader());
	@SuppressWarnings({ "rawtypes" })
	final MutableObjectIterator<?> iter = new ReaderIterator(inputReader, this.inputTypeSerializerFactory.getSerializer());
	this.reader = (MutableObjectIterator<IT>)iter;

	// final sanity check
	if (numGates != this.config.getNumInputs()) {
		throw new Exception("Illegal configuration: Number of input gates and group sizes are not consistent.");
	}
}
 
Example #8
Source File: ReaderIterator.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new iterator, wrapping the given reader.
 * 
 * @param reader The reader to wrap.
 */
public ReaderIterator(MutableReader<DeserializationDelegate<T>> reader, TypeSerializer<T> serializer) {
	this.reader = reader;
	this.reusingDelegate = new ReusingDeserializationDelegate<T>(serializer);
	this.nonReusingDelegate = new NonReusingDeserializationDelegate<T>(serializer);
}
 
Example #9
Source File: ReaderIterator.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new iterator, wrapping the given reader.
 * 
 * @param reader The reader to wrap.
 */
public ReaderIterator(MutableReader<DeserializationDelegate<T>> reader, TypeSerializer<T> serializer) {
	this.reader = reader;
	this.reusingDelegate = new ReusingDeserializationDelegate<T>(serializer);
	this.nonReusingDelegate = new NonReusingDeserializationDelegate<T>(serializer);
}
 
Example #10
Source File: ReaderIterator.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new iterator, wrapping the given reader.
 * 
 * @param reader The reader to wrap.
 */
public ReaderIterator(MutableReader<DeserializationDelegate<T>> reader, TypeSerializer<T> serializer) {
	this.reader = reader;
	this.reusingDelegate = new ReusingDeserializationDelegate<T>(serializer);
	this.nonReusingDelegate = new NonReusingDeserializationDelegate<T>(serializer);
}