TheNeuralBit commented on code in PR #23376:
URL: https://github.com/apache/beam/pull/23376#discussion_r980478866
##########
sdks/java/core/src/test/java/org/apache/beam/sdk/io/TextIOReadTest.java:
##########
@@ -363,10 +369,57 @@ public static Iterable<Object[]> data() {
public ImmutableList<String> expected;
@Test
- public void testReadLinesWithDelimiter() throws Exception {
+ public void testReadLinesWithDefaultDelimiter() throws Exception {
runTestReadWithData(line.getBytes(UTF_8), expected);
}
+ @Test
+ public void
testReadLinesWithDefaultDelimiterAndZeroAndOneLengthReturningChannel()
+ throws Exception {
+ Path path = tempFolder.newFile().toPath();
+ Files.write(path, line.getBytes(UTF_8));
+ Metadata metadata = FileSystems.matchSingleFileSpec(path.toString());
+ FileBasedSource source =
+ getTextSource(path.toString(), null)
+ .createForSubrangeOfFile(metadata, 0, metadata.sizeBytes());
+ FileBasedReader<String> reader =
+ source.createSingleFileReader(PipelineOptionsFactory.create());
+ ReadableByteChannel channel =
+ FileSystems.open(
+
FileSystems.matchSingleFileSpec(source.getFileOrPatternSpec()).resourceId());
+ InputStream stream = Channels.newInputStream(channel);
+ reader.startReading(
+ new ReadableByteChannel() {
Review Comment:
nit: could be nice to document this for readability (could happen later
though, I know you want to get this in)
```suggestion
reader.startReading(
// Placeholder channel that only yields 0- and 1-length buffers.
// Data is read one byte at a time from line parameter
new ReadableByteChannel() {
```
--
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]