diff --git a/src/main/java/org/apache/hadoop/hbase/util/SoftValue.java b/src/main/java/org/apache/hadoop/hbase/util/SoftValue.java deleted file mode 100644 index f81bc98..0000000 --- a/src/main/java/org/apache/hadoop/hbase/util/SoftValue.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2010 The Apache Software Foundation - * - * 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.hadoop.hbase.util; - -import java.lang.ref.ReferenceQueue; -import java.lang.ref.SoftReference; -import java.util.Map; - -/** - * A SoftReference derivative so that we can track down what keys to remove. - */ -class SoftValue extends SoftReference implements Map.Entry { - private final K key; - - @SuppressWarnings("unchecked") - SoftValue(K key, V value, ReferenceQueue queue) { - super(value, queue); - this.key = key; - } - - public K getKey() { - return this.key; - } - - public V getValue() { - return get(); - } - - public V setValue(V value) { - throw new RuntimeException("Not implemented"); - } -} \ No newline at end of file diff --git a/src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java b/src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java index 709892c..4d1a552 100644 --- a/src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java +++ b/src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.util; import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -72,7 +73,7 @@ public class SoftValueSortedMap implements SortedMap { for (Object obj; (obj = this.rq.poll()) != null;) { i++; //noinspection unchecked - this.internalMap.remove(((SoftValue)obj).getKey()); + this.internalMap.remove(((SoftValue)obj).key); } return i; } @@ -171,13 +172,7 @@ public class SoftValueSortedMap implements SortedMap { } public synchronized Set> entrySet() { - checkReferences(); - Set>> entries = this.internalMap.entrySet(); - Set> real_entries = new TreeSet>(); - for(Map.Entry> entry : entries) { - real_entries.add(entry.getValue()); - } - return real_entries; + throw new RuntimeException("Not implemented"); } public synchronized Collection values() { @@ -189,4 +184,13 @@ public class SoftValueSortedMap implements SortedMap { } return hardValues; } + + private static class SoftValue extends SoftReference { + final K key; + + SoftValue(K key, V value, ReferenceQueue q) { + super(value, q); + this.key = key; + } + } }