public override void EncodeObject(object value, bool arrayEncoding, ByteBuffer buffer) { if (arrayEncoding) { AmqpBitConverter.WriteLong(buffer, (long)value); } else { LongEncoding.Encode((long)value, buffer); } }
public override int GetObjectEncodeSize(object value, bool arrayEncoding) { if (arrayEncoding) { return(FixedWidth.Long); } else { return(LongEncoding.GetEncodeSize((long)value)); } }
/// <summary> /// Initializes a new instance of the <see cref="RelationIdentifier" /> class. /// </summary> /// <param name="outVertexId"></param> /// <param name="typeId"></param> /// <param name="relationId"></param> /// <param name="inVertexId"></param> public RelationIdentifier(long outVertexId, long typeId, long relationId, long inVertexId) { OutVertexId = outVertexId; TypeId = typeId; RelationId = relationId; InVertexId = inVertexId; var sb = new StringBuilder(); sb.Append(LongEncoding.Encode(relationId)).Append(ToStringDelimiter) .Append(LongEncoding.Encode(outVertexId)).Append(ToStringDelimiter).Append(LongEncoding.Encode(typeId)); if (inVertexId != 0) { sb.Append(ToStringDelimiter).Append(LongEncoding.Encode(inVertexId)); } StringRepresentation = sb.ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="RelationIdentifier" /> class. /// </summary> /// <param name="stringRepresentation">The underlying relation id.</param> public RelationIdentifier(string stringRepresentation) { StringRepresentation = stringRepresentation; var elements = stringRepresentation.Split(ToStringDelimiter); if (elements.Length != 3 && elements.Length != 4) { throw new ArgumentException($"Not a valid relation identifier: {stringRepresentation}"); } OutVertexId = LongEncoding.Decode(elements[1]); TypeId = LongEncoding.Decode(elements[2]); RelationId = LongEncoding.Decode(elements[0]); if (elements.Length == 4) { InVertexId = LongEncoding.Decode(elements[3]); } }
/// <summary> /// Decodes a 64-bit signed integer from the buffer and advances the buffer's position. /// </summary> /// <param name="buffer">The buffer to read.</param> /// <returns>A 64-bit signed integer.</returns> public static long?DecodeLong(ByteBuffer buffer) { return(LongEncoding.Decode(buffer, 0)); }
/// <summary> /// Encodes a 64-bit signed integer and appends the bytes to the buffer. /// </summary> /// <param name="data">The 64-bit signed integer.</param> /// <param name="buffer">The destination buffer.</param> public static void EncodeLong(long?data, ByteBuffer buffer) { LongEncoding.Encode(data, buffer); }
/// <summary> /// Gets the encode size of a 64-bit signed integer. /// </summary> /// <param name="value">The 64-bit signed integer.</param> /// <returns>Encode size in bytes of the 64-bit signed integer.</returns> public static int GetLongEncodeSize(long?value) { return(LongEncoding.GetEncodeSize(value)); }
public override object DecodeObject(ByteBuffer buffer, FormatCode formatCode) { return(LongEncoding.Decode(buffer, formatCode)); }