Scala,Spark中==和===之间的区别

编程入门 行业动态 更新时间:2024-10-14 10:38:59
本文介绍了Scala,Spark中==和===之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我来自Java背景,是Scala的新手.

I am from a Java background and new to Scala.

我正在使用Scala和Spark.但是我无法理解在哪里使用==和===.

I am using Scala and Spark. But I'm not able to understand where I use ==and ===.

任何人都可以让我知道在哪种情况下我需要使用这两个运算符,并且==和===有什么区别?

Could anyone let me know in which scenario I need to use these two operators, and what's are difference between == and ===?

推荐答案

"=="正在使用equals方法,该方法检查两个引用是否指向同一对象. "==="的定义取决于上下文/对象.对于Spark,"==="正在使用equalTo方法. 见

The "==" is using the equals methods which checks if the two references point to the same object. The definition of "===" depends on the context/object. For Spark , "===" is using the equalTo method. See

  • 用于== spark.apache/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equals(java.lang.Object)
  • 对于=== spark.apache/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equalTo(java.lang.Object)
  • for == spark.apache/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equals(java.lang.Object)
  • for === spark.apache/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equalTo(java.lang.Object)

(因为您正在引用Spark :) Spark的一个重要区别是返回值.对于列:

(Since you are referencing Spark:) An important difference for Spark is the return value. For Column:

  • ==返回一个布尔值

===返回一列(其中包含两列元素的比较结果)

=== returns a column (which contains the result of the comparisons of the elements of two columns)

更多推荐

Scala,Spark中==和===之间的区别

本文发布于:2023-11-25 15:12:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630249.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   Scala   Spark

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!