Skip to content

Improve collection related things that reusing a immutable object instead of creating a new object#4135

Merged
gianm merged 1 commit intoapache:masterfrom
asdf2014:code_refactoring
May 16, 2017
Merged

Improve collection related things that reusing a immutable object instead of creating a new object#4135
gianm merged 1 commit intoapache:masterfrom
asdf2014:code_refactoring

Conversation

@asdf2014
Copy link
Copy Markdown
Member

Improve collection related things that reusing a immutable object instead of creating a new object

  • Collections.singletonList(something) is immutable whereas Arrays.asList(something) is a fixed size List representation of an Array where the List and Array gets joined in the heap.
  • Collections.emptyList() reuses an object instead of creating a new object as it will be the case with Arrays.asList().

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it fully compatible? Couldn't somebody depend on the actual name of the module somehow?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think just we can ensure the name of SimpleModule be unique, that will be okay.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Last two )) should be on the next line

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I got it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could be new byte[] {value.byteValue()}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Great!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think it should be renamed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

U r right. I'll roll it back.

@asdf2014
Copy link
Copy Markdown
Member Author

Timeout Problem happened again... Somebody could help me to rerun the Travis job? :(

java.lang.Exception: test timed out after 60000 milliseconds
	at java.lang.Thread.sleep(Native Method)
	at io.druid.server.coordinator.DruidCoordinatorTest.testCoordinatorRun(DruidCoordinatorTest.java:375)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)

@jihoonson
Copy link
Copy Markdown
Contributor

LGTM. Thanks @asdf2014!

@leventov
Copy link
Copy Markdown
Member

@asdf2014 could you please resolve conflicts? Then we can merge this PR.

@leventov
Copy link
Copy Markdown
Member

@asdf2014 your latest commit doesn't have druid-io's master HEAD commit as parent, so Github doesn't hide repetitive changes. Could you please add parent to your latest commit (http://stackoverflow.com/a/4264151/648955 might help) and re-push it?

@leventov
Copy link
Copy Markdown
Member

In the future please resolve conflicts via git merge master, as described here: https://github.com/druid-io/druid/blob/master/CONTRIBUTING.md#github-workflow

@asdf2014
Copy link
Copy Markdown
Member Author

@leventov Hi, Leventov. I executed the git rebase --root --onto master --preserve-merges command on code_refactoring branch and get the Successfully rebased and updated refs/heads/code_refactoring. message. Is that ok?

@asdf2014
Copy link
Copy Markdown
Member Author

If that is fine. I would push it with the git push -u origin code_refactoring --force command.

@asdf2014
Copy link
Copy Markdown
Member Author

asdf2014 commented May 16, 2017

@leventov Already Done.

git rebase --abort
git checkout code_refactoring
git checkout -b re2
git branch root bbb61e638b391d29
git checkout re2
git diff master > ../123.patch
git checkout master
git checkout -b r2
git apply ../123.patch
git diff master
git status
git diff --name-status | wc -l
git add .
git status
git diff master
git commit -m 'Improve `collection` related things that reusing a immutable object instead of creating a new object'
git status
git push origin r2:code_refactoring -f

@asdf2014
Copy link
Copy Markdown
Member Author

Why i changed nothing, but i got the The job exceeded the maximum time limit for jobs, and has been terminated. message from travis? It seems like the time length limitation of the time of build job is 50min in travis.org. (https://docs.travis-ci.com/user/customizing-the-build#Build-Timeouts)

Can anyone help me to restart the build job?

@gianm
Copy link
Copy Markdown
Contributor

gianm commented May 16, 2017

@asdf2014 looks like the tests have passed now. thanks for the contribution!

@gianm gianm added this to the 0.10.1 milestone May 16, 2017
@gianm gianm merged commit e823085 into apache:master May 16, 2017
return reader.read(null, DecoderFactory.get().binaryDecoder(inputStream, null));
}
catch (EOFException eof) {
} catch (EOFException eof) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually this violate Druid code style. Former version of code is correct

@leventov
Copy link
Copy Markdown
Member

@asdf2014 irrelevant now but actually what you did is rebase of your entire branch, that is also should be avoided. I asked to rebase only the latest commit in the branch, which you was proposing to merge into druid-io/druid/master, asdf2014:code_refactoring. That commit used to be called "Fix conflicts".

@asdf2014
Copy link
Copy Markdown
Member Author

@leventov Sorry violate druid code style... I got it, in fact i also liked squash those commits into a single commit. @gianm You are welcome.

@leventov
Copy link
Copy Markdown
Member

@asdf2014 for the future PRs - please don't squash anything after you submitted a PR and some time has passed so somebody may has already started looking at your PR (and, moreover, if somebody already left some review comments), because reviewers lose the progress and in some cases need to re-review the whole PR, to be sure that they didn't miss anything.

@asdf2014
Copy link
Copy Markdown
Member Author

Okay, you are right. Those messages of commits should be retained.

@gianm
Copy link
Copy Markdown
Contributor

gianm commented May 17, 2017

In addition to the messages, Github also has a nice feature that lets reviewers see what has changed since their last review. It's based on diffing against new commits though, so squashing prevents that feature from working.

FWIW we only very recently changed our guidelines to suggest that people avoid squashing (#4087). Until then we did suggest squashing, but we changed our minds :)

@asdf2014
Copy link
Copy Markdown
Member Author

Oh... Don't know these, i will pay attention in the future.

@gianm
Copy link
Copy Markdown
Contributor

gianm commented May 17, 2017

No worries, and thanks again for the patch.

@asdf2014
Copy link
Copy Markdown
Member Author

Alright, you are welcome.

@asdf2014 asdf2014 deleted the code_refactoring branch March 7, 2018 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants