All Downloads are FREE. Search and download functionalities are using the official Maven repository.

au.csiro.variantspark.data.Representation.scala Maven / Gradle / Ivy

The newest version!
package au.csiro.variantspark.data

trait RepresentationFactory {
  def builderFor(variableType: VariableType): DataBuilder[_]
  def createRepresentation(variableType: VariableType, stringData: List[String]): Data =
    builderFor(variableType).from(stringData)
}

case object DefRepresentationFactory extends RepresentationFactory {
  def builderFor(variableType: VariableType): DataBuilder[_] = variableType match {
    case bounded: Bounded if bounded.nLevels < 128 => ByteArrayDataBuilder
    case _: CategoricalType => IntArrayDataBuilder
    case _: NumericalType => VectorDataBuilder
    case _ => throw new IllegalArgumentException(s"Do not know how to represent ${variableType}")
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy