-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
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.
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) { |
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.
Keep these around since a private DB implementation may rely on it.
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.
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) { |
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.
Keep it public please as mentioned above.
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.
Done.
dcf6a15
to
7ec7b76
Compare
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
It looks to me as if all the requested changes were addressed. |
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 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.
all feedback was addressed. requested methods were left in place.
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