Skip to content
Snippets Groups Projects
Commit 1344332a authored by pkupczyk's avatar pkupczyk
Browse files

SSDM-2294 : V3 AS API - paging and sorting of search results - do not...

SSDM-2294 : V3 AS API - paging and sorting of search results - do not serialize a comparator when a Set is sorted + improve performance by creating collections with initial capacity set

SVN: 34530
parent 0fbcb7e7
No related branches found
No related tags found
No related merge requests found
...@@ -22,10 +22,10 @@ import java.util.Collection; ...@@ -22,10 +22,10 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.FetchOptions; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.FetchOptions;
import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.sort.view.AbstractCollectionView; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.sort.view.AbstractCollectionView;
...@@ -73,17 +73,17 @@ public class SortAndPage ...@@ -73,17 +73,17 @@ public class SortAndPage
if (objects instanceof List) if (objects instanceof List)
{ {
sorted = new ArrayList(); sorted = new ArrayList(objects);
sorted.addAll(objects);
Collections.sort((List) sorted, comparator); Collections.sort((List) sorted, comparator);
} else if (objects instanceof Set) } else if (objects instanceof Set)
{ {
sorted = new TreeSet(comparator); List temp = new ArrayList(objects);
sorted.addAll(objects); Collections.sort(temp, comparator);
// if TreeSet was used then the comparator would be also serialized
sorted = new LinkedHashSet(temp);
} else if (objects instanceof Collection) } else if (objects instanceof Collection)
{ {
sorted = new ArrayList(); sorted = new ArrayList(objects);
sorted.addAll(objects);
Collections.sort((List) sorted, comparator); Collections.sort((List) sorted, comparator);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment