<commit_before>package com.dataintuitive.luciusapi

import com.dataintuitive.luciuscore.GeneModel.{GeneAnnotation, Genes}
import com.dataintuitive.luciuscore.Model._
import org.apache.spark.SparkContext
import org.apache.spark.broadcast.Broadcast
import org.apache.spark.rdd.RDD

/**
  * The API makes use of `NamedObjects`, but those are actor-based so automated tests are made hard.
  * This trait can be mixed into the endpoint definitions, in order to keep a global cache of
  * otherwise persisted objects in Spark Jobserver.
  */
trait Globals extends Serializable {

  val gene: GeneAnnotation = new GeneAnnotation("probesetidString",
    "entrezidString",
    "ensemblidString",
    "symbolString",
    "nameString")

  var thisGenes:Broadcast[Genes] = _

  def setGenes(g:Broadcast[Genes]) = { thisGenes = g }
  def getGenes = thisGenes

  def setDb(db:RDD[DbRow]) = db.cache.setName("db")
  def getDb(sc:SparkContext) =
    sc.getPersistentRDDs
      .map{case (index, rdd) => rdd}
      .filter(rdd => (rdd.name == "db"))
      .head.asInstanceOf[RDD[DbRow]]
<commit_msg>Small update<commit_after>package com.dataintuitive.luciusapi

import com.dataintuitive.luciuscore.GeneModel.{GeneAnnotation, Genes}
import com.dataintuitive.luciuscore.Model._
import org.apache.spark.SparkContext
import org.apache.spark.broadcast.Broadcast
import org.apache.spark.rdd.RDD

/**
  * The API makes use of `NamedObjects`, but those are actor-based so automated tests are made hard.
  * This trait can be mixed into the endpoint definitions, in order to keep a global cache of
  * otherwise persisted objects in Spark Jobserver.
  */
trait Globals extends Serializable {

  // Gene empty initialization and accessor methods
  var thisGenes:Broadcast[Genes] = _
  def setGenes(g:Broadcast[Genes]) = { thisGenes = g }
  def getGenes = thisGenes

  // db accessor methods
  def setDb(db:RDD[DbRow]) = db.cache.setName("db")
  def getDb(sc:SparkContext) =
    sc.getPersistentRDDs
      .map{case (index, rdd) => rdd}
      .filter(rdd => (rdd.name == "db"))
      .head.asInstanceOf[RDD[DbRow]]

  /** A utility function, similar to what `NamedObjects.getNames()` provides.
    */
{'fraction_non_alphanumeric': 0.10773480662983426, 'fraction_numerical': 0.0, 'mean_word_length': 4.161520190023753, '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': '1886372', 'n_tokens_mistral': 731, 'n_tokens_neox': 702, 'n_words': 185}