This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.cakesolutions.spark.kryo | |
import com.esotericsoftware.kryo.Kryo | |
import com.esotericsoftware.kryo.io.Input | |
import com.esotericsoftware.kryo.io.Output | |
import java.io.FileInputStream | |
import java.io.FileOutputStream | |
fun main(args: Array<String>) { | |
val kryo = Kryo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.cakesolutions.spark.sql | |
import org.apache.spark.SparkConf | |
import org.apache.spark.api.java.JavaSparkContext | |
import org.apache.spark.sql.DataFrame | |
import org.apache.spark.sql.Row | |
import org.apache.spark.sql.SQLContext | |
import org.cakesolutions.spark.awaitEnter | |
import java.io.Serializable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>){ | |
println("Hello, World") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<repository> | |
<id>central</id> | |
<name>bintray</name> | |
<url>http://jcenter.bintray.com</url> | |
</repository> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.funktionale</groupId> | |
<artifactId>funktionale-composition</artifactId> | |
<version>1.1</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.funktionale</groupId> | |
<artifactId>funktionale-all</artifactId> | |
<version>1.1</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val total = items | |
.map(extract) | |
.map(discount) | |
.map(price) | |
.sum() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val total = items | |
.map(extract andThen discount andThen price) | |
.sum() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val extract: (Item) -> Pair<Double, Double> = { (_, itemPrice, discount, quantity) -> itemPrice * quantity to discount } | |
val discount: (Pair<Double, Double>) -> Pair<Double, Double> = { (price, discount) -> price to discount / 100.0 } | |
val price: (Pair<Double, Double>) -> Double = { (price, discPercentage) -> price - (price * discPercentage) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val items = ItemDao.findItemsForInvoice(1) | |
val total = items | |
.map { (_, itemPrice, discount, quantity) -> itemPrice * quantity to discount } | |
.map { (price, discount) -> price to discount / 100.0 } | |
.map { (price, discPercentage) -> price - (price * discPercentage) } | |
.sum() |