-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for #191 #197
Fix for #191 #197
Conversation
please resolve conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I think the code that was used here before is way too over complicated and mostly beyond fixing. It needs more or less a complete rewrite of the respective methods. I suggested some directions in my comments.
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/test/java/org/aksw/iguana/cc/utils/FileUtilsTest.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Show resolved
Hide resolved
iguana.corecontroller/src/test/java/org/aksw/iguana/cc/utils/FileUtilsTest.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/test/java/org/aksw/iguana/cc/utils/FileUtilsTest.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/test/java/org/aksw/iguana/cc/utils/FileUtilsTest.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
…tations and use it
...a.corecontroller/src/main/java/org/aksw/iguana/cc/query/source/impl/FileLineQuerySource.java
Show resolved
Hide resolved
...econtroller/src/main/java/org/aksw/iguana/cc/query/source/impl/FileSeparatorQuerySource.java
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
Please request an review from @Clueliss when ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, so I'm not sure why I'm supposed to review this, because while I do know how to write Java I wouldn't know what constitutes good Java or what is available in the stdlib.
Regarding the exceptions being rethrown or not: I don't know what the goal is here so I can't comment on what's best there.
So in that spirit, this looks fine to me and the tests seem to be passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One little thing that came to my mind. Thx @Clueliss . I should have further specified, but I think you just did what I amtes you to: have a look for logical errors in the code.
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This turns out to be a much bigger change than anticipated. The general structure looks good, now. I've pointed out some bugs, smaller naming improvements and an suggestion for further testing below.
One general comment that is also reflected in some single comments: Please use character-wise reading instead of line-wise reading wherever we read and seek files manually.
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
...econtroller/src/main/java/org/aksw/iguana/cc/query/source/impl/FileSeparatorQuerySource.java
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedLineReader.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's getting into shape. I think we missed one case when parsing the separators. See my comments below.
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedQueryReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedQueryReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedQueryReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/FileUtils.java
Outdated
Show resolved
Hide resolved
...troller/src/test/java/org/aksw/iguana/cc/query/source/impl/FileSeparatorQuerySourceTest.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedQueryReader.java
Outdated
Show resolved
Hide resolved
iguana.corecontroller/src/main/java/org/aksw/iguana/cc/utils/IndexedQueryReader.java
Show resolved
Hide resolved
* the separator does not necessarily need to be surrounded by new line chars * Enforce UTF-8 when figuring out the line ending * Implement Knuth-Morris-Pratt on byte-level to index file
Conflicts have to be resolved and the documentation now needs checked and maybe updated now, because the behaviour of the FileSeparatorQuerySource has been changed.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a short look at some of the failing tests. At least some of them seem to be caused by leading/trailing whitespaces/new line characters in tests. The expected strings do not yet have them because they were removed before by the QuerySource.
So apperently, when the files are uploaded to GitHub they may have different line endings than the original ones. That's why I had to add the behaviour, that the expected values for tests are constructed with the proper line endings. |
Updated the FileUtilsTest class to create and use temporary files, instead of hard-coded file paths. This change ensures more reliable and portable tests as it no longer relies on specific files being present in the filesystem. Also, removed the '@ignore' annotation to enable the test.
Added a command to ensure that temporary files created during testing are deleted once the process has completed. This is to prevent accumulation of unnecessary test files that could potentially consume excessive memory space.
Changed the "readTest" method in FileUtilsTest.java to use a temporary file, instead of a static file, to improve test isolation and avoid possible interference between tests.
In the `FileUtilsTest` class, the logic for the parameterized test data was refactored. We moved from using hardcoded file paths to dynamically creating temporary files for testing purposes. The test content is now randomly generated UUID strings, allowing for a more diverse dataset for testing. The modified test now checks the hash of the generated string content instead of testing if the hash is simply over 0, ensuring a more accurate analysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the textfiles for the tests at some point. See #214 for that. For now, this looks fine and we can move on.
This pull request also does the following:
countLines
method, although it's a quite simple fix for that method.getLineEnding
method, which returns the used line separator of a file.