DB { synchronized public <K,V> BTreeMap<K,V> getTreeMap(String name){ checkNotClosed(); BTreeMap<K,V> ret = (BTreeMap<K,V>) getFromWeakCollection(name); if(ret!=null) return ret; Long recid = nameDir.get(name); if(recid!=null){ ret = new BTreeMap<K,V>(engine, recid,defaultSerializer); if(!ret.hasValues) throw new ClassCastException("Collection is Set, not Map"); }else{ ret = new BTreeMap<K,V>(engine,BTreeMap.DEFAULT_MAX_NODE_SIZE, true, false, defaultSerializer, null, null, null); nameDir.put(name, ret.treeRecid); } collections.put(name, new WeakReference<Object>(ret)); return ret; } DB(final Engine engine); synchronized HTreeMap<K,V> getHashMap(String name); synchronized HTreeMap<K,V> createHashMap(
            String name, Serializer<K> keySerializer, Serializer<V> valueSerializer); synchronized Set<K> getHashSet(String name); synchronized Set<K> createHashSet(String name, Serializer<K> serializer); synchronized BTreeMap<K,V> getTreeMap(String name); synchronized BTreeMap<K,V> createTreeMap(
            String name, int nodeSize, boolean valuesStoredOutsideNodes,
            BTreeKeySerializer<K> keySerializer, Serializer<V> valueSerializer, Comparator<K> comparator); Map<String, Long> getNameDir(); synchronized NavigableSet<K> getTreeSet(String name); synchronized NavigableSet<K> createTreeSet(String name, int nodeSize, BTreeKeySerializer<K> serializer, Comparator<K> comparator); synchronized Queue<E> getQueue(String name); synchronized Queue<E> getStack(String name); synchronized Queue<E> getCircularQueue(String name); synchronized Queue<E> createQueue(String name, Serializer<E> serializer); synchronized Queue<E> createStack(String name, Serializer<E> serializer, boolean useLocks); synchronized Queue<E> createCircularQueue(String name, Serializer<E> serializer, long size); synchronized void close(); synchronized boolean isClosed(); synchronized void commit(); synchronized void rollback(); synchronized void compact(); synchronized DB snapshot(); Serializer getDefaultSerializer(); Engine getEngine();  }
@Test public void testGetTreeMap() throws Exception { Map m1 = db.getTreeMap("test"); m1.put(1,2); m1.put(3,4); assertTrue(m1 == db.getTreeMap("test")); assertEquals(m1, new DB(engine).getTreeMap("test")); }