Skip to content

Commit 27231a0

Browse files
authored
Merge pull request #554 from echeipesh/scala-2.12
Scala 2.12 and Spark 3 support
2 parents 6f0f08b + 9f81443 commit 27231a0

File tree

271 files changed

+3595
-5140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+3595
-5140
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
# Operating System Files
2+
3+
*.DS_Store
4+
Thumbs.db
5+
16
*.class
27
*.log
38

49
# sbt specific
10+
.bsp
511
.cache
612
.history
713
.lib/

.java-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.scalafmt.conf

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
maxColumn = 138
1+
version = 3.0.3
2+
runner.dialect = scala212
3+
indent.main = 2
4+
indent.significant = 2
5+
maxColumn = 150
26
continuationIndent.defnSite = 2
3-
binPack.parentConstructors = true
4-
binPack.literalArgumentLists = false
5-
newlines.penalizeSingleSelectMultiArgList = false
6-
newlines.sometimesBeforeColonInMethodReturnType = false
7-
align.openParenCallSite = false
8-
align.openParenDefnSite = false
9-
docstrings = JavaDoc
10-
rewriteTokens {
11-
"⇒" = "=>"
12-
"←" = "<-"
13-
}
14-
optIn.selfAnnotationNewline = false
15-
optIn.breakChainOnFirstMethodDot = true
16-
importSelectors = BinPack
7+
assumeStandardLibraryStripMargin = true
8+
danglingParentheses.preset = true
9+
rewrite.rules = [SortImports, RedundantBraces, RedundantParens, SortModifiers]
10+
docstrings.style = Asterisk
11+
# align.preset = more

.sdkmanrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enable auto-env through the sdkman_auto_env config
2+
# Add key=value pairs of SDKs to use below
3+
java=11.0.11.hs-adpt

bench/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ libraryDependencies ++= Seq(
1111
jmhIterations := Some(5)
1212
jmhWarmupIterations := Some(8)
1313
jmhTimeUnit := None
14-
javaOptions in Jmh := Seq("-Xmx4g")
14+
Jmh / javaOptions := Seq("-Xmx4g")
1515

1616
// To enable profiling:
1717
// jmhExtraOptions := Some("-prof jmh.extras.JFR")

bench/src/main/scala/org/locationtech/rasterframes/bench/CatalystSerializerBench.scala

Lines changed: 0 additions & 92 deletions
This file was deleted.

bench/src/main/scala/org/locationtech/rasterframes/bench/CellTypeBench.scala

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121

2222
package org.locationtech.rasterframes.bench
2323
import java.util.concurrent.TimeUnit
24-
2524
import geotrellis.raster.{CellType, DoubleUserDefinedNoDataCellType, IntUserDefinedNoDataCellType}
2625
import org.apache.spark.sql.catalyst.InternalRow
27-
import org.locationtech.rasterframes.encoders.CatalystSerializer._
26+
import org.locationtech.rasterframes.encoders.StandardEncoders
2827
import org.openjdk.jmh.annotations._
2928

3029
@BenchmarkMode(Array(Mode.AverageTime))
@@ -37,16 +36,12 @@ class CellTypeBench {
3736
def setupData(): Unit = {
3837
ct = IntUserDefinedNoDataCellType(scala.util.Random.nextInt())
3938
val o: CellType = DoubleUserDefinedNoDataCellType(scala.util.Random.nextDouble())
40-
row = o.toInternalRow
39+
row = StandardEncoders.cellTypeEncoder.createSerializer()(o)
4140
}
4241

4342
@Benchmark
44-
def fromRow(): CellType = {
45-
row.to[CellType]
46-
}
43+
def fromRow(): CellType = StandardEncoders.cellTypeEncoder.createDeserializer()(row)
4744

4845
@Benchmark
49-
def intoRow(): InternalRow = {
50-
ct.toInternalRow
51-
}
46+
def intoRow(): InternalRow = StandardEncoders.cellTypeEncoder.createSerializer()(ct)
5247
}

bench/src/main/scala/org/locationtech/rasterframes/bench/TileCellScanBench.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit
2626
import geotrellis.raster.Dimensions
2727
import org.apache.spark.sql.catalyst.InternalRow
2828
import org.apache.spark.sql.rf.TileUDT
29-
import org.locationtech.rasterframes.tiles.InternalRowTile
3029
import org.openjdk.jmh.annotations._
3130

3231
@BenchmarkMode(Array(Mode.AverageTime))
@@ -62,15 +61,4 @@ class TileCellScanBench extends SparkEnv {
6261
tile.getDouble(cols/2, rows/2) +
6362
tile.getDouble(0, 0)
6463
}
65-
66-
@Benchmark
67-
def internalRowRead(): Double = {
68-
val tile = new InternalRowTile(tileRow)
69-
val cols = tile.cols
70-
val rows = tile.rows
71-
tile.getDouble(cols - 1, rows - 1) +
72-
tile.getDouble(cols/2, rows/2) +
73-
tile.getDouble(0, 0)
74-
}
7564
}
76-

bench/src/main/scala/org/locationtech/rasterframes/bench/TileEncodeBench.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ package org.locationtech.rasterframes.bench
2424
import java.net.URI
2525
import java.util.concurrent.TimeUnit
2626

27-
import org.locationtech.rasterframes.ref.RasterRef.RasterRefTile
28-
import org.locationtech.rasterframes.ref.RasterRef
2927
import geotrellis.raster.Tile
3028
import geotrellis.vector.Extent
3129
import org.apache.spark.sql.catalyst.InternalRow
@@ -53,24 +51,23 @@ class TileEncodeBench extends SparkEnv {
5351
@Setup(Level.Trial)
5452
def setupData(): Unit = {
5553
cellTypeName match {
56-
case "rasterRef"
54+
case "rasterRef" =>
5755
val baseCOG = "https://s3-us-west-2.amazonaws.com/landsat-pds/c1/L8/149/039/LC08_L1TP_149039_20170411_20170415_01_T1/LC08_L1TP_149039_20170411_20170415_01_T1_B1.TIF"
5856
val extent = Extent(253785.0, 3235185.0, 485115.0, 3471015.0)
59-
tile = RasterRefTile(RasterRef(RFRasterSource(URI.create(baseCOG)), 0, Some(extent), None))
60-
case _
57+
tile = RasterRef(RFRasterSource(URI.create(baseCOG)), 0, Some(extent), None)
58+
case _ =>
6159
tile = randomTile(tileSize, tileSize, cellTypeName)
6260
}
6361
}
6462

6563
@Benchmark
6664
def encode(): InternalRow = {
67-
tileEncoder.toRow(tile)
65+
tileEncoder.createSerializer.apply(tile)
6866
}
6967

7068
@Benchmark
7169
def roundTrip(): Tile = {
72-
val row = tileEncoder.toRow(tile)
73-
boundEncoder.fromRow(row)
70+
val row = tileEncoder.createSerializer().apply(tile)
71+
boundEncoder.createDeserializer().apply(row)
7472
}
7573
}
76-

bench/src/main/scala/org/locationtech/rasterframes/bench/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ package object bench {
3737
val cellType = CellType.fromName(cellTypeName)
3838
val tile = ArrayTile.alloc(cellType, cols, rows)
3939
if(cellType.isFloatingPoint) {
40-
tile.mapDouble(_ rnd.nextGaussian())
40+
tile.mapDouble(_ => rnd.nextGaussian())
4141
}
4242
else {
43-
tile.map(_ {
43+
tile.map(_ => {
4444
var c = NODATA
4545
do {
4646
c = rnd.nextInt(255)

0 commit comments

Comments
 (0)