Skip to content

Commit

Permalink
Code cleanup. Deleted a constructor from ByteBufferMessageSet and an …
Browse files Browse the repository at this point in the history
…overloaded method from MessageSet
  • Loading branch information
nehanarkhede committed Jul 22, 2011
1 parent fab1263 commit e039b8e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
23 changes: 2 additions & 21 deletions core/src/main/scala/kafka/message/ByteBufferMessageSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,6 @@ class ByteBufferMessageSet(val buffer: ByteBuffer,
}, 0L, ErrorMapping.NoError, true)
}

def this(compressionCodec: CompressionCodec, messages: Iterable[Message]) {
this(
compressionCodec match {
case NoCompressionCodec =>
val buffer = ByteBuffer.allocate(MessageSet.messageSetSize(messages))
for (message <- messages) {
message.serializeTo(buffer)
}
buffer.rewind
buffer
case _ =>
val message = CompressionUtils.compress(messages, compressionCodec)
val buffer = ByteBuffer.allocate(message.serializedSize)
message.serializeTo(buffer)
buffer.rewind
buffer
}, 0L, ErrorMapping.NoError, true)
}

def getDeepIterate = deepIterate

def getBuffer = buffer
Expand Down Expand Up @@ -120,7 +101,7 @@ class ByteBufferMessageSet(val buffer: ByteBuffer,
case false => shallowIterator
}

def shallowIterator(): Iterator[MessageOffset] = {
private def shallowIterator(): Iterator[MessageOffset] = {
ErrorMapping.maybeThrowException(errorCode)
new IteratorTemplate[MessageOffset] {
var iter = buffer.slice()
Expand Down Expand Up @@ -151,7 +132,7 @@ class ByteBufferMessageSet(val buffer: ByteBuffer,
}


def deepIterator(): Iterator[MessageOffset] = {
private def deepIterator(): Iterator[MessageOffset] = {
ErrorMapping.maybeThrowException(errorCode)
new IteratorTemplate[MessageOffset] {
var topIter = buffer.slice()
Expand Down
5 changes: 1 addition & 4 deletions core/src/main/scala/kafka/message/MessageSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ object MessageSet {
/**
* The size of a message set containing the given messages
*/
def messageSetSize(messages: Seq[Message]): Int =
messages.foldLeft(0)(_ + entrySize(_))

def messageSetSize(messages: Iterable[Message]): Int =
def messageSetSize(messages: Iterable[Message]): Int =
messages.foldLeft(0)(_ + entrySize(_))

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class CompressionUtilTest extends TestCase {
TestUtils.checkLength(decompressedMessages.iterator,3)

TestUtils.checkEquals(messages.iterator, decompressedMessages.iterator)
TestUtils.checkEquals(messages.iterator, decompressedMessages.deepIterator)
}

def testComplexCompressDecompress() {
Expand Down

0 comments on commit e039b8e

Please sign in to comment.