scala

Setting an environment variable from within the sbt shell

假装没事ソ 提交于 2020-07-30 05:22:21
问题 I would like to be able to set an environment variable from within the interactive sbt shell, and I can't seem to find a way to do that. (I have looked on the official sbt docs as well as on stackoverflow without success). I want to make it clear that I don't want to have to set this environment variable in the build.sbt file, but rather be able to change it on the fly on my interactive sbt shell session, so that the environment variable is used for the next sbt commands I run. For example, I

Why do both of these implicits match when only one of them would type check?

断了今生、忘了曾经 提交于 2020-07-30 04:09:50
问题 I am trying to diagnose a compiler error which is caused by diverging implicit expansion errors. Here is what I am seeing: ❯ scala Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 1.8.0_252). Type in expressions for evaluation. Or try :help. scala> :settings -Xlog-implicits scala> :paste // Entering paste mode (ctrl-D to finish) trait Invariant[A] trait Covariant[+A] trait Foo implicit def invariantTuple1[T1: Invariant]: Invariant[Tuple1[T1]] = ??? implicit def invariantFoo: Invariant

【赵强老师】什么是Spark SQL?

大城市里の小女人 提交于 2020-07-29 06:40:08
一、Spark SQL简介 Spark SQL是Spark用来处理结构化数据的一个模块,它提供了一个编程抽象叫做DataFrame并且作为分布式SQL查询引擎的作用。 为什么要学习Spark SQL?我们已经学习了Hive,它是将Hive SQL转换成MapReduce然后提交到集群上执行,大大简化了编写MapReduce的程序的复杂性,由于MapReduce这种计算模型执行效率比较慢。所以Spark SQL的应运而生,它是将Spark SQL转换成RDD,然后提交到集群执行,执行效率非常快!同时Spark SQL也支持从Hive中读取数据。 二、Spark SQL的特点 无缝集成在Spark中,将SQL查询与Spark程序混合。Spark SQL允许您使用SQL或熟悉的DataFrame API在Spark程序中查询结构化数据。适用于Java、Scala、Python和R语言。 提供统一的数据访问,以相同的方式连接到任何数据源。DataFrames和SQL提供了一种访问各种数据源的通用方法,包括Hive、Avro、Parquet、ORC、JSON和JDBC。您甚至可以通过这些源连接数据。 支持Hive集成。在现有仓库上运行SQL或HiveQL查询。Spark SQL支持HiveQL语法以及Hive SerDes和udf,允许您访问现有的Hive仓库。 支持标准的连接

scala forall and exists output , does it make sense

只愿长相守 提交于 2020-07-29 05:24:19
问题 scala> val l = List() l: List[Nothing] = List() scala> l.forall(x=>false) res0: Boolean = true scala> l.forall(x=>true) res1: Boolean = true scala> l.exists(x=>false) res2: Boolean = false scala> l.exists(x=>true) res3: Boolean = false For above 2 predicate, now that no element exists in the list, how come forall return true? I am confused. could you somebody help explain? 回答1: You could rephrase that forall means that none of the elements of the list violate the given predicate. In case

scala forall and exists output , does it make sense

不想你离开。 提交于 2020-07-29 05:23:48
问题 scala> val l = List() l: List[Nothing] = List() scala> l.forall(x=>false) res0: Boolean = true scala> l.forall(x=>true) res1: Boolean = true scala> l.exists(x=>false) res2: Boolean = false scala> l.exists(x=>true) res3: Boolean = false For above 2 predicate, now that no element exists in the list, how come forall return true? I am confused. could you somebody help explain? 回答1: You could rephrase that forall means that none of the elements of the list violate the given predicate. In case

scala forall and exists output , does it make sense

谁都会走 提交于 2020-07-29 05:23:08
问题 scala> val l = List() l: List[Nothing] = List() scala> l.forall(x=>false) res0: Boolean = true scala> l.forall(x=>true) res1: Boolean = true scala> l.exists(x=>false) res2: Boolean = false scala> l.exists(x=>true) res3: Boolean = false For above 2 predicate, now that no element exists in the list, how come forall return true? I am confused. could you somebody help explain? 回答1: You could rephrase that forall means that none of the elements of the list violate the given predicate. In case

JetBrains 发布 2020 年 Go 语言调查报告

给你一囗甜甜゛ 提交于 2020-07-29 05:04:06
有63%的人Go主要用于工作,28%的人用于个人项目 大多数人同时使用多个版本的Go,我估计是要维护不同版本下的项目,下面这个数据印证了这个猜测。 71%的Go开发者主要用来做微服务,排在Scala之后。 GOPATH影响深远啊,74%的人还是只使用一个全局GOPATH,其实最佳实践是分两个,一个用来下载第三方库,另一个用来做项目,但是目前引入新的module之后基本上不用GOPATH了。 版本管理基本上都已经切换到modules,dep和godep紧跟其后,我估计后面这些都是老版本维护工具了 大多数人还是使用Gin为主,echo和beego紧跟其后,44%的人不使用框架。 很多人使用gorilla/mux做路由,但是不可思议的居然有30%的人使用原生的。 大多数人使用内置的testing框架做测试,testify和gomock使用的人也很多,但是还是有20%左右的人不写test,还得继续努力啊 大多数项目看上去都不大,50%左右codebase的文件在100以内。 自从有了modules之后基本上可以脱离GOPATH,而且从数据也可以说明大多数人也是在GOPATH之外新建项目 modules虽好,但是也是存在很多bug或者问题,一半一半的人,一些人愿意,一半人不愿意。 从这个图可以看出来大多数人还是在网站开发,和我们之前调研的结果一样,国内外开发者还是主要在这一块。 来源:

Standalone模式下_taskScheduler和executor运行原理解密

…衆ロ難τιáo~ 提交于 2020-07-28 15:49:06
环境: spark 2.3.3 scala 2.11.8 Java 1.8.0_141 _taskScheduler和executor运行的代码调用流程,如下图所示: 将上述过程,整理简图如下: 下面进行具体说明: 一:Spark Executor工作原理: 1.创建并启动TaskScheduler 在SparkContext中调用内部方法createTaskScheduler创建TaskScheduler,并启动TaskScheduler; 1.1在Standalone模式下createTaskScheduler匹配到如下代码: SparkContext: case SPARK_REGEX(sparkUrl) => val scheduler = new TaskSchedulerImpl(sc) val masterUrls = sparkUrl.split(",").map("spark://" + _) val backend = new StandaloneSchedulerBackend(scheduler, sc, masterUrls) scheduler.initialize(backend) (backend, scheduler) 所以在Standalone 模式下,_taskScheduler是TaskSchedulerImpl,

Why doesn't Scala's implicit class work when one of the type parameters should be Nothing?

蹲街弑〆低调 提交于 2020-07-28 13:54:48
问题 Update: I modified the example so that can be compiled and tested. I have an implicit class that defines an enrichment method: case class Pipe[-I,+O,+R](f: I => (O, R)); object Pipe { // The problematic implicit class: implicit class PipeEnrich[I,O,R](val pipe: Pipe[I,O,R]) extends AnyVal { def >->[X](that: Pipe[O,X,R]): Pipe[I,X,R] = Pipe.fuse(pipe, that); def <-<[X](that: Pipe[X,I,R]): Pipe[X,O,R] = Pipe.fuse(that, pipe); } def fuse[I,O,X,R](i: Pipe[I,O,R], o: Pipe[O,X,R]): Pipe[I,X,R] =

Why doesn't Scala's implicit class work when one of the type parameters should be Nothing?

∥☆過路亽.° 提交于 2020-07-28 13:53:19
问题 Update: I modified the example so that can be compiled and tested. I have an implicit class that defines an enrichment method: case class Pipe[-I,+O,+R](f: I => (O, R)); object Pipe { // The problematic implicit class: implicit class PipeEnrich[I,O,R](val pipe: Pipe[I,O,R]) extends AnyVal { def >->[X](that: Pipe[O,X,R]): Pipe[I,X,R] = Pipe.fuse(pipe, that); def <-<[X](that: Pipe[X,I,R]): Pipe[X,O,R] = Pipe.fuse(that, pipe); } def fuse[I,O,X,R](i: Pipe[I,O,R], o: Pipe[O,X,R]): Pipe[I,X,R] =