scala

Listing files from resource directory in sbt 1.2.8

人走茶凉 提交于 2020-12-25 08:44:13
问题 I have a Scala application which processes binary files from some directory in resources . I would like to get this directory as java.io.File and list all the contents. In the newest sbt I am unable to do it the straight way. I have created minimal repo with my issue: https://github.com/mat646/sbt-resource-bug The issue does not occur with sbt 0.13.18 and lower. So after some research I've found out that since sbt 1.0 the design has changed and such issue has been already addressed here:

spark on yarn 资源计算

空扰寡人 提交于 2020-12-23 04:42:54
1、spark job 提交模式 spark on yarn 分两种情况,一种是yarn-client 提交,一种是yarn-cluster提交方式,两种方式的区别是: yarn-cluster模式下,driver运行在AM(Application Master)中,它负责向YARN申请资源,并监督作业的运行状况。当用户提交了作业之后,就可以关掉Client,作业会继续在YARN上运行; yarn-client模式下,Application Master仅仅向YARN请求executor,client会和请求的container通信来调度他们工作; 其中yarn集群包含RM,NM,AM的概念如下: ResourceManager:是集群所有应用程序的资源管理器,能够管理集群的计算资源并为每个Application分配,它是一个纯粹的调度器。 NodeManager:是每一台slave机器的代理,执行应用程序,并监控应用程序的资源使用情况。 Application Master:每一个应用程序都会有一个Application Master,它的主要职责是向RM申请资源、在每个NodeManager上启动executors、监控和跟踪应用程序的进程等。 spark中driver的作用: - 运行应用程序的main函数 - 创建spark的上下文 - 划分RDD并生成有向无环图

win10下Spark的环境搭建

五迷三道 提交于 2020-12-19 07:18:02
win10下Spark的环境搭建 2018-08-19 18:36:45 一、jdk 1.8.0 安装与配置 二、scala 2.11.8 安装与配置 http://www.scala-lang.org/download/2.11.8.html 上面两步见《 win10下安装scala 》 三、spark 2.3.0 安装与配置 1、下载spark:官网地址: http://spark.apache.org/downloads.html 2、下载完成后解压到D盘根目录下即可。D:\spark-2.3.0-bin-hadoop2.6。 3、配置Path:将D:\spark-2.3.0-bin-hadoop2.6\bin添加到Path中。 4、通过spark-shell进入到spark交互式命令行模式下 上面可以看见安装的scala版本、jdk版本、spark版本。 注意:上面出现了异常信息,是由于hadoop导致的。所以还要下载安装hadoop进行相关配置。 四、hadoop 2.6.4 安装与配置 1、下载hadoop:官方地址: http://hadoop.apache.org/releases.html 2、解压到D盘根目录下。 3、配置环境变量:HADOOP_HOME 和 Path。 4、winutils下载: https://github.com/steveloughran

2020年5月程序员工资统计,平均14542元

风流意气都作罢 提交于 2020-12-19 00:04:25
平均工资 2020年5月全国招收程序员312761人。2020年5月全国程序员平均工资14542元,工资中位数12500 元,其中95%的人的工资介于5250元到35000元。 一线城市工资 主要城市工资 职能与工资 普通软件工程师这一年的工资增长了1000元,你的工资增加了么? 数据异常检查 首先我们会对数据异常进行检查,方法就是用各种指标监视数据异常。比如,我们会把工资变化大于1000的城市找出来。 如下图: 这里,我们发现济南有一家公司校招300人,而且重复发了5次。这样就严重的降低了济南的平均工资。 于是,我们增加了一条新的规则,所有的应届生都删除。这样可以保证数据的稳定。 编程语言比例 scala的工资是2万,我想,这应该是大数据程序员。python的工资是1万8,应该是机器学习工程师。 你拖后腿了吗? 来源:https://blog.csdn.net/juwikuang/article/details/105875849 作者:有数可据 本文分享自微信公众号 - 前端宇宙(gh_8184da923ced)。 如有侵权,请联系 support@oschina.cn 删除。 本文参与“ OSC源创计划 ”,欢迎正在阅读的你也加入,一起分享。 来源: oschina 链接: https://my.oschina.net/u/4585038/blog/4394382

2020年5月程序员工资统计,平均14542元,我又拖后腿了!

最后都变了- 提交于 2020-12-18 21:42:22
作者:有数可据 来源:https://blog.csdn.net/juwikuang/article/details/105875849 今天,看到一篇关于程序员工资统计的文章,给大家分享一下,希望能给各位同学有所参考,毕竟数据来源于招聘网站,可能与实际情况有所偏差。总体来说,应该有不少同学被平均了,整体上来说,应该还是在正态分布的范围内。 # 平均工资 2020年5月全国招收程序员312761人。2020年5月全国程序员平均工资14542元,工资中位数12500 元,其中95%的人的工资介于5250元到35000元 # 一线城市工资 2020年5月 北京 招收软件工程师24478人。2019年5月北京软件工程师平均工资19273元,工资中位数17500元,其中95%的人的工资介于7000元到45000元。 2020年5月 上海 招收软件工程师51403人。2019年5月上海软件工程师平均工资17477元,工资中位数15500元,其中95%的人的工资介于7000元到40000元。 2020年5月 深圳 招收软件工程师44509人。2019年5月深圳软件工程师平均工资17052元,工资中位数15000元,其中95%的人的工资介于7000元到37500元。 2020年5月 杭州 招收软件工程师20042人。2019年5月杭州软件工程师平均工资15089元,工资中位数12500元

Scala学习之路 (五)Scala的关键字Lazy

拥有回忆 提交于 2020-12-18 13:55:44
Scala中使用关键字lazy来定义惰性变量,实现延迟加载(懒加载)。 惰性变量只能是不可变变量,并且只有在调用惰性变量时,才会去实例化这个变量。 在Java中,要实现延迟加载(懒加载),需要自己手动实现。一般的做法是这样的: public class JavaLazyDemo { private String name; // 初始化姓名为huangbo private String initName(){ return "huangbo" ; } public String getName(){ // 如果name为空,进行初始化 if (name == null ){ name = initName(); } return name; } } 在Scala中对延迟加载这一特性提供了语法级别的支持: lazy val name = initName() 使用lazy关键字修饰变量后,只有在使用该变量时,才会调用其实例化方法。也就是说在定义property=initProperty()时并不会调用initProperty()方法,只有在后面的代码中使用变量property时才会调用initProperty()方法。 如果 不使用lazy关键字对变量修饰 ,那么变量property是立即实例化的: object ScalaLazyDemo { def init():String =

Scala入门之面向对象

倾然丶 夕夏残阳落幕 提交于 2020-12-18 03:58:07
/** * Created by Administrator on 2018/9/27. * 在Scala中的Object是一个单例对象,没办法new * object中定义的成员变量和方法都是静态的 */ object ScalaStatic { val name: String = "liyitian" var age: Int = 22 def saySomething(msg: String) = { println(msg) } def apply(food: String) = { println("米饭 " + food) } } 调用object object TestMain { def main(args: Array[String]): Unit = { println(ScalaStatic.name) ScalaStatic.age = 18 println(ScalaStatic.age) ScalaStatic.saySomething("你好") ScalaStatic.apply("西红柿") ScalaStatic("鸡蛋") //语法糖 suger } } 输出 liyitian 18 你好 米饭 西红柿 米饭 鸡蛋 /** * Created by Administrator on 2018/9/27. *

Implicit macro. Default implicit value. How?

吃可爱长大的小学妹 提交于 2020-12-15 07:08:32
问题 I don't even know how to ask the question. I have a macro that creates an instance of IsEnum[T] for a type T . I'm doing testing for it, and want to make sure that the implicit is not found for types that are not sealed, or that, in general, don't meet the requirements of an enum. So I created this method for testing def enumOf[T](implicit isEnum:IsEnum[T] = null) = isEnum And then I ensure that enumOf[NotAnEnum] == null But instead, it fails at compile time. One thing is the macro erroring.

Implicit macro. Default implicit value. How?

我与影子孤独终老i 提交于 2020-12-15 07:07:08
问题 I don't even know how to ask the question. I have a macro that creates an instance of IsEnum[T] for a type T . I'm doing testing for it, and want to make sure that the implicit is not found for types that are not sealed, or that, in general, don't meet the requirements of an enum. So I created this method for testing def enumOf[T](implicit isEnum:IsEnum[T] = null) = isEnum And then I ensure that enumOf[NotAnEnum] == null But instead, it fails at compile time. One thing is the macro erroring.

In scala, how do I get access to specific index in tuple?

三世轮回 提交于 2020-12-15 06:24:50
问题 I am implementing function that gets random index and returns the element at random index of tuple. I know that for tuple like, val a=(1,2,3) a._1=2 However, when I use random index val index=random_index(integer that is smaller than size of tuple) , a._index doesnt work. 回答1: You can use productElement, note that it is zero based and has return type of Any : val a=(1,2,3) a.productElement(1) // returns 2nd element 回答2: If you know random_index only at runtime the best what you can have is