Java Code Examples for org.apache.flink.api.common.typeutils.base.DoubleSerializer#INSTANCE
The following examples show how to use
org.apache.flink.api.common.typeutils.base.DoubleSerializer#INSTANCE .
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: TupleComparatorTTT1Test.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() { return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>( (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class, new TypeSerializer[]{ new TupleSerializer<Tuple2<String, Double>> ( (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ StringSerializer.INSTANCE, DoubleSerializer.INSTANCE }), new TupleSerializer<Tuple2<Long, Long>> ( (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ LongSerializer.INSTANCE, LongSerializer.INSTANCE }), new TupleSerializer<Tuple2<Integer, Long>> ( (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE }) }); }
Example 2
Source File: TupleComparatorTTT2Test.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() { return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>( (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class, new TypeSerializer[]{ new TupleSerializer<Tuple2<String, Double>> ( (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ StringSerializer.INSTANCE, DoubleSerializer.INSTANCE}), new TupleSerializer<Tuple2<Long, Long>> ( (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ LongSerializer.INSTANCE, LongSerializer.INSTANCE}), new TupleSerializer<Tuple2<Integer, Long>> ( (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE}) }); }
Example 3
Source File: TupleComparatorTTT2Test.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createSerializer() { return new TupleSerializer<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>( (Class<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>) (Class<?>) Tuple3.class, new TypeSerializer[]{ new TupleSerializer<Tuple2<String, Double>> ( (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ StringSerializer.INSTANCE, DoubleSerializer.INSTANCE}), new TupleSerializer<Tuple2<Long, Long>> ( (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ LongSerializer.INSTANCE, LongSerializer.INSTANCE}), new TupleSerializer<Tuple2<Integer, Long>> ( (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE}) }); }
Example 4
Source File: SerializationProxiesTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testKeyedStateMetaInfoSerialization() throws Exception { String name = "test"; TypeSerializer<?> namespaceSerializer = LongSerializer.INSTANCE; TypeSerializer<?> stateSerializer = DoubleSerializer.INSTANCE; StateMetaInfoSnapshot metaInfo = new RegisteredKeyValueStateBackendMetaInfo<>( StateDescriptor.Type.VALUE, name, namespaceSerializer, stateSerializer).snapshot(); byte[] serialized; try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) { StateMetaInfoSnapshotReadersWriters.getWriter(). writeStateMetaInfoSnapshot(metaInfo, new DataOutputViewStreamWrapper(out)); serialized = out.toByteArray(); } try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) { final StateMetaInfoReader reader = StateMetaInfoSnapshotReadersWriters.getReader( CURRENT_STATE_META_INFO_SNAPSHOT_VERSION, StateMetaInfoSnapshotReadersWriters.StateTypeHint.KEYED_STATE); metaInfo = reader.readStateMetaInfoSnapshot( new DataInputViewStreamWrapper(in), Thread.currentThread().getContextClassLoader()); } Assert.assertEquals(name, metaInfo.getName()); }
Example 5
Source File: SerializationProxiesTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testKeyedStateMetaInfoSerialization() throws Exception { String name = "test"; TypeSerializer<?> namespaceSerializer = LongSerializer.INSTANCE; TypeSerializer<?> stateSerializer = DoubleSerializer.INSTANCE; StateMetaInfoSnapshot metaInfo = new RegisteredKeyValueStateBackendMetaInfo<>( StateDescriptor.Type.VALUE, name, namespaceSerializer, stateSerializer).snapshot(); byte[] serialized; try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) { StateMetaInfoSnapshotReadersWriters.getWriter(). writeStateMetaInfoSnapshot(metaInfo, new DataOutputViewStreamWrapper(out)); serialized = out.toByteArray(); } try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) { final StateMetaInfoReader reader = StateMetaInfoSnapshotReadersWriters.getReader( CURRENT_STATE_META_INFO_SNAPSHOT_VERSION, StateMetaInfoSnapshotReadersWriters.StateTypeHint.KEYED_STATE); metaInfo = reader.readStateMetaInfoSnapshot( new DataInputViewStreamWrapper(in), Thread.currentThread().getContextClassLoader()); } Assert.assertEquals(name, metaInfo.getName()); }
Example 6
Source File: TupleComparatorILDXC2Test.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) { return new TupleComparator<Tuple3<Integer, Long, Double>>( new int[]{2, 1}, new TypeComparator[]{ new DoubleComparator(ascending), new LongComparator(ascending) }, new TypeSerializer[]{ IntSerializer.INSTANCE, DoubleSerializer.INSTANCE, LongSerializer.INSTANCE }); }
Example 7
Source File: TupleComparatorILDXC2Test.java From flink with Apache License 2.0 | 5 votes |
@Override protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) { return new TupleComparator<Tuple3<Integer, Long, Double>>( new int[]{2, 1}, new TypeComparator[]{ new DoubleComparator(ascending), new LongComparator(ascending) }, new TypeSerializer[]{ IntSerializer.INSTANCE, DoubleSerializer.INSTANCE, LongSerializer.INSTANCE }); }
Example 8
Source File: SerializationProxiesTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testOperatorStateMetaInfoSerialization() throws Exception { String name = "test"; TypeSerializer<?> stateSerializer = DoubleSerializer.INSTANCE; StateMetaInfoSnapshot snapshot = new RegisteredOperatorStateBackendMetaInfo<>( name, stateSerializer, OperatorStateHandle.Mode.UNION).snapshot(); byte[] serialized; try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) { StateMetaInfoSnapshotReadersWriters.getWriter().writeStateMetaInfoSnapshot(snapshot, new DataOutputViewStreamWrapper(out)); serialized = out.toByteArray(); } try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) { final StateMetaInfoReader reader = StateMetaInfoSnapshotReadersWriters.getReader( CURRENT_STATE_META_INFO_SNAPSHOT_VERSION, StateMetaInfoSnapshotReadersWriters.StateTypeHint.OPERATOR_STATE); snapshot = reader.readStateMetaInfoSnapshot( new DataInputViewStreamWrapper(in), Thread.currentThread().getContextClassLoader()); } RegisteredOperatorStateBackendMetaInfo<?> restoredMetaInfo = new RegisteredOperatorStateBackendMetaInfo<>(snapshot); Assert.assertEquals(name, restoredMetaInfo.getName()); Assert.assertEquals(OperatorStateHandle.Mode.UNION, restoredMetaInfo.getAssignmentMode()); Assert.assertEquals(stateSerializer, restoredMetaInfo.getPartitionStateSerializer()); }
Example 9
Source File: SerializationProxiesTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testKeyedBackendSerializationProxyRoundtrip() throws Exception { TypeSerializer<?> keySerializer = IntSerializer.INSTANCE; TypeSerializer<?> namespaceSerializer = LongSerializer.INSTANCE; TypeSerializer<?> stateSerializer = DoubleSerializer.INSTANCE; List<StateMetaInfoSnapshot> stateMetaInfoList = new ArrayList<>(); stateMetaInfoList.add(new RegisteredKeyValueStateBackendMetaInfo<>( StateDescriptor.Type.VALUE, "a", namespaceSerializer, stateSerializer).snapshot()); stateMetaInfoList.add(new RegisteredKeyValueStateBackendMetaInfo<>( StateDescriptor.Type.VALUE, "b", namespaceSerializer, stateSerializer).snapshot()); stateMetaInfoList.add(new RegisteredKeyValueStateBackendMetaInfo<>( StateDescriptor.Type.VALUE, "c", namespaceSerializer, stateSerializer).snapshot()); KeyedBackendSerializationProxy<?> serializationProxy = new KeyedBackendSerializationProxy<>(keySerializer, stateMetaInfoList, true); byte[] serialized; try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) { serializationProxy.write(new DataOutputViewStreamWrapper(out)); serialized = out.toByteArray(); } serializationProxy = new KeyedBackendSerializationProxy<>(Thread.currentThread().getContextClassLoader()); try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) { serializationProxy.read(new DataInputViewStreamWrapper(in)); } Assert.assertTrue(serializationProxy.isUsingKeyGroupCompression()); Assert.assertTrue(serializationProxy.getKeySerializerSnapshot() instanceof IntSerializer.IntSerializerSnapshot); assertEqualStateMetaInfoSnapshotsLists(stateMetaInfoList, serializationProxy.getStateMetaInfoSnapshots()); }
Example 10
Source File: TupleComparatorTTT2Test.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override protected TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createComparator( boolean ascending) { return new TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>( new int[] { 0, 2 }, new TypeComparator[] { new TupleComparator<Tuple2<String, Double>>( new int[] { 0, 1 }, new TypeComparator[] { new StringComparator(ascending), new DoubleComparator(ascending) }, new TypeSerializer[] { StringSerializer.INSTANCE, DoubleSerializer.INSTANCE }), new TupleComparator<Tuple2<Integer, Long>>( new int[] { 0, 1 }, new TypeComparator[] { new IntComparator(ascending), new LongComparator(ascending) }, new TypeSerializer[] { IntSerializer.INSTANCE, LongSerializer.INSTANCE }) }, new TypeSerializer[] { new TupleSerializer<Tuple2<String, Double>>( (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class, new TypeSerializer[] { StringSerializer.INSTANCE, DoubleSerializer.INSTANCE }), new TupleSerializer<Tuple2<Long, Long>>( (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[] { LongSerializer.INSTANCE, LongSerializer.INSTANCE }), new TupleSerializer<Tuple2<Integer, Long>>( (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[] { IntSerializer.INSTANCE, LongSerializer.INSTANCE }) }); }
Example 11
Source File: TupleComparatorILDXC2Test.java From flink with Apache License 2.0 | 5 votes |
@Override protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) { return new TupleComparator<Tuple3<Integer, Long, Double>>( new int[]{2, 1}, new TypeComparator[]{ new DoubleComparator(ascending), new LongComparator(ascending) }, new TypeSerializer[]{ IntSerializer.INSTANCE, DoubleSerializer.INSTANCE, LongSerializer.INSTANCE }); }
Example 12
Source File: TupleComparatorILDC3Test.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) { return new TupleComparator<Tuple3<Integer, Long, Double>>( new int[]{2, 0, 1}, new TypeComparator[]{ new DoubleComparator(ascending), new IntComparator(ascending), new LongComparator(ascending) }, new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE, DoubleSerializer.INSTANCE }); }
Example 13
Source File: TupleComparatorILD3Test.java From flink with Apache License 2.0 | 5 votes |
@Override protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) { return new TupleComparator<Tuple3<Integer, Long, Double>>( new int[]{0, 1, 2}, new TypeComparator[]{ new IntComparator(ascending), new LongComparator(ascending), new DoubleComparator(ascending) }, new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE, DoubleSerializer.INSTANCE }); }
Example 14
Source File: TupleComparatorILDC3Test.java From flink with Apache License 2.0 | 5 votes |
@Override protected TupleComparator<Tuple3<Integer, Long, Double>> createComparator(boolean ascending) { return new TupleComparator<Tuple3<Integer, Long, Double>>( new int[]{2, 0, 1}, new TypeComparator[]{ new DoubleComparator(ascending), new IntComparator(ascending), new LongComparator(ascending) }, new TypeSerializer[]{ IntSerializer.INSTANCE, LongSerializer.INSTANCE, DoubleSerializer.INSTANCE }); }
Example 15
Source File: SerializationProxiesTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testOperatorBackendSerializationProxyRoundtrip() throws Exception { TypeSerializer<?> stateSerializer = DoubleSerializer.INSTANCE; TypeSerializer<?> keySerializer = DoubleSerializer.INSTANCE; TypeSerializer<?> valueSerializer = StringSerializer.INSTANCE; List<StateMetaInfoSnapshot> stateMetaInfoSnapshots = new ArrayList<>(); stateMetaInfoSnapshots.add(new RegisteredOperatorStateBackendMetaInfo<>( "a", stateSerializer, OperatorStateHandle.Mode.SPLIT_DISTRIBUTE).snapshot()); stateMetaInfoSnapshots.add(new RegisteredOperatorStateBackendMetaInfo<>( "b", stateSerializer, OperatorStateHandle.Mode.SPLIT_DISTRIBUTE).snapshot()); stateMetaInfoSnapshots.add(new RegisteredOperatorStateBackendMetaInfo<>( "c", stateSerializer, OperatorStateHandle.Mode.UNION).snapshot()); List<StateMetaInfoSnapshot> broadcastStateMetaInfoSnapshots = new ArrayList<>(); broadcastStateMetaInfoSnapshots.add(new RegisteredBroadcastStateBackendMetaInfo<>( "d", OperatorStateHandle.Mode.BROADCAST, keySerializer, valueSerializer).snapshot()); broadcastStateMetaInfoSnapshots.add(new RegisteredBroadcastStateBackendMetaInfo<>( "e", OperatorStateHandle.Mode.BROADCAST, valueSerializer, keySerializer).snapshot()); OperatorBackendSerializationProxy serializationProxy = new OperatorBackendSerializationProxy(stateMetaInfoSnapshots, broadcastStateMetaInfoSnapshots); byte[] serialized; try (ByteArrayOutputStreamWithPos out = new ByteArrayOutputStreamWithPos()) { serializationProxy.write(new DataOutputViewStreamWrapper(out)); serialized = out.toByteArray(); } serializationProxy = new OperatorBackendSerializationProxy(Thread.currentThread().getContextClassLoader()); try (ByteArrayInputStreamWithPos in = new ByteArrayInputStreamWithPos(serialized)) { serializationProxy.read(new DataInputViewStreamWrapper(in)); } assertEqualStateMetaInfoSnapshotsLists(stateMetaInfoSnapshots, serializationProxy.getOperatorStateMetaInfoSnapshots()); assertEqualStateMetaInfoSnapshotsLists(broadcastStateMetaInfoSnapshots, serializationProxy.getBroadcastStateMetaInfoSnapshots()); }
Example 16
Source File: LastValueWithRetractAggFunction.java From flink with Apache License 2.0 | 4 votes |
@Override protected TypeSerializer<Double> createValueSerializer() { return DoubleSerializer.INSTANCE; }
Example 17
Source File: PythonTypeUtils.java From flink with Apache License 2.0 | 4 votes |
@Override public TypeSerializer visit(DoubleType doubleType) { return DoubleSerializer.INSTANCE; }
Example 18
Source File: LastValueWithRetractAggFunction.java From flink with Apache License 2.0 | 4 votes |
@Override protected TypeSerializer<Double> createValueSerializer() { return DoubleSerializer.INSTANCE; }
Example 19
Source File: InternalSerializers.java From flink with Apache License 2.0 | 4 votes |
public static TypeSerializer create(LogicalType type, ExecutionConfig config) { switch (type.getTypeRoot()) { case BOOLEAN: return BooleanSerializer.INSTANCE; case TINYINT: return ByteSerializer.INSTANCE; case SMALLINT: return ShortSerializer.INSTANCE; case INTEGER: case DATE: case TIME_WITHOUT_TIME_ZONE: case INTERVAL_YEAR_MONTH: return IntSerializer.INSTANCE; case BIGINT: case TIMESTAMP_WITHOUT_TIME_ZONE: case TIMESTAMP_WITH_LOCAL_TIME_ZONE: case INTERVAL_DAY_TIME: return LongSerializer.INSTANCE; case FLOAT: return FloatSerializer.INSTANCE; case DOUBLE: return DoubleSerializer.INSTANCE; case CHAR: case VARCHAR: return BinaryStringSerializer.INSTANCE; case DECIMAL: DecimalType decimalType = (DecimalType) type; return new DecimalSerializer(decimalType.getPrecision(), decimalType.getScale()); case ARRAY: return new BaseArraySerializer(((ArrayType) type).getElementType(), config); case MAP: MapType mapType = (MapType) type; return new BaseMapSerializer(mapType.getKeyType(), mapType.getValueType(), config); case MULTISET: return new BaseMapSerializer(((MultisetType) type).getElementType(), new IntType(), config); case ROW: RowType rowType = (RowType) type; return new BaseRowSerializer(config, rowType); case BINARY: case VARBINARY: return BytePrimitiveArraySerializer.INSTANCE; case ANY: return new BinaryGenericSerializer( ((TypeInformationAnyType) type).getTypeInformation().createSerializer(config)); default: throw new RuntimeException("Not support type: " + type); } }
Example 20
Source File: TupleComparatorTTT3Test.java From flink with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override protected TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>> createComparator( boolean ascending) { return new TupleComparator<Tuple3<Tuple2<String, Double>, Tuple2<Long, Long>, Tuple2<Integer, Long>>>( new int[] { 0, 1, 2 }, new TypeComparator[] { new TupleComparator<Tuple2<String, Double>>( new int[] { 0, 1 }, new TypeComparator[] { new StringComparator(ascending), new DoubleComparator(ascending) }, new TypeSerializer[] { StringSerializer.INSTANCE, DoubleSerializer.INSTANCE }), new TupleComparator<Tuple2<Long, Long>>( new int[] { 0, 1 }, new TypeComparator[] { new LongComparator(ascending), new LongComparator(ascending) }, new TypeSerializer[] { LongSerializer.INSTANCE, LongSerializer.INSTANCE }), new TupleComparator<Tuple2<Integer, Long>>( new int[] { 0, 1 }, new TypeComparator[] { new IntComparator(ascending), new LongComparator(ascending) }, new TypeSerializer[] { IntSerializer.INSTANCE, LongSerializer.INSTANCE }) }, new TypeSerializer[] { new TupleSerializer<Tuple2<String, Double>>( (Class<Tuple2<String, Double>>) (Class<?>) Tuple2.class, new TypeSerializer[] { StringSerializer.INSTANCE, DoubleSerializer.INSTANCE }), new TupleSerializer<Tuple2<Long, Long>>( (Class<Tuple2<Long, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[] { LongSerializer.INSTANCE, LongSerializer.INSTANCE }), new TupleSerializer<Tuple2<Integer, Long>>( (Class<Tuple2<Integer, Long>>) (Class<?>) Tuple2.class, new TypeSerializer[] { IntSerializer.INSTANCE, LongSerializer.INSTANCE }) }); }