ITeye博客

2017 年文章归档

共 6 篇文章

crontab执行时区与系统时间不一致问题

[root@lock data]# tail -f /var/log/cron Jun 15 06:50:05 lock crond[8517]: (CRON) INFO (running with inotify support) Jun 15 06:50:05 lock crond[8517]: (CRON) INFO (@reboot jobs will be run at computer's startup.) Jun 15 06:50:19 lock crontab[8535]: (root) BEGIN EDIT (root) [root@lock data]# date Th…

2017-06-15 14:58 · linux

scala学习笔记(十五):模式匹配

模式匹配在spark中非常重要,你可以在很多地方能看见模式匹配 def main(args: Array[String]): Unit = { // trigger the constant patterns println(echoWhatYouGaveMe(0)) println(echoWhatYouGaveMe(true)) println(echoWhatYouGaveMe("hello")) println(echoWhatYouGaveMe(Nil)) println(echoWhatYouGaveMe(List(1,2,3))) println(echoWhatYouGave…

2017-02-07 11:31 · scala · Scala

scala学习笔记(十四):fluent style(流式风格代码)

我们在使用spark的时候 开头经常写这样的fluent style代码 val conf = new SparkConf().setAppName("ParallelizeCollection").setMaster("local") 那我们自己怎样然我们自己的代码能实现这样的效果,其实想要使用流式风格 1、如果你的类会被继承的话 方法返回类型必须是this.type 2、如果你的类不会被继承的话 方法return是this就可以 object FluentStyleScala { def main(args: Array[String]): Unit = { /** * A fluent…

2017-02-07 11:21 · scala · Scala

scala学习笔记(十三):implicit 详解

implicit 可分为三种 隐式参数 隐式转换类型 隐式调用函数 1、隐式参数 implicit参数都是定义在方法最后,修饰implicit表示该组参数是隐式参数。一个方法只会有一个隐式参数列表,置于方法的最后一个参数列表。如果方法有多个隐式参数,只需一个implicit修饰即可 //使用隐式参数的方式 需要在外部定义一个Comparator[A]类型的变量 def maxThrid[A](first: A, second: A)(implicit cp: Comparator[A]) = { if (cp.compare(first, second) > 0) first else se…

2017-01-24 15:39 · scala

scala学习笔记(十二):for循环及translated

scala中有许多方式去循环集合 for loops, while loops, 和集合中的方法诸如 foreach , map , flatMap,这节主要说明for的用法和for的翻译(translated) 1、for的用法 val a = Array("apple","banana", "orange") //for 循环 for(item <- a) println(item) for(item <- a){ val s = item.toUpperCase() println(s) } //带有返回值的for循环 for(item <- a) yield item.toUpper…

2017-01-13 12:07 · scala

scala学习笔记(十一):Queue、stack

一、Queue队列是FIFO(先进先出),Queue分可变和不可变(immutable queue and mutable queue) import scala.collection.mutable.Queue var ints = Queue[Int]() var fruits = Queue[String]() var q = Queue[Person]() scala> val q = Queue(1, 2, 3) q: scala.collection.mutable.Queue[Int] = Queue(1, 2, 3) 使用+=、++=、enqueue来添加元素 scala> …

2017-01-12 21:49 · scala