incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/3] git commit: First commit of new slab unsafe alloc.
Date Mon, 08 Jun 2015 14:12:31 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master fc3422f3a -> 131ddb6d9


First commit of new slab unsafe alloc.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/264a6313
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/264a6313
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/264a6313

Branch: refs/heads/master
Commit: 264a6313712e499de00cb883934c85316a8a6028
Parents: 9309ce6
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Jun 2 08:31:27 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Jun 2 08:31:27 2015 -0400

----------------------------------------------------------------------
 .../blur/store/blockcache_v2/BaseCache.java     |  11 +-
 .../blockcache_v2/BaseCacheValueBufferPool.java |  52 ++++++
 .../blockcache_v2/CacheValueBufferPool.java     | 123 --------------
 .../SimpleCacheValueBufferPool.java             | 104 ++++++++++++
 .../SlabAllocationCacheValueBufferPool.java     |  69 ++++++++
 .../cachevalue/UnsafeAllocateCacheValue.java    |  48 ++++++
 .../cachevalue/UnsafeCacheValue.java            |  50 ++----
 .../cachevalue/UnsafeWrappedCacheValue.java     |  44 +++++
 .../UnsafeWrapperMultiCacheValue.java           |  74 ++++++++
 .../blur/store/blockcache_v2/BaseCacheTest.java | 100 +++++++++++
 .../CacheDirectoryLoadUnloadTest.java           | 170 +++++++++++++++++++
 .../UnsafeAllocateCacheValueTest.java           |  73 ++++++++
 .../cachevalue/UnsafeCacheValueTest.java        |  73 --------
 13 files changed, 753 insertions(+), 238 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCache.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCache.java b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCache.java
