You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ju...@apache.org on 2012/11/06 00:10:39 UTC

svn commit: r1406004 - /incubator/kafka/branches/0.8/core/src/main/scala/kafka/log/LogSegment.scala

Author: junrao
Date: Mon Nov  5 23:10:38 2012
New Revision: 1406004

URL: http://svn.apache.org/viewvc?rev=1406004&view=rev
Log:
LogSegment.firstAppendTime not reset after truncate to; patched by Swapnil Ghike; reviewed by Jun Rao, Neha Narkhede; KAFKA-596

Modified:
    incubator/kafka/branches/0.8/core/src/main/scala/kafka/log/LogSegment.scala

Modified: incubator/kafka/branches/0.8/core/src/main/scala/kafka/log/LogSegment.scala
URL: http://svn.apache.org/viewvc/incubator/kafka/branches/0.8/core/src/main/scala/kafka/log/LogSegment.scala?rev=1406004&r1=1406003&r2=1406004&view=diff
==============================================================================
--- incubator/kafka/branches/0.8/core/src/main/scala/kafka/log/LogSegment.scala (original)
+++ incubator/kafka/branches/0.8/core/src/main/scala/kafka/log/LogSegment.scala Mon Nov  5 23:10:38 2012
@@ -20,7 +20,11 @@ class LogSegment(val messageSet: FileMes
                  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: FileMes
       return
     index.truncateTo(offset)  
     messageSet.truncateTo(mapping.position)
+    if (messageSet.sizeInBytes == 0)
+      firstAppendTime = None
   }
   
   /**