Skip to content

Instantly share code, notes, and snippets.

View josep2's full-sized avatar
🎯
Focusing

Jowanza Joseph josep2

🎯
Focusing
View GitHub Profile
case class Sale(id: String, amount: Double)
val sales: DataStream[Sale] = env.addSource( SOME_STREAMING_SOURCE) // Read in a stream that is typed as a Sale
sales.window(Count.of(50)).every(Time.of(1, TimeUnit.SECONDS)).sum("amount") // Every second sum the sales
case class Player(firstName: String, lastName: String, ppg: Double, apg: Double, rpg: Double)
val jf = Player.apply("Jimmer", "Fredette", 1.1, 0.1, 0.2)
print(jf)
// Player(Jimmer,Fredette,1.1,0.1,0.2)
case class Player(firstName: String, lastName: String, ppg: Double, apg: Double, rpg: Double)
val jf = Player.tupled("Jimmer", "Fredette", 1.1, 0.1, 0.2)
print(jf)
// Player(Jimmer,Fredette,1.1,0.1,0.2)
case class Player(firstName: String, lastName: String, ppg: Double, apg: Double, rpg: Double)
val jf = Player.curried("Jimmer")("Fredette")(1.1)(0.1)(0.2)
print(jf)
// Player(Jimmer,Fredette,1.1,0.1,0.2)
case class Player(firstName: String, lastName: String, ppg: Double, apg: Double, rpg: Double)
// Taken From: https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/expressions/udaf.scala#L128-L136
@scala.annotation.varargs
def apply(exprs: Column*): Column = {
val aggregateExpression =
AggregateExpression(
ScalaUDAF(exprs.map(_.expr), this),
Complete,
isDistinct = false)
Column(aggregateExpression)
@josep2
josep2 / exec
Created January 14, 2019 22:37
#!/usr/bin/env scala
import com.jowanza.ExecutePipeline
import spray.json._
import spray.json.DefaultJsonProtocol._
object JowanzaMain {
def main(args: Array[String]): Unit = {
@josep2
josep2 / mleap.sbt
Last active January 14, 2019 22:27
name := "mleap-spark-action"
version := "1.0"
scalaVersion := "2.11.6"
assemblyJarName := "mleap.jar"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
package com.jowanza
import ml.combust.mleap.runtime.frame.DefaultLeapFrame
import ml.combust.mleap.runtime.frame.ArrayRow
import ml.combust.bundle.BundleFile
import ml.combust.mleap.runtime.MleapSupport._
import resource._
import spray.json._
import ml.combust.mleap.core.types._
# Dockerfile for example whisk docker action
FROM openwhisk/dockerskeleton
# Set Port for Flask Server
ENV FLASK_PROXY_PORT 8080
# Install Java 8
RUN apk add openjdk8