Package krati.store

Examples of krati.store.ArrayStorePartition


 
  public static <E extends Element> ArrayStoreElement<E> createElementStorePartition(File storeHomeDir, int idStart, int idCount, SegmentFactory segmentFactory, int segmentFileSizeMB, ElementSerializer<E> serializer)
  throws Exception {
    int batchSize = 5000;
    int numSyncBatches = 20;
    ArrayStorePartition p = new StaticArrayStorePartition(idStart, idCount, batchSize, numSyncBatches, storeHomeDir, segmentFactory, segmentFileSizeMB, false);
    return new KratiArrayStoreElement<E>(p, serializer);
  }
View Full Code Here


        int count = length;
       
        /**
         * ArrayStorePartition does not change length after the store has been created.
         */
        ArrayStorePartition store = StoreFactory.createArrayStorePartition(
                homeDir,
                start,
                count,
                segmentFileSizeMB,
                segmentFactory);
       
        assertEquals(length, store.length());
        assertEquals(length, store.capacity());
        assertEquals(start, store.getIndexStart());
        store.clear();
        store.close();
       
        // Fail on smaller capacity
        int smallerCapacity = length - 500;
        try {
            store = StoreFactory.createArrayStorePartition(
                homeDir,
                start,
                smallerCapacity,
                batchSize,
                numSyncBatches,
                segmentFileSizeMB,
                segmentFactory);
            assertFalse(true);
        } catch(IOException e) {}
       
        // Fail on larger capacity
        int largerCapacity = length + 500;
        try {
            store = StoreFactory.createArrayStorePartition(
                homeDir,
                start,
                largerCapacity,
                batchSize,
                numSyncBatches,
                segmentFileSizeMB,
                segmentFactory,
                segmentCompactFactor);
            assertFalse(true);
        } catch(IOException e) {}
       
        store = StoreFactory.createArrayStorePartition(
                homeDir,
                start,
                count,
                batchSize,
                numSyncBatches,
                segmentFileSizeMB,
                segmentFactory,
                segmentCompactFactor);
       
        assertEquals(length, store.length());
        assertEquals(length, store.capacity());
        assertEquals(start, store.getIndexStart());
        store.clear();
        store.close();
       
        // Use StoreConfig
        StorePartitionConfig config = new StorePartitionConfig(homeDir, start, count);
        config.setBatchSize(batchSize);
        config.setNumSyncBatches(numSyncBatches);
        config.setSegmentFileSizeMB(segmentFileSizeMB);
        config.setSegmentFactory(segmentFactory);
        config.setSegmentCompactFactor(segmentCompactFactor);
        store = StoreFactory.createArrayStorePartition(config);
       
        assertEquals(length, store.length());
        assertEquals(length, store.capacity());
        assertEquals(start, store.getIndexStart());
        store.clear();
        store.close();
       
        FileUtils.deleteDirectory(homeDir);
    }
View Full Code Here

    protected SegmentFactory getSegmentFactory() {
        return new krati.core.segment.MemorySegmentFactory();
    }
   
    protected ArrayStorePartition getDataPartition(File homeDir) throws Exception {
        ArrayStorePartition partition =
            new StaticArrayStorePartition(_idStart,
                                          _idCount,
                                          homeDir,
                                          getSegmentFactory(),
                                          _segFileSizeMB);
View Full Code Here

       
        TestDataPartition eval = new TestDataPartition();
       
        try {
            File homeDir = getHomeDirectory();
            ArrayStorePartition partition = getDataPartition(homeDir);
           
            if (partition.getLWMark() == 0) {
                StatsLog.logger.info(">>> populate");
                eval.populate(partition);

                StatsLog.logger.info(">>> validate");
                validate(partition);
            }
           
            int timeAllocated = Math.round((float)_runTimeSeconds/3);
           
            StatsLog.logger.info(">>> read only");
            evalRead(partition, _numReaders, Math.min(timeAllocated, 10));
           
            StatsLog.logger.info(">>> write only");
            evalWrite(partition, timeAllocated);
            partition.persist();
           
            StatsLog.logger.info(">>> validate");
            validate(partition);
           
            StatsLog.logger.info(">>> read & write");
            evalReadWrite(partition, _numReaders, timeAllocated, false);
            partition.persist();
           
            StatsLog.logger.info(">>> validate");
            validate(partition);
           
            StatsLog.logger.info(">>> check & write");
            evalReadWrite(partition, _numReaders, timeAllocated, true);
            partition.persist();
           
            StatsLog.logger.info(">>> validate");
            validate(partition);
           
            partition.sync();
        } catch (Exception e) {
            e.printStackTrace();
        }
       
        cleanTestOutput();
View Full Code Here

TOP

Related Classes of krati.store.ArrayStorePartition

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.