This file contains hidden or 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.darion.yaphet.gearpump | |
| import org.apache.gearpump.cluster.UserConfig | |
| import org.apache.gearpump.cluster.client.ClientContext | |
| import org.apache.gearpump.streaming.{Processor, StreamApplication} | |
| import org.apache.gearpump.streaming.partitioner.HashPartitioner | |
| import org.apache.gearpump.streaming.source.DataSourceProcessor | |
| import org.apache.gearpump.util.{AkkaApp, Graph} | |
| import org.apache.gearpump.util.Graph.Node |
This file contains hidden or 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
| case class People(name: String, age: Int) | |
| val me = People("darion.yaphet", 26) | |
| val (name, age) = People.unapply(me).get | |
| ************************************************************ | |
| val (name_, age_) = me match { | |
| case People(name, age) => (name, age) | |
| } |
This file contains hidden or 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
| scala> Array(1,2,3,4,5,6,7).partition(_%2 == 0) | |
| res1: (Array[Int], Array[Int]) = (Array(2, 4, 6),Array(1, 3, 5, 7) | |
This file contains hidden or 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.darion.yaphet.scala.examples.other | |
| import scala.util.control.TailCalls._ | |
| import scala.annotation._ | |
| object Sum extends App { | |
| def evenLength(xs: Seq[Int]): TailRec[Boolean] = | |
| if (xs.isEmpty) done(true) else tailcall(oddLength(xs.tail)) | |
| def oddLength(xs: Seq[Int]): TailRec[Boolean] = |
This file contains hidden or 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
| file | |
| .map(line => (line.split(",")(0), 1)) | |
| .reduceByKey(_ + _) | |
| .map(item => item.swap) | |
| .sortByKey(false) | |
| .map(item => item.swap) | |
| .take(20) | |
| .foreach(println) |
This file contains hidden or 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.darion.yaphet.jobs | |
| import com.typesafe.config.Config | |
| import org.apache.spark.SparkContext | |
| import spark.jobserver.{SparkJob, SparkJobInvalid, SparkJobValid, SparkJobValidation} | |
| import scala.util.Try | |
| /** | |
| * Created by darionwang on 2017/3/3. |
This file contains hidden or 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
| object MatchExample { | |
| def main(args: Array[String]): Unit = { | |
| val key = "3" | |
| key match { | |
| case "1" => println("1") | |
| case "2" => println("2") | |
| case _ => println("default") | |
| } | |
| } |
This file contains hidden or 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 m = Map("k0"->"v0","k1"->"v1","k2"->"v2") | |
| val n = m.map{case (k,v) => (v,k)}.toMap | |
| println(n) |
This file contains hidden or 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.darion.yaphet.kryo; | |
| import java.io.ByteArrayOutputStream; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.FileOutputStream; | |
| import com.esotericsoftware.kryo.Kryo; | |
| import com.esotericsoftware.kryo.Serializer; | |
| import com.esotericsoftware.kryo.io.Input; |
This file contains hidden or 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.darion.yaphet.parquet; | |
| import org.apache.hadoop.conf.Configuration; | |
| import org.apache.hadoop.fs.Path; | |
| import org.apache.parquet.example.data.Group; | |
| import org.apache.parquet.hadoop.ParquetReader; | |
| import org.apache.parquet.hadoop.example.GroupReadSupport; | |
| import java.io.IOException; |
NewerOlder