Created
January 31, 2013 19:35
-
-
Save coderunner/4685703 to your computer and use it in GitHub Desktop.
Revisions
-
Felix Trepanier created this gist
Jan 31, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ // ** Ensure previous timestamp match last transaction event timestamp // before if (tx.previous != lastTimestamp) { throw new IOException("This transaction %s previous timestamp %s is not %s".format( tx, tx.previous, lastTimestamp)) } // after require(tx.previous == lastTimestamp, "This transaction %s previous timestamp %s is not %s".format( tx, tx.previous, lastTimestamp)) // ** Close all open streams but the most recent one // before val toClose = fileStreams.tail fileStreams = List(fileStreams.head) toClose.foreach(_.close()) // after fileStreams match { case fileStream :: toClose => { fileStreams = fileStream :: Nil toClose.foreach(_.close()) } case Nil => // Nothing to close } // ** Return the list of log files that contains transaction after a certain timestamp //before if (logFiles.isEmpty) { logFiles } else { val sortedFiles = logFiles.sortWith((f1, f2) => getTimestampFromName(f1.getName) < getTimestampFromName(f2.getName)) sortedFiles.indexWhere(f => getTimestampFromName(f.getName) > timestamp) match { case -1 => List(sortedFiles.last) case 0 => sortedFiles case i => sortedFiles.drop(i - 1) } //after val sortedFiles = logFiles.sortWith((f1, f2) => getTimestampFromName(f1.getName) < getTimestampFromName(f2.getName)) sortedFiles.indexWhere(f => getTimestampFromName(f.getName) > timestamp) match { case -1 if sortedFiles.isEmpty => sortedFiles case -1 => List(sortedFiles.last) case 0 => sortedFiles case i => sortedFiles.drop(i - 1) }