1
00:00:01,000 --> 00:00:03,500
What's that way to walk with 
spark? 

2
00:00:03,500 --> 00:00:08,800
That frames taught cash? 
How should we exactly use it 

3
00:00:08,800 --> 00:00:12,800
when exactly? 
And when should we not be using 

4
00:00:12,800 --> 00:00:17,500
it because the dot cash method? 
It's true. 

5
00:00:17,600 --> 00:00:21,600
It will make things faster but 
the situation where it would 

6
00:00:21,600 --> 00:00:25,900
make things slower. 
Also, it's important to notice. 

7
00:00:26,200 --> 00:00:28,400
When exactly. 
Are we going to use it? 

8
00:00:28,400 --> 00:00:33,700
And how to basically, If we do 
multiple operations on a spark 

9
00:00:33,700 --> 00:00:36,600
that find out from that filter, 
that went to the doctor to find 

10
00:00:36,600 --> 00:00:38,900
out filter that a frame dot 
whatever. 

11
00:00:39,300 --> 00:00:44,700
Then at a certain point we can 
stuck their data frame dot cash 

12
00:00:45,200 --> 00:00:49,200
and later on we would have their
action that a DOT count. 

13
00:00:49,200 --> 00:00:55,100
Then this only then this would 
get cached and we could really 

14
00:00:55,100 --> 00:00:56,800
use this. 
Okay. 

15
00:00:56,800 --> 00:01:00,300
So we already see that. 
We can cash. 

16
00:01:00,400 --> 00:01:04,900
Schmoopy put that frames and the
cash under the hood, try to fit 

17
00:01:04,900 --> 00:01:10,300
that, that framing pole both 
memory and also disk it's 

18
00:01:10,300 --> 00:01:14,200
important to note that the data 
frame do not persist will accept

19
00:01:14,200 --> 00:01:17,400
the parameter where we would 
tell it, whether we want it to 

20
00:01:17,400 --> 00:01:22,000
be cached only to marry only 
today's off to a win this and 

21
00:01:22,000 --> 00:01:24,600
there are few couple of flour 
more options there. 

22
00:01:25,500 --> 00:01:30,800
So, basically whenever we do 
this, Hey, we want to do this on

23
00:01:31,400 --> 00:01:34,800
parts of that frames. 
That would repeat themselves. 

24
00:01:34,800 --> 00:01:39,100
And if this part is a huge 
gigantic a part, we probably 

25
00:01:39,100 --> 00:01:44,600
don't want to do this because it
could possibly not fit our 

26
00:01:44,600 --> 00:01:50,500
memory and and disc, okay? 
So maybe there are other way of 

27
00:01:50,500 --> 00:01:54,500
optimizing, our stock that 
friends walking such that we 

28
00:01:54,500 --> 00:01:58,300
would not need to reuse this 
data frame. 

29
00:01:58,500 --> 00:02:01,300
At all. 
So when we can share that frame,

30
00:02:01,300 --> 00:02:05,100
we create a new variable for it,
it's best to call to create a 

31
00:02:05,100 --> 00:02:10,199
new variable for it because then
we could reference it later. 

32
00:02:11,200 --> 00:02:15,100
If we don't do this, we would 
not have a way to reference this

33
00:02:15,100 --> 00:02:20,300
data file, unless we use create 
a holy Place, Global late term 

34
00:02:20,300 --> 00:02:23,100
for you. 
In this case, we could also 

35
00:02:23,100 --> 00:02:26,500
catch it and then reference it 
in Sparky scale as cash. 

36
00:02:26,900 --> 00:02:32,000
Also, it's important to Persist 
data frame after it no longer 

37
00:02:32,000 --> 00:02:35,400
needed. 
So we call data frame that we 

38
00:02:35,400 --> 00:02:40,300
have cashed previously, Dot and 
persist, this will prevent from 

39
00:02:40,300 --> 00:02:44,000
having the caching layer 
becoming pull. 

40
00:02:44,400 --> 00:02:47,400
If it's pulled spark, will be 
able to manage it. 

41
00:02:47,400 --> 00:02:52,400
It would start removing 
evicting, the data from memory 

42
00:02:52,400 --> 00:02:58,200
in and allowing you style least 
recently used strategy, but it 

43
00:02:58,200 --> 00:03:01,500
is Good part is when you know 
that you don't would need 

44
00:03:01,500 --> 00:03:03,900
anymore. 
The cash to just collect 

45
00:03:03,900 --> 00:03:10,200
explicitly the and persist and 
unload and the memory and the 

46
00:03:10,200 --> 00:03:17,800
disk and this would save us from
all this ilario has next tip is 

47
00:03:17,800 --> 00:03:23,300
to just cash whatever we exactly
actually needing to queries and 

48
00:03:23,300 --> 00:03:27,700
not just cash everything 
including things that we don't 

49
00:03:27,800 --> 00:03:31,200
need. 
This includes both data frames 

50
00:03:31,200 --> 00:03:36,300
and columns. 
If we have 100 columns, coming 

51
00:03:36,500 --> 00:03:39,400
returning for Macquarie and 
we'll catch this data frame, 

52
00:03:39,400 --> 00:03:41,600
because we need only one column 
out of them. 

53
00:03:41,900 --> 00:03:44,800
This does not make sense. 
We could make better use of our 

54
00:03:44,800 --> 00:03:47,200
memory and first do that 
offended. 

55
00:03:47,200 --> 00:03:50,500
Select column, one, and only. 
Then cash. 

56
00:03:50,500 --> 00:03:54,200
This, the that frame at this 
point I want to repeat what do 

57
00:03:54,200 --> 00:03:56,000
we cache? 
We do that. 

58
00:03:56,000 --> 00:03:58,400
Defy him dot filter that front 
of Select. 

59
00:03:58,600 --> 00:04:01,600
Advantage filter that will 
framework to add whatever. 

60
00:04:01,800 --> 00:04:05,700
And before we actually make the 
action, we call that fine dot 

61
00:04:05,700 --> 00:04:08,500
cash which would not cash at 
this point. 

62
00:04:08,500 --> 00:04:12,200
Only at a point where we 
actually make an action like 

63
00:04:12,200 --> 00:04:17,899
that from dot count that front 
of collect and Etc. 

64
00:04:19,800 --> 00:04:21,800
There is an overhead to the cash
show. 

65
00:04:21,800 --> 00:04:26,700
So as we said, if we have small 
that frames it and we reuse them

66
00:04:26,700 --> 00:04:30,400
over and over, it might make 
sense to catch them, but if we 

67
00:04:30,400 --> 00:04:37,300
have gigantic tens of gigabytes 
of data frame, then converting 

68
00:04:37,300 --> 00:04:40,400
them to a data structure that we
want to fit in memory and then 

69
00:04:40,400 --> 00:04:44,600
placing them in memory and then 
later on a victim then all this 

70
00:04:44,600 --> 00:04:48,000
with consume some time. 
So we should take note of when 

71
00:04:48,000 --> 00:04:50,600
we want to cash in one. 
Don't want to Cache want 

72
00:04:50,600 --> 00:04:53,900
occasion smaller that frames on 
specific columns that we are 

73
00:04:53,900 --> 00:04:56,200
going to use over and over. 
Check. 

74
00:04:56,200 --> 00:04:59,600
If there are no other solution 
before cashing in case you 

75
00:04:59,608 --> 00:05:01,400
exactly what we need.
