Skip to content

Commit

Permalink
#34: Upgrade to Scala 2.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
netzwerg committed Nov 3, 2016
1 parent 2f352df commit 20958ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ libraries.jackson = 'com.fasterxml.jackson.core:jackson-databind:2.6.3'
libraries.junit = 'junit:junit:4.11'
libraries.chabis = 'ch.netzwerg:chabis:0.2.0'

def scalaVersion = '2.11.8'
def scalaVersion = '2.12.0'
libraries.scala = "org.scala-lang:scala-library:$scalaVersion"
libraries.scalaTools = ["org.scala-lang:scala-compiler:$scalaVersion",
ext.libraries.scala]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package ch.netzwerg.paleo.io.impl

import java.io.{File, Reader}
import java.lang
import java.time.format.DateTimeFormatter
import java.time.{Instant, LocalDateTime, ZoneId}
import java.util.Scanner
Expand All @@ -31,13 +30,12 @@ import ch.netzwerg.paleo.ColumnIds._
import ch.netzwerg.paleo._
import ch.netzwerg.paleo.schema.{Field, Schema}

import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import scala.io.Source

object ScalaParserImpl {

val LineDelimiter = Pattern.compile("[\\r\\n]+")
val LineDelimiter: Pattern = Pattern.compile("[\\r\\n]+")

def parseTabDelimited(reader: Reader, timestampPattern: Option[String]): DataFrame = {
val scanner: Scanner = new Scanner(reader)
Expand All @@ -63,16 +61,15 @@ object ScalaParserImpl {
}

}
val iterator: lang.Iterable[Field] = () => fields.iterator
javaslang.collection.List.ofAll[Field](iterator)
javaslang.collection.List.ofAll[Field](fields.toIterable.asJava)
}

def parseTabDelimited(schema: Schema, parentDir: File): DataFrame = {
val fields = schema.getFields
val source = Source.fromFile(new File(parentDir, schema.getDataFileName))
try {
val lines = source.getLines()
parseTabDelimited(fields, lines, 0, schema.getMetaData)
parseTabDelimited(fields, lines.asJava, 0, schema.getMetaData)
} finally {
source.close()
}
Expand All @@ -83,7 +80,7 @@ object ScalaParserImpl {
val accumulators = scalaFields.map(createAcc)

var rowIndex = 1
for (line <- lines) {
for (line <- lines.asScala) {
val values = line.split("\t", -1) // empty values allowed

if (values.size != accumulators.length) {
Expand All @@ -96,7 +93,7 @@ object ScalaParserImpl {
accumulators.zip(values).map(t => t._1.addValue(t._2))
rowIndex += 1
}
val columns = accumulators.map(_.build()).toIterable.asJava
val columns = accumulators.map(_.build()).asJava
DataFrame.ofAll(columns).withMetaData(dataFrameMetaData)
}

Expand Down Expand Up @@ -140,7 +137,7 @@ class Acc[V, C <: Column[_]](builder: Column.Builder[V, C], parseLogic: (String)
this
}

def putAllMetaData(metaData: javaslang.collection.Map[String, String]) = {
def putAllMetaData(metaData: javaslang.collection.Map[String, String]): Acc[V, C] = {
builder.putAllMetaData(metaData)
this
}
Expand Down

0 comments on commit 20958ef

Please sign in to comment.