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

[core] Optimize toArray of all ByteIterators except RandomByteIterator #1112

Merged
merged 1 commit into from
Apr 26, 2019

Conversation

isopov
Copy link
Contributor

@isopov isopov commented Mar 19, 2018

Method nextBuf is a clever hack that outperforms Random.nextBytes
but performs poorly for all other ByteIterator implementations

This commit moves it to RandomByteIterator and adds efficient
toArray implementations for other ByteIterator classes.

Also InputStreamByteIterator.reset method that unconditionally
throws UnsupportedOperationException is fixed

Benchmarks for this change is available at https://github.com/isopov/isopov-jmh/blob/master/src/main/java/com/sopovs/moradanen/jmh/ycsb/ByteIteratorBenchmark.java

Copy link
Collaborator

@manolama manolama left a comment

Choose a reason for hiding this comment

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

LGTM, just keep the existing methods public and change the title of the PR to [core] Optimize...

@@ -56,16 +56,6 @@ public Byte next() {

public abstract byte nextByte();

/** @return byte offset immediately after the last valid byte */
public int nextBuf(byte[] buf, int bufOff) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Keep these around since a private DB implementation may rely on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -73,8 +73,7 @@ public byte nextByte() {
return buf[bufOff - 1];
}

@Override
public int nextBuf(byte[] buffer, int bufOffset) {
private int nextBuf(byte[] buffer, int bufOffset) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Keep it public please as mentioned above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@isopov isopov force-pushed the byte-iterators branch 2 times, most recently from dcf6a15 to 7ec7b76 Compare March 20, 2018 08:00
Method nextBuf is a clever hack that outperforms Random.nextBytes
but performs poorly for all other ByteIterator implementations

This commit moves it to RandomByteIterator and adds efficient
toArray implementations for other ByteIterator classes.

Also InputStreamByteIterator.reset method that unconditionally
throws UnsupportedOperationException is fixed
@isopov isopov changed the title Optimize toArray of all ByteIterators except RandomByteIterator [core] Optimize toArray of all ByteIterators except RandomByteIterator Mar 20, 2018
@bimargulies-google
Copy link
Contributor

It looks to me as if all the requested changes were addressed.

Copy link
Collaborator

@busbey busbey left a comment

Choose a reason for hiding this comment

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

I agree all the feedback was addressed. this looks fine at doing what it says on the tin. Reviewing the toArray added to StringByteIterator I've realized the class is wrong before and after this patch. it drops the upper 8 bits of every character in the string. something for follow-on I think, it's been around for a while.

@busbey busbey dismissed manolama’s stale review April 26, 2019 03:23

all feedback was addressed. requested methods were left in place.

@busbey busbey merged commit 8b9bb8f into brianfrankcooper:master Apr 26, 2019
@busbey busbey mentioned this pull request Jun 4, 2019
@busbey busbey mentioned this pull request Sep 21, 2019
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.

4 participants