Skip to content

JDK-8254627: Cleanup {Abstract,Single,Split}IndexWriter classes #621

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

Closed

Conversation

jonathan-gibbons
Copy link
Contributor

@jonathan-gibbons jonathan-gibbons commented Oct 12, 2020

Inspired by other recent work to cleanup index generation, this change is primarily about cleanup for AbstractIndexWriter, SingleIndexWriter, SplitIndexWriter to reduce code duplication and to reduce the 3 class to just 1 that can handle either single index files or split index files.

As part of this cleanup, some anomalies were uncovered in the naming of annotation types, enum constants and records, which have also been addressed.

The changes involved moving/merging code from SingleIndexWriter and SplitIndexWriter in to AbstractIndexWriter, which is now no longer abstract and is thus renamed to just IndexWriter. Regrettably, the rename is not properly tracked.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Testing

Linux x64 Windows x64 macOS x64
Build ⏳ (5/5 running) ⏳ (2/2 running) ⏳ (2/2 running)

Issue

  • JDK-8254627: Cleanup {Abstract,Single,Split}IndexWriter classes

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/621/head:pull/621
$ git checkout pull/621

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 12, 2020

👋 Welcome back jjg! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 12, 2020
@openjdk
Copy link

openjdk bot commented Oct 12, 2020

@jonathan-gibbons The following label will be automatically applied to this pull request:

  • javadoc

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the javadoc javadoc-dev@openjdk.org label Oct 12, 2020
@mlbridge
Copy link

mlbridge bot commented Oct 12, 2020

Webrevs

@jonathan-gibbons
Copy link
Contributor Author

Note that the apparently-new file IndexWriter.java is just a rename of the apparently-deleted file AbstractIndexWriter.java.

Copy link
Member

@hns hns left a comment

Choose a reason for hiding this comment

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

Nice work!

headerContent.add(navBar.getContent(Navigation.Position.TOP));
Content mainContent = new ContentBuilder();
List<Character> allFirstCharacters = new ArrayList<>(mainIndex.getFirstCharacters());
allFirstCharacters.sort(Comparator.naturalOrder());
Copy link
Member

Choose a reason for hiding this comment

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

It seems a bit redundant to retrieve and sort the allFirstCharacters list in each invocation of generateIndexFile, maybe pass it as an argument from the generate(HtmlConfiguration) method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given your other comment (listed next in this page) that the sort is actually unnecessary, it may be not so important to pass in the list of all first characters from the generate method, but it is easy enough to do so. I will check it out.

public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
IndexBuilder mainIndex = configuration.mainIndex;
List<Character> firstCharacters = mainIndex.getFirstCharacters();
firstCharacters.sort(Comparator.naturalOrder());
Copy link
Member

Choose a reason for hiding this comment

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

Is this sorting step necessary? Aren't the characters returned by IndexBuilder#getFirstCharacters() already guaranteed to be in natural order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting ... while the contract is not enforced through the type system, the words of the spec do guarantee the ordering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A related minor improvement that I will try out is to return an immutable set from main Index.getFirstCharacters

@openjdk
Copy link

openjdk bot commented Oct 13, 2020

@jonathan-gibbons This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8254627: Cleanup {Abstract,Single,Split}IndexWriter classes

Reviewed-by: hannesw

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 16 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 13, 2020
@jonathan-gibbons
Copy link
Contributor Author

/integrate

@openjdk openjdk bot closed this Oct 13, 2020
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 13, 2020
@openjdk
Copy link

openjdk bot commented Oct 13, 2020

@jonathan-gibbons Since your change was applied there have been 16 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

Pushed as commit 3fb2e82.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@jonathan-gibbons jonathan-gibbons deleted the 8254627-IndexWriter branch November 4, 2020 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated javadoc javadoc-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

2 participants