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

The following examples show how to use org.apache.flink.api.java.typeutils.runtime.DataOutputViewStream. 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: KryoSerializerSnapshotData.java    From Flink-CEPplus with 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 File: KryoSerializerSnapshotData.java    From flink with 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 #3
Source File: MapDataSerializer.java    From flink with 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 #4
Source File: BaseMapSerializer.java    From flink with 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 #5
Source File: BaseRowSerializer.java    From flink with 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 File: KryoSerializerSnapshotData.java    From flink with 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 #7
Source File: RowDataSerializer.java    From flink with 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 File: MapDataSerializer.java    From flink with 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 File: RowDataSerializer.java    From flink with 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 #10
Source File: JavaSerializer.java    From flink with 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 #11
Source File: KryoSerializer.java    From Flink-CEPplus with 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 #12
Source File: KryoSerializer.java    From flink with 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 #13
Source File: ArrayDataSerializer.java    From flink with 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 #14
Source File: ArrayDataSerializer.java    From flink with 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 #15
Source File: SortedMapSerializerSnapshot.java    From flink with 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 #16
Source File: TimestampedHiveInputSplit.java    From flink with 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 #17
Source File: JavaSerializer.java    From flink with 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 #18
Source File: KryoSerializer.java    From flink with 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 #19
Source File: BinaryGenericSerializer.java    From flink with 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 #20
Source File: SortedMapSerializerSnapshot.java    From flink with 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 #21
Source File: BaseArraySerializer.java    From flink with 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 #22
Source File: JavaSerializer.java    From Flink-CEPplus with 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);
	}
}