IRedisMessage DecodeRedisArrayHeader(ArrayHeaderRedisMessage header)
        {
            if (header.IsNull)
            {
                return(ArrayRedisMessage.Null);
            }
            else if (0ul >= (ulong)header.Length)
            {
                return(ArrayRedisMessage.Empty);
            }
            else if ((ulong)header.Length > 0ul)
            {
                // Currently, this codec doesn't support `long` length for arrays because Java's List.size() is int.
                if ((ulong)header.Length > int.MaxValue)
                {
                    throw new CodecException($"This codec doesn't support longer length than {int.MaxValue}");
                }

                // start aggregating array
                this.depths.Push(new AggregateState((int)header.Length));
                return(null);
            }

            throw new CodecException($"Bad length: {header.Length}");
        }
Beispiel #2
0
        void Write(IByteBufferAllocator allocator, ArrayHeaderRedisMessage message, ICollection <object> output)
        {
            Contract.Requires(allocator != null);
            Contract.Requires(message != null);
            Contract.Requires(output != null);

            this.WriteArrayHeader(allocator, message.IsNull ? default(long?) : message.Length, output);
        }
Beispiel #3
0
 void WriteArrayHeader(IByteBufferAllocator allocator, ArrayHeaderRedisMessage msg, List <object> output) =>
 this.WriteArrayHeader(allocator, msg.IsNull, msg.Length, output);