Package org.apache.lucene.store.bytebuffer

Examples of org.apache.lucene.store.bytebuffer.ByteBufferDirectory


*/
public class SimpleByteBufferStoreTests {

    @Test public void test1BufferNoCache() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(1, 0, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 1);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here


        cache.close();
    }

    @Test public void test1Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(1, 10, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 1);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        cache.close();
    }

    @Test public void test3Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(3, 10, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 3);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        cache.close();
    }

    @Test public void test10Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(10, 20, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 10);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        cache.close();
    }

    @Test public void test15Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(15, 30, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 15);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        cache.close();
    }

    @Test public void test40Buffer() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(40, 80, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);
        insertData(dir, 40);
        verifyData(dir);
        dir.close();
        cache.close();
    }
View Full Code Here

        cache.close();
    }

    @Test public void testSimpleLocking() throws Exception {
        ByteBufferCache cache = new ByteBufferCache(40, 80, true);
        ByteBufferDirectory dir = new ByteBufferDirectory(cache);

        Lock lock = dir.makeLock("testlock");

        assertThat(lock.isLocked(), equalTo(false));
        assertThat(lock.obtain(200), equalTo(true));
        assertThat(lock.isLocked(), equalTo(true));
        try {
            assertThat(lock.obtain(200), equalTo(false));
            assertThat("lock should be thrown", false, equalTo(true));
        } catch (LockObtainFailedException e) {
            // all is well
        }
        lock.release();
        assertThat(lock.isLocked(), equalTo(false));
        dir.close();
        cache.close();
    }
View Full Code Here

    protected Tuple<SwitchDirectory, Boolean> buildSwitchDirectoryIfNeeded(Directory fsDirectory, ByteBufferCache byteBufferCache) {
        boolean cache = componentSettings.getAsBoolean("memory.enabled", false);
        if (!cache) {
            return null;
        }
        Directory memDir = new ByteBufferDirectory(byteBufferCache);
        // see http://lucene.apache.org/java/3_0_1/fileformats.html
        String[] primaryExtensions = componentSettings.getAsArray("memory.extensions", new String[]{"", "del", "gen"});
        if (primaryExtensions == null || primaryExtensions.length == 0) {
            return null;
        }
View Full Code Here

TOP

Related Classes of org.apache.lucene.store.bytebuffer.ByteBufferDirectory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.