public override StreamElement Deserialize(StreamElement reuse, IDataInputView source)
        {
            int tag = source.ReadByte();

            if (tag == TagRecWithTimestamp)
            {
                var timestamp   = source.ReadLong();
                var value       = ContainedTypeSerializer.Deserialize(source);
                var reuseRecord = reuse.AsRecord <T>();
                reuseRecord.Replace(value, timestamp);
                return(reuseRecord);
            }
            else if (tag == TagRecWithoutTimestamp)
            {
                var value       = ContainedTypeSerializer.Deserialize(source);
                var reuseRecord = reuse.AsRecord <T>();
                reuseRecord.Replace(value);
                return(reuseRecord);
            }
            else if (tag == TagWatermark)
            {
                return(new Watermark(source.ReadLong()));
            }
            else if (tag == TagLatencyMarker)
            {
                return(new LatencyMarker(source.ReadLong(), new OperatorId(source.ReadLong(), source.ReadLong()), source.ReadInt()));
            }
            else
            {
                throw new IOException("Corrupt stream, found tag: " + tag);
            }
        }
        public override StreamElement Deserialize(IDataInputView source)
        {
            int tag = source.ReadByte();

            if (tag == TagRecWithTimestamp)
            {
                var timestamp = source.ReadLong();
                return(new StreamRecord <T>(ContainedTypeSerializer.Deserialize(source), timestamp));
            }
            else if (tag == TagRecWithoutTimestamp)
            {
                return(new StreamRecord <T>(ContainedTypeSerializer.Deserialize(source)));
            }
            else if (tag == TagWatermark)
            {
                return(new Watermark(source.ReadLong()));
            }
            else if (tag == TagStreamStatus)
            {
                return(new StreamStatus(source.ReadInt()));
            }
            else if (tag == TagLatencyMarker)
            {
                return(new LatencyMarker(source.ReadLong(), new OperatorId(source.ReadLong(), source.ReadLong()), source.ReadInt()));
            }
            else
            {
                throw new IOException("Corrupt stream, found tag: " + tag);
            }
        }
        public override long[] Deserialize(IDataInputView source)
        {
            var len    = source.ReadLong();
            var result = new long[len];

            for (var i = 0; i < len; i++)
            {
                result[i] = source.ReadLong();
            }
            return(result);
        }
        public static int CompareSerializedDate(IDataInputView firstSource, IDataInputView secondSource, bool ascendingComparison)
        {
            var l1   = firstSource.ReadLong();
            var l2   = secondSource.ReadLong();
            var comp = (l1 < l2 ? -1 : (l1 == l2 ? 0 : 1));

            return(ascendingComparison ? comp : -comp);
        }
        public override int CompareSerialized(IDataInputView firstSource, IDataInputView secondSource)
        {
            var l1   = firstSource.ReadLong();
            var l2   = secondSource.ReadLong();
            var comp = (l1 < l2 ? -1 : (l1 == l2 ? 0 : 1));

            return(AscendingComparison ? comp : -comp);
        }
        public override DateTime Deserialize(IDataInputView source)
        {
            var ticks = source.ReadLong();

            return(new DateTime(ticks));
        }
 public override void Copy(IDataInputView source, IDataOutputView target) => target.WriteLong(source.ReadLong());
 public override long Deserialize(IDataInputView source) => source.ReadLong();