AHeise commented on a change in pull request #11751: [FLINK-16587][network] 
Provide the method for getting unconsumed buffer from RecordDeserializer
URL: https://github.com/apache/flink/pull/11751#discussion_r408820504
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/io/network/api/serialization/SpanningRecordSerializationTest.java
 ##########
 @@ -179,6 +187,126 @@ private static void testSerializationRoundTrip(
                Assert.assertFalse(deserializer.hasUnfinishedData());
        }
 
+       @Test
+       public void testSmallRecordUnconsumedBuffer() throws Exception {
+               RecordSerializer<SerializationTestType> serializer = new 
SpanningRecordSerializer<>();
+               RecordDeserializer<SerializationTestType> deserializer =
+                       new SpillingAdaptiveSpanningRecordDeserializer<>(
+                               new 
String[]{tempFolder.getRoot().getAbsolutePath()});
+
+               testUnconsumedBuffer(serializer, deserializer, 
Util.randomRecord(SerializationTestTypeFactory.INT), 1024);
+       }
+
+       /**
+        * Test both for spanning records and for handling the length buffer, 
that's why it's going byte by byte.
+        */
+       @Test
+       public void testSpanningRecordUnconsumedBuffer() throws Exception {
+               RecordSerializer<SerializationTestType> serializer = new 
SpanningRecordSerializer<>();
+               RecordDeserializer<SerializationTestType> deserializer =
+                       new SpillingAdaptiveSpanningRecordDeserializer<>(
+                               new 
String[]{tempFolder.getRoot().getAbsolutePath()});
+
+               testUnconsumedBuffer(serializer, deserializer, 
Util.randomRecord(SerializationTestTypeFactory.INT), 1);
+       }
+
+       @Test
+       public void testLargeSpanningRecordUnconsumedBuffer() throws Exception {
+               RecordSerializer<SerializationTestType> serializer = new 
SpanningRecordSerializer<>();
+               RecordDeserializer<SerializationTestType> deserializer =
+                       new SpillingAdaptiveSpanningRecordDeserializer<>(
+                               new 
String[]{tempFolder.getRoot().getAbsolutePath()});
+
+               testUnconsumedBuffer(serializer, deserializer, 
Util.randomRecord(SerializationTestTypeFactory.BYTE_ARRAY), 1);
+       }
+
+       @Test
+       public void testLargeSpanningRecordUnconsumedBufferWithLeftOverBytes() 
throws Exception {
+               RecordSerializer<SerializationTestType> serializer = new 
SpanningRecordSerializer<>();
+               RecordDeserializer<SerializationTestType> deserializer =
+                       new SpillingAdaptiveSpanningRecordDeserializer<>(
+                               new 
String[]{tempFolder.getRoot().getAbsolutePath()});
+
+               testUnconsumedBuffer(
+                       serializer,
+                       deserializer,
+                       
Util.randomRecord(SerializationTestTypeFactory.BYTE_ARRAY),
+                       1,
+                       new byte[] {42, 43, 44});
+       }
+
+       public void testUnconsumedBuffer(
 
 Review comment:
   nit: overload could be avoided by using `byte... leftOverBytes`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to