• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JohnSnowLabs / spark-nlp / 10675586955

03 Sep 2024 02:30AM UTC coverage: 61.821% (-0.06%) from 61.884%
10675586955

Pull #14379

github

web-flow
Merge 1f222af49 into 9285df8c6
Pull Request #14379: SPARKNLP Introducing LLAMA 3

0 of 27 new or added lines in 3 files covered. (0.0%)

15 existing lines in 11 files now uncovered.

8982 of 14529 relevant lines covered (61.82%)

0.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/src/main/scala/com/johnsnowlabs/storage/StorageReadWriter.scala
1
/*
2
 * Copyright 2017-2022 John Snow Labs
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *    http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.johnsnowlabs.storage
18

19
import org.rocksdb.WriteBatch
20

21
import scala.collection.mutable.{Map => MMap}
22

23
trait StorageReadWriter[A] extends StorageWriter[A] {
24

25
  this: StorageReader[A] =>
26

27
  @transient private val readableWriteBuffer: MMap[String, A] = MMap.empty[String, A]
1✔
28
  private var bufferCounter = 0
1✔
29

30
  def add(word: String, content: A): Unit = {
UNCOV
31
    if (bufferCounter >= writeBufferSize) {
×
32
      flush(new WriteBatch())
×
33
      bufferCounter = 0
×
34
    }
35
    bufferCounter += 1
1✔
36
    readableWriteBuffer.update(word, content)
1✔
37
  }
38

39
  override def lookup(index: String): Option[A] = {
40
    readableWriteBuffer.get(index).orElse(_lookup(index))
1✔
41
  }
42

43
  override def flush(batch: WriteBatch): Unit = {
44
    readableWriteBuffer.foreach { case (word, content) =>
1✔
45
      put(batch, word, content)
1✔
46
    }
47
    super.flush(batch)
1✔
48
    readableWriteBuffer.clear()
1✔
49
    if (connection.isConnected)
1✔
50
      connection.reconnectReadWrite
1✔
51
  }
52

53
  override def close(): Unit = {
54
    flush(new WriteBatch())
1✔
55
    this.clear()
1✔
56
    super.close()
1✔
57
  }
58

59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc