<commit_before>package actors.counter

import actors.counter.CounterPersistentActor.{GetAmount, IncrementAndGet, Init}
import akka.actor.{ActorLogging, Props}
import akka.persistence._
import util.Named

object CounterPersistentActor extends Named {

  object GetAmount

  case class Init(amount: Int)

  case class IncrementAndGet(amount: Int)

  def props = Props(new CounterPersistentActor)

  override final val name = "CounterPersistentActor"
}

class CounterPersistentActor extends PersistentActor with ActorLogging {

  override def preStart {
    log.info(s"Actor [$self] starting ...")
    deleteSnapshots(SnapshotSelectionCriteria())
  }

  override def persistenceId: String = CounterPersistentActor.name

  private var counter: Int = 0

  override def receiveRecover: Receive = {
    case SnapshotOffer(metadata, snapshot: Int) => counter = snapshot

    case RecoveryCompleted => log.info(s"Counter recovery completed. Current state: [$counter]")
  }

  override def receiveCommand: Receive = {
    case incrementAndGet: IncrementAndGet =>
      log.info(s"Received message: [ $incrementAndGet ]")
      increment(incrementAndGet.amount)
      saveSnapshot(counter)
      sender ! counter

    case GetAmount => sender ! counter

    case init: Init =>
      initCounter(init.amount)
      saveSnapshot(counter)
      sender ! counter

    case DeleteSnapshotsSuccess(_) => log.info("Snapshots successfully deleted")

    case DeleteMessagesSuccess(_) => log.info("Messages successfully deleted")
  }

  private def initCounter(amount: Int) = counter = amount

  private def increment(amount: Int) = counter += amount

  override def postStop {
    log.info(s"Actor [$self] stopped")
  }

  override def postRestart(reason: Throwable) {
    log.info(s"Actor [$self] has restarted due to [$reason]")
  }
}<commit_msg>Delete unnecessary methods<commit_after>package actors.counter

import actors.counter.CounterPersistentActor.{GetAmount, IncrementAndGet, Init}
import akka.actor.{ActorLogging, Props}
import akka.persistence._
import util.Named

object CounterPersistentActor extends Named {

  object GetAmount

  case class Init(amount: Int)

  case class IncrementAndGet(amount: Int)

  def props = Props(new CounterPersistentActor)

  override final val name = "CounterPersistentActor"
}

class CounterPersistentActor extends PersistentActor with ActorLogging {

  override def preStart() {
    log.info(s"Actor [$self] starting ...")
    deleteSnapshots(SnapshotSelectionCriteria())
  }

  override def persistenceId: String = CounterPersistentActor.name

  private var counter: Int = 0

  override def receiveRecover: Receive = {
    case SnapshotOffer(_, snapshot: Int) => counter = snapshot

    case RecoveryCompleted => log.info(s"Counter recovery completed. Current state: [$counter]")
  }

  override def receiveCommand: Receive = {
    case incrementAndGet: IncrementAndGet =>
      log.info(s"Received message: [ $incrementAndGet ]")
      counter += incrementAndGet.amount
      saveSnapshot(counter)
      sender ! counter

    case GetAmount => sender ! counter

    case init: Init =>
      counter = init.amount
      saveSnapshot(counter)
      sender ! counter

    case DeleteSnapshotsSuccess(_) => log.info("Snapshots successfully deleted")

    case DeleteMessagesSuccess(_) => log.info("Messages successfully deleted")
  }

  override def postStop() {
    log.info(s"Actor [$self] stopped")
  }

  override def postRestart(reason: Throwable) {
    log.info(s"Actor [$self] has restarted due to [$reason]")
  }
}
{'fraction_non_alphanumeric': 0.09301014656144306, 'fraction_numerical': 0.0005636978579481398, 'mean_word_length': 4.22680412371134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5009712', 'n_tokens_mistral': 1031, 'n_tokens_neox': 968, 'n_words': 274}