Package krati.store

Examples of krati.store.DynamicDataStore


                              double hashLoadFactor,
                              int initLevel,
                              File dataDirectory) {
        super(name);
        try {
            this.datastore = new DynamicDataStore(dataDirectory,
                                                  initLevel,
                                                  segmentFileSizeMB,
                                                  segmentFactory,
                                                  hashLoadFactor,
                                                  new FnvHashFunction());
View Full Code Here


        try {
            StoreConfig storeConfig = new StoreConfig(homeDir, initialCapacity);
            storeConfig.setSegmentFactory(segmentFactory);
            storeConfig.setHashFunction(hashFunction);
            storeConfig.setSegmentFileSizeMB(segmentFileSize);
            DataStore<byte[], byte[]> dynamicDataStore = new DynamicDataStore(storeConfig);
            result = new SerializableObjectStore<K, V>(dynamicDataStore, keySerializer, valueSerializer);
        } catch (Exception e) {
            throw new RuntimeCamelException("Failed to create Krati DataStore.", e);
        }
        return result;
View Full Code Here

        try {
            StoreConfig storeConfig = new StoreConfig(homeDir, initialCapacity);
            storeConfig.setSegmentFactory(segmentFactory);
            storeConfig.setHashFunction(hashFunction);
            storeConfig.setSegmentFileSizeMB(segmentFileSize);
            DataStore<byte[], byte[]> dynamicDataStore = new DynamicDataStore(storeConfig);
            result = new SerializableObjectStore<K, V>(dynamicDataStore, keySerializer, valueSerializer);
        } catch (Exception e) {
            throw new RuntimeCamelException("Failed to create Krati DataStore.", e);
        }
        return result;
View Full Code Here

     *
     * @param config - HashIndex configuration
     * @throws Exception if the index cannot be created.
     */
    public HashIndex(StoreConfig config) throws Exception {
        _store = new DynamicDataStore(config);
        _logger.info("init " + config.getHomeDir().getPath());
    }
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();
       
        FileUtils.deleteDirectory(dir);
    }
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 = "key".getBytes();
        byte[] value = randomValue();
        store = new DynamicDataStore(config);
        store.put(key, value);
        assertTrue(Arrays.equals(value, store.get(key)));
        store.close();
       
        StoreConfig config2 = StoreConfig.newInstance(dir);
        assertTrue(config2.getDataHandler() != null);
        assertEquals(config.getDataHandler().getClass(), config2.getDataHandler().getClass());
       
        store = new DynamicDataStore(config2);
        assertTrue(Arrays.equals(value, store.get(key)));
        store.close();
       
        FileUtils.deleteDirectory(dir);
    }
View Full Code Here

   
    public void testMaxCapacity() throws Exception {
        StoreConfig config = new StoreConfig(getHomeDir(), Integer.MAX_VALUE);
        config.setIndexesCached(false); // Do not cache indexes in memory
       
        DynamicDataStore store = StoreFactory.createDynamicDataStore(config);
       
        // Compute maxLevel
        LinearHashing h = new LinearHashing(DynamicConstants.SUB_ARRAY_SIZE);
        h.reinit(Integer.MAX_VALUE);
        int maxLevel = h.getLevel();
       
        // Check store initLevel
        assertEquals(maxLevel, store.getLevel());
       
        // Check store capacity
        int capacityExpected = DynamicConstants.SUB_ARRAY_SIZE << maxLevel;
        assertEquals(capacityExpected, store.capacity());
        assertEquals(capacityExpected, store.getDataArray().length());
       
        store.close();
    }
View Full Code Here

*/
public class TestDynamicDataStoreIterator extends AbstractTestDataStoreIterator {
   
    @Override
    protected DataStore<byte[], byte[]> createStore(File homeDir) throws Exception {
        return new DynamicDataStore(
                homeDir,
                1,     /* initLevel */
                100,   /* batchSize */
                5,     /* numSyncBatches */
                32,    /* segmentFileSizeMB */
 
View Full Code Here

*/
public class TestDynamicDataStoreApi extends AbstractTestDataStoreApi {

    @Override
    protected DataStore<byte[], byte[]> createStore(File homeDir) throws Exception {
        return new DynamicDataStore(
                homeDir,
                1,     /* initLevel */
                100,   /* batchSize */
                5,     /* numSyncBatches */
                32,    /* segmentFileSizeMB */
 
View Full Code Here

     * @param config - DataStore configuration
     * @return A dynamic DataStore with growing capacity as needed.
     * @throws Exception if the store cannot be created.
     */
    public static DynamicDataStore createDynamicDataStore(StoreConfig config) throws Exception {
        return new DynamicDataStore(config);
    }
View Full Code Here

TOP

Related Classes of krati.store.DynamicDataStore

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.