spark的runJob方法

摘要: //保存的路径 val basePath = "/tmp/kuan2" //设置日志级别 // Example.setStreamingLogLevels() //创建sparkConf val sparkConf = new SparkConf().setAppName("runJob") //设 阅读全文
posted @ 2016-03-07 13:53 luckuan1985 阅读(1019) 评论(0) 推荐(0) 编辑

RDD的checkpoint源码分析

摘要: 当调用RDD#checkpoint的,checkpoint的方法如下: 1 /** 2 * Mark this RDD for checkpointing. It will be saved to a file inside the checkpoint 3 * directory set with 阅读全文
posted @ 2016-03-06 17:49 luckuan1985 阅读(806) 评论(0) 推荐(0) 编辑

柯里化的一点小理解

摘要: 假如有一个函数,此函数只有一个参数,此 输入Int,输出String的汗水 ,如下: 此时另外一个函数的定义如下: 这种情况下,f1将无法调用p2,参数不匹配。但如果将p2改造一下呢?改造好的函数我们设成p3 那么f1可以采用以下方式来调用p3函数 或者这么来写好理解 我们可以利用柯里化的函数创造一 阅读全文
posted @ 2016-03-04 18:49 luckuan1985 阅读(188) 评论(0) 推荐(0) 编辑

scala的type alias特性

摘要: 今天通过崔鹏飞的博客,地址http://cuipengfei.me,我学到了type alias的使用方法,借助于这个特性,可以给予它来实现好多封装。 比如说: type Fly = ()=>Unit def doFly(fly:Fly): Unit ={ fly() } val birdFly = 阅读全文
posted @ 2016-03-03 22:48 luckuan1985 阅读(248) 评论(0) 推荐(0) 编辑

隐式转换的一点想法

摘要: object App { implicit def toM2(m1:M1): M2 ={ println("m1 to m2") new M2() } class M1 { def method1(): Unit ={ println("invoke method 1") } } class M2( 阅读全文
posted @ 2016-02-29 18:03 luckuan1985 阅读(180) 评论(0) 推荐(0) 编辑

spark streaming 的batchDuration slideDuration windowDuration关系

摘要: batchDuration:尝试提交Job任务的间隔,请注意这里是尝试。具体代码如下 /** Checks whether the 'time' is valid wrt slideDuration for generating RDD */ private[streaming] def isTim 阅读全文
posted @ 2016-02-25 16:45 luckuan1985 阅读(2344) 评论(0) 推荐(0) 编辑

sbt自定义spark参数

摘要: 开发spark程序时,需要依赖于spark的jar包,因此需要将spark的jar包的作用域(scope)设置成compile,如果设置成provided的话,会提示找不到ClassNotFoundException的错误。但在线上服务构建时,又需要将作用域改成provided。那么build.sb 阅读全文
posted @ 2016-02-22 16:46 luckuan1985 阅读(416) 评论(0) 推荐(0) 编辑

spark生成HFile导入到hbase

摘要: import java.util.Date import org.apache.hadoop.fs.Path import org.apache.hadoop.hbase.client.{HTable, Table, _} import org.apache.hadoop.hbase.io.ImmutableBytesWritable import org.apache.hadoop.hbas... 阅读全文
posted @ 2016-01-19 14:44 luckuan1985 阅读(4521) 评论(0) 推荐(0) 编辑

scala ip转换器

摘要: spark在运算过程需要根据ip得到对应省份和城市的信息,需要把ip地址转变成数字,才能进行进行操作。下面就是用scala对ip地址和数字进行相互转换的代码。object ip { def main(args: Array[String]) { long2ip(ip2long("12222.... 阅读全文
posted @ 2015-12-07 01:13 luckuan1985 阅读(614) 评论(0) 推荐(0) 编辑

Spark Streaming集成Kafak的问题之Ran out of messages

摘要: Causedby:java.lang.AssertionError:assertionfailed:Ranoutofmessagesbeforereachingendingoffset264251742fortopictopic partition1start264245135.Thisshould... 阅读全文
posted @ 2015-11-16 15:01 luckuan1985 阅读(1357) 评论(0) 推荐(0) 编辑