// Path: hawtdb/src/main/java/org/fusesource/hawtdb/internal/page/LFUPageCache.java
// public class LFUPageCache<Integer, Value> implements PageCache<Integer, Value> {
//     
//     private final LFUCache<Integer, Value> cache;
// 
//     public LFUPageCache(int maxCacheSize, float evictionFactor) {
//         cache = new LFUCache<Integer, Value>(maxCacheSize, evictionFactor);
//     }
// 
//     synchronized public void put(Integer k, Value v) {
//         cache.put(k, v);
//     }
// 
//     synchronized public Value get(Integer k) {
//         return cache.get(k);
//     }
// 
//     synchronized public Value remove(Integer k) {
//         return cache.remove(k);
//     }
// 
//     synchronized public void clear() {
//         cache.clear();
//     }
// 
//     synchronized public int size() {
//         return cache.size();
//     }
// }


import org.fusesource.hawtbuf.codec.LongCodec;
import org.fusesource.hawtdb.api.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import org.fusesource.hawtdb.internal.page.LFUPageCache;
import static org.junit.Assert.assertEquals;
/**
 * 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.fusesource.hawtdb.internal.index;





/**
 * Tests an Index
 *
 * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
 */
public class BTreeCacheTest {

    protected TxPageFileFactory pff;
    protected TxPageFile pf;
    protected BTreeIndexFactory<Long,Long> factory;


    protected TxPageFileFactory createConcurrentPageFileFactory() {
        TxPageFileFactory rc = new TxPageFileFactory();
        rc.setFile(new File("target/test-data/" + getClass().getName() + ".db"));
        rc.setPageSize((short) 512);
        rc.setPageCache(new LFUPageCache(1000, 0.5f));
        return rc;
    }

    @Before
    public void setup() {
        pff = createConcurrentPageFileFactory();
        pff.getFile().delete();
        pff.open();
        pf = pff.getTxPageFile();

        factory = new BTreeIndexFactory<Long,Long>();
        factory.setKeyCodec(LongCodec.INSTANCE);
        factory.setValueCodec(LongCodec.INSTANCE);
        factory.setDeferredEncoding(true);
    }

    @After
    public void tearDown() throws Exception {
// Path: hawtdb/src/main/java/org/fusesource/hawtdb/internal/page/LFUPageCache.java
// public class LFUPageCache<Integer, Value> implements PageCache<Integer, Value> {
//     
//     private final LFUCache<Integer, Value> cache;
// 
//     public LFUPageCache(int maxCacheSize, float evictionFactor) {
//         cache = new LFUCache<Integer, Value>(maxCacheSize, evictionFactor);
//     }
// 
//     synchronized public void put(Integer k, Value v) {
//         cache.put(k, v);
//     }
// 
//     synchronized public Value get(Integer k) {
//         return cache.get(k);
//     }
// 
//     synchronized public Value remove(Integer k) {
//         return cache.remove(k);
//     }
// 
//     synchronized public void clear() {
//         cache.clear();
//     }
// 
//     synchronized public int size() {
//         return cache.size();
//     }
// }


// Path: hawtdb/src/test/java/org/fusesource/hawtdb/internal/index/BTreeCacheTest.java
import org.fusesource.hawtbuf.codec.LongCodec;
import org.fusesource.hawtdb.api.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import org.fusesource.hawtdb.internal.page.LFUPageCache;
import static org.junit.Assert.assertEquals;

/**
 * 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.fusesource.hawtdb.internal.index;





/**
 * Tests an Index
 *
 * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
 */
public class BTreeCacheTest {

    protected TxPageFileFactory pff;
    protected TxPageFile pf;
    protected BTreeIndexFactory<Long,Long> factory;


    protected TxPageFileFactory createConcurrentPageFileFactory() {
        TxPageFileFactory rc = new TxPageFileFactory();
        rc.setFile(new File("target/test-data/" + getClass().getName() + ".db"));
        rc.setPageSize((short) 512);
        rc.setPageCache(new LFUPageCache(1000, 0.5f));
        return rc;
    }

    @Before
    public void setup() {
        pff = createConcurrentPageFileFactory();
        pff.getFile().delete();
        pff.open();
        pf = pff.getTxPageFile();

        factory = new BTreeIndexFactory<Long,Long>();
        factory.setKeyCodec(LongCodec.INSTANCE);
        factory.setValueCodec(LongCodec.INSTANCE);
        factory.setDeferredEncoding(true);
    }

    @After
    public void tearDown() throws Exception {
        if( pf!=null ) {