-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9acbff0
commit 0e6f300
Showing
3 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/com/github/mmolimar/kafka/connect/fs/file/reader/EmptyFileReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.github.mmolimar.kafka.connect.fs.file.reader; | ||
|
||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.kafka.connect.data.Struct; | ||
|
||
import java.util.Map; | ||
|
||
public class EmptyFileReader extends AbstractFileReader<Void>{ | ||
/* | ||
An empty file reader that will always return no records | ||
Used as a null object instead of returning null | ||
*/ | ||
boolean closed; | ||
|
||
public EmptyFileReader(FileSystem fs, Path filePath, Map<String, Object> config) { | ||
super(fs, filePath, new FakeReaderAdapter(), config); | ||
this.closed = false; | ||
} | ||
|
||
@Override | ||
protected void configure(Map<String, String> config) {} | ||
|
||
@Override | ||
protected Void nextRecord() { | ||
return null; | ||
} | ||
|
||
@Override | ||
protected boolean hasNextRecord() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void seekFile(long offset) {} | ||
|
||
@Override | ||
public boolean isClosed(){ | ||
return this.closed; | ||
} | ||
|
||
@Override | ||
public void close() { | ||
closed = true; | ||
} | ||
|
||
static class FakeReaderAdapter implements ReaderAdapter<Void> { | ||
|
||
@Override | ||
public Struct apply(Void record) { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters