arjunashok commented on code in PR #41:
URL: 
https://github.com/apache/cassandra-analytics/pull/41#discussion_r1520627909


##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/CassandraBulkSourceRelation.java:
##########
@@ -107,17 +112,25 @@ private void persist(@NotNull JavaPairRDD<DecoratedKey, 
Object[]> sortedRDD, Str
     {
         try
         {
-            sortedRDD.foreachPartition(writeRowsInPartition(broadcastContext, 
columnNames));
+            List<StreamResult> results = sortedRDD
+                                         
.mapPartitions(partitionsFlatMapFunc(broadcastContext, columnNames))
+                                         .collect();
+            long rowCount = results.stream().mapToLong(res -> 
res.rowCount).sum();
+            long totalBytesWritten = results.stream().mapToLong(res -> 
res.bytesWritten).sum();
+            LOGGER.info("Bulk writer has written {} rows and {} bytes", 
rowCount, totalBytesWritten);
+            recordSuccessfulJobStats(rowCount, totalBytesWritten);
         }
         catch (Throwable throwable)
         {
+            recordFailureStats(throwable.getMessage());
             LOGGER.error("Bulk Write Failed", throwable);
             throw new RuntimeException("Bulk Write to Cassandra has failed", 
throwable);
         }
         finally
         {
             try
             {
+                writerContext.publishJobStats();

Review Comment:
   You're right. Fixed to only report/publish stats from the driver. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to