假期二
Posted jbwen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了假期二相关的知识,希望对你有一定的参考价值。
Spark提供的数据集操作类型有很多种,大致分为:转换操作和行动操作两大类,即对RDD的操作,RDD相关操作较多,这里不做表述。此外各个处理节点之间的通信模型不再像Hadoop只有Shuffle一种模式,用户可以命名、物化,控制中间结果的存储、分区等。下载完Spark后,启动spark shell 然后建在了spark自带的本地测试文件,以及简单的RDD操作和退出spark shell。
case
class
Point(
var
x
:
Double,
var
y
:
Double)
extends
Drawable{
def
shift(deltaX
:
Double,deltaY
:
Double){x+
=
deltaX;y+
=
deltaY}
}
trait
Drawable{
def
draw(){println(
this
.toString)}
}
abstract
class
Shape(
var
location
:
Point){
//location是Shape的一个可变字段
def
moveTo(newLocation
:
Point){
//默认实现,只是修改位置
location
=
newLocation
}
def
zoom(scale
:
Double)
}
class
Line(beginPoint
:
Point,
var
endPoint
:
Point)
extends
Shape(beginPoint)
with
Drawable{
override
def
draw(){
println(s
"Line:(${location.x},${location.y})--(${endPoint.x},${endPoint.y})"
)
}
override
def
moveTo(newLocation
:
Point){
endPoint.shift(newLocation.x - location.x,newLocation.y -
location.y)
//直线移动时,先移动另外一个端点
location
=
newLocation
//移动位置
}
override
def
zoom(scale
:
Double){
val
midPoint
=
Point((endPoint.x + location.x)/
2
,(endPoint.y +
location.y)/
2
)
//求出中点,并按中点进行缩放
location.x
=
midPoint.x + scale * (location.x - midPoint.x)
location.y
=
midPoint.y + scale * (location.y -midPoint.y)
endPoint.x
=
midPoint.x + scale * (endPoint.x - midPoint.x)
endPoint.y
=
midPoint.y + scale * (endPoint.y -midPoint.y)
}}
class
Circle(center
:
Point,
var
radius
:
Double)
extends
Shape(center)
with
Drawable{
override
def
draw(){
println(s
"Circle center:(${location.x},${location.y}),R=$radius"
)
}
override
def
zoom(scale
:
Double){
radius
=
radius*scale
//对圆的缩放只用修改半径
} }
object
MyDraw{
def
main(args
:
Array[String]) {
val
p
=
new
Point(
10
,
30
)
p.draw;
val
line
1
=
new
Line(Point(
0
,
0
),Point(
20
,
20
))
line
1
.draw
line
1
.moveTo(Point(
5
,
5
))
line
1
.draw
line
1
.zoom(
2
)
line
1
.draw
val
cir
=
new
Circle(Point(
10
,
10
),
5
)
cir.draw
cir.moveTo(Point(
30
,
20
))
cir.draw
cir.zoom(
0.5
)
cir.draw
} }
以上是关于假期二的主要内容,如果未能解决你的问题,请参考以下文章
Pythontesseract+uiautomator2+夜神模拟器 悠长假期手游集市识别验证码自动购买