本文整理汇总了Java中org.apache.flink.api.common.typeutils.base.FloatSerializer类的典型用法代码示例。如果您正苦于以下问题:Java FloatSerializer类的具体用法?Java FloatSerializer怎么用?Java FloatSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FloatSerializer类属于org.apache.flink.api.common.typeutils.base包,在下文中一共展示了FloatSerializer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSerializer
import org.apache.flink.api.common.typeutils.base.FloatSerializer; //导入依赖的package包/类
@Override
protected TypeSerializer<Float> createSerializer() {
return new FloatSerializer();
}
示例2: testValueStateRestoreWithWrongSerializers
import org.apache.flink.api.common.typeutils.base.FloatSerializer; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testValueStateRestoreWithWrongSerializers() throws Exception {
CheckpointStreamFactory streamFactory = createStreamFactory();
AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE);
try {
ValueStateDescriptor<String> kvId = new ValueStateDescriptor<>("id", String.class);
ValueState<String> state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
backend.setCurrentKey(1);
state.update("1");
backend.setCurrentKey(2);
state.update("2");
// draw a snapshot
KeyedStateHandle snapshot1 = FutureUtil.runIfNotDoneAndGet(backend.snapshot(682375462378L, 2, streamFactory, CheckpointOptions.forCheckpoint()));
backend.dispose();
// restore the first snapshot and validate it
backend = restoreKeyedBackend(IntSerializer.INSTANCE, snapshot1);
snapshot1.discardState();
@SuppressWarnings("unchecked")
TypeSerializer<String> fakeStringSerializer =
(TypeSerializer<String>) (TypeSerializer<?>) FloatSerializer.INSTANCE;
try {
kvId = new ValueStateDescriptor<>("id", fakeStringSerializer);
state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
state.value();
fail("should recognize wrong serializers");
} catch (StateMigrationException ignored) {
// expected
}
} finally {
backend.dispose();
}
}
示例3: testListStateRestoreWithWrongSerializers
import org.apache.flink.api.common.typeutils.base.FloatSerializer; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testListStateRestoreWithWrongSerializers() throws Exception {
CheckpointStreamFactory streamFactory = createStreamFactory();
AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE);
try {
ListStateDescriptor<String> kvId = new ListStateDescriptor<>("id", String.class);
ListState<String> state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
backend.setCurrentKey(1);
state.add("1");
backend.setCurrentKey(2);
state.add("2");
// draw a snapshot
KeyedStateHandle snapshot1 = FutureUtil.runIfNotDoneAndGet(backend.snapshot(682375462378L, 2, streamFactory, CheckpointOptions.forCheckpoint()));
backend.dispose();
// restore the first snapshot and validate it
backend = restoreKeyedBackend(IntSerializer.INSTANCE, snapshot1);
snapshot1.discardState();
@SuppressWarnings("unchecked")
TypeSerializer<String> fakeStringSerializer =
(TypeSerializer<String>) (TypeSerializer<?>) FloatSerializer.INSTANCE;
try {
kvId = new ListStateDescriptor<>("id", fakeStringSerializer);
state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
state.get();
fail("should recognize wrong serializers");
} catch (StateMigrationException ignored) {
// expected
}
} finally {
backend.dispose();
}
}
示例4: testReducingStateRestoreWithWrongSerializers
import org.apache.flink.api.common.typeutils.base.FloatSerializer; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testReducingStateRestoreWithWrongSerializers() throws Exception {
CheckpointStreamFactory streamFactory = createStreamFactory();
AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE);
try {
ReducingStateDescriptor<String> kvId = new ReducingStateDescriptor<>("id",
new AppendingReduce(),
StringSerializer.INSTANCE);
ReducingState<String> state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
backend.setCurrentKey(1);
state.add("1");
backend.setCurrentKey(2);
state.add("2");
// draw a snapshot
KeyedStateHandle snapshot1 = FutureUtil.runIfNotDoneAndGet(backend.snapshot(682375462378L, 2, streamFactory, CheckpointOptions.forCheckpoint()));
backend.dispose();
// restore the first snapshot and validate it
backend = restoreKeyedBackend(IntSerializer.INSTANCE, snapshot1);
snapshot1.discardState();
@SuppressWarnings("unchecked")
TypeSerializer<String> fakeStringSerializer =
(TypeSerializer<String>) (TypeSerializer<?>) FloatSerializer.INSTANCE;
try {
kvId = new ReducingStateDescriptor<>("id", new AppendingReduce(), fakeStringSerializer);
state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
state.get();
fail("should recognize wrong serializers");
} catch (StateMigrationException ignored) {
// expected
}
} finally {
backend.dispose();
}
}
示例5: testMapStateRestoreWithWrongSerializers
import org.apache.flink.api.common.typeutils.base.FloatSerializer; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testMapStateRestoreWithWrongSerializers() throws Exception {
CheckpointStreamFactory streamFactory = createStreamFactory();
AbstractKeyedStateBackend<Integer> backend = createKeyedBackend(IntSerializer.INSTANCE);
try {
MapStateDescriptor<String, String> kvId = new MapStateDescriptor<>("id", StringSerializer.INSTANCE, StringSerializer.INSTANCE);
MapState<String, String> state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
backend.setCurrentKey(1);
state.put("1", "First");
backend.setCurrentKey(2);
state.put("2", "Second");
// draw a snapshot
KeyedStateHandle snapshot1 = FutureUtil.runIfNotDoneAndGet(backend.snapshot(682375462378L, 2, streamFactory, CheckpointOptions.forCheckpoint()));
backend.dispose();
// restore the first snapshot and validate it
backend = restoreKeyedBackend(IntSerializer.INSTANCE, snapshot1);
snapshot1.discardState();
@SuppressWarnings("unchecked")
TypeSerializer<String> fakeStringSerializer =
(TypeSerializer<String>) (TypeSerializer<?>) FloatSerializer.INSTANCE;
try {
kvId = new MapStateDescriptor<>("id", fakeStringSerializer, StringSerializer.INSTANCE);
state = backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, kvId);
state.entries();
fail("should recognize wrong serializers");
} catch (StateMigrationException ignored) {
// expected
}
backend.dispose();
} finally {
backend.dispose();
}
}