def read()

in cassovary-core/src/main/scala/com/twitter/cassovary/util/io/LabelsReader.scala [70:89]


  def read(isSparse: Option[Boolean] = None, maxId: Option[Int] = None): Labels[Int] = {
    def parse(fileName: String) : (String, String) = {
      val fileNameParts = fileName.split(Array('_', '.'))
      val name = fileNameParts(fileNameParts.length - 3)
      val valueType = fileNameParts(fileNameParts.length - 2)
      (name, valueType)
    }

    val labelFiles = IoUtils.readFileNames(directory, collPrefix)
    val labels = new Labels[Int]
    labelFiles foreach { fileName =>
      val (labelName, labelTypeString) = parse(fileName)
      labelTypeString.toLowerCase match {
        case "int" => labels += readOneLabel[Int](labelName, fileName, isSparse, maxId)
        case "string" => labels += readOneLabel[String](labelName, fileName, isSparse, maxId)
        case _ => println(s"unable to understand label value type of $fileName. Ignoring this file.")
      }
    }
    labels
  }