Change in ovirt-engine[master]: webadmin: Reimplement TagAssigningModel#postGetAttachedTags

Code Review gerrit at ovirt.org
Wed Apr 12 11:18:32 UTC 2017


>From Allon Mureinik <amureini at redhat.com>:

Allon Mureinik has submitted this change and it was merged.

Change subject: webadmin: Reimplement TagAssigningModel#postGetAttachedTags
......................................................................


webadmin: Reimplement TagAssigningModel#postGetAttachedTags

TagAssigningModel#postGetAttachedTags was implemented naively using
Linq as follows:
1. Iterating over the list of tags and producing a list of tags with
   one tag per unique ID
2. Iterating over the unique list and counting how many tags share
   the same ID
3. Comparing this number to the size of the selected items list

This patch reimplements steps (1) and (2) using Java 8's streams by
iterating over the list of tags once and reducing it to a map from
the tag's ID to the number of appearances this ID has in the list.
This reimplementation not only cleans up the code and makes it easier
to read, it improves this method's performance by an order of
magnitude.

As a consequence of this change, the method Linq#distinct, the
IEqualityComparer interface that it uses and its TagsEqualityComparer
implementation are no longer used, and are removed from the codebase.

Change-Id: I3fa4e139787cfe80caaf43efae5ea4ce72a06ea5
Signed-off-by: Allon Mureinik <amureini at redhat.com>
---
M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java
M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/TagAssigningModel.java
D frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/TagsEqualityComparer.java
D frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IEqualityComparer.java
4 files changed, 6 insertions(+), 53 deletions(-)

Approvals:
  Tal Nisan: Looks good to me, approved
  Jenkins CI: Passed CI tests
  Allon Mureinik: Verified



-- 
To view, visit https://gerrit.ovirt.org/75449
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3fa4e139787cfe80caaf43efae5ea4ce72a06ea5
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Tal Nisan <tnisan at redhat.com>
Gerrit-Reviewer: Vojtech Szocs <vszocs at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>


More information about the Engine-commits mailing list