Java Code Examples for org.apache.flink.api.common.typeutils.base.DoubleValueSerializer

The following examples show how to use org.apache.flink.api.common.typeutils.base.DoubleValueSerializer. 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   Author: ljygz   File: InstantiationUtilTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializationToByteArray() throws IOException {
	final DoubleValue toSerialize = new DoubleValue(Math.random());
	final DoubleValueSerializer serializer = new DoubleValueSerializer();

	byte[] serialized = InstantiationUtil.serializeToByteArray(serializer, toSerialize);

	DoubleValue deserialized = InstantiationUtil.deserializeFromByteArray(serializer, serialized);

	assertEquals("Serialized record is not equal after serialization.", toSerialize, deserialized);
}
 
Example #2
Source Project: flink   Author: flink-tpc-ds   File: InstantiationUtilTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializationToByteArray() throws IOException {
	final DoubleValue toSerialize = new DoubleValue(Math.random());
	final DoubleValueSerializer serializer = new DoubleValueSerializer();

	byte[] serialized = InstantiationUtil.serializeToByteArray(serializer, toSerialize);

	DoubleValue deserialized = InstantiationUtil.deserializeFromByteArray(serializer, serialized);

	assertEquals("Serialized record is not equal after serialization.", toSerialize, deserialized);
}
 
Example #3
Source Project: flink   Author: apache   File: InstantiationUtilTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializationToByteArray() throws IOException {
	final DoubleValue toSerialize = new DoubleValue(Math.random());
	final DoubleValueSerializer serializer = new DoubleValueSerializer();

	byte[] serialized = InstantiationUtil.serializeToByteArray(serializer, toSerialize);

	DoubleValue deserialized = InstantiationUtil.deserializeFromByteArray(serializer, serialized);

	assertEquals("Serialized record is not equal after serialization.", toSerialize, deserialized);
}
 
Example #4
Source Project: Flink-CEPplus   Author: ljygz   File: ValueTypeInfo.java    License: Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
@PublicEvolving
public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
	if (BooleanValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) BooleanValueSerializer.INSTANCE;
	}
	else if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ByteValueSerializer.INSTANCE;
	}
	else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) CharValueSerializer.INSTANCE;
	}
	else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) DoubleValueSerializer.INSTANCE;
	}
	else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) FloatValueSerializer.INSTANCE;
	}
	else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) IntValueSerializer.INSTANCE;
	}
	else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) LongValueSerializer.INSTANCE;
	}
	else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) NullValueSerializer.INSTANCE;
	}
	else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ShortValueSerializer.INSTANCE;
	}
	else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) StringValueSerializer.INSTANCE;
	}
	else if (CopyableValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
	}
	else {
		return new ValueSerializer<T>(type);
	}
}
 
Example #5
Source Project: flink   Author: flink-tpc-ds   File: ValueTypeInfo.java    License: Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
@PublicEvolving
public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
	if (BooleanValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) BooleanValueSerializer.INSTANCE;
	}
	else if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ByteValueSerializer.INSTANCE;
	}
	else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) CharValueSerializer.INSTANCE;
	}
	else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) DoubleValueSerializer.INSTANCE;
	}
	else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) FloatValueSerializer.INSTANCE;
	}
	else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) IntValueSerializer.INSTANCE;
	}
	else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) LongValueSerializer.INSTANCE;
	}
	else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) NullValueSerializer.INSTANCE;
	}
	else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ShortValueSerializer.INSTANCE;
	}
	else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) StringValueSerializer.INSTANCE;
	}
	else if (CopyableValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
	}
	else {
		return new ValueSerializer<T>(type);
	}
}
 
Example #6
Source Project: flink   Author: apache   File: ValueTypeInfo.java    License: Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
@PublicEvolving
public TypeSerializer<T> createSerializer(ExecutionConfig executionConfig) {
	if (BooleanValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) BooleanValueSerializer.INSTANCE;
	}
	else if (ByteValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ByteValueSerializer.INSTANCE;
	}
	else if (CharValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) CharValueSerializer.INSTANCE;
	}
	else if (DoubleValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) DoubleValueSerializer.INSTANCE;
	}
	else if (FloatValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) FloatValueSerializer.INSTANCE;
	}
	else if (IntValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) IntValueSerializer.INSTANCE;
	}
	else if (LongValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) LongValueSerializer.INSTANCE;
	}
	else if (NullValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) NullValueSerializer.INSTANCE;
	}
	else if (ShortValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) ShortValueSerializer.INSTANCE;
	}
	else if (StringValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) StringValueSerializer.INSTANCE;
	}
	else if (CopyableValue.class.isAssignableFrom(type)) {
		return (TypeSerializer<T>) createCopyableValueSerializer(type.asSubclass(CopyableValue.class));
	}
	else {
		return new ValueSerializer<T>(type);
	}
}