<commit_before>package com.socrata.datacoordinator.truth.universe

import com.rojoma.simplearm.Managed

import com.socrata.datacoordinator.truth.loader._
import com.socrata.datacoordinator.truth.metadata.{PlaybackManifest, GlobalLogPlayback, DatasetMapWriter, DatasetMapReader}
import com.socrata.datacoordinator.truth._
import com.socrata.datacoordinator.util.TimingReport
import com.socrata.datacoordinator.secondary.{SecondaryConfig, PlaybackToSecondary, SecondaryManifest}

// Not sure I'll need all of these!  Certainly not all of them are implemented.
// The idea behind these traits is that they encapsulate "things which need a Connection".
// In order to hide the Connection from user code, they will all live in a single joined-up
// object.  In order to allow fine-grained access, client code can specify exactly which
// bits they want.  In theory there will be only one concrete implementing class at runtime,
// so hotspot ought to be able to resolve all these calls to non-virtual direct calls...

trait TypeUniverse {
  type CT
  type CV
}

/**
 * This both provides generic utility stuff and acts as a anchor-point
 * for the type system to match up `CT`/`CV` with other systems' `CT`/`CV`.
 * The general pattern will be to take a `Managed[Universe[A,B] with This with That with TheOther]`
 * and then access it like
 *     for { u <- universe } yield {
 *       import u._
 *       // ...use the various methods of the individual traits...
 *     }
 * Possibly some sub-calls would be passed `u` directly.
 */
trait Universe[ColumnType, ColumnValue] extends TypeUniverse {
  type CT = ColumnType
  type CV = ColumnValue
  def commit() // may be a no-op if the universe is non-transactional
  val timingReport: TimingReport
}

trait LoggerProvider { this: TypeUniverse =>
  val logger: Logger[CV]
}

trait DeloggerProvider { this: TypeUniverse =>
  def delogger(logTableName: String): Delogger[CV]
}

trait PrevettedLoaderProvider { this: TypeUniverse =>
  def prevettedLoader: Managed[PrevettedLoader[CV]]
}

trait LoaderProvider { this: TypeUniverse =>
  def loader: Managed[Loader[CV]]
}

trait SchemaLoaderProvider {
  val schemaLoaderProvider: SchemaLoader<commit_msg>Be a bit more explicit in Universe#commit's docs<commit_after>package com.socrata.datacoordinator.truth.universe

import com.rojoma.simplearm.Managed

import com.socrata.datacoordinator.truth.loader._
import com.socrata.datacoordinator.truth.metadata.{PlaybackManifest, GlobalLogPlayback, DatasetMapWriter, DatasetMapReader}
import com.socrata.datacoordinator.truth._
import com.socrata.datacoordinator.util.TimingReport
import com.socrata.datacoordinator.secondary.{SecondaryConfig, PlaybackToSecondary, SecondaryManifest}

// Not sure I'll need all of these!  Certainly not all of them are implemented.
// The idea behind these traits is that they encapsulate "things which need a Connection".
// In order to hide the Connection from user code, they will all live in a single joined-up
// object.  In order to allow fine-grained access, client code can specify exactly which
// bits they want.  In theory there will be only one concrete implementing class at runtime,
// so hotspot ought to be able to resolve all these calls to non-virtual direct calls...

trait TypeUniverse {
  type CT
  type CV
}

/**
 * This both provides generic utility stuff and acts as a anchor-point
 * for the type system to match up `CT`/`CV` with other systems' `CT`/`CV`.
 * The general pattern will be to take a `Managed[Universe[A,B] with This with That with TheOther]`
 * and then access it like
 *     for { u <- universe } yield {
 *       import u._
 *       // ...use the various methods of the individual traits...
 *     }
 * Possibly some sub-calls would be passed `u` directly.
 */
trait Universe[ColumnType, ColumnValue] extends TypeUniverse {
  type CT = ColumnType
  type CV = ColumnValue

  /** Commit the current transaction, if this `Universe` is transactional.
    * Otherwise, does nothing.
    * @note If this `Universe` was received via the resource-management system,
    *       that system is responsible for committing on normal completion of
    *       the management block.  As a result, most code should not need to
    *       explicitly call this method.
    */
  def commit()

  val timingReport: TimingReport
}

trait LoggerProvider { this: TypeUniverse =>
  val logger: Logger[CV]
}

trait DeloggerProvider { this: TypeUniverse =>
  def delogger(logTableName: String): Delogger[CV]
}

trait PrevettedLoaderProvider { this: TypeUniverse =>
  def prevettedLoader: Managed[PrevettedLoader[CV]]
}

trait LoaderProvider { this: TypeUniverse =>
  def loader: Managed[Loader[CV]]
}

trait SchemaLoaderProvider {
  val schemaLoaderProvider: SchemaLoader
{'fraction_non_alphanumeric': 0.08037029244687566, 'fraction_numerical': 0.0, 'mean_word_length': 4.073639274279616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '3145108', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1350, 'n_words': 519}