Package krati.util

Examples of krati.util.LinearHashing


                _config.getNumSyncBatches(),
                _config.getIndexesCached());
        _unitCapacity = DynamicConstants.SUB_ARRAY_SIZE;
       
        // Compute maxLevel
        LinearHashing h = new LinearHashing(_unitCapacity);
        h.reinit(Integer.MAX_VALUE);
        _maxLevel = h.getLevel();
       
        int initLevel = StoreParams.getDynamicStoreInitialLevel(_config.getInitialCapacity());
        if(initLevel > _maxLevel) {
            _log.warn("initLevel reset from " + initLevel + " to " + _maxLevel);
            initLevel = _maxLevel;
View Full Code Here


                          SegmentFactory segmentFactory,
                          double segmentCompactFactor,
                          double hashLoadFactor,
                          HashFunction<byte[]> hashFunction) throws Exception {
        // Compute maxLevel
        LinearHashing h = new LinearHashing(DynamicConstants.SUB_ARRAY_SIZE);
        h.reinit(Integer.MAX_VALUE);
        _maxLevel = h.getLevel();
       
        // Compute initialCapacity
        int initialCapacity = DynamicConstants.SUB_ARRAY_SIZE;
        if(initLevel >= 0) {
            if(initLevel > _maxLevel) {
View Full Code Here

        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
View Full Code Here

                _config.getNumSyncBatches(),
                _config.getIndexesCached());
        _unitCapacity = DynamicConstants.SUB_ARRAY_SIZE;
       
        // Compute maxLevel
        LinearHashing h = new LinearHashing(_unitCapacity);
        h.reinit(Integer.MAX_VALUE);
        _maxLevel = h.getLevel();
       
        int initLevel = StoreParams.getDynamicStoreInitialLevel(_config.getInitialCapacity());
        if(initLevel > _maxLevel) {
            _log.warn("initLevel reset from " + initLevel + " to " + _maxLevel);
            initLevel = _maxLevel;
View Full Code Here

                            SegmentFactory segmentFactory,
                            double segmentCompactFactor,
                            double hashLoadFactor,
                            HashFunction<byte[]> hashFunction) throws Exception {
        // Compute maxLevel
        LinearHashing h = new LinearHashing(DynamicConstants.SUB_ARRAY_SIZE);
        h.reinit(Integer.MAX_VALUE);
        _maxLevel = h.getLevel();
       
        // Compute initialCapacity
        int initialCapacity = DynamicConstants.SUB_ARRAY_SIZE;
        if(initLevel >= 0) {
            if(initLevel > _maxLevel) {
View Full Code Here

        assertEquals(1 << 30, h.getLevelCapacity());
    }
   
    public void testRandom() {
        int unitCapacity = 1 << DynamicConstants.SUB_ARRAY_BITS;
        LinearHashing h = new LinearHashing(unitCapacity);
        assertEquals(unitCapacity, h.getUnitCapacity());
       
        for(int level = 0; level < 11; level++) {
            check(h, level);
        }
    }
View Full Code Here

        }
    }
   
    public void testMaxLevel() {
        int unitCapacity = DynamicConstants.SUB_ARRAY_SIZE;
        LinearHashing h = new LinearHashing(unitCapacity);
        h.reinit(Integer.MAX_VALUE);
        assertEquals(14, h.getLevel());
        assertEquals(1 << 30, h.getLevelCapacity());
    }
View Full Code Here

     * @param initialLevel - the initial level of store, which should be in the range [0, 15).
     * @return the initial capacity of a dynamic store.
     */
    public static final int getDynamicStoreInitialCapacity(int initialLevel) {
        // Compute maxLevel
        LinearHashing h = new LinearHashing(DynamicConstants.SUB_ARRAY_SIZE);
        h.reinit(Integer.MAX_VALUE);
        int maxLevel = h.getLevel();
       
        // Compute initialCapacity
        int initialCapacity = DynamicConstants.SUB_ARRAY_SIZE;
        if(initialLevel > 0) {
            if(initialLevel > maxLevel) {
View Full Code Here

public class TestLinearHashing extends TestCase {
   
    public void testBasics() {
        int capacity;
        int unitCapacity = DynamicConstants.SUB_ARRAY_SIZE;
        LinearHashing h = new LinearHashing(unitCapacity);
        assertEquals(unitCapacity, h.getUnitCapacity());
       
        assertEquals(0, h.getSplit());
        assertEquals(0, h.getLevel());
        assertEquals(unitCapacity, h.getLevelCapacity());
       
        capacity = unitCapacity;
        assertEquals(0, h.getSplit());
        assertEquals(0, h.getLevel());
        assertEquals(unitCapacity, h.getLevelCapacity());
       
        capacity = unitCapacity << 1;
        h.reinit(capacity);
        assertEquals(0, h.getSplit());
        assertEquals(0, h.getLevel());
        assertEquals(unitCapacity, h.getLevelCapacity());
       
        capacity = unitCapacity << 2;
        h.reinit(capacity);
        assertEquals(unitCapacity, h.getSplit());
        assertEquals(1, h.getLevel());
        assertEquals(unitCapacity << 1, h.getLevelCapacity());
       
        capacity = unitCapacity << 3;
        h.reinit(capacity);
        assertEquals((unitCapacity << 2) - unitCapacity, h.getSplit());
        assertEquals(2, h.getLevel());
        assertEquals(unitCapacity << 2, h.getLevelCapacity());
       
        capacity = (unitCapacity << 3) - 1;
        h.reinit(capacity);
        assertEquals((unitCapacity << 2) - 2 * unitCapacity, h.getSplit());
        assertEquals(2, h.getLevel());
        assertEquals(unitCapacity << 2, h.getLevelCapacity());

        capacity = (unitCapacity << 3) - unitCapacity + 1;
        h.reinit(capacity);
        assertEquals((unitCapacity << 2) - 2 * unitCapacity, h.getSplit());
        assertEquals(2, h.getLevel());
        assertEquals(unitCapacity << 2, h.getLevelCapacity());
       
        capacity = (unitCapacity << 3) - unitCapacity;
        h.reinit(capacity);
        assertEquals((unitCapacity << 2) - 2 * unitCapacity, h.getSplit());
        assertEquals(2, h.getLevel());
        assertEquals(unitCapacity << 2, h.getLevelCapacity());
       
        capacity = Integer.MAX_VALUE;
        h.reinit(capacity);
        assertEquals((1 << 30) - (unitCapacity << 1), h.getSplit());
        assertEquals(14, h.getLevel());
        assertEquals(1 << 30, h.getLevelCapacity());
    }
View Full Code Here

TOP

Related Classes of krati.util.LinearHashing

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.