diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2010-08-18 16:54:59 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2010-08-18 16:54:59 +0000 |
commit | c270234f37f0d9bdb1755f22561cbcba156b6e8c (patch) | |
tree | 1c1d2b14e7b9d383945c050425575802ab7aa782 /src/main/java/com/amazon/carbonado/repo | |
parent | 41baed7d94d0cef87d77bd9dbdac78940a71180a (diff) |
Introduce SoftValuedCache, which evicts more aggressively than SoftValuedHashMap.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
3 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java index e929e6b..e40ce04 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java @@ -43,7 +43,6 @@ import org.cojen.classfile.Opcode; import org.cojen.classfile.TypeDesc;
import org.cojen.util.ClassInjector;
import org.cojen.util.KeyFactory;
-import org.cojen.util.SoftValuedHashMap;
import org.joda.time.ReadableInstant;
@@ -65,6 +64,8 @@ import com.amazon.carbonado.gen.StorableGenerator; import com.amazon.carbonado.gen.TriggerSupport;
import static com.amazon.carbonado.gen.CommonMethodNames.*;
+import com.amazon.carbonado.util.SoftValuedCache;
+
/**
* Generates concrete implementations of {@link Storable} types for
* {@link JDBCRepository}.
@@ -87,10 +88,10 @@ class JDBCStorableGenerator<S extends Storable> { private static final int INITIAL_VERSION = 2;
private static final int INCREMENT_VERSION = 3;
- private static final Map<Object, Class<? extends Storable>> cCache;
+ private static final SoftValuedCache<Object, Class<? extends Storable>> cCache;
static {
- cCache = new SoftValuedHashMap();
+ cCache = SoftValuedCache.newCache(11);
}
static <S extends Storable> Class<? extends S> getGeneratedClass(JDBCStorableInfo<S> info,
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java index 042974f..acba43e 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java @@ -46,7 +46,6 @@ import org.apache.commons.logging.LogFactory; import org.cojen.classfile.TypeDesc;
import org.cojen.util.KeyFactory;
-import org.cojen.util.SoftValuedHashMap;
import org.cojen.util.ThrowUnchecked;
import com.amazon.carbonado.capability.IndexInfo;
@@ -66,6 +65,8 @@ import com.amazon.carbonado.info.StorableProperty; import com.amazon.carbonado.info.StorablePropertyAdapter;
import com.amazon.carbonado.info.StorablePropertyConstraint;
+import com.amazon.carbonado.util.SoftValuedCache;
+
/**
* Provides additional metadata for a {@link Storable} type needed by
* JDBCRepository. The storable type must match to a table in an external
@@ -80,7 +81,8 @@ import com.amazon.carbonado.info.StorablePropertyConstraint; public class JDBCStorableIntrospector extends StorableIntrospector {
// Maps compound keys to softly referenced JDBCStorableInfo objects.
@SuppressWarnings("unchecked")
- private static Map<Object, JDBCStorableInfo<?>> cCache = new SoftValuedHashMap();
+ private static SoftValuedCache<Object, JDBCStorableInfo<?>> cCache =
+ SoftValuedCache.newCache(11);
/**
* Examines the given class and returns a JDBCStorableInfo describing it. A
diff --git a/src/main/java/com/amazon/carbonado/repo/map/Key.java b/src/main/java/com/amazon/carbonado/repo/map/Key.java index 9348516..86a0023 100644 --- a/src/main/java/com/amazon/carbonado/repo/map/Key.java +++ b/src/main/java/com/amazon/carbonado/repo/map/Key.java @@ -34,7 +34,6 @@ import org.cojen.classfile.Modifiers; import org.cojen.classfile.TypeDesc;
import org.cojen.util.ClassInjector;
-import org.cojen.util.SoftValuedHashMap;
import com.amazon.carbonado.Storable;
@@ -45,6 +44,8 @@ import com.amazon.carbonado.info.StorableProperty; import com.amazon.carbonado.gen.CodeBuilderUtil;
+import com.amazon.carbonado.util.SoftValuedCache;
+
/**
*
*
@@ -82,10 +83,10 @@ class Key<S extends Storable> implements Comparable<Key<S>> { void setKeyValues(S storable, Object[] identityValues, Object rangeValue);
}
- private static final Map<Class, Assigner> mAssigners;
+ private static final SoftValuedCache<Class, Assigner> mAssigners;
static {
- mAssigners = new SoftValuedHashMap();
+ mAssigners = SoftValuedCache.newCache(11);
}
public static synchronized <S extends Storable> Assigner<S> getAssigner(Class<S> clazz) {
|