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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to