Commit 0a55c5f4b8844263f405fb0b03f8e4973ce4102d
1 parent
26616791
Exists in
master
and in
1 other branch
staged.
Showing
1 changed file
with
9 additions
and
0 deletions
Show diff stats
mspark/SC.py
... | ... | @@ -373,6 +373,15 @@ class Sparker(object): |
373 | 373 | if collect: |
374 | 374 | return hbase_rdd.collect() |
375 | 375 | else: |
376 | + """ | |
377 | + RDD-hbase bug fixed.(with 'repartition()') | |
378 | + <http://stackoverflow.com/questions/29011574/how-is-spark-partitioning-from-hdfs> | |
379 | + | |
380 | + When Spark reads a file from HDFS, it creates a single partition for a single input split. Input split is set by the Hadoop InputFormat used to read this file. For instance, if you use textFile() it would be TextInputFormat in Hadoop, which would return you a single partition for a single block of HDFS (but the split between partitions would be done on line split, not the exact block split), unless you have a compressed text file. In case of compressed file you would get a single partition for a single file (as compressed text files are not splittable). | |
381 | + When you call rdd.repartition(x) it would perform a shuffle of the data from N partititons you have in rdd to x partitions you want to have, partitioning would be done on round robin basis. | |
382 | + If you have a 30GB uncompressed text file stored on HDFS, then with the default HDFS block size setting (128MB) it would be stored in 235 blocks, which means that the RDD you read from this file would have 235 partitions. When you call repartition(1000) your RDD would be marked as to be repartitioned, but in fact it would be shuffled to 1000 partitions only when you will execute an action on top of this RDD (lazy execution concept) | |
383 | + | |
384 | + """ | |
376 | 385 | return hbase_rdd.repartition(parallelism) |
377 | 386 | |
378 | 387 | def write_hbase(self, table_name, data, fromrdd=False, columns=None, withdata=False): | ... | ... |