diff --git a/src/com/wentch/redkale/source/EntityCache.java b/src/com/wentch/redkale/source/EntityCache.java index 33a9eb28f..cdb2b29a5 100644 --- a/src/com/wentch/redkale/source/EntityCache.java +++ b/src/com/wentch/redkale/source/EntityCache.java @@ -31,8 +31,6 @@ public final class EntityCache { private final Collection list = new ConcurrentLinkedQueue(); // CopyOnWriteArrayList 插入慢、查询快; 10w数据插入需要3.2秒; ConcurrentLinkedQueue 插入快、查询慢;10w数据查询需要 0.062秒, 查询慢40%; - private final HashMap, ConcurrentHashMap>> uniques = new HashMap<>(); - private final Map> sortComparators = new ConcurrentHashMap<>(); private final Class type; @@ -65,24 +63,13 @@ public final class EntityCache { return false; } }); - for (Unique unique : type.getAnnotationsByType(Unique.class)) { - final String[] cols = unique.columns(); - final Attribute[] attrs = new Attribute[cols.length]; - for (int i = 0; i < attrs.length; i++) { - attrs[i] = info.getAttribute(cols[i]); - if (info.getUpdateAttribute(cols[i]) != null) throw new RuntimeException(type + "." + cols[i] + " unique but can be updatable"); - } - this.uniques.put(UniqueAttribute.create(attrs), new ConcurrentHashMap<>()); - } } public void fullLoad(List all) { if (all == null) return; clear(); - final HashMap, ConcurrentHashMap>> localUniques = this.uniques; all.stream().filter(x -> x != null).forEach(x -> { this.map.put(this.primary.get(x), x); - localUniques.forEach((k, v) -> v.computeIfAbsent(k.getValue(x), (c) -> new ConcurrentLinkedQueue<>()).add(x)); }); this.list.addAll(all); this.fullloaded = true; @@ -95,7 +82,6 @@ public final class EntityCache { public void clear() { this.fullloaded = false; this.list.clear(); - this.uniques.values().forEach(x -> x.clear()); this.map.clear(); } @@ -363,7 +349,6 @@ public final class EntityCache { T old = this.map.put(this.primary.get(rs), rs); if (old == null) { this.list.add(rs); - this.uniques.forEach((k, v) -> v.computeIfAbsent(k.getValue(rs), (c) -> new ConcurrentLinkedQueue<>()).add(rs)); } else { logger.log(Level.WARNING, "cache repeat insert data: " + value); } @@ -373,10 +358,6 @@ public final class EntityCache { if (id == null) return; final T rs = this.map.remove(id); if (rs != null) this.list.remove(rs); - this.uniques.forEach((k, v) -> v.computeIfPresent(k.getValue(rs), (x, u) -> { - u.remove(rs); - return u; - })); } public Serializable[] delete(final FilterNode node) { @@ -389,10 +370,6 @@ public final class EntityCache { ids[++i] = this.primary.get(t); this.map.remove(ids[i]); this.list.remove(t); - this.uniques.forEach((k, v) -> v.computeIfPresent(k.getValue(t), (x, u) -> { - u.remove(t); - return u; - })); } return ids; } diff --git a/src/com/wentch/redkale/source/Unique.java b/src/com/wentch/redkale/source/Unique.java deleted file mode 100644 index fca52f4e0..000000000 --- a/src/com/wentch/redkale/source/Unique.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.source; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * - * @author zhangjx - */ -@Inherited -@Documented -@Target({FIELD}) -@Retention(RUNTIME) -@Repeatable(Uniques.class) -public @interface Unique { - - String[] columns(); -} diff --git a/src/com/wentch/redkale/source/Uniques.java b/src/com/wentch/redkale/source/Uniques.java deleted file mode 100644 index f1397e63f..000000000 --- a/src/com/wentch/redkale/source/Uniques.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.wentch.redkale.source; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * - * @author zhangjx - */ -@Inherited -@Documented -@Target({FIELD}) -@Retention(RUNTIME) -public @interface Uniques { - - Unique[] value(); -}