netudima commented on code in PR #4927:
URL: https://github.com/apache/cassandra/pull/4927#discussion_r3573083768


##########
test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java:
##########
@@ -120,6 +121,121 @@ public void testNoopWriter() throws IOException
         runTests("Noop");
     }
 
+    @Test
+    public void testWriterOptionsPropagatedToCompressedWriter() throws 
IOException
+    {
+        CompressionParams params = CompressionParams.lz4();
+        BufferType compressorBufferType = 
params.getSstableCompressor().preferredBufferType();
+        // caller values chosen to differ from what the writer derives, so an 
override is provable
+        BufferType callerBufferType = compressorBufferType == 
BufferType.ON_HEAP ? BufferType.OFF_HEAP
+                                                                               
  : BufferType.ON_HEAP;
+        SequentialWriterOption option = SequentialWriterOption.newBuilder()
+                                                              
.bufferSize(params.chunkLength() / 2)
+                                                              
.bufferType(callerBufferType)
+                                                              
.trickleFsync(true)
+                                                              
.trickleFsyncByteInterval(1 << 16)
+                                                              
.finishOnClose(true)
+                                                              .build();
+        File f = FileUtils.createTempFile("writerOptionPropagated", "1");
+        File offsets = new File(f.path() + ".metadata");
+        MetadataCollector collector = new MetadataCollector(new 
ClusteringComparator(UTF8Type.instance));
+        try (ObservableCSW writer = new ObservableCSW(f, offsets, null, 
option, params, collector))
+        {
+            writer.write(new byte[64]); // give finishOnClose a non-empty file 
to finalize
+            SequentialWriterOption effective = writer.effectiveOption();
+
+            assertTrue(effective.trickleFsync());
+            assertEquals(1 << 16, effective.trickleFsyncByteInterval());
+            assertTrue(effective.finishOnClose());
+
+            // buffer sizing is derived from the compression layout, not the 
caller's values
+            assertEquals(params.chunkLength(), effective.bufferSize());
+            assertEquals(compressorBufferType, effective.bufferType());
+        }
+        finally
+        {
+            f.tryDelete();
+            offsets.tryDelete();
+        }
+    }
+
+    @Test
+    public void testTrickleFsyncFiresWhileWritingCompressedData() throws 
IOException

Review Comment:
   nit: should we split the test to 2? (also to not share collector: it is not 
an issue now but if it is changed the test may start to fail)



-- 
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