Github user edi-bice commented on a diff in the pull request:
https://github.com/apache/incubator-samoa/pull/48#discussion_r56010998
--- Diff:
samoa-api/src/main/java/org/apache/samoa/streams/ArffFileStream.java ---
@@ -57,32 +60,39 @@ public void prepareForUseImpl(TaskMonitor monitor,
ObjectRepository repository)
@Override
protected void reset() {
try {
- if (this.fileReader != null)
- this.fileReader.close();
-
fileSource.reset();
} catch (IOException ioe) {
throw new RuntimeException("FileStream restart failed.", ioe);
}
- if (!getNextFileReader()) {
+ if (!getNextFileStream()) {
hitEndOfStream = true;
throw new RuntimeException("FileStream is empty.");
}
}
@Override
- protected boolean getNextFileReader() {
- boolean ret = super.getNextFileReader();
- if (ret) {
- this.instances = new Instances(this.fileReader, 1, -1);
- if (this.classIndexOption.getValue() < 0) {
- this.instances.setClassIndex(this.instances.numAttributes() - 1);
- } else if (this.classIndexOption.getValue() > 0) {
- this.instances.setClassIndex(this.classIndexOption.getValue() - 1);
+ protected boolean getNextFileStream() {
--- End diff --
Good point. I'm not sure if there are tests that cover both scenarios. But
at least it seems from code that the file reader/stream is closed (and set to
null) upon failure to read an instance (end of file) and is also checked and
closed upon call to getNextFileStream.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---