diff options
Diffstat (limited to 'examples/src/main/scala/BroadcastTest.scala')
-rw-r--r-- | examples/src/main/scala/BroadcastTest.scala | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/src/main/scala/BroadcastTest.scala b/examples/src/main/scala/BroadcastTest.scala new file mode 100644 index 0000000000..40c2be8f6d --- /dev/null +++ b/examples/src/main/scala/BroadcastTest.scala @@ -0,0 +1,28 @@ +import spark.SparkContext + +object BroadcastTest { + def main(args: Array[String]) { + if (args.length == 0) { + System.err.println("Usage: BroadcastTest <host> [<slices>]") + System.exit(1) + } + val spark = new SparkContext(args(0), "Broadcast Test") + val slices = if (args.length > 1) args(1).toInt else 2 + val num = if (args.length > 2) args(2).toInt else 1000000 + + var arr1 = new Array[Int](num) + for (i <- 0 until arr1.length) + arr1(i) = i + +// var arr2 = new Array[Int](num * 2) +// for (i <- 0 until arr2.length) +// arr2(i) = i + + val barr1 = spark.broadcast(arr1) +// val barr2 = spark.broadcast(arr2) + spark.parallelize(1 to 10, slices).foreach { +// i => println(barr1.value.size + barr2.value.size) + i => println(barr1.value.size) + } + } +} |