index 861482c..5b0da07 100644
--- a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCache.java
+++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCache.java
@@ -66,6 +66,7 @@ public class BaseCache extends Cache implements Closeable {
   class BaseCacheEvictionListener implements EvictionListener<CacheKey, CacheValue>
{
     @Override
     public void onEviction(CacheKey key, CacheValue value) {
+      System.out.println("onEviction [" + key + "] [" + value + "]");
       _evictions.mark();
       _cacheValueBufferPool.returnToPool(value.detachFromCache());
     }
@@ -97,7 +98,7 @@ public class BaseCache extends Cache implements Closeable {
   private final Meter _removals;
   private final Thread _oldFileDaemonThread;
   private final AtomicBoolean _running = new AtomicBoolean(true);
-  private final CacheValueBufferPool _cacheValueBufferPool;
+  private final SimpleCacheValueBufferPool _cacheValueBufferPool;
 
   public BaseCache(long totalNumberOfBytes, Size fileBufferSize, Size cacheBlockSize, FileNameFilter
readFilter,
       FileNameFilter writeFilter, Quiet quiet, STORE store) {
@@ -114,7 +115,7 @@ public class BaseCache extends Cache implements Closeable {
     _evictions = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE, EVICTION), EVICTION,
TimeUnit.SECONDS);
     _removals = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE, REMOVAL), REMOVAL,
TimeUnit.SECONDS);
     // @TODO make configurable
-    _cacheValueBufferPool = new CacheValueBufferPool(_store, 1000);
+    _cacheValueBufferPool = new SimpleCacheValueBufferPool(_store, 1000);
     Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, CACHE, ENTRIES), new Gauge<Long>()
{
       @Override
       public Long value() {
@@ -267,7 +268,7 @@ public class BaseCache extends Cache implements Closeable {
     CacheValue cacheValue = _cacheMap.get(key);
     if (cacheValue == null) {
       _misses.mark();
-//      System.out.println("Loud Miss [" + fileName + "] Key [" + key + "]");
+      // System.out.println("Loud Miss [" + fileName + "] Key [" + key + "]");
     } else {
       _hits.mark();
     }
@@ -280,7 +281,7 @@ public class BaseCache extends Cache implements Closeable {
     if (cacheValue != null) {
       _hits.mark();
     } else {
-//      System.out.println("Quiet Miss [" + fileName + "] Key [" + key + "]");
+      // System.out.println("Quiet Miss [" + fileName + "] Key [" + key + "]");
     }
     return cacheValue;
   }
@@ -289,7 +290,9 @@ public class BaseCache extends Cache implements Closeable {
   public void put(CacheDirectory directory, String fileName, CacheKey key, CacheValue value)
{
     CacheValue cacheValue = _cacheMap.put(key, value);
     if (cacheValue != null) {
+      System.out.println("put [" + key + "] [" + value + "]");
       _evictions.mark();
+      _cacheValueBufferPool.returnToPool(cacheValue.detachFromCache());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCacheValueBufferPool.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCacheValueBufferPool.java
b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCacheValueBufferPool.java
new file mode 100644
index 0000000..fc0c464
--- /dev/null
+++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/BaseCacheValueBufferPool.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2;
+
+import static org.apache.blur.metrics.MetricsConstants.CACHE_POOL;
+import static org.apache.blur.metrics.MetricsConstants.CREATED;
+import static org.apache.blur.metrics.MetricsConstants.DESTROYED;
+import static org.apache.blur.metrics.MetricsConstants.ORG_APACHE_BLUR;
+import static org.apache.blur.metrics.MetricsConstants.REUSED;
+
+import java.io.Closeable;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.blur.store.blockcache_v2.BaseCache.STORE;
+
+import com.yammer.metrics.Metrics;
+import com.yammer.metrics.core.Meter;
+import com.yammer.metrics.core.MetricName;
+
+public abstract class BaseCacheValueBufferPool implements Closeable {
+
+  protected final STORE _store;
+  protected final Meter _reused;
+  protected final Meter _detroyed;
+  protected final Meter _created;
+
+  public BaseCacheValueBufferPool(STORE store) {
+    _store = store;
+    _created = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, CREATED), CREATED,
TimeUnit.SECONDS);
+    _reused = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, REUSED), REUSED,
TimeUnit.SECONDS);
+    _detroyed = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, DESTROYED),
DESTROYED, TimeUnit.SECONDS);
+  }
+
+  public abstract CacheValue getCacheValue(int cacheBlockSize);
+
+  public abstract void returnToPool(CacheValue cacheValue);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java
b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java
deleted file mode 100644
index 7cfbd0c..0000000
--- a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.blur.store.blockcache_v2;
-
-import static org.apache.blur.metrics.MetricsConstants.CACHE_POOL;
-import static org.apache.blur.metrics.MetricsConstants.CREATED;
-import static org.apache.blur.metrics.MetricsConstants.DESTROYED;
-import static org.apache.blur.metrics.MetricsConstants.ORG_APACHE_BLUR;
-import static org.apache.blur.metrics.MetricsConstants.REUSED;
-
-import java.io.Closeable;
-import java.util.Map.Entry;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.blur.log.Log;
-import org.apache.blur.log.LogFactory;
-import org.apache.blur.store.blockcache_v2.BaseCache.STORE;
-import org.apache.blur.store.blockcache_v2.cachevalue.ByteArrayCacheValue;
-import org.apache.blur.store.blockcache_v2.cachevalue.UnsafeCacheValue;
-
-import com.yammer.metrics.Metrics;
-import com.yammer.metrics.core.Meter;
-import com.yammer.metrics.core.MetricName;
-
-public class CacheValueBufferPool implements Closeable {
-
-  private static final Log LOG = LogFactory.getLog(CacheValueBufferPool.class);
-
-  private final STORE _store;
-  private final ConcurrentMap<Integer, BlockingQueue<CacheValue>> _cacheValuePool
= new ConcurrentHashMap<Integer, BlockingQueue<CacheValue>>();
-  private final int _capacity;
-  private final Meter _reused;
-  private final Meter _detroyed;
-  private final Meter _created;
-
-  public CacheValueBufferPool(STORE store, int capacity) {
-    _store = store;
-    _capacity = capacity;
-    _created = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, CREATED), CREATED,
TimeUnit.SECONDS);
-    _reused = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, REUSED), REUSED,
TimeUnit.SECONDS);
-    _detroyed = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, CACHE_POOL, DESTROYED),
DESTROYED, TimeUnit.SECONDS);
-  }
-
-  public CacheValue getCacheValue(int cacheBlockSize) {
-    BlockingQueue<CacheValue> blockingQueue = getPool(cacheBlockSize);
-    CacheValue cacheValue = blockingQueue.poll();
-    if (cacheValue == null) {
-      _created.mark();
-      return createCacheValue(cacheBlockSize);
-    }
-    _reused.mark();
-    return cacheValue;
-  }
-
-  private BlockingQueue<CacheValue> getPool(int cacheBlockSize) {
-    BlockingQueue<CacheValue> blockingQueue = _cacheValuePool.get(cacheBlockSize);
-    if (blockingQueue == null) {
-      blockingQueue = buildNewBlockQueue(cacheBlockSize);
-    }
-    return blockingQueue;
-  }
-
-  private BlockingQueue<CacheValue> buildNewBlockQueue(int cacheBlockSize) {
-    LOG.info("Allocating new ArrayBlockingQueue with capacity [{0}]", _capacity);
-    BlockingQueue<CacheValue> value = new ArrayBlockingQueue<CacheValue>(_capacity);
-    _cacheValuePool.putIfAbsent(cacheBlockSize, value);
-    return _cacheValuePool.get(cacheBlockSize);
-  }
-
-  private CacheValue createCacheValue(int cacheBlockSize) {
-    switch (_store) {
-    case ON_HEAP:
-      return new ByteArrayCacheValue(cacheBlockSize);
-    case OFF_HEAP:
-      return new UnsafeCacheValue(cacheBlockSize);
-    default:
-      throw new RuntimeException("Unknown type [" + _store + "]");
-    }
-  }
-
-  public void returnToPool(CacheValue cacheValue) {
-    if (cacheValue == null || cacheValue.isEvicted()) {
-      return;
-    }
-    try {
-      BlockingQueue<CacheValue> blockingQueue = getPool(cacheValue.length());
-      if (!blockingQueue.offer(cacheValue)) {
-        _detroyed.mark();
-        cacheValue.release();
-      }
-    } catch (EvictionException e) {
-      return;
-    }
-  }
-
-  @Override
-  public void close() {
-    for (Entry<Integer, BlockingQueue<CacheValue>> e : _cacheValuePool.entrySet())
{
-      BlockingQueue<CacheValue> queue = _cacheValuePool.remove(e.getKey());
-      for (CacheValue cacheValue : queue) {
-        cacheValue.release();
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/SimpleCacheValueBufferPool.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/SimpleCacheValueBufferPool.java
b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/SimpleCacheValueBufferPool.java
new file mode 100644
index 0000000..e6fa9a2
--- /dev/null
+++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/SimpleCacheValueBufferPool.java
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2;
+
+import java.util.Map.Entry;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.blur.log.Log;
+import org.apache.blur.log.LogFactory;
+import org.apache.blur.store.blockcache_v2.BaseCache.STORE;
+import org.apache.blur.store.blockcache_v2.cachevalue.ByteArrayCacheValue;
+import org.apache.blur.store.blockcache_v2.cachevalue.UnsafeAllocateCacheValue;
+
+public class SimpleCacheValueBufferPool extends BaseCacheValueBufferPool {
+
+  private static final Log LOG = LogFactory.getLog(SimpleCacheValueBufferPool.class);
+
+  private final ConcurrentMap<Integer, BlockingQueue<CacheValue>> _cacheValuePool
= new ConcurrentHashMap<Integer, BlockingQueue<CacheValue>>();
+  private final int _capacity;
+
+  public SimpleCacheValueBufferPool(STORE store, int capacity) {
+    super(store);
+    _capacity = capacity;
+  }
+
+  public CacheValue getCacheValue(int cacheBlockSize) {
+    BlockingQueue<CacheValue> blockingQueue = getPool(cacheBlockSize);
+    CacheValue cacheValue = blockingQueue.poll();
+    if (cacheValue == null) {
+      _created.mark();
+      return createCacheValue(cacheBlockSize);
+    }
+    _reused.mark();
+    return cacheValue;
+  }
+
+  private BlockingQueue<CacheValue> getPool(int cacheBlockSize) {
+    BlockingQueue<CacheValue> blockingQueue = _cacheValuePool.get(cacheBlockSize);
+    if (blockingQueue == null) {
+      blockingQueue = buildNewBlockQueue(cacheBlockSize);
+    }
+    return blockingQueue;
+  }
+
+  private BlockingQueue<CacheValue> buildNewBlockQueue(int cacheBlockSize) {
+    LOG.info("Allocating new ArrayBlockingQueue with capacity [{0}]", _capacity);
+    BlockingQueue<CacheValue> value = new ArrayBlockingQueue<CacheValue>(_capacity);
+    _cacheValuePool.putIfAbsent(cacheBlockSize, value);
+    return _cacheValuePool.get(cacheBlockSize);
+  }
+
+  private CacheValue createCacheValue(int cacheBlockSize) {
+    switch (_store) {
+    case ON_HEAP:
+      return new ByteArrayCacheValue(cacheBlockSize);
+    case OFF_HEAP:
+      return new UnsafeAllocateCacheValue(cacheBlockSize);
+    default:
+      throw new RuntimeException("Unknown type [" + _store + "]");
+    }
+  }
+
+  public void returnToPool(CacheValue cacheValue) {
+    if (cacheValue == null || cacheValue.isEvicted()) {
+      return;
+    }
+    try {
+      BlockingQueue<CacheValue> blockingQueue = getPool(cacheValue.length());
+      if (!blockingQueue.offer(cacheValue)) {
+        _detroyed.mark();
+        cacheValue.release();
+      }
+    } catch (EvictionException e) {
+      return;
+    }
+  }
+
+  @Override
+  public void close() {
+    for (Entry<Integer, BlockingQueue<CacheValue>> e : _cacheValuePool.entrySet())
{
+      BlockingQueue<CacheValue> queue = _cacheValuePool.remove(e.getKey());
+      for (CacheValue cacheValue : queue) {
+        cacheValue.release();
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/SlabAllocationCacheValueBufferPool.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/SlabAllocationCacheValueBufferPool.java
b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/SlabAllocationCacheValueBufferPool.java
new file mode 100644
index 0000000..7891fbf
--- /dev/null
+++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/SlabAllocationCacheValueBufferPool.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.blur.store.blockcache.BlockLocks;
+import org.apache.blur.store.blockcache_v2.BaseCache.STORE;
+
+public class SlabAllocationCacheValueBufferPool extends BaseCacheValueBufferPool {
+
+  public SlabAllocationCacheValueBufferPool(STORE store) {
+    super(store);
+  }
+
+  static class Slab {
+    final long _address;
+    final BlockLocks _locks;
+
+    Slab(long address, int numberOfBlocks) {
+      _address = address;
+      _locks = new BlockLocks(numberOfBlocks);
+    }
+
+    int findChunk() {
+      throw new RuntimeException("Not implemented.");
+    }
+  }
+
+  @Override
+  public CacheValue getCacheValue(int cacheBlockSize) {
+    
+    List<Slab> slabs = getSlabs();
+    for (Slab slab : slabs) {
+      int chunkId = slab.findChunk();
+    }
+    throw new RuntimeException("Not implemented.");
+  }
+
+  private List<Slab> getSlabs() {
+    throw new RuntimeException("Not implemented.");
+  }
+
+  @Override
+  public void returnToPool(CacheValue cacheValue) {
+    throw new RuntimeException("Not implemented.");
+  }
+
+  @Override
+  public void close() throws IOException {
+    throw new RuntimeException("Not implemented.");
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeAllocateCacheValue.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeAllocateCacheValue.java
b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeAllocateCacheValue.java
new file mode 100644
index 0000000..57135ad
--- /dev/null
+++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeAllocateCacheValue.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2.cachevalue;
+
+public class UnsafeAllocateCacheValue extends UnsafeCacheValue {
+
+  private final long _address;
+
+  public UnsafeAllocateCacheValue(int length) {
+    super(length);
+    _address = _unsafe.allocateMemory(_length);
+  }
+
+  @Override
+  protected void writeInternal(int position, byte[] buf, int offset, int length) {
+    copyFromArray(buf, offset, length, resolveAddress(_address, position));
+  }
+
+  @Override
+  protected void readInternal(int position, byte[] buf, int offset, int length) {
+    copyToArray(resolveAddress(_address, position), buf, offset, length);
+  }
+
+  @Override
+  protected byte readInternal(int position) {
+    return _unsafe.getByte(resolveAddress(_address, position));
+  }
+
+  @Override
+  protected void releaseInternal() {
+    _unsafe.freeMemory(_address);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValue.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValue.java
b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValue.java
index 3b7badb..0ce31fd 100644
--- a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValue.java
+++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValue.java
@@ -32,17 +32,17 @@ import sun.misc.Unsafe;
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.MetricName;
 
-public class UnsafeCacheValue extends BaseCacheValue {
+public abstract class UnsafeCacheValue extends BaseCacheValue {
 
-  private static final AtomicLong _neededFinalizedCall = new AtomicLong();
+  protected static final AtomicLong _neededFinalizedCall = new AtomicLong();
 
   static {
     Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, JVM, CACHE_VALUE_FINALIZE), new AtomicLongGauge(
         _neededFinalizedCall));
   }
 
-  private static final Unsafe _unsafe;
-  private static final AtomicLong _offHeapMemorySize = new AtomicLong();
+  protected static final Unsafe _unsafe;
+  protected static final AtomicLong _offHeapMemorySize = new AtomicLong();
 
   static {
     _unsafe = UnsafeUtil.getUnsafe();
@@ -51,61 +51,35 @@ public class UnsafeCacheValue extends BaseCacheValue {
 
   private static final int BYTE_ARRAY_BASE_OFFSET = _unsafe.arrayBaseOffset(byte[].class);
 
-  private static void copyFromArray(byte[] src, int srcOffset, int length, long destAddress)
{
+  protected static void copyFromArray(byte[] src, int srcOffset, int length, long destAddress)
{
     long offset = BYTE_ARRAY_BASE_OFFSET + srcOffset;
     _unsafe.copyMemory(src, offset, null, destAddress, length);
   }
 
-  private static void copyToArray(long srcAddress, byte[] dst, int dstOffset, int length)
{
+  protected static void copyToArray(long srcAddress, byte[] dst, int dstOffset, int length)
{
     long offset = BYTE_ARRAY_BASE_OFFSET + dstOffset;
     _unsafe.copyMemory(null, srcAddress, dst, offset, length);
   }
 
-  private final long _address;
-
   public UnsafeCacheValue(int length) {
     super(length);
-    _address = _unsafe.allocateMemory(_length);
     _offHeapMemorySize.addAndGet(_length);
   }
 
-  @Override
-  protected void writeInternal(int position, byte[] buf, int offset, int length) {
-    copyFromArray(buf, offset, length, resolveAddress(position));
-  }
-
-  @Override
-  protected void readInternal(int position, byte[] buf, int offset, int length) {
-    copyToArray(resolveAddress(position), buf, offset, length);
-  }
-
-  @Override
-  protected byte readInternal(int position) {
-    return _unsafe.getByte(resolveAddress(position));
-  }
 
-  private long resolveAddress(int position) {
-    return _address + position;
+  protected static long resolveAddress(long address, int position) {
+    return address + position;
   }
 
   @Override
-  public void release() {
+  public final void release() {
     if (!_released) {
-      _unsafe.freeMemory(_address);
+      releaseInternal();
       _released = true;
       _offHeapMemorySize.addAndGet(0 - _length);
     }
   }
 
-  // This is commented out normally. Add code when debugging memory related
-  // issues.
-  // @Override
-  // protected void finalize() throws Throwable {
-  // if (!_released) {
-  // new Throwable().printStackTrace();
-  // System.exit(1);
-  // release();
-  // _neededFinalizedCall.incrementAndGet();
-  // }
-  // }
+  protected abstract void releaseInternal();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeWrappedCacheValue.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeWrappedCacheValue.java
b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeWrappedCacheValue.java
new file mode 100644
index 0000000..ae24a94
--- /dev/null
+++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeWrappedCacheValue.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2.cachevalue;
+
+public abstract class UnsafeWrappedCacheValue extends UnsafeCacheValue {
+
+  private final long _address;
+
+  public UnsafeWrappedCacheValue(int length, long address) {
+    super(length);
+    _address = address;
+  }
+
+  @Override
+  protected void writeInternal(int position, byte[] buf, int offset, int length) {
+    copyFromArray(buf, offset, length, resolveAddress(_address, position));
+  }
+
+  @Override
+  protected void readInternal(int position, byte[] buf, int offset, int length) {
+    copyToArray(resolveAddress(_address, position), buf, offset, length);
+  }
+
+  @Override
+  protected byte readInternal(int position) {
+    return _unsafe.getByte(resolveAddress(_address, position));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeWrapperMultiCacheValue.java
----------------------------------------------------------------------
diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeWrapperMultiCacheValue.java
b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeWrapperMultiCacheValue.java
new file mode 100644
index 0000000..ac4dfb6
--- /dev/null
+++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeWrapperMultiCacheValue.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2.cachevalue;
+
+public abstract class UnsafeWrapperMultiCacheValue extends UnsafeCacheValue {
+
+  private final long[] _chunkAddresses;
+  private final int _chunkSize;
+
+  public UnsafeWrapperMultiCacheValue(int length, long[] chunkAddresses, int chunkSize) {
+    super(length);
+    _chunkAddresses = chunkAddresses;
+    _chunkSize = chunkSize;
+  }
+
+  @Override
+  protected byte readInternal(int position) {
+    int chunkIndex = getChunkIndex(position);
+    int chunkPos = getChunkPosition(position);
+    long address = _chunkAddresses[chunkIndex];
+    return _unsafe.getByte(resolveAddress(address, chunkPos));
+  }
+
+  @Override
+  protected void writeInternal(int position, byte[] buf, int offset, int length) {
+    while (length > 0) {
+      int chunkIndex = getChunkIndex(position);
+      int chunkPos = getChunkPosition(position);
+      int len = Math.min(length, _chunkSize - chunkPos);
+      long address = _chunkAddresses[chunkIndex];
+      copyFromArray(buf, offset, len, resolveAddress(address, chunkPos));
+      position += len;
+      offset += len;
+      length -= len;
+    }
+  }
+
+  @Override
+  protected void readInternal(int position, byte[] buf, int offset, int length) {
+    while (length > 0) {
+      int chunkIndex = getChunkIndex(position);
+      int chunkPos = getChunkPosition(position);
+      int len = Math.min(length, _chunkSize - chunkPos);
+      long address = _chunkAddresses[chunkIndex];
+      copyToArray(resolveAddress(address, position), buf, offset, len);
+      position += len;
+      offset += len;
+      length -= len;
+    }
+  }
+
+  protected int getChunkPosition(int position) {
+    return position % _chunkSize;
+  }
+
+  protected int getChunkIndex(int position) {
+    return position / _chunkSize;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/BaseCacheTest.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/BaseCacheTest.java
b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/BaseCacheTest.java
new file mode 100644
index 0000000..6457f87
--- /dev/null
+++ b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/BaseCacheTest.java
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2;
+
+import java.io.IOException;
+
+import org.apache.blur.store.blockcache.LastModified;
+import org.apache.blur.store.blockcache_v2.BaseCache.STORE;
+import org.apache.blur.store.blockcache_v2.CacheDirectoryTest.RDir;
+import org.apache.blur.store.buffer.BufferStore;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+import org.junit.Test;
+
+public class BaseCacheTest {
+
+  private BaseCache _cache;
+  private CacheDirectory _cacheDirectory;
+
+  @Test
+  public void test1() {
+    int totalNumberOfBytes = 1000000;
+    final int fileBufferSizeInt = 127;
+    final int cacheBlockSizeInt = 131;
+    Size fileBufferSize = new Size() {
+      @Override
+      public int getSize(CacheDirectory directory, String fileName) {
+        return fileBufferSizeInt;
+      }
+    };
+    Size cacheBlockSize = new Size() {
+      @Override
+      public int getSize(CacheDirectory directory, String fileName) {
+        return cacheBlockSizeInt;
+      }
+    };
+    FileNameFilter writeFilter = new FileNameFilter() {
+      @Override
+      public boolean accept(CacheDirectory directory, String fileName) {
+        return true;
+      }
+    };
+    FileNameFilter readFilter = new FileNameFilter() {
+      @Override
+      public boolean accept(CacheDirectory directory, String fileName) {
+        return true;
+      }
+    };
+    Quiet quiet = new Quiet() {
+      @Override
+      public boolean shouldBeQuiet(CacheDirectory directory, String fileName) {
+        return false;
+      }
+    };
+    _cache = new BaseCache(totalNumberOfBytes, fileBufferSize, cacheBlockSize, readFilter,
writeFilter, quiet,
+        STORE.ON_HEAP);
+
+    Directory directory = newDirectory();
+    BufferStore.initNewBuffer(1024, 1024 * 128);
+    BufferStore.initNewBuffer(8192, 8192 * 128);
+    _cacheDirectory = new CacheDirectory("test", "test", directory, _cache, null);
+
+    String fileName = "test";
+    {
+      CacheKey key = new CacheKey();
+      CacheValue value = _cache.newInstance(_cacheDirectory, fileName);
+      _cache.put(_cacheDirectory, fileName, key, value);
+    }
+    {
+      CacheKey key = new CacheKey();
+      CacheValue value = _cache.newInstance(_cacheDirectory, fileName);
+      _cache.put(_cacheDirectory, fileName, key, value);
+    }
+  }
+
+  private Directory newDirectory() {
+    return new RDir();
+  }
+
+  static class RDir extends RAMDirectory implements LastModified {
+    @Override
+    public long getFileModified(String name) throws IOException {
+      return 0;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryLoadUnloadTest.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryLoadUnloadTest.java
b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryLoadUnloadTest.java
new file mode 100644
index 0000000..751c2b9
--- /dev/null
+++ b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/CacheDirectoryLoadUnloadTest.java
@@ -0,0 +1,170 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Random;
+
+import org.apache.blur.store.blockcache.LastModified;
+import org.apache.blur.store.blockcache_v2.BaseCache.STORE;
+import org.apache.blur.store.buffer.BufferStore;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IOContext;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.store.SimpleFSDirectory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CacheDirectoryLoadUnloadTest {
+
+  private BaseCache _cache;
+
+//  @Before
+  public void setup() throws IOException {
+    long totalNumberOfBytes = 2000000000L;
+    final int fileBufferSizeInt = 8192;
+    final int cacheBlockSizeInt = 8192;
+    Size fileBufferSize = new Size() {
+      @Override
+      public int getSize(CacheDirectory directory, String fileName) {
+        return fileBufferSizeInt;
+      }
+    };
+    Size cacheBlockSize = new Size() {
+      @Override
+      public int getSize(CacheDirectory directory, String fileName) {
+        return cacheBlockSizeInt;
+      }
+    };
+    FileNameFilter writeFilter = new FileNameFilter() {
+      @Override
+      public boolean accept(CacheDirectory directory, String fileName) {
+        return true;
+      }
+    };
+    FileNameFilter readFilter = new FileNameFilter() {
+      @Override
+      public boolean accept(CacheDirectory directory, String fileName) {
+        return true;
+      }
+    };
+    Quiet quiet = new Quiet() {
+      @Override
+      public boolean shouldBeQuiet(CacheDirectory directory, String fileName) {
+        return false;
+      }
+    };
+    _cache = new BaseCache(totalNumberOfBytes, fileBufferSize, cacheBlockSize, readFilter,
writeFilter, quiet,
+        STORE.OFF_HEAP);
+  }
+
+  @After
+  public void tearDown() throws IOException {
+    _cache.close();
+  }
+
+  private Directory newDirectory(File path) throws IOException {
+    return new FSDir(path);
+  }
+
+  static class FSDir extends SimpleFSDirectory implements LastModified {
+
+    public FSDir(File path) throws IOException {
+      super(path);
+    }
+
+    @Override
+    public long getFileModified(String name) throws IOException {
+      return 0;
+    }
+
+  }
+
+//  @Test
+  public void test1() throws IOException {
+    int i = 0;
+    long length = 100000000;
+    int numberOfFilesPerPass = 25;
+    Random random = new Random(1);
+
+    while (true) {
+      CacheDirectory dir = getDir();
+      for (int p = 0; p < numberOfFilesPerPass; p++) {
+        String file = i + "-" + p + ".tim";
+        System.out.println("Writing [" + file + "]");
+        System.out.println("Cache Size " + _cache.getWeightedSize());
+
+        IndexOutput output = dir.createOutput(file, IOContext.DEFAULT);
+        write(output, length, random);
+        output.close();
+      }
+      for (int p = 0; p < 10; p++) {
+        String file = i + "-" + p + ".tim";
+        System.out.println(dir.fileLength(file));
+      }
+
+      for (int p = 0; p < 10; p++) {
+        String file = i + "-" + p + ".tim";
+        System.out.println("Cache Size " + _cache.getWeightedSize());
+        System.out.println("Reading [" + file + "]");
+        IndexInput input = dir.openInput(file, IOContext.DEFAULT);
+        read(input);
+        input.close();
+      }
+      for (int p = 0; p < 10; p++) {
+        String file = i + "-" + p + ".tim";
+        dir.deleteFile(file);
+      }
+      i++;
+      System.out.println("Cache Size " + _cache.getWeightedSize());
+      dir.close();
+      _cache.cleanupOldFiles();
+    }
+  }
+
+  private CacheDirectory getDir() throws IOException {
+    Directory directory = newDirectory(new File("./target/tmp/CacheDirectoryLoadUnloadTest"));
+    BufferStore.initNewBuffer(1024, 1024 * 128);
+    BufferStore.initNewBuffer(8192, 8192 * 128);
+    return new CacheDirectory("test", "test", directory, _cache, null);
+  }
+
+  private void read(IndexInput input) throws IOException {
+    byte[] buf = new byte[10000];
+    long length = input.length();
+    while (length > 0) {
+      int len = (int) Math.min(length, buf.length);
+      input.readBytes(buf, 0, len);
+      length -= len;
+    }
+  }
+
+  private void write(IndexOutput output, long length, Random random) throws IOException {
+    byte[] buf = new byte[10000];
+    while (length > 0) {
+      random.nextBytes(buf);
+      int len = (int) Math.min(length, buf.length);
+      output.writeBytes(buf, len);
+      length -= len;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeAllocateCacheValueTest.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeAllocateCacheValueTest.java
b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeAllocateCacheValueTest.java
new file mode 100644
index 0000000..b7b4768
--- /dev/null
+++ b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeAllocateCacheValueTest.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.store.blockcache_v2.cachevalue;
+
+import static org.junit.Assert.*;
+
+import org.apache.blur.store.blockcache_v2.EvictionException;
+import org.junit.Test;
+
+public class UnsafeAllocateCacheValueTest {
+
+  @Test
+  public void test1() throws EvictionException {
+    UnsafeCacheValue value = new UnsafeAllocateCacheValue(10);
+    byte[] buf = "hello world".getBytes();
+    value.write(0, buf, 0, 10);
+    byte[] buf2 = new byte[10];
+    value.read(0, buf2, 0, 10);
+    assertArrayEquals("hello worl".getBytes(), buf2);
+    value.release();
+  }
+
+  @Test
+  public void test2() {
+    UnsafeCacheValue value = new UnsafeAllocateCacheValue(10);
+    byte[] buf = "hello world".getBytes();
+    try {
+      value.write(0, buf, 0, 11);
+      fail();
+    } catch (ArrayIndexOutOfBoundsException e) {
+    }
+    value.release();
+  }
+
+  @Test
+  public void test3() {
+    UnsafeCacheValue value = new UnsafeAllocateCacheValue(10);
+    byte[] buf = "hello world".getBytes();
+    try {
+      value.write(8, buf, 0, 3);
+      fail();
+    } catch (ArrayIndexOutOfBoundsException e) {
+    }
+    value.release();
+  }
+
+  @Test
+  public void test4() throws EvictionException {
+    UnsafeCacheValue value = new UnsafeAllocateCacheValue(10);
+    byte[] buf = "hello world".getBytes();
+    value.write(8, buf, 0, 2);
+
+    assertEquals('h', value.read(8));
+    assertEquals('e', value.read(9));
+    value.release();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/264a6313/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValueTest.java
----------------------------------------------------------------------
diff --git a/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValueTest.java
b/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValueTest.java
deleted file mode 100644
index 62095f8..0000000
--- a/blur-store/src/test/java/org/apache/blur/store/blockcache_v2/cachevalue/UnsafeCacheValueTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.blur.store.blockcache_v2.cachevalue;
-
-import static org.junit.Assert.*;
-
-import org.apache.blur.store.blockcache_v2.EvictionException;
-import org.junit.Test;
-
-public class UnsafeCacheValueTest {
-
-  @Test
-  public void test1() throws EvictionException {
-    UnsafeCacheValue value = new UnsafeCacheValue(10);
-    byte[] buf = "hello world".getBytes();
-    value.write(0, buf, 0, 10);
-    byte[] buf2 = new byte[10];
-    value.read(0, buf2, 0, 10);
-    assertArrayEquals("hello worl".getBytes(), buf2);
-    value.release();
-  }
-
-  @Test
-  public void test2() {
-    UnsafeCacheValue value = new UnsafeCacheValue(10);
-    byte[] buf = "hello world".getBytes();
-    try {
-      value.write(0, buf, 0, 11);
-      fail();
-    } catch (ArrayIndexOutOfBoundsException e) {
-    }
-    value.release();
-  }
-
-  @Test
-  public void test3() {
-    UnsafeCacheValue value = new UnsafeCacheValue(10);
-    byte[] buf = "hello world".getBytes();
-    try {
-      value.write(8, buf, 0, 3);
-      fail();
-    } catch (ArrayIndexOutOfBoundsException e) {
-    }
-    value.release();
-  }
-
-  @Test
-  public void test4() throws EvictionException {
-    UnsafeCacheValue value = new UnsafeCacheValue(10);
-    byte[] buf = "hello world".getBytes();
-    value.write(8, buf, 0, 2);
-
-    assertEquals('h', value.read(8));
-    assertEquals('e', value.read(9));
-    value.release();
-  }
-
-}


Mime
View raw message