You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "yifan-c (via GitHub)" <gi...@apache.org> on 2023/08/08 20:41:05 UTC

[GitHub] [cassandra-analytics] yifan-c commented on a diff in pull request #13: CASSANDRA-18692 Fix bulk writes with Buffered RowBufferMode

yifan-c commented on code in PR #13:
URL: https://github.com/apache/cassandra-analytics/pull/13#discussion_r1287667789


##########
cassandra-four-zero/src/main/java/org/apache/cassandra/bridge/SSTableWriterImplementation.java:
##########
@@ -80,4 +79,28 @@ public void close() throws IOException
     {
         writer.close();
     }
+
+    @VisibleForTesting
+    static CQLSSTableWriter.Builder configureBuilder(String inDirectory,
+                                                     String createStatement,
+                                                     String insertStatement,
+                                                     RowBufferMode rowBufferMode,
+                                                     int bufferSizeMB,
+                                                     IPartitioner cassPartitioner)
+    {
+        CQLSSTableWriter.Builder builder = CQLSSTableWriter.builder()
+                                                           .inDirectory(inDirectory)
+                                                           .forTable(createStatement)
+                                                           .withPartitioner(cassPartitioner)
+                                                           .using(insertStatement);
+        if (rowBufferMode == RowBufferMode.UNBUFFERED)
+        {
+            builder.sorted();
+        }
+        else if (rowBufferMode == RowBufferMode.BUFFERED)
+        {
+            builder.withBufferSizeInMB(bufferSizeMB);

Review Comment:
   nit: maybe decide a valid value range for `bufferSizeMB` and validate. `CQLSSTableWriter` accepts whatever int value. 
   For the upper bound, I think 1/2 of the `spark.executor.memory` is a good limit. 



##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/bulkwriter/RecordWriter.java:
##########
@@ -114,16 +115,21 @@ public StreamResult write(Iterator<Tuple2<DecoratedKey, Object[]>> sourceIterato
                 checkBatchSize(streamSession, partitionId, job);
             }
 
-            if (batchSize != 0)
+            if (sstableWriter != null)
             {
-               finalizeSSTable(streamSession, partitionId, sstableWriter, batchNumber, batchSize);
+                finalizeSSTable(streamSession, partitionId, sstableWriter, batchNumber, batchSize);

Review Comment:
   nit: reset `sstableWriter` to `null` after `finalizeSSTable`



-- 
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-unsubscribe@cassandra.apache.org

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


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