@Override protected void serialize(T record, DataOutputView dataOutput) throws IOException { if (serializer == null){ throw new RuntimeException("TypeSerializerOutputFormat requires a type serializer to " + "be defined."); } serializer.serialize(record, dataOutput); }
@Override public void serialize(Lockable<E> record, DataOutputView target) throws IOException { IntSerializer.INSTANCE.serialize(record.refCounter, target); elementSerializer.serialize(record.element, target); }
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); final int size = dataSet.size(); out.writeInt(size); if (size > 0) { DataOutputViewStreamWrapper wrapper = new DataOutputViewStreamWrapper(out); for (T element : dataSet){ serializer.serialize(element, wrapper); } } }
@Override public void serialize(List<T> list, DataOutputView target) throws IOException { final int size = list.size(); target.writeInt(size); // We iterate here rather than accessing by index, because we cannot be sure that // the given list supports RandomAccess. // The Iterator should be stack allocated on new JVMs (due to escape analysis) for (T element : list) { elementSerializer.serialize(element, target); } }
public void add(T value, TypeSerializer<T> serializer) throws IOException { try { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); DataOutputViewStreamWrapper out = new DataOutputViewStreamWrapper(outStream); serializer.serialize(value, out); localValue.add(outStream.toByteArray()); } catch (IOException e) { throw new IOException("Failed to serialize value '" + value + '\'', e); } }
@Override public void setOutputType(TypeInformation<OUT> outTypeInfo, ExecutionConfig executionConfig) { outTypeSerializer = outTypeInfo.createSerializer(executionConfig); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputViewStreamWrapper out = new DataOutputViewStreamWrapper(baos); try { outTypeSerializer.serialize(initialValue, out); } catch (IOException ioe) { throw new RuntimeException("Unable to serialize initial value of type " + initialValue.getClass().getSimpleName() + " of fold operator.", ioe); } serializedInitialValue = baos.toByteArray(); }
@Override public void serialize(T value, DataOutputView target) throws IOException { for (int i = 0; i < arity; i++) { Object o = value.getField(i); try { fieldSerializers[i].serialize(o, target); } catch (NullPointerException npex) { throw new NullFieldException(i, npex); } } }
public void migrateSerializedValue( DataInputDeserializer serializedOldValueInput, DataOutputSerializer serializedMigratedValueOutput, TypeSerializer<V> priorSerializer, TypeSerializer<V> newSerializer) throws StateMigrationException { try { V value = priorSerializer.deserialize(serializedOldValueInput); newSerializer.serialize(value, serializedMigratedValueOutput); } catch (Exception e) { throw new StateMigrationException("Error while trying to migrate RocksDB state.", e); } }
private void serializeStartEvent(EventId startEventID, DataOutputView target) throws IOException { if (startEventID != null) { target.writeByte(1); eventIdSerializer.serialize(startEventID, target); } else { target.writeByte(0); } }
public static <N> void writeNameSpace( N namespace, TypeSerializer<N> namespaceSerializer, DataOutputSerializer keySerializationDataOutputView, boolean ambiguousKeyPossible) throws IOException { int beforeWrite = keySerializationDataOutputView.length(); namespaceSerializer.serialize(namespace, keySerializationDataOutputView); if (ambiguousKeyPossible) { //write length of namespace writeLengthFrom(beforeWrite, keySerializationDataOutputView); } }
public static <K> void writeKey( K key, TypeSerializer<K> keySerializer, DataOutputSerializer keySerializationDataOutputView, boolean ambiguousKeyPossible) throws IOException { //write key int beforeWrite = keySerializationDataOutputView.length(); keySerializer.serialize(key, keySerializationDataOutputView); if (ambiguousKeyPossible) { //write size of key writeLengthFrom(beforeWrite, keySerializationDataOutputView); } }
@Nonnull private byte[] serializeElement(@Nonnull E element) { try { outputView.clear(); outputView.write(groupPrefixBytes); byteOrderProducingSerializer.serialize(element, outputView); return outputView.getCopyOfBuffer(); } catch (IOException e) { throw new FlinkRuntimeException("Error while serializing the element.", e); } }
@Override public void serialize(T record, DataOutputView target) throws IOException { if (record == null) { target.writeBoolean(true); target.write(padding); } else { target.writeBoolean(false); originalSerializer.serialize(record, target); } }
@Override public void processElement(StreamRecord<IN> element) throws Exception { IN value = element.getValue(); // generate initial operator state if (out == null) { out = checkpointStorage.createTaskOwnedStateStream(); } serializer.serialize(value, new DataOutputViewStreamWrapper(out)); }
private void serializeSingleComputationState( ComputationState computationState, DataOutputView target) throws IOException { StringValue.writeString(computationState.getCurrentStateName(), target); nodeIdSerializer.serialize(computationState.getPreviousBufferEntry(), target); versionSerializer.serialize(computationState.getVersion(), target); target.writeLong(computationState.getStartTimestamp()); serializeStartEvent(computationState.getStartEventID(), target); }