protected bool Equals(ByteBufferMessageSet other) { if (this.Buffer.Length != other.Buffer.Length) { return(false); } var pos1 = this.Buffer.Position; var pos2 = other.Buffer.Position; try { for (var i = 0; i < this.Buffer.Length; i++) { if (this.Buffer.ReadByte() != other.Buffer.ReadByte()) { return(false); } } } finally { this.Buffer.Position = pos1; other.Buffer.Position = pos2; } return(true); }
public MessageAndOffset MakeNextOuter() { // if there isn't at least an offset and size, we are done if (this.topIter.Remaining() < 12) { return(this.AllDone()); } var offset = this.topIter.GetLong(); var size = this.topIter.GetInt(); if (size < Message.MinHeaderSize) { throw new InvalidMessageException("Message found with corrupt size (" + size + ")"); } // we have an incomplete message if (this.topIter.Remaining() < size) { return(this.AllDone()); } // read the current message and check correctness var message = this.topIter.Slice(); message.Limit(size); this.topIter.Position = this.topIter.Position + size; var newMessage = new Message(message); if (this.isShallow) { return(new MessageAndOffset(newMessage, offset)); } else { switch (newMessage.CompressionCodec) { case CompressionCodecs.NoCompressionCodec: this.innerIter = null; return(new MessageAndOffset(newMessage, offset)); default: this.innerIter = ByteBufferMessageSet.Decompress(newMessage).InternalIterator(); if (!this.innerIter.HasNext()) { this.innerIter = null; } return(this.MakeNext()); } } }
public ByteBufferMessageSetIterator(ByteBufferMessageSet parent, bool isShallow) { this.parent = parent; this.topIter = parent.Buffer.Slice(); this.isShallow = isShallow; }