summaryrefslogtreecommitdiff
path: root/site/docs/1.0.1/api/python/pyspark.context.SparkContext-class.html
blob: ab52ec640e4574f4167c3697d4eb69f411c21dfb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>pyspark.context.SparkContext</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="pyspark-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://spark.apache.org">Spark 1.0.0 Python API Docs</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="pyspark-module.html">Package&nbsp;pyspark</a> ::
        <a href="pyspark.context-module.html">Module&nbsp;context</a> ::
        Class&nbsp;SparkContext
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="pyspark.context.SparkContext-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class SparkContext</h1><p class="nomargin-top"><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext">source&nbsp;code</a></span></p>
<pre class="base-tree">
object --+
         |
        <strong class="uidshort">SparkContext</strong>
</pre>

<hr />
<p>Main entry point for Spark functionality. A SparkContext represents 
  the connection to a Spark cluster, and can be used to create <a 
  href="pyspark.rdd.RDD-class.html" class="link">RDD</a>s and broadcast 
  variables on that cluster.</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Instance Methods</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">master</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">appName</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">sparkHome</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">pyFiles</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">environment</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">batchSize</span>=<span class="summary-sig-default">1024</span>,
        <span class="summary-sig-arg">serializer</span>=<span class="summary-sig-default">PickleSerializer()</span>,
        <span class="summary-sig-arg">conf</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">gateway</span>=<span class="summary-sig-default">None</span>)</span><br />
      Create a new SparkContext.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#defaultParallelism" class="summary-sig-name">defaultParallelism</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Default level of parallelism to use when not given by user (e.g.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.defaultParallelism">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#defaultMinPartitions" class="summary-sig-name">defaultMinPartitions</a>(<span class="summary-sig-arg">self</span>)</span><br />
      Default min number of partitions for Hadoop RDDs when not given by 
      user</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.defaultMinPartitions">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="__del__"></a><span class="summary-sig-name">__del__</span>(<span class="summary-sig-arg">self</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.__del__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="stop"></a><span class="summary-sig-name">stop</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Shut down the SparkContext.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.stop">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#parallelize" class="summary-sig-name">parallelize</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">c</span>,
        <span class="summary-sig-arg">numSlices</span>=<span class="summary-sig-default">None</span>)</span><br />
      Distribute a local Python collection to form an RDD.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.parallelize">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#textFile" class="summary-sig-name">textFile</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">name</span>,
        <span class="summary-sig-arg">minPartitions</span>=<span class="summary-sig-default">None</span>)</span><br />
      Read a text file from HDFS, a local file system (available on all 
      nodes), or any Hadoop-supported file system URI, and return it as an 
      RDD of Strings.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.textFile">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#wholeTextFiles" class="summary-sig-name">wholeTextFiles</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">path</span>,
        <span class="summary-sig-arg">minPartitions</span>=<span class="summary-sig-default">None</span>)</span><br />
      Read a directory of text files from HDFS, a local file system 
      (available on all nodes), or any  Hadoop-supported file system URI.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.wholeTextFiles">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#union" class="summary-sig-name">union</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">rdds</span>)</span><br />
      Build the union of a list of RDDs.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.union">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#broadcast" class="summary-sig-name">broadcast</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">value</span>)</span><br />
      Broadcast a read-only variable to the cluster, returning a <a 
      href="pyspark.broadcast.Broadcast-class.html" 
      class="link">Broadcast</a> object for reading it in distributed 
      functions.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.broadcast">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#accumulator" class="summary-sig-name">accumulator</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">value</span>,
        <span class="summary-sig-arg">accum_param</span>=<span class="summary-sig-default">None</span>)</span><br />
      Create an <a href="pyspark.accumulators.Accumulator-class.html" 
      class="link">Accumulator</a> with the given initial value, using a 
      given <a href="pyspark.accumulators.AccumulatorParam-class.html" 
      class="link">AccumulatorParam</a> helper object to define how to add 
      values of the data type if provided.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.accumulator">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#addFile" class="summary-sig-name">addFile</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">path</span>)</span><br />
      Add a file to be downloaded with this Spark job on every node.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.addFile">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="clearFiles"></a><span class="summary-sig-name">clearFiles</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Clear the job's list of files added by <a 
      href="pyspark.context.SparkContext-class.html#addFile" 
      class="link">addFile</a> or <a 
      href="pyspark.context.SparkContext-class.html#addPyFile" 
      class="link">addPyFile</a> so that they do not get downloaded to any 
      new nodes.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.clearFiles">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#addPyFile" class="summary-sig-name">addPyFile</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">path</span>)</span><br />
      Add a .py or .zip dependency for all tasks to be executed on this 
      SparkContext in the future.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.addPyFile">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#setCheckpointDir" class="summary-sig-name">setCheckpointDir</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">dirName</span>)</span><br />
      Set the directory under which RDDs are going to be checkpointed.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.setCheckpointDir">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#setJobGroup" class="summary-sig-name">setJobGroup</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">groupId</span>,
        <span class="summary-sig-arg">description</span>,
        <span class="summary-sig-arg">interruptOnCancel</span>=<span class="summary-sig-default">False</span>)</span><br />
      Assigns a group ID to all the jobs started by this thread until the 
      group ID is set to a different value or cleared.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.setJobGroup">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="setLocalProperty"></a><span class="summary-sig-name">setLocalProperty</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">key</span>,
        <span class="summary-sig-arg">value</span>)</span><br />
      Set a local property that affects jobs submitted from this thread, 
      such as the Spark fair scheduler pool.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.setLocalProperty">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#getLocalProperty" class="summary-sig-name">getLocalProperty</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">key</span>)</span><br />
      Get a local property set in this thread, or null if it is missing.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.getLocalProperty">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="sparkUser"></a><span class="summary-sig-name">sparkUser</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Get SPARK_USER for user who is running SparkContext.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.sparkUser">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#cancelJobGroup" class="summary-sig-name">cancelJobGroup</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">groupId</span>)</span><br />
      Cancel active jobs for the specified group.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.cancelJobGroup">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="cancelAllJobs"></a><span class="summary-sig-name">cancelAllJobs</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Cancel all jobs that have been scheduled or are running.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.cancelAllJobs">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__format__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__sizeof__</code>,
      <code>__str__</code>,
      <code>__subclasshook__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== CLASS METHODS ==================== -->
