Package krati.core

Examples of krati.core.StoreConfig


* @since 10/03, 2011
*/
public class Utility {
   
    public static DataStore<byte[], byte[]> createStaticDataStore(File storeDir, int capacity) throws Exception {
        StoreConfig config = new StoreConfig(storeDir, capacity);
        config.setSegmentFactory(new MemorySegmentFactory());
        config.setSegmentFileSizeMB(32);
        config.setNumSyncBatches(2);
        config.setBatchSize(100);
       
        return StoreFactory.createStaticDataStore(config);
    }
View Full Code Here


       
        return StoreFactory.createStaticDataStore(config);
    }
   
    public static DataStore<byte[], byte[]> createDynamicDataStore(File storeDir, int capacity) throws Exception {
        StoreConfig config = new StoreConfig(storeDir, capacity);
        config.setSegmentFactory(new MemorySegmentFactory());
        config.setSegmentFileSizeMB(32);
        config.setNumSyncBatches(2);
        config.setBatchSize(100);
       
        return StoreFactory.createDynamicDataStore(config);
    }
View Full Code Here

    }
   
    public void testStoreConfig() throws Exception {
        File dir = FileUtils.getTestDir(getClass().getSimpleName());
       
        StoreConfig config;
        DynamicDataStore store;
       
        config = new StoreConfig(dir, 10000);
        config.setSegmentFileSizeMB(32);
        assertTrue(config.getDataHandler() == null);
        config.setDataHandler(createDataStoreHandler());
        assertTrue(config.getDataHandler() != null);
       
        byte[] key = nextKey();
        byte[] value = nextValue();
        store = new DynamicDataStore(config);
        store.put(key, value);
        assertTrue(Arrays.equals(value, store.get(key)));
        store.close();
       
        StoreConfig config2 = StoreConfig.newInstance(dir);
        if(config.getDataHandler().getClass() != DefaultDataStoreHandler.class) {
            assertTrue(config2.getDataHandler() != null);
            assertEquals(config.getDataHandler().getClass(), config2.getDataHandler().getClass());
        }
       
        store = new DynamicDataStore(config2);
        assertTrue(Arrays.equals(value, store.get(key)));
        store.close();
View Full Code Here

        return new SimpleRetention<String>(config);
    }
   
    @Override
    protected DataStore<String, String> createStore() throws Exception {
        StoreConfig config = new StoreConfig(new File(getHomeDir(), "store"), 10000);
        config.setSegmentFileSizeMB(16);
        config.setNumSyncBatches(10);
        config.setBatchSize(100);
       
        ObjectStoreFactory<String, String> factory = new DynamicObjectStoreFactory<String, String>();
        return factory.create(config, new StringSerializerUtf8(), new StringSerializerUtf8());
    }
View Full Code Here

        assertEquals(0, store.getIndexStart());
        store.clear();
        store.close();
       
        // Use StoreConfig
        StoreConfig config = new StoreConfig(homeDir, length);
        config.setBatchSize(batchSize);
        config.setNumSyncBatches(numSyncBatches);
        config.setSegmentFileSizeMB(segmentFileSizeMB);
        config.setSegmentFactory(segmentFactory);
        config.setSegmentCompactFactor(segmentCompactFactor);
        store = StoreFactory.createStaticArrayStore(config);
       
        assertEquals(length, store.length());
        assertEquals(length, store.capacity());
        assertEquals(0, store.getIndexStart());
View Full Code Here

        assertEquals(0, store.getIndexStart());
        store.clear();
        store.close();
       
        // Use StoreConfig
        StoreConfig config = new StoreConfig(homeDir, initialLength);
        config.setBatchSize(batchSize);
        config.setNumSyncBatches(numSyncBatches);
        config.setSegmentFileSizeMB(segmentFileSizeMB);
        config.setSegmentFactory(segmentFactory);
        config.setSegmentCompactFactor(segmentCompactFactor);
        store = StoreFactory.createDynamicArrayStore(config);
       
        assertEquals(expectedLength, store.length());
        assertEquals(expectedLength, store.capacity());
        assertEquals(0, store.getIndexStart());
View Full Code Here

       
        assertTrue(Arrays.equals(value, store.get(key)));
        store.close();
       
        // Use StoreConfig
        StoreConfig config = new StoreConfig(homeDir, capacity);
        config.setBatchSize(batchSize);
        config.setNumSyncBatches(numSyncBatches);
        config.setSegmentFileSizeMB(segmentFileSizeMB);
        config.setSegmentFactory(segmentFactory);
        config.setSegmentCompactFactor(segmentCompactFactor);
        store = StoreFactory.createStaticDataStore(config);
       
        assertTrue(Arrays.equals(value, store.get(key)));
        store.close();
       
View Full Code Here

       
        assertTrue(Arrays.equals(value, store.get(key)));
        store.close();
       
        // Use StoreConfig
        StoreConfig config = new StoreConfig(homeDir, capacity);
        config.setBatchSize(batchSize);
        config.setNumSyncBatches(numSyncBatches);
        config.setSegmentFileSizeMB(segmentFileSizeMB);
        config.setSegmentFactory(segmentFactory);
        config.setSegmentCompactFactor(segmentCompactFactor);
        config.setHashLoadFactor(hashLoadFactor);
        store = StoreFactory.createDynamicDataStore(config);
       
        assertTrue(Arrays.equals(value, store.get(key)));
        store.close();
       
View Full Code Here

    }
   
    public void testStoreConfig() throws Exception {
        File dir = FileUtils.getTestDir(getClass().getSimpleName());
       
        StoreConfig config;
        DynamicDataStore store;
       
        config = new StoreConfig(dir, 10000);
        config.setSegmentFileSizeMB(32);
        assertTrue(config.getDataHandler() == null);
       
        store = new DynamicDataStore(config);
        store.put("key".getBytes(), "value".getBytes());
        assertTrue(Arrays.equals("value".getBytes(), store.get("key".getBytes())));
        store.close();
       
        config.setDataHandler(new DefaultDataStoreHandler());
        assertTrue(config.getDataHandler() != null);
        config.save();
       
        StoreConfig config2 = new StoreConfig(dir, 10000);
        assertTrue(config2.getDataHandler() == null);
       
        store = new DynamicDataStore(config2);
        assertTrue(Arrays.equals("value".getBytes(), store.get("key".getBytes())));
        store.close();
       
View Full Code Here

public class TestDynamicDataStoreCapacity extends TestCase {
    protected Random _rand = new Random();
   
    protected DynamicDataStore create(int initialCapacity) throws Exception {
        File storeDir = DirUtils.getTestDir(getClass());
        StoreConfig config = new StoreConfig(storeDir, initialCapacity);
        config.setSegmentFactory(new ChannelSegmentFactory());
        config.setSegmentFileSizeMB(16);
        return new DynamicDataStore(config);
    }
View Full Code Here

TOP

Related Classes of krati.core.StoreConfig

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.