Changeset 19675


Ignore:
Timestamp:
02/08/12 11:00:46 (4 months ago)
Author:
sys
Message:

Tree en cours...

Location:
trunk/Jav_Orient
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/BalancedLayout.java

    r19672 r19675  
    5555                                                        vSlot = vRightSlot; 
    5656                                                } 
    57                                                 if (vSlotProvider.replace(vCurrentOffset, pKey, pValue)) return; 
     57                                                if (vSlot.replace(vCurrentOffset, pKey, pValue)) return; 
    5858                                        } else { 
    5959                                                if (-vCurrentOffset - 1 > vSlotProvider.getSize()) { 
     
    6363                                                        vSlot = vRightSlot; 
    6464                                                } 
    65                                                 if (vSlotProvider.insert(-vCurrentOffset - 1, pKey, pValue)) return; 
     65                                                if (vSlot.insert(-vCurrentOffset - 1, pKey, pValue)) return; 
    6666                                        } 
    6767                                } 
     
    8383                                                                vSlot = vLeftSlot; 
    8484                                                        } 
    85                                                         if (vSlotProvider.replace(vCurrentOffset, pKey, pValue)) return; 
     85                                                        if (vSlot.replace(vCurrentOffset, pKey, pValue)) return; 
    8686                                                } else { 
    8787                                                        vCurrentOffset += vMoved; 
     
    9292                                                                vSlot = vLeftSlot; 
    9393                                                        } 
    94                                                         if (vSlotProvider.insert(-vCurrentOffset - 1, pKey, pValue)) return; 
     94                                                        if (vSlot.insert(-vCurrentOffset - 1, pKey, pValue)) return; 
    9595                                                } 
    9696                                        } 
     
    114114 
    115115                //Fourth step : balance slot contents 
    116                 vNewSlot.adoptEntriesFromLeft(vSlot, fTargetFillRateForNewRightNode); 
    117  
     116                if (fTargetFillRateForNewRightNode == 0) { 
     117                        if ((-vCurrentOffset - 1) != vSlotProvider.getSize()) { 
     118                                //it's not an append at end, we move some entries. 
     119                                vNewSlot.adoptEntriesFromLeft(vSlot, 0.1f); 
     120                        } 
     121                } else { 
     122                        vNewSlot.adoptEntriesFromLeft(vSlot, fTargetFillRateForNewRightNode); 
     123                } 
    118124                //Fifth step : replace or insert K, V 
    119125                if (vCurrentOffset >= 0) { 
     
    124130                                vSlot = vNewSlot; 
    125131                        } 
    126                         if (vSlotProvider.replace(vCurrentOffset, pKey, pValue)) return; 
     132                        if (vSlot.replace(vCurrentOffset, pKey, pValue)) return; 
    127133                        //failed, try again, more spaces will be added. 
    128134                        vTree.put(pKey, pValue); 
    129135                } else { 
    130                         if (-vCurrentOffset - 1 > vSlotProvider.getSize()) { 
     136                        if (-vCurrentOffset - 1 >= vSlotProvider.getSize()) { 
    131137                                //Must insert in the other slot. 
    132138                                vCurrentOffset = vCurrentOffset + vSlotProvider.getSize(); 
     
    134140                                vSlot = vNewSlot; 
    135141                        } 
    136                         if (vSlotProvider.insert(-vCurrentOffset - 1, pKey, pValue)) return; 
     142                        if (vSlot.insert(-vCurrentOffset - 1, pKey, pValue)) return; 
    137143                        //failed, try again, more spaces will be added. 
    138144                        vTree.put(pKey, pValue); 
     
    248254 
    249255                //Fourth step : balance rake contents 
    250                 vNewRake.adoptEntriesFromLeft(vRake, fTargetFillRateForNewRightNode); 
     256                if (fTargetFillRateForNewRightNode == 0) { 
     257                        if (vInsertPoint != vRakeProvider.getSize()) { 
     258                                //it's not an append at end, we move some entries. 
     259                                vNewRake.adoptEntriesFromLeft(vRake, 0.1f); 
     260                        } 
     261                } else { 
     262                        vNewRake.adoptEntriesFromLeft(vRake, fTargetFillRateForNewRightNode); 
     263                } 
    251264                if (vInsertPoint >= vRakeProvider.getSize()) { 
    252265                        //Must replace in the other rake. 
     
    321334 
    322335                //Fourth step : balance rake contents 
    323                 vNewRake.adoptEntriesFromLeft(vRake, fTargetFillRateForNewRightNode); 
     336                if (fTargetFillRateForNewRightNode == 0) { 
     337                        if (vInsertPoint != vRakeProvider.getSize()) { 
     338                                //it's not an append at end, we move some entries. 
     339                                vNewRake.adoptEntriesFromLeft(vRake, 0.1f); 
     340                        } 
     341                } else { 
     342                        vNewRake.adoptEntriesFromLeft(vRake, fTargetFillRateForNewRightNode); 
     343                } 
    324344                if (vInsertPoint >= vRakeProvider.getSize()) { 
    325345                        //Must replace in the other rake. 
  • trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/IBalancingLayout.java

    r19672 r19675  
    55        public final IBalancingLayout DEFAULT_BALANCED_RANDOM_INSERT = new BalancedLayout(); 
    66 
    7         public final IBalancingLayout DEFAULT_BALANCED_INCREMENTAL_INSERT = new BalancedLayout(0.0f, 0.2f, 0.1f); 
     7        public final IBalancingLayout DEFAULT_BALANCED_INCREMENTAL_INSERT = new BalancedLayout(0.0f, 0.2f, 0.0f); 
    88 
    99        /** Call on a put if the target slot is full. */ 
  • trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/Tree.java

    r19674 r19675  
    245245                boolean vResult; 
    246246                if (vCurrentOffset >= 0) { 
    247                         vResult = vSlotProvider.replace(vCurrentOffset, pKey, pValue); 
     247                        vResult = vSlot.replace(vCurrentOffset, pKey, pValue); 
    248248                } else { 
    249                         vResult = vSlotProvider.insert(-vCurrentOffset - 1, pKey, pValue); 
     249                        vResult = vSlot.insert(-vCurrentOffset - 1, pKey, pValue); 
    250250                } 
    251251                if (!vResult) { 
  • trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/TreeSlot.java

    r19672 r19675  
    9393 
    9494        public void removeEntry(int pOffset) { 
    95                 assert (pOffset < getProvider().getSize()); 
     95                assert (pOffset > 0 && pOffset < getProvider().getSize()); 
    9696                if (pOffset == 0 && fProvider.getSize() == 1) { 
    9797                        //cleanup 
     
    106106        } 
    107107 
    108         //      public boolean balanceWithNextAndPut(TreeSlot<K, V> pNextSlot, int pOffset, K pKey, V pValue) { 
    109         //              ITreeSlotProvider<K, V> vNextSlotProvider = pNextSlot.getProvider(); 
    110         //              boolean vSlotWasDirty = fProvider.isDirty(); 
    111         //              boolean vNextSlotWasDirty = vNextSlotProvider.isDirty(); 
    112         //              int vMoved = vNextSlotProvider.adoptEntriesFromLeft(pSlotProvider); 
    113         //              if (vMoved > 0) { 
    114         //                      //Some entries have been moved. 
    115         //                      if (!vSlotWasDirty) markDirty(pSlotProvider); 
    116         //                      if (!vNextSlotWasDirty) markDirty(vNextSlotProvider); 
    117         //                      TreeRake<K, V> vParent = pNextSlot.getParent(); 
    118         //                      if (vParent != null) vParent.updateKey(pNextSlot.fOffsetInParent, pNextSlot.getProvider().getKey(0)); 
    119         //                      if (pOffset >= 0) { 
    120         //                              if (pOffset >= pSlotProvider.getSize()) { 
    121         //                                      //Must replace in the other slot. 
    122         //                                      pOffset = pOffset - pSlotProvider.getSize(); 
    123         //                                      pSlotProvider = vNextSlotProvider; 
    124         //                                      vSlot = pNextSlot; 
    125         //                              } 
    126         //                              vResult = pSlotProvider.replace(pOffset, pKey, pValue); 
    127         //                      } else { 
    128         //                              if (-pOffset - 1 > pSlotProvider.getSize()) { 
    129         //                                      //Must insert in the other slot. 
    130         //                                      pOffset = pOffset - pSlotProvider.getSize(); 
    131         //                                      pSlotProvider = vNextSlotProvider; 
    132         //                                      vSlot = pNextSlot; 
    133         //                              } 
    134         //                              vResult = pSlotProvider.insertBefore(-pOffset - 1, pKey, pValue); 
    135         //                      } 
    136         //              } 
    137         //              return vResult; 
    138         //      } 
     108        public boolean insert(int pOffset, K pKey, V pValue) { 
     109                assert (pOffset >= 0 && pOffset <= getProvider().getSize()); 
     110                if (getProvider().insert(pOffset, pKey, pValue)) { 
     111                        if (pOffset == 0 && fParent != null) { 
     112                                fParent.updateKey(fOffsetInParent, pKey); 
     113                        } 
     114                        return true; 
     115                } 
     116                return false; 
     117        } 
     118 
     119        public boolean replace(int pOffset, K pKey, V pValue) { 
     120                assert (pOffset >= 0 && pOffset < getProvider().getSize()); 
     121                if (getProvider().replace(pOffset, pKey, pValue)) { 
     122                        if (pOffset == 0 && fParent != null) { 
     123                                fParent.updateKey(fOffsetInParent, pKey); 
     124                        } 
     125                        return true; 
     126                } 
     127                return false; 
     128        } 
    139129 
    140130} 
  • trunk/Jav_Orient/test/eu/scenari/orient/tree/FactorySequentialLong.java

    r19674 r19675  
    77import junit.framework.Assert; 
    88import eu.scenari.commons.util.collections.IteratorBufferedNextBase; 
    9 import eu.scenari.commons.util.lang.ScException; 
    109 
    1110public class FactorySequentialLong implements IKeyFactory<Long>, IValueFactory<Long> { 
     
    2625 
    2726        public Iterator<Long> unorderedIterator() { 
    28                 throw new ScException("not implemented"); 
     27                return null; 
    2928        } 
    3029 
  • trunk/Jav_Orient/test/eu/scenari/orient/tree/TreeBasicTest.java

    r19674 r19675  
    5959public class TreeBasicTest extends TestDbAbstract { 
    6060 
    61         public static final TreeStorageConfig TREECONFIG = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(false).setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_INCREMENTAL_INSERT); 
     61        public static final TreeStorageConfig TREECONFIG = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(false).setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_INCREMENTAL_INSERT) 
     62                        .setRakeCapacity(256).setSlotCapacity(256); 
    6263 
    6364        public static final StructTree TREE_LONG_LONG = new StructTree(new ExtendedStructId(1, 1), "trreeLongLong").setTreeConfig(TREECONFIG); 
     
    7172        @Test 
    7273        public void test1() { 
    73                 int vSize = 20000; 
     74                int vSize = 200000; 
    7475                fDatabase = fDbDriver.acquireDatabase(); 
    7576                IRecordStruct<ValueTree<Long, Long>> vRecord = fDatabase.newInstance(); 
  • trunk/Jav_Orient/test/eu/scenari/orient/tree/perf/MVRBTreePerfTest.java

    r19674 r19675  
    2626        @Test 
    2727        public void test1() { 
    28                 int vSize = 20000; 
     28                int vSize = 200000; 
    2929                fDatabase = fDbDriver.acquireDatabase(); 
    3030 
Note: See TracChangeset for help on using the changeset viewer.