From 989c9bfbab5838525783a0cb3ca48c5db4939c85 Mon Sep 17 00:00:00 2001 From: Jun Rao Date: Mon, 5 Nov 2012 23:10:38 +0000 Subject: [PATCH] LogSegment.firstAppendTime not reset after truncate to; patched by Swapnil Ghike; reviewed by Jun Rao, Neha Narkhede; KAFKA-596 git-svn-id: https://svn.apache.org/repos/asf/incubator/kafka/branches/0.8@1406004 13f79535-47bb-0310-9956-ffa450edef68 --- core/src/main/scala/kafka/log/LogSegment.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/kafka/log/LogSegment.scala b/core/src/main/scala/kafka/log/LogSegment.scala index 5b30604304a..0315d7e2991 100644 --- a/core/src/main/scala/kafka/log/LogSegment.scala +++ b/core/src/main/scala/kafka/log/LogSegment.scala @@ -20,7 +20,11 @@ class LogSegment(val messageSet: FileMessageSet, val indexIntervalBytes: Int, time: Time) extends Range with Logging { - var firstAppendTime: Option[Long] = None + var firstAppendTime: Option[Long] = + if (messageSet.sizeInBytes > 0) + Some(time.milliseconds) + else + None /* the number of bytes since we last added an entry in the offset index */ var bytesSinceLastIndexEntry = 0 @@ -118,6 +122,8 @@ class LogSegment(val messageSet: FileMessageSet, return index.truncateTo(offset) messageSet.truncateTo(mapping.position) + if (messageSet.sizeInBytes == 0) + firstAppendTime = None } /**