Changeset 19675
- Timestamp:
- 02/08/12 11:00:46 (4 months ago)
- Location:
- trunk/Jav_Orient
- Files:
-
- 7 edited
-
src/eu/scenari/orient/tree/impl/BalancedLayout.java (modified) (9 diffs)
-
src/eu/scenari/orient/tree/impl/IBalancingLayout.java (modified) (1 diff)
-
src/eu/scenari/orient/tree/impl/Tree.java (modified) (1 diff)
-
src/eu/scenari/orient/tree/impl/TreeSlot.java (modified) (2 diffs)
-
test/eu/scenari/orient/tree/FactorySequentialLong.java (modified) (2 diffs)
-
test/eu/scenari/orient/tree/TreeBasicTest.java (modified) (2 diffs)
-
test/eu/scenari/orient/tree/perf/MVRBTreePerfTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/BalancedLayout.java
r19672 r19675 55 55 vSlot = vRightSlot; 56 56 } 57 if (vSlot Provider.replace(vCurrentOffset, pKey, pValue)) return;57 if (vSlot.replace(vCurrentOffset, pKey, pValue)) return; 58 58 } else { 59 59 if (-vCurrentOffset - 1 > vSlotProvider.getSize()) { … … 63 63 vSlot = vRightSlot; 64 64 } 65 if (vSlot Provider.insert(-vCurrentOffset - 1, pKey, pValue)) return;65 if (vSlot.insert(-vCurrentOffset - 1, pKey, pValue)) return; 66 66 } 67 67 } … … 83 83 vSlot = vLeftSlot; 84 84 } 85 if (vSlot Provider.replace(vCurrentOffset, pKey, pValue)) return;85 if (vSlot.replace(vCurrentOffset, pKey, pValue)) return; 86 86 } else { 87 87 vCurrentOffset += vMoved; … … 92 92 vSlot = vLeftSlot; 93 93 } 94 if (vSlot Provider.insert(-vCurrentOffset - 1, pKey, pValue)) return;94 if (vSlot.insert(-vCurrentOffset - 1, pKey, pValue)) return; 95 95 } 96 96 } … … 114 114 115 115 //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 } 118 124 //Fifth step : replace or insert K, V 119 125 if (vCurrentOffset >= 0) { … … 124 130 vSlot = vNewSlot; 125 131 } 126 if (vSlot Provider.replace(vCurrentOffset, pKey, pValue)) return;132 if (vSlot.replace(vCurrentOffset, pKey, pValue)) return; 127 133 //failed, try again, more spaces will be added. 128 134 vTree.put(pKey, pValue); 129 135 } else { 130 if (-vCurrentOffset - 1 > vSlotProvider.getSize()) {136 if (-vCurrentOffset - 1 >= vSlotProvider.getSize()) { 131 137 //Must insert in the other slot. 132 138 vCurrentOffset = vCurrentOffset + vSlotProvider.getSize(); … … 134 140 vSlot = vNewSlot; 135 141 } 136 if (vSlot Provider.insert(-vCurrentOffset - 1, pKey, pValue)) return;142 if (vSlot.insert(-vCurrentOffset - 1, pKey, pValue)) return; 137 143 //failed, try again, more spaces will be added. 138 144 vTree.put(pKey, pValue); … … 248 254 249 255 //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 } 251 264 if (vInsertPoint >= vRakeProvider.getSize()) { 252 265 //Must replace in the other rake. … … 321 334 322 335 //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 } 324 344 if (vInsertPoint >= vRakeProvider.getSize()) { 325 345 //Must replace in the other rake. -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/IBalancingLayout.java
r19672 r19675 5 5 public final IBalancingLayout DEFAULT_BALANCED_RANDOM_INSERT = new BalancedLayout(); 6 6 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); 8 8 9 9 /** Call on a put if the target slot is full. */ -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/Tree.java
r19674 r19675 245 245 boolean vResult; 246 246 if (vCurrentOffset >= 0) { 247 vResult = vSlot Provider.replace(vCurrentOffset, pKey, pValue);247 vResult = vSlot.replace(vCurrentOffset, pKey, pValue); 248 248 } else { 249 vResult = vSlot Provider.insert(-vCurrentOffset - 1, pKey, pValue);249 vResult = vSlot.insert(-vCurrentOffset - 1, pKey, pValue); 250 250 } 251 251 if (!vResult) { -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/TreeSlot.java
r19672 r19675 93 93 94 94 public void removeEntry(int pOffset) { 95 assert (pOffset < getProvider().getSize());95 assert (pOffset > 0 && pOffset < getProvider().getSize()); 96 96 if (pOffset == 0 && fProvider.getSize() == 1) { 97 97 //cleanup … … 106 106 } 107 107 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 } 139 129 140 130 } -
trunk/Jav_Orient/test/eu/scenari/orient/tree/FactorySequentialLong.java
r19674 r19675 7 7 import junit.framework.Assert; 8 8 import eu.scenari.commons.util.collections.IteratorBufferedNextBase; 9 import eu.scenari.commons.util.lang.ScException;10 9 11 10 public class FactorySequentialLong implements IKeyFactory<Long>, IValueFactory<Long> { … … 26 25 27 26 public Iterator<Long> unorderedIterator() { 28 throw new ScException("not implemented");27 return null; 29 28 } 30 29 -
trunk/Jav_Orient/test/eu/scenari/orient/tree/TreeBasicTest.java
r19674 r19675 59 59 public class TreeBasicTest extends TestDbAbstract { 60 60 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); 62 63 63 64 public static final StructTree TREE_LONG_LONG = new StructTree(new ExtendedStructId(1, 1), "trreeLongLong").setTreeConfig(TREECONFIG); … … 71 72 @Test 72 73 public void test1() { 73 int vSize = 20000 ;74 int vSize = 200000; 74 75 fDatabase = fDbDriver.acquireDatabase(); 75 76 IRecordStruct<ValueTree<Long, Long>> vRecord = fDatabase.newInstance(); -
trunk/Jav_Orient/test/eu/scenari/orient/tree/perf/MVRBTreePerfTest.java
r19674 r19675 26 26 @Test 27 27 public void test1() { 28 int vSize = 20000 ;28 int vSize = 200000; 29 29 fDatabase = fDbDriver.acquireDatabase(); 30 30
Note: See TracChangeset
for help on using the changeset viewer.