You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/09/26 20:38:26 UTC
[GitHub] [beam] TheNeuralBit commented on a diff in pull request #23376: Fix TextSource incorrect handling in channels that return short reads.
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org