<commit_before>package akka.persistence.hbase.journal

import akka.actor.ActorSystem
import akka.persistence.hbase.common.RowKey
import akka.testkit.{ImplicitSender, TestKit}
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}

class RowKeySpec extends TestKit(ActorSystem("test")) with FlatSpecLike
  with ImplicitSender with Matchers with BeforeAndAfterAll {

  behavior of "RowKey"

  val config = system.settings.config

  implicit val settings = PersistencePluginSettings(config)

  it should "find first key in partition" in {
    val rowKeys = for {
      p <- 1 to 50
    } yield RowKey.firstInPartition("x", p)

    val keys = rowKeys.map(_.toKeyString)

//    keys foreach { k => info("key: " + k.toKeyString) }
    keys should contain ("004-x-00000000000000000004")
    keys should contain ("050-x-00000000000000000050")

    rowKeys.map(_.part) should equal ((1 to 50).toList)
  }

  it should "find first key in partition, with lower bound 4" in {
    val rowKeys = for {
      p <- 1 to 50
    } yield RowKey.firstInPartition("x", p, fromSequenceNr = 4)

    val keys = rowKeys.map(_.toKeyString)

//    keys foreach { k => info("key: " + k.toKeyString) }
    keys should contain ("001-x-00000000000000000004")
    keys should contain ("002-x-00000000000000000004")
    keys should contain ("003-x-00000000000000000004")
    keys should contain ("004-x-00000000000000000004")
    keys should contain ("005-x-00000000000000000005")
    keys should contain ("050-x-00000000000000000050")

    rowKeys.map(_.part) should equal ((1 to 50).toList)
  }

  it should "find last key in partition" in {
    val rowKeys = for {
      p <- 1 to 50
    } yield RowKey.lastInPartition("x", p)

    val keys = rowKeys.map(_.toKeyString)

//    rowKeys foreach { k => info("key: " + k.toKeyString) }
    keys should contain ("001-x-09223372036854775807")
    keys should contain ("002-x-09223372036854775806")
    keys should contain ("050-x-09223372036854775800")

    rowKeys.map(_.part) should equal ((1 to 50).toList)
  }

  it should "find last key in partition, with upper bound 7" in {
    val rowKeys = for {
      p <- 1 to 50
    } yield RowKey.lastInPartition("x", p, toSequenceNr = 7)

    val keys = rowKeys.map(_.toKeyString)

//    rowKeys foreach { k => info("key: " + k.toKeyString) }
    keys should contain ("001-x-00000000000000000007")
    keys should contain ("002-x-00000000000000000007")
    keys should contain ("050-x-00000000000000000007")

    rowKeys.map(_.part) should equal ((1 to 50).toList)
  }

  override def afterAll() {
    shutdown(system)

    HBaseJournalInit.disableTable(config, settings.table)
    HBaseJournalInit.deleteTable(config, settings.table)

    HBaseJournalInit.disableTable(config, settings.snapshotTable)
    HBaseJournalInit.deleteTable(config, settings.snapshotTable)

    super.afterAll()
  }

}<commit_msg>no actor sys needed here<commit_after>package akka.persistence.hbase.journal

import akka.persistence.hbase.common.RowKey
import org.scalatest.{FlatSpec, Matchers}

class RowKeySpec extends FlatSpec with Matchers {

  behavior of "RowKey"

  implicit val journalConfig = new PersistencePluginSettings(null, null, null, 50, 1, null, null, false, null, null, null, null)

  it should "find first key in partition" in {
    val rowKeys = for {
      p <- 1 to 50
    } yield RowKey.firstInPartition("x", p)

    val keys = rowKeys.map(_.toKeyString)

//    keys foreach { k => info("key: " + k.toKeyString) }
    keys should contain ("004-x-00000000000000000004")
    keys should contain ("050-x-00000000000000000050")

    rowKeys.map(_.part) should equal ((1 to 50).toList)
  }

  it should "find first key in partition, with lower bound 4" in {
    val rowKeys = for {
      p <- 1 to 50
    } yield RowKey.firstInPartition("x", p, fromSequenceNr = 4)

    val keys = rowKeys.map(_.toKeyString)

//    keys foreach { k => info("key: " + k.toKeyString) }
    keys should contain ("001-x-00000000000000000004")
    keys should contain ("002-x-00000000000000000004")
    keys should contain ("003-x-00000000000000000004")
    keys should contain ("004-x-00000000000000000004")
    keys should contain ("005-x-00000000000000000005")
    keys should contain ("050-x-00000000000000000050")

    rowKeys.map(_.part) should equal ((1 to 50).toList)
  }

  it should "find last key in partition" in {
    val rowKeys = for {
      p <- 1 to 50
    } yield RowKey.lastInPartition("x", p)

    val keys = rowKeys.map(_.toKeyString)

//    rowKeys foreach { k => info("key: " + k.toKeyString) }
    keys should contain ("001-x-09223372036854775807")
    keys should contain ("002-x-09223372036854775806")
    keys should contain ("050-x-09223372036854775800")

    rowKeys.map(_.part) should equal ((1 to 50).toList)
  }

  it should "find last key in partition, with upper bound 7" in {
    val rowKeys = for {
      p <- 1 to 50
    } yield RowKey.lastInPartition("x", p, toSequenceNr = 7)

    val keys = rowKeys.map(_.toKeyString)

//    rowKeys foreach { k => info("key: " + k.toKeyString) }
    keys should contain ("001-x-00000000000000000007")
    keys should contain ("002-x-00000000000000000007")
    keys should contain ("050-x-00000000000000000007")

    rowKeys.map(_.part) should equal ((1 to 50).toList)
  }

}
{'fraction_non_alphanumeric': 0.11661311661311662, 'fraction_numerical': 0.13286713286713286, 'mean_word_length': 3.4395973154362416, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 22, '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': '4939001', 'n_tokens_mistral': 2248, 'n_tokens_neox': 1641, 'n_words': 476}