<commit_before>/*
 * Copyright 2014 Treode, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.treode.store.tier

import scala.util.Random

import com.treode.async.{Async, Scheduler}, Async.{async, supply}
import com.treode.async.implicits._
import com.treode.async.io.stubs.StubFile
import com.treode.async.stubs.StubScheduler
import com.treode.disk.{DiskLaunch, DiskRecovery}
import com.treode.disk.stubs.edit.{StubDisk, StubDiskChecks}
import com.treode.store.{Bytes, StoreConfig, StoreTestConfig, TableId}
import com.treode.tags.{Intensive, Periodic}
import org.scalatest.FreeSpec

import TierTestTools._

class TierSystemSpec extends FreeSpec with StubDiskChecks {

  private class TableTracker (id: TableId, nkeys: Int) (implicit config: StoreConfig)
  extends Tracker {

    type Medic = TestMedic
    type Struct = TestTable

    private var attempted = Map.empty [Int, Option [Int]] .withDefaultValue (None)
    private var accepted = Map.empty [Int, Option [Int]] .withDefaultValue (None)

    def recover () (implicit random: Random, scheduler: Scheduler, recovery: DiskRecovery): Medic =
      new TestMedic (id)

    def launch (medic: Medic) (implicit launch: DiskLaunch): Async [Struct] =
      medic.launch (launch)

    def put (table: TestTable, key: Int, value: Int): Async [Unit] = {
      attempted += key -> Some (value)
      for {
        _ <- table.put (key, value)
      } yield {
        accepted += key -> Some (value)
      }}
<commit_msg>Fix a mistake in the TierTable test.<commit_after>/*
 * Copyright 2014 Treode, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.treode.store.tier

import scala.util.Random

import com.treode.async.{Async, Scheduler}, Async.{async, supply}
import com.treode.async.implicits._
import com.treode.async.io.stubs.StubFile
import com.treode.async.stubs.StubScheduler
import com.treode.disk.{DiskLaunch, DiskRecovery}
import com.treode.disk.stubs.edit.{StubDisk, StubDiskChecks}
import com.treode.store.{Bytes, StoreConfig, StoreTestConfig, TableId}
import com.treode.tags.{Intensive, Periodic}
import org.scalatest.FreeSpec

import TierTestTools._

class TierSystemSpec extends FreeSpec with StubDiskChecks {

  private class TableTracker (id: TableId, nkeys: Int) (implicit config: StoreConfig)
  extends Tracker {

    type Medic = TestMedic

    type Struct = TestTable

    private var attempted = Map.empty [Int, Set [Int]] .withDefaultValue (Set.empty)
    private var accepted = Map.empty [Int, Option [Int]] .withDefaultValue (None)

    def recover () (implicit random: Random, scheduler: Scheduler, recovery: DiskRecovery): Medic =
      new TestMedic (id)

    def launch (medic: Medic) (implicit launch: DiskLaunch): Async [Struct] =
      medic.launch (launch)

    def put (table: TestTable, key: Int, value: Int): Async [Unit] = {
      attempted += key -> (attempted (key) + value)
      for {
        _ <- table.put (key, value)
      } yield {
        attempted += key -> (attempted (key) - value)
        accepted += key -> Some (value)
      }}

{'fraction_non_alphanumeric': 0.10080743821874236, 'fraction_numerical': 0.003914851969659897, 'mean_word_length': 3.74245939675174, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3829705', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1198, 'n_words': 422}