public void Copy(IDataInputView source, IDataOutputView target) { var len = source.ReadUnsignedByte(); target.WriteByte(len); if (len >= HighBit) { var shift = 7; int curr; len = len & 0x7f; while ((curr = source.ReadUnsignedByte()) >= HighBit) { len |= (curr & 0x7f) << shift; shift += 7; target.WriteByte(curr); } len |= curr << shift; target.WriteByte(curr); } for (var i = 0; i < len; i++) { var c = source.ReadUnsignedByte(); target.WriteByte(c); while (c >= HighBit) { c = source.ReadUnsignedByte(); target.WriteByte(c); } } }
public override void Serialize(byte[] record, IDataOutputView target) { if (record == null) { throw new IllegalArgumentException("The record must not be null."); } var len = record.Length; target.WriteInt(len); target.Write(record); }
public override void Serialize(short[] record, IDataOutputView target) { if (record == null) { throw new IllegalArgumentException("The record must not be null."); } var len = record.Length; target.WriteShort(len); for (var i = 0; i < len; i++) { target.WriteShort(record[i]); } }
public override void Serialize(StreamElement value, IDataOutputView target) { if (value.IsRecord) { var record = value.AsRecord <T>(); if (record.HasTimestamp) { target.Write(TagRecWithTimestamp); target.WriteLong(record.Timestamp); } else { target.Write(TagRecWithoutTimestamp); } ContainedTypeSerializer.Serialize(record.Value, target); } else if (value.IsWatermark) { target.Write(TagWatermark); target.WriteLong(value.AsWatermark().Timestamp); } else if (value.IsStreamStatus) { target.Write(TagStreamStatus); target.WriteInt(value.AsStreamStatus().Status); } else if (value.IsLatencyMarker) { target.Write(TagLatencyMarker); target.WriteLong(value.AsLatencyMarker().MarkedTime); target.WriteLong(value.AsLatencyMarker().OperatorId.LowerPart); target.WriteLong(value.AsLatencyMarker().OperatorId.UpperPart); target.WriteInt(value.AsLatencyMarker().SubTaskIndex); } else { throw new RuntimeException(); } }
public override void Serialize(string record, IDataOutputView target) { throw new NotImplementedException(); }
public override void Serialize(byte record, IDataOutputView target) => target.WriteByte(record);
public override void Write(IDataOutputView output) { // Nothing to do here }
public void Write(IDataOutputView output) { throw new System.NotImplementedException(); }
public override void Copy(IDataInputView source, IDataOutputView target) { throw new System.NotImplementedException(); }
public override void Copy(IDataInputView source, IDataOutputView target) => target.WriteInt(source.ReadInt());
public override void WriteWithKeyNormalization(TElement[] record, IDataOutputView target) => throw new UnSupportedOperationException();
public override void Serialize(float record, IDataOutputView target) => target.WriteFloat(record);
public override void Serialize(short record, IDataOutputView target) => target.WriteShort(record);
public abstract void Write(IDataOutputView output);
public override void Serialize(long record, IDataOutputView target) => target.WriteLong(record);
/// <summary> /// Writes the record in such a fashion that all keys are normalizing and at the beginning of the serialized data. /// This must only be used when for all the key fields the full normalized key is used. /// </summary> /// <param name="record">The record object into which to read the record data.</param> /// <param name="target">The stream to which to write the data,</param> public abstract void WriteWithKeyNormalization(T record, IDataOutputView target);
/// <summary> /// Serializes the given record to the given target output view. /// </summary> /// <param name="record">The record to serialize.</param> /// <param name="target">The output view to write the serialized data to</param> public abstract void Serialize(T record, IDataOutputView target);
/// <summary> /// Copies exactly one record from the source input view to the target output view. Whether this operation works on binary data or partially de-serializes the record to determine its length (such as for records of variable length) is up to the implementer. Binary copies are typically faster. /// </summary> /// <param name="source">The input view from which to read the record.</param> /// <param name="target">The target output view to which to write the record.</param> /// <exception cref="IOException">Thrown if any of the two views raises an exception.</exception> public abstract void Copy(IDataInputView source, IDataOutputView target);
public override void Serialize(double record, IDataOutputView target) => target.WriteDouble(record);
public override void Serialize(DateTime record, IDataOutputView target) => target.WriteLong(record.Ticks);
public override void Serialize(bool record, IDataOutputView target) => target.WriteBool(record);
public override void WriteWithKeyNormalization(T record, IDataOutputView target) => throw new InvalidOperationException();
public override void Serialize(int record, IDataOutputView target) => target.WriteInt(record);
public override void Write(IDataOutputView output) => throw new UnSupportedOperationException("This method should never be called");
public override void Serialize(VoidNamespace record, IDataOutputView target) { throw new System.NotImplementedException(); }
public override void Serialize(char record, IDataOutputView target) => target.WriteChar(record);
public void WriteSnapshot(IDataOutputView output) { }
public override void Serialize(IDictionary <TKey, TValue> record, IDataOutputView target) { throw new NotImplementedException(); }