Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit e939a7d

Browse files
committed
Fixed bug with determining correct level of parallelism when writing
1 parent 51e917d commit e939a7d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/scala/com/audienceproject/spark/dynamodb/rdd/DynamoWriteRelation.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ private[dynamodb] class DynamoWriteRelation(data: DataFrame, parameters: Map[Str
3333

3434
private val tableName = parameters("tableName")
3535
private val batchSize = parameters.getOrElse("writeBatchSize", "25").toInt
36-
private val connector = new TableConnector(tableName, sqlContext.sparkContext.defaultParallelism, parameters)
36+
37+
private val numPartitions = data.rdd.getNumPartitions
38+
private val writeSegments = math.min(numPartitions, sqlContext.sparkContext.defaultParallelism)
39+
40+
private val connector = new TableConnector(tableName, writeSegments, parameters)
3741

3842
override val schema: StructType = data.schema
3943

0 commit comments

Comments
 (0)