<commit_before>package konstructs

import java.io.File
import scala.util.Try
import akka.actor.{ Actor, ActorRef, Props }
import spray.json._
import org.apache.commons.io.FileUtils
import konstructs.plugin.{ PluginConstructor, Config }

class BinaryStorageActor(name: String, directory: File) extends Actor {
  import BinaryStorage._
  import Storage._

  val Suffix = ".binary"

  def receive = {
    case StoreBinary(id, ns, data) =>
      write(directory, id, ns, Suffix, data)
    case LoadBinary(id, ns) =>
      sender ! BinaryLoaded(id, load(directory, id, ns, Suffix))
  }
}

object BinaryStorage {
  case class StoreBinary(id: String, ns: String, data: Array[Byte])
  case class LoadBinary(id: String, ns: String)
  case class BinaryLoaded(id: String, data: Option[Array[Byte]])
}

trait BinaryStorage {
  import BinaryStorage.{ StoreBinary, LoadBinary }

  def ns: String
  def binaryStorage: ActorRef

  def loadBinary(id: String)(implicit sender: ActorRef) = binaryStorage ! LoadBinary(id, ns)
  def storeBinary(id: String, data: Array[Byte])(implicit sender: ActorRef) = binaryStorage ! StoreBinary(id, ns, data)
}

object BinaryStorageActor {
  @PluginConstructor
  def props(name: String, universe: ActorRef,
    @Config(key = "directory") directory: File) = Props(classOf[BinaryStorageActor], name, directory)
}

class JsonStorageActor(name: String, directory: File) extends Actor {
  import JsonStorage.{ StoreJson, LoadJson, JsonLoaded }
  import Storage._
  private val Suffix = ".json"

  def receive = {<commit_msg>Fix suffixes<commit_after>package konstructs

import java.io.File
import scala.util.Try
import akka.actor.{ Actor, ActorRef, Props }
import spray.json._
import org.apache.commons.io.FileUtils
import konstructs.plugin.{ PluginConstructor, Config }

class BinaryStorageActor(name: String, directory: File) extends Actor {
  import BinaryStorage._
  import Storage._

  val Suffix = "binary"

  def receive = {
    case StoreBinary(id, ns, data) =>
      write(directory, id, ns, Suffix, data)
    case LoadBinary(id, ns) =>
      sender ! BinaryLoaded(id, load(directory, id, ns, Suffix))
  }
}

object BinaryStorage {
  case class StoreBinary(id: String, ns: String, data: Array[Byte])
  case class LoadBinary(id: String, ns: String)
  case class BinaryLoaded(id: String, data: Option[Array[Byte]])
}

trait BinaryStorage {
  import BinaryStorage.{ StoreBinary, LoadBinary }

  def ns: String
  def binaryStorage: ActorRef

  def loadBinary(id: String)(implicit sender: ActorRef) = binaryStorage ! LoadBinary(id, ns)
  def storeBinary(id: String, data: Array[Byte])(implicit sender: ActorRef) = binaryStorage ! StoreBinary(id, ns, data)
}

object BinaryStorageActor {
  @PluginConstructor
  def props(name: String, universe: ActorRef,
    @Config(key = "directory") directory: File) = Props(classOf[BinaryStorageActor], name, directory)
}

class JsonStorageActor(name: String, directory: File) extends Actor {
  import JsonStorage.{ StoreJson, LoadJson, JsonLoaded }
  import Storage._
  private val Suffix = "json"

  def receive = {
{'fraction_non_alphanumeric': 0.10817855979146301, 'fraction_numerical': 0.0, 'mean_word_length': 4.836501901140684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5987611', 'n_tokens_mistral': 965, 'n_tokens_neox': 924, 'n_words': 283}