Skip to content

IO-543-ReversedLinesFileReader-with-RandowFileAccess-API#39

Closed
JeanPierrePortier wants to merge 2 commits intoapache:masterfrom
Jean-Pierre-Portier:IO-543-ReversedLinesFileReader-with-RandowFileAccess-API
Closed

IO-543-ReversedLinesFileReader-with-RandowFileAccess-API#39
JeanPierrePortier wants to merge 2 commits intoapache:masterfrom
Jean-Pierre-Portier:IO-543-ReversedLinesFileReader-with-RandowFileAccess-API

Conversation

@JeanPierrePortier
Copy link

pull request for ticket: https://issues.apache.org/jira/browse/IO-543

  • Added getFilePointer and seek API to ReversedLinesFileReader
  • Added new JUnit tests (ReversedLinesFileReaderTestRandomAccess)

@coveralls
Copy link

coveralls commented Jul 3, 2017

Coverage Status

Coverage increased (+0.09%) to 90.086% when pulling a5bc2f8 on JeanPierrePortier:IO-543-ReversedLinesFileReader-with-RandowFileAccess-API into acceb62 on apache:master.

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeanPierrePortier
Thank you for your PR. May you please rebase on git master and address my comments?

seek (totalByteLength);

}
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All new public and protected method should have complete Javadoc. Here the first sentence is missing as is the since tag.

/**
* @return Returns the current offset in this file
*/
public long getFilePointer(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting is missing a space.

asfgit pushed a commit that referenced this pull request Jan 30, 2022
overwrite target file #319.

- Based on PR #39 but different.
- New assert method leaks input stream; this bug was copied from
existing code into a new method.
- Use NIO.
- Tests don't need to schedule files for deletion on exit when JUnit
already manages the directory.
private byte[] leftOver;

private int currentLastBytePos;
private int mappedFilePointer; // store file pointer position according to currentLastBytePos but take
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a Javadoc comment instead.

line = new String(lineData, encoding);

currentLastBytePos = i - newLineMatchByteCount;
mappedFilePointer=i;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix formatting.

leftOver = null;
}
currentLastBytePos = -1;
mappedFilePointer=0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix formatting

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jean-Pierre-Portier
Copy link

Hi @garydgregory
This is a very old PR and I did not work onto it for a long time now.
Let me sync with sources; please.

Added new JUnit tests (ReversedLinesFileReaderTestRandomAccess)
@Jean-Pierre-Portier
Copy link

Hello @garydgregory ,
sorry for the delay; tried to sync my mind with current master state (more than 1500 commits behind....)
So just pushed a rebased branch with improved unit tests

@garydgregory
Copy link
Member

Hello @JeanPierrePortier
Thank you for the update.
You'll want to run a local command line build with just mvn which runs the default Maven goal. This will make sure you do not cause your branch build here to fail by fixing issues before you push your branch. ATM, you have failures.

@codecov-commenter
Copy link

Codecov Report

Merging #39 (cdf495f) into master (279a4c4) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master      #39      +/-   ##
============================================
- Coverage     85.66%   85.65%   -0.01%     
+ Complexity     3102     3101       -1     
============================================
  Files           204      204              
  Lines          7368     7370       +2     
  Branches        905      904       -1     
============================================
+ Hits           6312     6313       +1     
  Misses          810      810              
- Partials        246      247       +1     
Impacted Files Coverage Δ
src/main/java/org/apache/commons/io/FileUtils.java 94.42% <100.00%> (-0.04%) ⬇️
...ache/commons/io/input/ReversedLinesFileReader.java 90.71% <100.00%> (+3.40%) ⬆️
.../apache/commons/io/input/ReadAheadInputStream.java 68.53% <0.00%> (-3.38%) ⬇️
.../main/java/org/apache/commons/io/input/Tailer.java 86.06% <0.00%> (+0.49%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Jean-Pierre-Portier
Copy link

Yes just seen this (I just launched mvn verify command) before pushing and it is not enough...

@garydgregory
Copy link
Member

garydgregory commented Aug 11, 2022

Yes just seen this (I just launched mvn verify command) before pushing and it is not enough...

Just run mvn

@Jean-Pierre-Portier
Copy link

Last CI run failed for windows env for files not related to this PR.
No idea why and failures should not be related to this PR (I do not have windows host for validation)

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JeanPierrePortier
Please rebase on master where the OS and Java version-specific build failure are fixed; please also address my comments in the PR comments. TY!

* Returns the current offset in this file
* @return the current offset
* @throws IOException if an I/O error occurs.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New public and protected APIs need an @since tag.

* @return the current offset
* @throws IOException if an I/O error occurs.
*/
public long getFilePointer() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not call the new method position since (1) there are no pointers in Java and (2) it reflects the underlying operation?

/**
* Sets the file-pointer offset, measured from the beginning of this file, at which the next read occurs.
* @param pos the offset value to be set
* @throws IOException if an I/O error occurs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New public and protected APIs need an @SInCE tag.

* @param pos the offset value to be set
* @throws IOException if an I/O error occurs.
*/
public void seek (long pos) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No space after the method name. Use final where you can.

this.currentFilePart = new FilePart(block, blockLength, null);

}
} No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files should end in a blank line.

@AfterEach
public void closeReader() {
try {
reversedLinesFileReader.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use IOUtils.closeQuietly() instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedbacks @garydgregory
I won't be able to take them before two weeks, but will do it ASAP.

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments.

@Jean-Pierre-Portier Jean-Pierre-Portier closed this by deleting the head repository Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants