Browse Source

Changes to not drop the after context lines because of timeout

Abhinav Sarkar 7 years ago
parent
commit
b5b7ec12b2
1 changed files with 4 additions and 10 deletions
  1. 4
    10
      src/main/scala/net/abhinavsarkar/ircsearch/lucene/Indexer.scala

+ 4
- 10
src/main/scala/net/abhinavsarkar/ircsearch/lucene/Indexer.scala View File

@@ -128,11 +128,11 @@ object Indexer extends Logging {
128 128
       }
129 129
     }}
130 130
 
131
-  def schedule(initialDelay : Int, delay : Int, unit : TimeUnit)(f : => Unit) = {
131
+  private def schedule(initialDelay : Int, delay : Int, unit : TimeUnit)(f : => Unit) = {
132 132
     scheduler.scheduleWithFixedDelay(f, initialDelay, delay, unit)
133 133
   }
134 134
 
135
-  def fillContext(rec: IndexRecord, recs: Seq[IndexRecord], idx : Int) = {
135
+  private def fillContext(rec: IndexRecord, recs: Seq[IndexRecord], idx : Int) = {
136 136
     rec.copy(chatLine =
137 137
       rec.chatLine.copy(
138 138
         contextBefore = recs.slice(idx - ContextSize, idx).map(_.chatLine)
@@ -158,14 +158,8 @@ object Indexer extends Logging {
158 158
               doInLock {
159 159
                 doIndex(fillContext(recs(ContextSize), recs, ContextSize))
160 160
               }
161
-            } else if (recs.size < ContextSize + 1) {
162
-              recs.foreach(indexQueue.offer)
163 161
             } else {
164
-              recs.zipWithIndex.drop(ContextSize).foreach { r =>
165
-                doInLock {
166
-                  doIndex(fillContext(r._1, recs, r._2))
167
-                }
168
-              }
162
+              recs.foreach(indexQueue.put)
169 163
             }
170 164
           }
171 165
 
@@ -198,7 +192,7 @@ object Indexer extends Logging {
198 192
     }
199 193
   }
200 194
 
201
-  def ctxToStr(ctx : List[ChatLine]) =
195
+  private def ctxToStr(ctx : List[ChatLine]) =
202 196
     ctx.map { line => s"${line.timestamp} ${line.user}: ${line.message}" }  mkString "\n"
203 197
 
204 198
   private def doIndex(indexRecord: IndexRecord) {

Loading…
Cancel
Save