Skip to content

Commit

Permalink
Merge pull request #32 from teralytics/fix-udfs
Browse files Browse the repository at this point in the history
Using UDFs in Java
  • Loading branch information
franzhcs authored Feb 17, 2020
2 parents 107bf65 + ad51c46 commit d0488e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 0 additions & 7 deletions jvm/src/main/scala/net/teralytics/terahex/TeraHex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,4 @@ object TeraHex {
def decode(code: Long): Zone = encoding.decode(code)

def size(level: Int): Double = grid.size(level)
}

object TeraHexSparkUDF extends UDF3[Double, Double, Integer, Long] {

override def call(longitude: Double, latitude: Double, level: Integer): Long = {
TeraHex.encode(LatLon(Lon(longitude), Lat(latitude)), level)
}
}
11 changes: 11 additions & 0 deletions jvm/src/main/scala/net/teralytics/terahex/TeraHexSpark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package net.teralytics.terahex;

import org.apache.spark.sql.api.java.UDF3;

public class TeraHexSpark implements UDF3<Double, Double, Integer, Long> {
@Override
public Long call(Double longitude, Double latitude, Integer level) throws Exception {
return TeraHex.encode(new LatLon(longitude, latitude), level);
}
}

0 comments on commit d0488e0

Please sign in to comment.