Changes to not drop the after context lines because of timeout

master
Abhinav Sarkar 2013-05-21 22:11:27 +05:30
parent e77c187e2e
commit b5b7ec12b2
1 changed files with 4 additions and 10 deletions

View File

@ -128,11 +128,11 @@ object Indexer extends Logging {
} }
}} }}
def schedule(initialDelay : Int, delay : Int, unit : TimeUnit)(f : => Unit) = { private def schedule(initialDelay : Int, delay : Int, unit : TimeUnit)(f : => Unit) = {
scheduler.scheduleWithFixedDelay(f, initialDelay, delay, unit) scheduler.scheduleWithFixedDelay(f, initialDelay, delay, unit)
} }
def fillContext(rec: IndexRecord, recs: Seq[IndexRecord], idx : Int) = { private def fillContext(rec: IndexRecord, recs: Seq[IndexRecord], idx : Int) = {
rec.copy(chatLine = rec.copy(chatLine =
rec.chatLine.copy( rec.chatLine.copy(
contextBefore = recs.slice(idx - ContextSize, idx).map(_.chatLine) contextBefore = recs.slice(idx - ContextSize, idx).map(_.chatLine)
@ -158,14 +158,8 @@ object Indexer extends Logging {
doInLock { doInLock {
doIndex(fillContext(recs(ContextSize), recs, ContextSize)) doIndex(fillContext(recs(ContextSize), recs, ContextSize))
} }
} else if (recs.size < ContextSize + 1) {
recs.foreach(indexQueue.offer)
} else { } else {
recs.zipWithIndex.drop(ContextSize).foreach { r => recs.foreach(indexQueue.put)
doInLock {
doIndex(fillContext(r._1, recs, r._2))
}
}
} }
} }
@ -198,7 +192,7 @@ object Indexer extends Logging {
} }
} }
def ctxToStr(ctx : List[ChatLine]) = private def ctxToStr(ctx : List[ChatLine]) =
ctx.map { line => s"${line.timestamp} ${line.user}: ${line.message}" } mkString "\n" ctx.map { line => s"${line.timestamp} ${line.user}: ${line.message}" } mkString "\n"
private def doIndex(indexRecord: IndexRecord) { private def doIndex(indexRecord: IndexRecord) {