<a name="section-ClassMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Class Methods</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="pyspark.context.SparkContext-class.html#setSystemProperty" class="summary-sig-name">setSystemProperty</a>(<span class="summary-sig-arg">cls</span>,
        <span class="summary-sig-arg">key</span>,
        <span class="summary-sig-arg">value</span>)</span><br />
      Set a Java system property, such as spark.executor.memory.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.setSystemProperty">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Properties</span></td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Method Details</span></td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">master</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">appName</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">sparkHome</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">pyFiles</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">environment</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">batchSize</span>=<span class="sig-default">1024</span>,
        <span class="sig-arg">serializer</span>=<span class="sig-default">PickleSerializer()</span>,
        <span class="sig-arg">conf</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">gateway</span>=<span class="sig-default">None</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">

Create a new SparkContext. At least the master and app name should be set,
either through the named parameters here or through C{conf}.

@param master: Cluster URL to connect to
       (e.g. mesos://host:port, spark://host:port, local[4]).
@param appName: A name for your job, to display on the cluster web UI.
@param sparkHome: Location where Spark is installed on cluster nodes.
@param pyFiles: Collection of .zip or .py files to send to the cluster
       and add to PYTHONPATH.  These can be paths on the local file
       system or HDFS, HTTP, HTTPS, or FTP URLs.
@param environment: A dictionary of environment variables to set on
       worker nodes.
@param batchSize: The number of Python objects represented as a single
       Java object.  Set 1 to disable batching or -1 to use an
       unlimited batch size.
@param serializer: The serializer for RDDs.
@param conf: A L{SparkConf} object setting Spark properties.
@param gateway: Use an existing gateway and JVM, otherwise a new JVM
       will be instatiated.


&gt;&gt;&gt; from pyspark.context import SparkContext
&gt;&gt;&gt; sc = SparkContext('local', 'test')

&gt;&gt;&gt; sc2 = SparkContext('local', 'test2') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
    ...
ValueError:...

</pre>
  <dl class="fields">
    <dt>Overrides:
        object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="setSystemProperty"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">setSystemProperty</span>(<span class="sig-arg">cls</span>,
        <span class="sig-arg">key</span>,
        <span class="sig-arg">value</span>)</span>
    <br /><em class="fname">Class Method</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.setSystemProperty">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Set a Java system property, such as spark.executor.memory. This must 
  must be invoked before instantiating SparkContext.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="defaultParallelism"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">defaultParallelism</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.defaultParallelism">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Default level of parallelism to use when not given by user (e.g. for 
  reduce tasks)</p>
  <dl class="fields">
    <dt>Decorators:</dt>
    <dd><ul class="nomargin-top">
        <li><code>@property</code></li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="defaultMinPartitions"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">defaultMinPartitions</span>(<span class="sig-arg">self</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.defaultMinPartitions">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Default min number of partitions for Hadoop RDDs when not given by 
  user</p>
  <dl class="fields">
    <dt>Decorators:</dt>
    <dd><ul class="nomargin-top">
        <li><code>@property</code></li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="parallelize"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">parallelize</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">c</span>,
        <span class="sig-arg">numSlices</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.parallelize">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Distribute a local Python collection to form an RDD.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>sc.parallelize(range(5), 5).glom().collect()
<span class="py-output">[[0], [1], [2], [3], [4]]</span></pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="textFile"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">textFile</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">name</span>,
        <span class="sig-arg">minPartitions</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.textFile">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Read a text file from HDFS, a local file system (available on all 
  nodes), or any Hadoop-supported file system URI, and return it as an RDD 
  of Strings.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>path = os.path.join(tempdir, <span class="py-string">&quot;sample-text.txt&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>with open(path, <span class="py-string">&quot;w&quot;</span>) <span class="py-keyword">as</span> testFile:
<span class="py-more">... </span>   testFile.write(<span class="py-string">&quot;Hello world!&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>textFile = sc.textFile(path)
<span class="py-prompt">&gt;&gt;&gt; </span>textFile.collect()
<span class="py-output">[u'Hello world!']</span></pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="wholeTextFiles"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">wholeTextFiles</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">path</span>,
        <span class="sig-arg">minPartitions</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.wholeTextFiles">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Read a directory of text files from HDFS, a local file system 
  (available on all nodes), or any  Hadoop-supported file system URI. Each 
  file is read as a single record and returned in a key-value pair, where 
  the key is the path of each file, the value is the content of each 
  file.</p>
  <p>For example, if you have the following files:</p>
<pre class="literalblock">
 hdfs://a-hdfs-path/part-00000
 hdfs://a-hdfs-path/part-00001
 ...
 hdfs://a-hdfs-path/part-nnnnn
</pre>
  <p>Do <code>rdd = 
  sparkContext.wholeTextFiles(&quot;hdfs://a-hdfs-path&quot;)</code>, then 
  <code>rdd</code> contains:</p>
<pre class="literalblock">
 (a-hdfs-path/part-00000, its content)
 (a-hdfs-path/part-00001, its content)
 ...
 (a-hdfs-path/part-nnnnn, its content)
</pre>
  <p>NOTE: Small files are preferred, as each file will be loaded fully in 
  memory.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>dirPath = os.path.join(tempdir, <span class="py-string">&quot;files&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>os.mkdir(dirPath)
<span class="py-prompt">&gt;&gt;&gt; </span>with open(os.path.join(dirPath, <span class="py-string">&quot;1.txt&quot;</span>), <span class="py-string">&quot;w&quot;</span>) <span class="py-keyword">as</span> file1:
<span class="py-more">... </span>   file1.write(<span class="py-string">&quot;1&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>with open(os.path.join(dirPath, <span class="py-string">&quot;2.txt&quot;</span>), <span class="py-string">&quot;w&quot;</span>) <span class="py-keyword">as</span> file2:
<span class="py-more">... </span>   file2.write(<span class="py-string">&quot;2&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>textFiles = sc.wholeTextFiles(dirPath)
<span class="py-prompt">&gt;&gt;&gt; </span>sorted(textFiles.collect())
<span class="py-output">[(u'.../1.txt', u'1'), (u'.../2.txt', u'2')]</span></pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="union"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">union</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">rdds</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.union">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Build the union of a list of RDDs.</p>
  <p>This supports unions() of RDDs with different serialized formats, 
  although this forces them to be reserialized using the default 
  serializer:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>path = os.path.join(tempdir, <span class="py-string">&quot;union-text.txt&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>with open(path, <span class="py-string">&quot;w&quot;</span>) <span class="py-keyword">as</span> testFile:
<span class="py-more">... </span>   testFile.write(<span class="py-string">&quot;Hello&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>textFile = sc.textFile(path)
<span class="py-prompt">&gt;&gt;&gt; </span>textFile.collect()
<span class="py-output">[u'Hello']</span>
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span>parallelized = sc.parallelize([<span class="py-string">&quot;World!&quot;</span>])
<span class="py-prompt">&gt;&gt;&gt; </span>sorted(sc.union([textFile, parallelized]).collect())
<span class="py-output">[u'Hello', 'World!']</span></pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="broadcast"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">broadcast</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">value</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.broadcast">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Broadcast a read-only variable to the cluster, returning a <a 
  href="pyspark.broadcast.Broadcast-class.html" class="link">Broadcast</a> 
  object for reading it in distributed functions. The variable will be sent
  to each cluster only once.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="accumulator"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">accumulator</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">value</span>,
        <span class="sig-arg">accum_param</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.accumulator">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Create an <a href="pyspark.accumulators.Accumulator-class.html" 
  class="link">Accumulator</a> with the given initial value, using a given 
  <a href="pyspark.accumulators.AccumulatorParam-class.html" 
  class="link">AccumulatorParam</a> helper object to define how to add 
  values of the data type if provided. Default AccumulatorParams are used 
  for integers and floating-point numbers if you do not provide one. For 
  other types, a custom AccumulatorParam can be used.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="addFile"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">addFile</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">path</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.addFile">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add a file to be downloaded with this Spark job on every node. The 
  <code>path</code> passed can be either a local file, a file in HDFS (or 
  other Hadoop-supported filesystems), or an HTTP, HTTPS or FTP URI.</p>
  <p>To access the file in Spark jobs, use <a 
  href="pyspark.files.SparkFiles-class.html#get" 
  class="link">SparkFiles.get(path)</a> to find its download location.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> pyspark <span class="py-keyword">import</span> SparkFiles
<span class="py-prompt">&gt;&gt;&gt; </span>path = os.path.join(tempdir, <span class="py-string">&quot;test.txt&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>with open(path, <span class="py-string">&quot;w&quot;</span>) <span class="py-keyword">as</span> testFile:
<span class="py-more">... </span>   testFile.write(<span class="py-string">&quot;100&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>sc.addFile(path)
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">def</span> <span class="py-defname">func</span>(iterator):
<span class="py-more">... </span>   with open(SparkFiles.get(<span class="py-string">&quot;test.txt&quot;</span>)) <span class="py-keyword">as</span> testFile:
<span class="py-more">... </span>       fileVal = int(testFile.readline())
<span class="py-more">... </span>       return [x * 100 <span class="py-keyword">for</span> x <span class="py-keyword">in</span> iterator]
<span class="py-prompt">&gt;&gt;&gt; </span>sc.parallelize([1, 2, 3, 4]).mapPartitions(func).collect()
<span class="py-output">[100, 200, 300, 400]</span></pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="addPyFile"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">addPyFile</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">path</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.addPyFile">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Add a .py or .zip dependency for all tasks to be executed on this 
  SparkContext in the future.  The <code>path</code> passed can be either a
  local file, a file in HDFS (or other Hadoop-supported filesystems), or an
  HTTP, HTTPS or FTP URI.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="setCheckpointDir"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">setCheckpointDir</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">dirName</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.setCheckpointDir">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Set the directory under which RDDs are going to be checkpointed. The 
  directory must be a HDFS path if running on a cluster.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="setJobGroup"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">setJobGroup</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">groupId</span>,
        <span class="sig-arg">description</span>,
        <span class="sig-arg">interruptOnCancel</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.setJobGroup">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Assigns a group ID to all the jobs started by this thread until the 
  group ID is set to a different value or cleared.</p>
  <p>Often, a unit of execution in an application consists of multiple 
  Spark actions or jobs. Application programmers can use this method to 
  group all those jobs together and give a group description. Once set, the
  Spark web UI will associate such jobs with this group.</p>
  <p>The application can use <a 
  href="pyspark.context.SparkContext-class.html#cancelJobGroup" 
  class="link">SparkContext.cancelJobGroup</a> to cancel all running jobs 
  in this group.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">import</span> thread, threading
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> time <span class="py-keyword">import</span> sleep
<span class="py-prompt">&gt;&gt;&gt; </span>result = <span class="py-string">&quot;Not Set&quot;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>lock = threading.Lock()
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">def</span> <span class="py-defname">map_func</span>(x):
<span class="py-more">... </span>    sleep(100)
<span class="py-more">... </span>    raise Exception(<span class="py-string">&quot;Task should have been cancelled&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">def</span> <span class="py-defname">start_job</span>(x):
<span class="py-more">... </span>    <span class="py-keyword">global</span> result
<span class="py-more">... </span>    try:
<span class="py-more">... </span>        sc.setJobGroup(<span class="py-string">&quot;job_to_cancel&quot;</span>, <span class="py-string">&quot;some description&quot;</span>)
<span class="py-more">... </span>        result = sc.parallelize(range(x)).map(map_func).collect()
<span class="py-more">... </span>    <span class="py-keyword">except</span> Exception <span class="py-keyword">as</span> e:
<span class="py-more">... </span>        result = <span class="py-string">&quot;Cancelled&quot;</span>
<span class="py-more">... </span>    lock.release()
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">def</span> <span class="py-defname">stop_job</span>():
<span class="py-more">... </span>    sleep(5)
<span class="py-more">... </span>    sc.cancelJobGroup(<span class="py-string">&quot;job_to_cancel&quot;</span>)
<span class="py-prompt">&gt;&gt;&gt; </span>supress = lock.acquire()
<span class="py-prompt">&gt;&gt;&gt; </span>supress = thread.start_new_thread(start_job, (10,))
<span class="py-prompt">&gt;&gt;&gt; </span>supress = thread.start_new_thread(stop_job, tuple())
<span class="py-prompt">&gt;&gt;&gt; </span>supress = lock.acquire()
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> result
<span class="py-output">Cancelled</span></pre>
  <p>If interruptOnCancel is set to true for the job group, then job 
  cancellation will result in Thread.interrupt() being called on the job's 
  executor threads. This is useful to help ensure that the tasks are 
  actually stopped in a timely manner, but is off by default due to 
  HDFS-1208, where HDFS may respond to Thread.interrupt() by marking nodes 
  as dead.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="getLocalProperty"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">getLocalProperty</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">key</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.getLocalProperty">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Get a local property set in this thread, or null if it is missing. See
  <a href="pyspark.context.SparkContext-class.html#setLocalProperty" 
  class="link">setLocalProperty</a></p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="cancelJobGroup"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">cancelJobGroup</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">groupId</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="pyspark.context-pysrc.html#SparkContext.cancelJobGroup">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Cancel active jobs for the specified group. See <a 
  href="pyspark.context.SparkContext-class.html#setJobGroup" 
  class="link">SparkContext.setJobGroup</a> for more information.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="pyspark-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://spark.apache.org">Spark 1.0.0 Python API Docs</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Fri Jul  4 18:52:26 2014
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>