Package krati.store

Examples of krati.store.ArrayStore


     * @throws IOException if the store cannot be created.
     */
    @Override
    public ObjectStore<Integer, V> create(StoreConfig config, Serializer<Integer> keySerializer, Serializer<V> valueSerializer) throws IOException {
        try {
            ArrayStore base =  (config instanceof StorePartitionConfig) ?
                               StoreFactory.createArrayStorePartition((StorePartitionConfig)config) :
                               StoreFactory.createStaticArrayStore(config);
            return new SerializableObjectArray<V>(base, keySerializer, valueSerializer);
        } catch (Exception e) {
            if(e instanceof IOException) {
View Full Code Here


     * @throws IOException if the store cannot be created.
     */
    @Override
    public ObjectStore<Integer, V> create(StoreConfig config, Serializer<Integer> keySerializer, Serializer<V> valueSerializer) throws IOException {
        try {
            ArrayStore base = StoreFactory.createDynamicArrayStore(config);
            return new SerializableObjectArray<V>(base, keySerializer, valueSerializer);
        } catch (Exception e) {
            if(e instanceof IOException) {
                throw (IOException)e;
            } else {
View Full Code Here

        return getIndexStart() + _rand.nextInt(_store.capacity());
    }
   
    protected SerializableObjectArray<String> createStore(File homeDir) throws Exception {
        StoreConfig config = new StoreConfig(homeDir, 1000);
        ArrayStore arrayStore = StoreFactory.createDynamicArrayStore(config);
        return new SerializableObjectArray<String>(arrayStore, new StringSerializerUtf8());
    }
View Full Code Here

        }
    }
   
    public void testStaticArrayStoreFactory() throws IOException {
        ArrayStoreFactory storeFactory = new StaticArrayStoreFactory();
        ArrayStore store = storeFactory.create(_config);
        assertEquals(StaticDataArray.class, store.getClass());
        store.close();
    }
View Full Code Here

        store.close();
    }
   
    public void testDynamicDataStoreFactory() throws IOException {
        ArrayStoreFactory storeFactory = new DynamicArrayStoreFactory();
        ArrayStore store = storeFactory.create(_config);
        assertEquals(DynamicDataArray.class, store.getClass());
        store.close();
    }
View Full Code Here

   
    public void testStaticArrayStorePartitionFactory() throws IOException {
        setUpStorePartitionConfig();
       
        ArrayStoreFactory storeFactory = new StaticArrayStoreFactory();
        ArrayStore store = storeFactory.create(_config);
        assertEquals(StaticArrayStorePartition.class, store.getClass());
       
        StaticArrayStorePartition p = (StaticArrayStorePartition)store;
        assertEquals(p.capacity(), p.length());
        assertEquals(p.capacity(), store.capacity());
        assertEquals(p.capacity(), _config.getInitialCapacity());
        assertEquals(p.getIndexStart(), ((StorePartitionConfig)_config).getPartitionStart());
       
        store.close();
    }
View Full Code Here

        StoreResponderFactory responderFactory = new BasicArrayStoreResponderFactory(storeFactory);
        MultiTenantStoreResponder mtStoreResponder = new MultiTenantStoreResponder(homeDir, configTemplate, responderFactory);
       
        String source;
        StoreResponder responder;
        ArrayStore baseStore;
        Serializer<Integer> keySerializer = new IntSerializer();
        Map<String, AvroStore<Integer>> map = new HashMap<String, AvroStore<Integer>>();
       
        // Create "Person" AvroStore
        source = "Person";
View Full Code Here

        SegmentFactory segmentFactory = new MappedSegmentFactory();
       
        /**
         * StaticArrayStore does not change length after the store has been created.
         */
        ArrayStore store = StoreFactory.createStaticArrayStore(
                homeDir,
                length,
                segmentFileSizeMB,
                segmentFactory);
       
        assertEquals(length, store.length());
        assertEquals(length, store.capacity());
        assertEquals(0, store.getIndexStart());
        store.clear();
        store.close();
       
        // Smaller length has no impact
        int smallerLength = length - 500;
        store = StoreFactory.createStaticArrayStore(
                homeDir,
                smallerLength,
                batchSize,
                numSyncBatches,
                segmentFileSizeMB,
                segmentFactory);
       
        assertEquals(length, store.length());
        assertEquals(length, store.capacity());
        assertEquals(0, store.getIndexStart());
        store.clear();
        store.close();
       
        // Larger length has no impact
        int largerLength = length + 500;
        store = StoreFactory.createStaticArrayStore(
                homeDir,
                largerLength,
                batchSize,
                numSyncBatches,
                segmentFileSizeMB,
                segmentFactory,
                segmentCompactFactor);
       
        assertEquals(length, store.length());
        assertEquals(length, store.capacity());
        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());
        store.clear();
        store.close();
       
        FileUtils.deleteDirectory(homeDir);
    }
View Full Code Here

        SegmentFactory segmentFactory = new MappedSegmentFactory();
       
        /**
         * DynamicArrayStore only grows its capacity/length after the store has been created.
         */
        ArrayStore store = StoreFactory.createDynamicArrayStore(
                homeDir,
                initialLength,
                segmentFileSizeMB,
                segmentFactory);
       
        assertEquals(initialLength, store.length());
        assertEquals(initialLength, store.capacity());
        assertEquals(0, store.getIndexStart());
        store.clear();
        store.close();
       
        // Smaller length has no impact
        int smallerLength = initialLength - 500;
        store = StoreFactory.createDynamicArrayStore(
                homeDir,
                smallerLength,
                batchSize,
                numSyncBatches,
                segmentFileSizeMB,
                segmentFactory);
       
        assertEquals(initialLength, store.length());
        assertEquals(initialLength, store.capacity());
        assertEquals(0, store.getIndexStart());
        store.clear();
        store.close();
       
        // Larger length caused the store to grow capacity
        int largerLength = initialLength + 500;
        int expectedLength = initialLength + DynamicConstants.SUB_ARRAY_SIZE;
        store = StoreFactory.createDynamicArrayStore(
                homeDir,
                largerLength,
                batchSize,
                numSyncBatches,
                segmentFileSizeMB,
                segmentFactory,
                segmentCompactFactor);
       
        assertEquals(expectedLength, store.length());
        assertEquals(expectedLength, store.capacity());
        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());
        store.clear();
        store.close();
       
        FileUtils.deleteDirectory(homeDir);
    }
View Full Code Here

        this._storeFactory = storeFactory;
    }
   
    @Override
    public BasicArrayStoreResponder createResponder(StoreConfig config) throws Exception {
        ArrayStore store = _storeFactory.create(config);
        return new BasicArrayStoreResponder(store);
    }
View Full Code Here

TOP

Related Classes of krati.store.ArrayStore

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.