Exemplo n.º 1
0
        public override object Deserialize(IPackStreamReader reader, byte signature, long size)
        {
            var urn      = reader.ReadLong();
            var startUrn = reader.ReadLong();
            var endUrn   = reader.ReadLong();
            var relType  = reader.ReadString();
            var props    = reader.ReadMap();

            return(new Relationship(urn, startUrn, endUrn, relType, props));
        }
        public object Deserialize(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("Duration", StructSize, size);

            var months  = reader.ReadLong();
            var days    = reader.ReadLong();
            var seconds = reader.ReadLong();
            var nanos   = reader.ReadInteger();

            return(new Duration(months, days, seconds, nanos));
        }
Exemplo n.º 3
0
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("LocalTime", StructSize, size);

            var nanosOfDay = reader.ReadLong();

            return(TemporalHelpers.NanoOfDayToTime(nanosOfDay));
        }
Exemplo n.º 4
0
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("Date", StructSize, size);

            var epochDays = reader.ReadLong();

            return(TemporalHelpers.EpochDaysToDate(epochDays));
        }
        public override object Read(IPackStreamReader reader, byte signature, long size)
        {
            var urn     = reader.ReadLong();
            var relType = reader.ReadString();
            var props   = reader.ReadMap();

            return(new Relationship(urn, -1, -1, relType, props));
        }
Exemplo n.º 6
0
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("LocalTime", StructSize, size);

            var nanosOfDay = reader.ReadLong();

            return(new CypherTime(nanosOfDay));
        }
Exemplo n.º 7
0
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("Date", StructSize, size);

            var epochDays = reader.ReadLong();

            return(new CypherDate(epochDays));
        }
        public object Deserialize(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("LocalDateTime", StructSize, size);

            var epochSeconds  = reader.ReadLong();
            var nanosOfSecond = reader.ReadInteger();

            return(TemporalHelpers.EpochSecondsAndNanoToDateTime(epochSeconds, nanosOfSecond));
        }
        public object Deserialize(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("Time", StructSize, size);

            var nanosOfDay    = reader.ReadLong();
            var offsetSeconds = reader.ReadInteger();

            return(new OffsetTime(TemporalHelpers.NanoOfDayToTime(nanosOfDay), offsetSeconds));
        }
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("Time", StructSize, size);

            var nanosOfDay    = reader.ReadLong();
            var offsetSeconds = reader.ReadInteger();

            return(new CypherTimeWithOffset(nanosOfDay, offsetSeconds));
        }
Exemplo n.º 11
0
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("LocalDateTime", StructSize, size);

            var epochSeconds  = reader.ReadLong();
            var nanosOfSecond = reader.ReadInteger();

            return(new CypherDateTime(epochSeconds, nanosOfSecond));
        }
Exemplo n.º 12
0
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("DateTimeWithOffset", StructSize, size);

            var epochSecondsUtc = reader.ReadLong();
            var nanosOfSecond   = reader.ReadInteger();
            var offsetSeconds   = reader.ReadInteger();

            return(new CypherDateTimeWithOffset(epochSecondsUtc, nanosOfSecond, offsetSeconds));
        }
        public object Read(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize("DateTimeWithZoneId", StructSize, size);

            var epochSecondsUtc = reader.ReadLong();
            var nanosOfSecond   = reader.ReadInteger();
            var zoneId          = reader.ReadString();

            return(new CypherDateTimeWithZoneId(epochSecondsUtc, nanosOfSecond, zoneId));
        }
Exemplo n.º 14
0
        public override object Read(IPackStreamReader reader, byte signature, long size)
        {
            var urn = reader.ReadLong();

            var numLabels = (int)reader.ReadListHeader();
            var labels    = new List <string>(numLabels);

            for (var i = 0; i < numLabels; i++)
            {
                labels.Add(reader.ReadString());
            }
            var numProps = (int)reader.ReadMapHeader();
            var props    = new Dictionary <string, object>(numProps);

            for (var j = 0; j < numProps; j++)
            {
                var key = reader.ReadString();
                props.Add(key, reader.Read());
            }

            return(new Node(urn, labels, props));
        }
        public object Deserialize(IPackStreamReader reader, byte signature, long size)
        {
            PackStream.EnsureStructSize($"ZonedDateTime[{(char) signature}]", StructSize, size);

            var epochSecondsUtc = reader.ReadLong();
            var nanosOfSecond   = reader.ReadInteger();

            switch (signature)
            {
            case StructTypeWithId:
                return(new ZonedDateTime(
                           TemporalHelpers.EpochSecondsAndNanoToDateTime(epochSecondsUtc, nanosOfSecond),
                           Zone.Of(reader.ReadString())));

            case StructTypeWithOffset:
                return(new ZonedDateTime(
                           TemporalHelpers.EpochSecondsAndNanoToDateTime(epochSecondsUtc, nanosOfSecond),
                           Zone.Of(reader.ReadInteger())));

            default:
                throw new ProtocolException(
                          $"Unsupported struct signature {signature} passed to {nameof(ZonedDateTimeSerializer)}!");
            }
        }
Exemplo n.º 16
0
        public override object Read(IPackStreamReader reader, byte signature, long size)
        {
            // List of unique nodes
            var uniqNodes = new INode[(int)reader.ReadListHeader()];

            for (var i = 0; i < uniqNodes.Length; i++)
            {
                var node = reader.Read() as INode;

                Throw.ProtocolException.IfFalse(node != null, "receivedNode");

                uniqNodes[i] = node;
            }

            // List of unique relationships, without start/end information
            var uniqRels = new Relationship[(int)reader.ReadListHeader()];

            for (var i = 0; i < uniqRels.Length; i++)
            {
                var uniqRel = reader.Read() as Relationship;

                Throw.ProtocolException.IfFalse(uniqRel != null, "receivedUnboundRelationship");

                uniqRels[i] = uniqRel;
            }

            // Path sequence
            var length = (int)reader.ReadListHeader();

            // Knowing the sequence length, we can create the arrays that will represent the nodes, rels and segments in their "path order"
            var segments = new ISegment[length / 2];
            var nodes    = new INode[segments.Length + 1];
            var rels     = new IRelationship[segments.Length];

            var prevNode = uniqNodes[0];

            nodes[0] = prevNode;
            for (var i = 0; i < segments.Length; i++)
            {
                var relIdx   = (int)reader.ReadLong();
                var nextNode =
                    uniqNodes[(int)reader.ReadLong()];  // Start node is always 0, and isn't encoded in the sequence
                // Negative rel index means this rel was traversed "inversed" from its direction
                Relationship rel;
                if (relIdx < 0)
                {
                    rel = uniqRels[(-relIdx) - 1]; // -1 because rel idx are 1-indexed
                    rel.SetStartAndEnd(nextNode.Id, prevNode.Id);
                }
                else
                {
                    rel = uniqRels[relIdx - 1];
                    rel.SetStartAndEnd(prevNode.Id, nextNode.Id);
                }

                nodes[i + 1] = nextNode;
                rels[i]      = rel;
                segments[i]  = new Segment(prevNode, rel, nextNode);
                prevNode     = nextNode;
            }

            return(new Path(segments.ToList(), nodes.ToList(), rels.ToList()));
        }