@Override public T deserialize(T reuse, DataInputView source) throws IOException { boolean isNull = deserializeNull(source); return isNull ? null : (reuse == null ? originalSerializer.deserialize(source) : originalSerializer.deserialize(reuse, source)); }
@Override public SharedBufferEdge deserialize(DataInputView source) throws IOException { NodeId target = nodeIdSerializer.deserialize(source); DeweyNumber deweyNumber = deweyNumberSerializer.deserialize(source); return new SharedBufferEdge(target, deweyNumber); }
private static <UK> UK deserializeUserKey( DataInputDeserializer dataInputView, int userKeyOffset, byte[] rawKeyBytes, TypeSerializer<UK> keySerializer) throws IOException { dataInputView.setBuffer(rawKeyBytes, userKeyOffset, rawKeyBytes.length - userKeyOffset); return keySerializer.deserialize(dataInputView); }
public static <T> T deserializeFromByteArray(TypeSerializer<T> serializer, T reuse, byte[] buf) throws IOException { if (buf == null) { throw new NullPointerException("Byte array to deserialize from must not be null."); } DataInputViewStreamWrapper inputViewWrapper = new DataInputViewStreamWrapper(new ByteArrayInputStream(buf)); return serializer.deserialize(reuse, inputViewWrapper); }
@Override public T deserialize(DataInputView source) throws IOException { boolean isNull = deserializeNull(source); return isNull ? null : originalSerializer.deserialize(source); }
@Override public Either<L, R> deserialize(DataInputView source) throws IOException { boolean isLeft = source.readBoolean(); if (isLeft) { return Left(leftSerializer.deserialize(source)); } else { return Right(rightSerializer.deserialize(source)); } }
@Override public int compareSerialized(DataInputView firstSource, DataInputView secondSource) throws IOException { T first = this.serializer.createInstance(); T second = this.serializer.createInstance(); first = this.serializer.deserialize(first, firstSource); second = this.serializer.deserialize(second, secondSource); return this.compare(first, second); }
@Override public TimerHeapInternalTimer<K, N> deserialize(DataInputView source) throws IOException { long timestamp = MathUtils.flipSignBit(source.readLong()); K key = keySerializer.deserialize(source); N namespace = namespaceSerializer.deserialize(source); return new TimerHeapInternalTimer<>(timestamp, key, namespace); }
@Override public void open(Configuration configuration) throws Exception { FunctionUtils.openFunction(this.windowFunction, configuration); if (serializedInitialValue == null) { throw new RuntimeException("No initial value was serialized for the fold " + "window function. Probably the setOutputType method was not called."); } ByteArrayInputStream bais = new ByteArrayInputStream(serializedInitialValue); DataInputViewStreamWrapper in = new DataInputViewStreamWrapper(bais); initialValue = accSerializer.deserialize(in); ctx = new InternalProcessApplyWindowContext<>(windowFunction); }
@Override public BufferEntry<T> deserialize(DataInputView source) throws IOException { boolean hasBeenJoined = source.readBoolean(); T element = elementSerializer.deserialize(source); return new BufferEntry<>(element, hasBeenJoined); }
@Override public T deserialize(T reuse, DataInputView source) throws IOException { for (int i = 0; i < arity; i++) { Object field = fieldSerializers[i].deserialize(reuse.getField(i), source); reuse.setField(field, i); } return reuse; }
@Override public T deserialize(DataInputView source) throws IOException { Preconditions.checkNotNull(source); Object[] fields = new Object[fieldSerializers.length]; for (int i = 0; i < fieldSerializers.length; i++) { fields[i] = fieldSerializers[i].deserialize(source); } return createInstance(fields); }
@Override public void open(Configuration configuration) throws Exception { FunctionUtils.openFunction(this.windowFunction, configuration); if (serializedInitialValue == null) { throw new RuntimeException("No initial value was serialized for the fold " + "window function. Probably the setOutputType method was not called."); } ByteArrayInputStream bais = new ByteArrayInputStream(serializedInitialValue); DataInputViewStreamWrapper in = new DataInputViewStreamWrapper(bais); initialValue = accSerializer.deserialize(in); ctx = new InternalProcessApplyAllWindowContext<>(windowFunction); }
private static <UV> UV deserializeUserValue( DataInputDeserializer dataInputView, byte[] rawValueBytes, TypeSerializer<UV> valueSerializer) throws IOException { dataInputView.setBuffer(rawValueBytes); boolean isNull = dataInputView.readBoolean(); return isNull ? null : valueSerializer.deserialize(dataInputView); }
SV getInternal(byte[] key) { try { byte[] valueBytes = backend.db.get(columnFamily, key); if (valueBytes == null) { return null; } dataInputView.setBuffer(valueBytes); return valueSerializer.deserialize(dataInputView); } catch (IOException | RocksDBException e) { throw new FlinkRuntimeException("Error while retrieving data from RocksDB", e); } }
public static <V> ValueTimeWrapper<V> deserialize( final TypeSerializer<V> valueSerializer, final DataInputView source) throws IOException { final V value = valueSerializer.deserialize(source); final long timestamp = source.readLong(); final int counter = source.readInt(); return new ValueTimeWrapper<>(value, timestamp, counter); } }
@Override public Tuple3<Integer, Integer, String> deserialize(byte[] messageKey, byte[] message, String topic, int partition, long offset) throws IOException { DataInputView in = new DataInputViewStreamWrapper(new ByteArrayInputStream(message)); Tuple2<Integer, Integer> t2 = ts.deserialize(in); return new Tuple3<>(t2.f0, t2.f1, topic); }
@Override public T deserialize(T reuse, DataInputView source) throws IOException { Preconditions.checkNotNull(reuse); Preconditions.checkNotNull(source); Object[] fields = new Object[fieldSerializers.length]; for (int index = 0; index < fieldSerializers.length; index++) { fields[index] = fieldSerializers[index].deserialize(getField(reuse, index), source); } return precomputed.immutable ? createInstance(fields) : createInstanceWithReuse(fields, reuse); }
@Override public MigratedNFA<T> deserialize(DataInputView source) throws IOException { MigrationUtils.skipSerializedStates(source); source.readLong(); source.readBoolean(); org.apache.flink.cep.nfa.SharedBuffer<T> sharedBuffer = sharedBufferSerializer.deserialize(source); Queue<ComputationState> computationStates = deserializeComputationStates(sharedBuffer, eventSerializer, source); return new MigratedNFA<>(computationStates, sharedBuffer); }
@Test public void restoredSerializerIsAbleToDeserializePreviousData() throws IOException { TypeSerializerSnapshot<ElementT> snapshot = snapshotUnderTest(); TypeSerializer<ElementT> serializer = snapshot.restoreSerializer(); DataInputView input = dataUnderTest(); final Matcher<ElementT> matcher = testSpecification.testDataElementMatcher; for (int i = 0; i < testSpecification.testDataCount; i++) { final ElementT result = serializer.deserialize(input); assertThat(result, matcher); } }