From e7cad6b5a0e19bb0f45825318310d610fe6621ea Mon Sep 17 00:00:00 2001 From: kamhung <22250530@qq.com> Date: Thu, 12 Nov 2015 10:49:52 +0800 Subject: [PATCH] --- .../wentch/redkale/source/EntityCache.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/com/wentch/redkale/source/EntityCache.java b/src/com/wentch/redkale/source/EntityCache.java index 405e9f90d..783a6e781 100644 --- a/src/com/wentch/redkale/source/EntityCache.java +++ b/src/com/wentch/redkale/source/EntityCache.java @@ -213,6 +213,14 @@ public final class EntityCache { return -1; } + public Set querySet(final SelectColumn selects, final Predicate filter, final Comparator sort) { + return (Set) queryCollection(true, selects, filter, sort); + } + + public List queryList(final SelectColumn selects, final Predicate filter, final Comparator sort) { + return (List) queryCollection(false, selects, filter, sort); + } + public Collection queryCollection(final boolean set, final SelectColumn selects, final Predicate filter, final Comparator sort) { final boolean parallel = isParallel(); final Collection rs = parallel ? (set ? new CopyOnWriteArraySet<>() : new CopyOnWriteArrayList<>()) : (set ? new LinkedHashSet<>() : new ArrayList<>()); @@ -221,7 +229,7 @@ public final class EntityCache { if (sort != null) stream = stream.sorted(sort); if (selects == null) { Consumer action = x -> rs.add(needcopy ? reproduce.copy(creator.create(), x) : x); - if (parallel && sort != null) { + if (sort != null) { stream.forEachOrdered(action); } else { stream.forEach(action); @@ -238,7 +246,7 @@ public final class EntityCache { } rs.add(item); }; - if (parallel && sort != null) { + if (sort != null) { stream.forEachOrdered(action); } else { stream.forEach(action); @@ -247,14 +255,6 @@ public final class EntityCache { return parallel ? (set ? new LinkedHashSet<>(rs) : new ArrayList<>(rs)) : rs; } - public Set querySet(final SelectColumn selects, final Predicate filter, final Comparator sort) { - return (Set) queryCollection(true, selects, filter, sort); - } - - public List queryList(final SelectColumn selects, final Predicate filter, final Comparator sort) { - return (List) queryCollection(false, selects, filter, sort); - } - public Sheet querySheet(final SelectColumn selects, final Predicate filter, final Flipper flipper, final Comparator sort) { Stream stream = listStream(); if (filter != null) stream = stream.filter(filter); @@ -270,7 +270,7 @@ public final class EntityCache { final List rs = parallel ? new CopyOnWriteArrayList<>() : new ArrayList<>(); if (selects == null) { Consumer action = x -> rs.add(needcopy ? reproduce.copy(creator.create(), x) : x); - if (parallel && sort != null) { + if (sort != null) { stream.forEachOrdered(action); } else { stream.forEach(action); @@ -287,7 +287,7 @@ public final class EntityCache { } rs.add(item); }; - if (parallel && sort != null) { + if (sort != null) { stream.forEachOrdered(action); } else { stream.forEach(action); @@ -394,7 +394,7 @@ public final class EntityCache { } public boolean isParallel() { - return this.list.size() > 1024 * 1024; + return this.list.size() > 1024 * 64; } private Stream listStream() {