Java Code Examples for org.apache.flink.api.java.typeutils.runtime.DataOutputViewStream

The following examples show how to use org.apache.flink.api.java.typeutils.runtime.DataOutputViewStream. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: KryoSerializerSnapshotData.java    License: Apache License 2.0 5 votes vote down vote up
private void writeDefaultKryoSerializers(
	DataOutputView out,
	LinkedOptionalMap<Class<?>, SerializableSerializer<?>> defaultKryoSerializers) throws IOException {

	writeOptionalMap(
		out,
		defaultKryoSerializers,
		(stream, klass) -> stream.writeUTF(klass.getName()),
		(stream, instance) -> {
			try (final DataOutputViewStream outViewWrapper = new DataOutputViewStream(stream)) {
				InstantiationUtil.serializeObject(outViewWrapper, instance);
			}
		});
}
 
Example 2
Source Project: flink   Source File: BaseMapSerializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	DataOutputViewStream outStream = new DataOutputViewStream(out);
	InstantiationUtil.serializeObject(outStream, previousKeyType);
	InstantiationUtil.serializeObject(outStream, previousValueType);
	InstantiationUtil.serializeObject(outStream, previousKeySerializer);
	InstantiationUtil.serializeObject(outStream, previousValueSerializer);
}
 
Example 3
Source Project: flink   Source File: BaseRowSerializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	out.writeInt(previousTypes.length);
	DataOutputViewStream stream = new DataOutputViewStream(out);
	for (LogicalType previousType : previousTypes) {
		InstantiationUtil.serializeObject(stream, previousType);
	}
	nestedSerializersSnapshotDelegate.writeNestedSerializerSnapshots(out);
}
 
Example 4
Source Project: flink   Source File: KryoSerializerSnapshotData.java    License: Apache License 2.0 5 votes vote down vote up
private void writeDefaultKryoSerializers(
	DataOutputView out,
	LinkedOptionalMap<Class<?>, SerializableSerializer<?>> defaultKryoSerializers) throws IOException {

	writeOptionalMap(
		out,
		defaultKryoSerializers,
		(stream, klass) -> stream.writeUTF(klass.getName()),
		(stream, instance) -> {
			try (final DataOutputViewStream outViewWrapper = new DataOutputViewStream(stream)) {
				InstantiationUtil.serializeObject(outViewWrapper, instance);
			}
		});
}
 
Example 5
Source Project: flink   Source File: RowDataSerializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	out.writeInt(previousTypes.length);
	DataOutputViewStream stream = new DataOutputViewStream(out);
	for (LogicalType previousType : previousTypes) {
		InstantiationUtil.serializeObject(stream, previousType);
	}
	nestedSerializersSnapshotDelegate.writeNestedSerializerSnapshots(out);
}
 
Example 6
Source Project: flink   Source File: MapDataSerializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	DataOutputViewStream outStream = new DataOutputViewStream(out);
	InstantiationUtil.serializeObject(outStream, previousKeyType);
	InstantiationUtil.serializeObject(outStream, previousValueType);
	InstantiationUtil.serializeObject(outStream, previousKeySerializer);
	InstantiationUtil.serializeObject(outStream, previousValueSerializer);
}
 
Example 7
Source Project: flink   Source File: RowDataSerializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	out.writeInt(previousTypes.length);
	DataOutputViewStream stream = new DataOutputViewStream(out);
	for (LogicalType previousType : previousTypes) {
		InstantiationUtil.serializeObject(stream, previousType);
	}
	nestedSerializersSnapshotDelegate.writeNestedSerializerSnapshots(out);
}
 
Example 8
Source Project: flink   Source File: MapDataSerializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	DataOutputViewStream outStream = new DataOutputViewStream(out);
	InstantiationUtil.serializeObject(outStream, previousKeyType);
	InstantiationUtil.serializeObject(outStream, previousValueType);
	InstantiationUtil.serializeObject(outStream, previousKeySerializer);
	InstantiationUtil.serializeObject(outStream, previousValueSerializer);
}
 
Example 9
Source Project: flink   Source File: KryoSerializerSnapshotData.java    License: Apache License 2.0 5 votes vote down vote up
private void writeDefaultKryoSerializers(
	DataOutputView out,
	LinkedOptionalMap<Class<?>, SerializableSerializer<?>> defaultKryoSerializers) throws IOException {

	writeOptionalMap(
		out,
		defaultKryoSerializers,
		(stream, klass) -> stream.writeUTF(klass.getName()),
		(stream, instance) -> {
			try (final DataOutputViewStream outViewWrapper = new DataOutputViewStream(stream)) {
				InstantiationUtil.serializeObject(outViewWrapper, instance);
			}
		});
}
 
Example 10
Source Project: Flink-CEPplus   Source File: KryoSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(T record, DataOutputView target) throws IOException {
	if (CONCURRENT_ACCESS_CHECK) {
		enterExclusiveThread();
	}

	try {
		checkKryoInitialized();

		if (target != previousOut) {
			DataOutputViewStream outputStream = new DataOutputViewStream(target);
			output = new Output(outputStream);
			previousOut = target;
		}

		// Sanity check: Make sure that the output is cleared/has been flushed by the last call
		// otherwise data might be written multiple times in case of a previous EOFException
		if (output.position() != 0) {
			throw new IllegalStateException("The Kryo Output still contains data from a previous " +
				"serialize call. It has to be flushed or cleared at the end of the serialize call.");
		}

		try {
			kryo.writeClassAndObject(output, record);
			output.flush();
		}
		catch (KryoException ke) {
			// make sure that the Kryo output buffer is cleared in case that we can recover from
			// the exception (e.g. EOFException which denotes buffer full)
			output.clear();

			Throwable cause = ke.getCause();
			if (cause instanceof EOFException) {
				throw (EOFException) cause;
			}
			else {
				throw ke;
			}
		}
	}
	finally {
		if (CONCURRENT_ACCESS_CHECK) {
			exitExclusiveThread();
		}
	}
}
 
Example 11
Source Project: Flink-CEPplus   Source File: JavaSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(T record, DataOutputView target) throws IOException {
	try (final DataOutputViewStream outViewWrapper = new DataOutputViewStream(target)) {
		InstantiationUtil.serializeObject(outViewWrapper, record);
	}
}
 
Example 12
Source Project: flink   Source File: BaseArraySerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	DataOutputViewStream outStream = new DataOutputViewStream(out);
	InstantiationUtil.serializeObject(outStream, previousType);
	InstantiationUtil.serializeObject(outStream, previousEleSer);
}
 
Example 13
Source Project: flink   Source File: SortedMapSerializerSnapshot.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	checkState(comparator != null, "Comparator cannot be null.");
	InstantiationUtil.serializeObject(new DataOutputViewStream(out), comparator);
	nestedSerializersSnapshotDelegate.writeNestedSerializerSnapshots(out);
}
 
Example 14
Source Project: flink   Source File: BinaryGenericSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	InstantiationUtil.serializeObject(new DataOutputViewStream(out), previousSerializer);
}
 
Example 15
Source Project: flink   Source File: KryoSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(T record, DataOutputView target) throws IOException {
	if (CONCURRENT_ACCESS_CHECK) {
		enterExclusiveThread();
	}

	try {
		checkKryoInitialized();

		if (target != previousOut) {
			DataOutputViewStream outputStream = new DataOutputViewStream(target);
			output = new Output(outputStream);
			previousOut = target;
		}

		// Sanity check: Make sure that the output is cleared/has been flushed by the last call
		// otherwise data might be written multiple times in case of a previous EOFException
		if (output.position() != 0) {
			throw new IllegalStateException("The Kryo Output still contains data from a previous " +
				"serialize call. It has to be flushed or cleared at the end of the serialize call.");
		}

		try {
			kryo.writeClassAndObject(output, record);
			output.flush();
		}
		catch (KryoException ke) {
			// make sure that the Kryo output buffer is cleared in case that we can recover from
			// the exception (e.g. EOFException which denotes buffer full)
			output.clear();

			Throwable cause = ke.getCause();
			if (cause instanceof EOFException) {
				throw (EOFException) cause;
			}
			else {
				throw ke;
			}
		}
	}
	finally {
		if (CONCURRENT_ACCESS_CHECK) {
			exitExclusiveThread();
		}
	}
}
 
Example 16
Source Project: flink   Source File: JavaSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(T record, DataOutputView target) throws IOException {
	try (final DataOutputViewStream outViewWrapper = new DataOutputViewStream(target)) {
		InstantiationUtil.serializeObject(outViewWrapper, record);
	}
}
 
Example 17
Source Project: flink   Source File: TimestampedHiveInputSplit.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(TimestampedHiveInputSplit record, DataOutputView target) throws IOException {
	try (final DataOutputViewStream outViewWrapper = new DataOutputViewStream(target)) {
		InstantiationUtil.serializeObject(outViewWrapper, record);
	}
}
 
Example 18
Source Project: flink   Source File: SortedMapSerializerSnapshot.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	checkState(comparator != null, "Comparator cannot be null.");
	InstantiationUtil.serializeObject(new DataOutputViewStream(out), comparator);
	nestedSerializersSnapshotDelegate.writeNestedSerializerSnapshots(out);
}
 
Example 19
Source Project: flink   Source File: ArrayDataSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	DataOutputViewStream outStream = new DataOutputViewStream(out);
	InstantiationUtil.serializeObject(outStream, previousType);
	InstantiationUtil.serializeObject(outStream, previousEleSer);
}
 
Example 20
Source Project: flink   Source File: ArrayDataSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void writeSnapshot(DataOutputView out) throws IOException {
	DataOutputViewStream outStream = new DataOutputViewStream(out);
	InstantiationUtil.serializeObject(outStream, previousType);
	InstantiationUtil.serializeObject(outStream, previousEleSer);
}
 
Example 21
Source Project: flink   Source File: KryoSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(T record, DataOutputView target) throws IOException {
	if (CONCURRENT_ACCESS_CHECK) {
		enterExclusiveThread();
	}

	try {
		checkKryoInitialized();

		if (target != previousOut) {
			DataOutputViewStream outputStream = new DataOutputViewStream(target);
			output = new Output(outputStream);
			previousOut = target;
		}

		// Sanity check: Make sure that the output is cleared/has been flushed by the last call
		// otherwise data might be written multiple times in case of a previous EOFException
		if (output.position() != 0) {
			throw new IllegalStateException("The Kryo Output still contains data from a previous " +
				"serialize call. It has to be flushed or cleared at the end of the serialize call.");
		}

		try {
			kryo.writeClassAndObject(output, record);
			output.flush();
		}
		catch (KryoException ke) {
			// make sure that the Kryo output buffer is cleared in case that we can recover from
			// the exception (e.g. EOFException which denotes buffer full)
			output.clear();

			Throwable cause = ke.getCause();
			if (cause instanceof EOFException) {
				throw (EOFException) cause;
			}
			else {
				throw ke;
			}
		}
	}
	finally {
		if (CONCURRENT_ACCESS_CHECK) {
			exitExclusiveThread();
		}
	}
}
 
Example 22
Source Project: flink   Source File: JavaSerializer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(T record, DataOutputView target) throws IOException {
	try (final DataOutputViewStream outViewWrapper = new DataOutputViewStream(target)) {
		InstantiationUtil.serializeObject(outViewWrapper, record);
	}
}