db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r604153 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache: ClockPolicy.java ConcurrentCache.java ConcurrentCacheFactory.java
Date Fri, 14 Dec 2007 10:42:02 GMT
Author: kahatlen
Date: Fri Dec 14 02:42:02 2007
New Revision: 604153

URL: http://svn.apache.org/viewvc?rev=604153&view=rev
Log:
DERBY-2911: Implement a buffer manager using java.util.concurrent classes

Use the initialSize parameter that is given to
CacheFactory.newCacheManager() to specify the initial capacity of the
ConcurrentHashMap in ConcurrentCache and the ArrayList in ClockPolicy.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCacheFactory.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java?rev=604153&r1=604152&r2=604153&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
Fri Dec 14 02:42:02 2007
@@ -84,7 +84,7 @@
      * cache. Accesses to <code>clock</code> and <code>hand</code>
must be
      * synchronized on <code>clock</code>.
      */
-    private final ArrayList<Holder> clock = new ArrayList<Holder>();
+    private final ArrayList<Holder> clock;
 
     /** The current position of the clock hand. */
     private int hand;
@@ -107,11 +107,13 @@
      * Create a new <code>ClockPolicy</code> instance.
      *
      * @param cacheManager the cache manager that requests this policy
+     * @param initialSize the initial capacity of the cache
      * @param maxSize the maximum size of the cache
      */
-    ClockPolicy(ConcurrentCache cacheManager, int maxSize) {
+    ClockPolicy(ConcurrentCache cacheManager, int initialSize, int maxSize) {
         this.cacheManager = cacheManager;
         this.maxSize = maxSize;
+        clock = new ArrayList<Holder>(initialSize);
     }
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java?rev=604153&r1=604152&r2=604153&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCache.java
Fri Dec 14 02:42:02 2007
@@ -82,11 +82,13 @@
      *
      * @param holderFactory factory which creates <code>Cacheable</code>s
      * @param name the name of the cache
+     * @param initialSize the initial capacity of the cache
      * @param maxSize maximum number of elements in the cache
      */
-    ConcurrentCache(CacheableFactory holderFactory, String name, int maxSize) {
-        cache = new ConcurrentHashMap<Object, CacheEntry>();
-        replacementPolicy = new ClockPolicy(this, maxSize);
+    ConcurrentCache(CacheableFactory holderFactory, String name,
+                    int initialSize, int maxSize) {
+        cache = new ConcurrentHashMap<Object, CacheEntry>(initialSize);
+        replacementPolicy = new ClockPolicy(this, initialSize, maxSize);
         this.holderFactory = holderFactory;
         this.name = name;
         this.maxSize = maxSize;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCacheFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCacheFactory.java?rev=604153&r1=604152&r2=604153&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCacheFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ConcurrentCacheFactory.java
Fri Dec 14 02:42:02 2007
@@ -35,14 +35,14 @@
      *
      * @param holderFactory factory which creates <code>Cacheable</code>s
      * @param name name of the cache
-     * @param initialSize initial size of the cache (number of objects)
+     * @param initialSize initial capacity of the cache (number of objects)
      * @param maximumSize maximum size of the cache (number of objects)
      * @return a <code>ConcurrentCache</code> instance
      */
     public CacheManager newCacheManager(CacheableFactory holderFactory,
                                         String name,
                                         int initialSize, int maximumSize) {
-        // TODO - use the initial size
-        return new ConcurrentCache(holderFactory, name, maximumSize);
+        return new ConcurrentCache(holderFactory, name,
+                                   initialSize, maximumSize);
     }
 }



Mime
View raw message