diff options
author | Mosharaf Chowdhury <mosharaf@mosharaf-mbp.(none)> | 2011-02-09 10:48:48 -0800 |
---|---|---|
committer | Mosharaf Chowdhury <mosharaf@mosharaf-mbp.(none)> | 2011-02-09 10:48:48 -0800 |
commit | 1a73c0d2658f90f533eccbb2203f8b12fa247fc9 (patch) | |
tree | ddd31adab710f1bc1baf7130156223236a4c3d30 /examples/src | |
parent | 495b38658e99101240a9b028fd7c2fb8bf1034a4 (diff) | |
download | spark-1a73c0d2658f90f533eccbb2203f8b12fa247fc9.tar.gz spark-1a73c0d2658f90f533eccbb2203f8b12fa247fc9.tar.bz2 spark-1a73c0d2658f90f533eccbb2203f8b12fa247fc9.zip |
Merged with master. Using sbt.
Diffstat (limited to 'examples/src')
-rw-r--r-- | examples/src/main/scala/spark/examples/MultiBroadcastTest.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/src/main/scala/spark/examples/MultiBroadcastTest.scala b/examples/src/main/scala/spark/examples/MultiBroadcastTest.scala new file mode 100644 index 0000000000..c5c63ec4cb --- /dev/null +++ b/examples/src/main/scala/spark/examples/MultiBroadcastTest.scala @@ -0,0 +1,30 @@ +package spark.examples + +import spark.SparkContext + +object MultiBroadcastTest { + def main(args: Array[String]) { + if (args.length == 0) { + System.err.println("Usage: BroadcastTest <host> [<slices>] [numElem]") + 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) + 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) + } + } +} |