Skip to content
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

#764: Implement HeadInput #801

Merged
merged 3 commits into from
May 5, 2018
Merged

#764: Implement HeadInput #801

merged 3 commits into from
May 5, 2018

Conversation

proshin-roman
Copy link
Contributor

Pull request for issue #764.

  • added new classes HeadInput and HeadInputStream
  • added test cases to reach 83% of test coverage

@0crat 0crat added the scope label May 1, 2018
@0crat
Copy link
Collaborator

0crat commented May 1, 2018

Job #801 is now in scope, role is REV

@proshin-roman proshin-roman mentioned this pull request May 1, 2018
@codecov-io
Copy link

codecov-io commented May 1, 2018

Codecov Report

Merging #801 into master will increase coverage by 0.23%.
The diff coverage is 84.84%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #801      +/-   ##
===========================================
+ Coverage     83.36%   83.6%   +0.23%     
- Complexity     1297    1331      +34     
===========================================
  Files           232     242      +10     
  Lines          3541    3622      +81     
  Branches        202     211       +9     
===========================================
+ Hits           2952    3028      +76     
- Misses          542     546       +4     
- Partials         47      48       +1
Impacted Files Coverage Δ Complexity Δ
src/main/java/org/cactoos/io/HeadInput.java 100% <100%> (ø) 2 <2> (?)
src/main/java/org/cactoos/io/HeadInputStream.java 82.14% <82.14%> (ø) 8 <8> (?)
src/main/java/org/cactoos/scalar/Folded.java 100% <0%> (ø) 4% <0%> (-1%) ⬇️
src/main/java/org/cactoos/scalar/Reduced.java 100% <0%> (ø) 5% <0%> (+1%) ⬆️
...n/java/org/cactoos/iterable/IterableOfDoubles.java 100% <0%> (ø) 3% <0%> (?)
.../java/org/cactoos/iterable/IterableOfBooleans.java 100% <0%> (ø) 3% <0%> (?)
...ain/java/org/cactoos/iterable/IterableOfBytes.java 100% <0%> (ø) 3% <0%> (?)
...ain/java/org/cactoos/iterable/IterableOfChars.java 100% <0%> (ø) 3% <0%> (?)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb31449...1ec6627. Read the comment docs.

@0crat
Copy link
Collaborator

0crat commented May 2, 2018

This pull request #801 is assigned to @krzyk/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @llorllale/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer

@memoyil
Copy link

memoyil commented May 2, 2018

@proshin-roman I will close mine, don't worry :)

@proshin-roman
Copy link
Contributor Author

@memoyil It wasn't necessary, as you could submit your changes even after applying mine ones: your pull request has a lot of ctors and test cases.

Copy link
Contributor

@krzyk krzyk left a comment

Choose a reason for hiding this comment

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

@proshin-roman Please see my comments above


@Override
public InputStream stream() throws IOException {
return new HeadInputStream(this.origin.stream(), this.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

@proshin-roman I'm wondering, why did you implement it using another InputStream? Is there any benefit from that? Wouldn't be using a ByteInputStream enough for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@krzyk Even using ByteInputStream I would need to implement all this custom logic that I wrote in HeadInputStream. So, I would prefer to keep the current impl.

Copy link
Contributor

Choose a reason for hiding this comment

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

@proshin-roman OK, your implementation is more robust but I think you lost more time on it. Using byte array would be faster :) - e.g. you wouldn't need skip and available

Copy link
Contributor

Choose a reason for hiding this comment

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

@krzyk I just want to add that @proshin-roman's solution is in line with existing designs in org.cactoos.io (eg. TeeInput/TeeInputStream, LoggingOutput/LoggingOutputStream, etc.).

adjusted = skip;
}
this.processed = this.processed + adjusted;
return this.origin.skip(adjusted);
Copy link
Contributor

Choose a reason for hiding this comment

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

@proshin-roman skip might return value smaller than adjusted, in that case processed might have incorrect number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@krzyk thanks, I've adjusted the logic

stream.skip(3L);
MatcherAssert.assertThat(
"Incorrect head of the input stream has been read",
new TextOf(stream).asString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

@proshin-roman instead of asString() you should use TextHasString matcher

stream.reset();
MatcherAssert.assertThat(
"Reset didn't change the state",
new TextOf(stream).asString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

@proshin-roman instead of asString() you should use TextHasString matcher

new InputOf("readsHeadOfLongerInput"),
5
)
).asString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

@proshin-roman instead of asString() you should use TextHasString matcher

new InputOf(input),
35
)
).asString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

@proshin-roman instead of asString() you should use TextHasString matcher

Copy link
Contributor

@krzyk krzyk left a comment

Choose a reason for hiding this comment

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

@proshin-roman looks good

@krzyk
Copy link
Contributor

krzyk commented May 4, 2018

@llorllale looks good to merge

@llorllale
Copy link
Contributor

@rultor merge

@rultor
Copy link
Collaborator

rultor commented May 5, 2018

@rultor merge

@llorllale OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 1ec6627 into yegor256:master May 5, 2018
@rultor
Copy link
Collaborator

rultor commented May 5, 2018

@rultor merge

@llorllale Done! FYI, the full log is here (took me 10min)

@0crat
Copy link
Collaborator

0crat commented May 5, 2018

@elenavolokhova/z please review this job completed by @krzyk/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed

@0crat 0crat removed the scope label May 5, 2018
@0crat
Copy link
Collaborator

0crat commented May 5, 2018

The job #801 is now out of scope

@0crat
Copy link
Collaborator

0crat commented May 5, 2018

Payment to ARC for a closed pull request, as in §28: +10 point(s) just awarded to @llorllale/z

@proshin-roman proshin-roman deleted the 764 branch May 6, 2018 06:17
@elenavolokhova
Copy link

@0crat quality good

@0crat
Copy link
Collaborator

0crat commented May 6, 2018

Order was finished, quality is "good": +20 point(s) just awarded to @krzyk/z

@0crat
Copy link
Collaborator

0crat commented May 6, 2018

Quality review completed: +8 point(s) just awarded to @elenavolokhova/z

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.

8 participants