Changeset 19674
- Timestamp:
- 02/08/12 09:39:42 (4 months ago)
- Location:
- trunk/Jav_Orient
- Files:
-
- 1 added
- 7 edited
-
src/eu/scenari/orient/recordstruct/lib/base/StructList.java (modified) (1 diff)
-
src/eu/scenari/orient/recordstruct/value/ValueListImmutableFixed.java (modified) (4 diffs)
-
src/eu/scenari/orient/tree/impl/Tree.java (modified) (2 diffs)
-
src/eu/scenari/orient/tree/impl/TreeNode.java (modified) (1 diff)
-
src/eu/scenari/orient/tree/impl/TreeRake.java (modified) (2 diffs)
-
test/eu/scenari/orient/tree/FactorySequentialLong.java (modified) (3 diffs)
-
test/eu/scenari/orient/tree/TreeBasicTest.java (modified) (5 diffs)
-
test/eu/scenari/orient/tree/perf/MVRBTreePerfTest.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/lib/base/StructList.java
r19672 r19674 49 49 import eu.scenari.orient.recordstruct.struct.StructAbstract; 50 50 51 public class StructList extends StructAbstract<ValueList > implements IStructList<ValueList> {51 public class StructList extends StructAbstract<ValueList<?>> implements IStructList<ValueList<?>> { 52 52 53 53 public StructList(int pCoreStructId) { -
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/value/ValueListImmutableFixed.java
r19672 r19674 86 86 87 87 public E get(int pIndex) { 88 assert (pIndex >= 0 && pIndex < fToIndex); 88 89 return ValueListImmutableFixed.this.get(fFromIndex + pIndex); 89 90 } … … 105 106 106 107 public void add(int pIndex, E pElt) { 108 assert (pIndex >= 0 && pIndex <= fToIndex); 107 109 fToIndex++; 108 110 ValueListImmutableFixed.this.add(fFromIndex + pIndex, pElt); … … 110 112 111 113 public boolean addAll(int pIndex, Collection<? extends E> pC) { 114 assert (pIndex >= 0 && pIndex <= fToIndex); 112 115 fToIndex += pC.size(); 113 116 return ValueListImmutableFixed.this.addAll(fFromIndex + pIndex, pC); … … 115 118 116 119 public E set(int pIndex, E pElement) { 120 assert (pIndex >= 0 && pIndex < fToIndex); 117 121 return ValueListImmutableFixed.this.set(fFromIndex + pIndex, pElement); 118 122 } 119 123 120 124 public E remove(int pIndex) { 125 assert (pIndex >= 0 && pIndex < fToIndex); 121 126 fToIndex--; 122 127 return ValueListImmutableFixed.this.remove(fFromIndex + pIndex); -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/Tree.java
r19672 r19674 228 228 229 229 public V get(Object pKey) { 230 return fRoot.findSlot(pKey).get(pKey); 230 TreeSlot<K, V> vSlot = fRoot.findSlot(pKey); 231 return vSlot != null ? vSlot.get(pKey) : null; 231 232 } 232 233 233 234 public boolean containsKey(Object pKey) { 234 return fRoot.findSlot(pKey).indexOf(pKey) >= 0; 235 TreeSlot<K, V> vSlot = fRoot.findSlot(pKey); 236 return vSlot != null ? vSlot.indexOf(pKey) >= 0 : false; 235 237 } 236 238 237 239 public V put(K pKey, V pValue) { 238 240 TreeSlot<K, V> vSlot = fRoot.findSlot(pKey); 241 if (vSlot == null) vSlot = fRoot.findFirstSlot(); 239 242 ITreeSlotProvider<K, V> vSlotProvider = vSlot.getProvider(); 240 243 int vCurrentOffset = vSlot.indexOf(pKey); … … 259 262 public V remove(Object pKey) { 260 263 TreeSlot<K, V> vSlot = fRoot.findSlot(pKey); 264 if (vSlot == null) return null; 261 265 int vOffset = vSlot.indexOf(pKey); 262 266 if (vOffset < 0) return null; -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/TreeNode.java
r19672 r19674 43 43 44 44 public K getKey(int pOffset) { 45 return fProvider.getKey( 0);45 return fProvider.getKey(pOffset); 46 46 } 47 47 -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/TreeRake.java
r19672 r19674 187 187 188 188 public TreeSlot<K, V> findSlot(Object pKey) { 189 int vLast = -1; 189 190 int vLow = 0; 190 191 int vHigh = fProvider.getSize() - 1; 191 while (vLow < vHigh) {192 while (vLow <= vHigh) { 192 193 int vMid = (vLow + vHigh) >>> 1; 193 194 K vMidKey = getKey(vMid); 194 195 int vCmp = fTree.fComparator.compare(vMidKey, (K) pKey); 195 196 if (vCmp < 0) { 197 vLast = vMid; 196 198 vLow = vMid + 1; 197 199 } else if (vCmp > 0) { … … 202 204 } 203 205 } 204 return getNode(vLow).findSlot(pKey);206 return vLast >= 0 ? getNode(vLast).findSlot(pKey) : null; 205 207 } 206 208 -
trunk/Jav_Orient/test/eu/scenari/orient/tree/FactorySequentialLong.java
r19672 r19674 11 11 public class FactorySequentialLong implements IKeyFactory<Long>, IValueFactory<Long> { 12 12 13 protected long fStartValue = 1; 14 13 15 protected Random fRandom = new Random(); 14 16 15 protected AtomicLong fCounter = new AtomicLong( 1);17 protected AtomicLong fCounter = new AtomicLong(fStartValue); 16 18 17 19 public Long newKey() { … … 29 31 public Iterator<Long> creationOrderIterator() { 30 32 return new IteratorBufferedNextBase<Long>() { 31 protected long fLast = 1;33 protected long fLast = fStartValue; 32 34 33 35 public boolean hasNext() { … … 35 37 if (fNext != null) return true; 36 38 //Cherche à renseigner fNext 37 if (fLast < =fCounter.get()) {39 if (fLast < fCounter.get()) { 38 40 fNext = fLast++; 39 41 } -
trunk/Jav_Orient/test/eu/scenari/orient/tree/TreeBasicTest.java
r19672 r19674 39 39 package eu.scenari.orient.tree; 40 40 41 import java.util.Iterator; 41 42 import java.util.Map; 42 43 … … 54 55 import eu.scenari.orient.recordstruct.types.TypesBase; 55 56 import eu.scenari.orient.test.TestDbAbstract; 57 import eu.scenari.orient.tree.impl.IBalancingLayout; 56 58 57 59 public class TreeBasicTest extends TestDbAbstract { 58 60 59 public static final TreeStorageConfig TREECONFIG = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG).setValuesStruct(TypesBase.LIST_LONG) ;61 public static final TreeStorageConfig TREECONFIG = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(false).setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_INCREMENTAL_INSERT); 60 62 61 63 public static final StructTree TREE_LONG_LONG = new StructTree(new ExtendedStructId(1, 1), "trreeLongLong").setTreeConfig(TREECONFIG); 62 64 63 protected FactorySequentialLong fFactory = new FactorySequentialLong();65 protected FactorySequentialLong fFactorySeqLong = new FactorySequentialLong(); 64 66 65 67 @Override … … 78 80 Map<Long, Long> vTree = vRecord.getValue().getPojo(); 79 81 for (int i = 1; i <= vSize; i++) { 80 Long vKey = fFactory .newKey();81 vTree.put(vKey, fFactory .newValueFor(vKey));82 Long vKey = fFactorySeqLong.newKey(); 83 vTree.put(vKey, fFactorySeqLong.newValueFor(vKey)); 82 84 vRecord.save(); 83 85 Assert.assertEquals(i, vTree.size()); … … 91 93 Assert.assertEquals(vSize, vTree.size()); 92 94 checkAllEntries(vTree); 95 93 96 } 94 97 … … 96 99 int vCount = 0; 97 100 for (Map.Entry<Long, Long> vEntry : pTree.entrySet()) { 98 fFactory .checkValueForKey(vEntry.getKey(), vEntry.getValue());101 fFactorySeqLong.checkValueForKey(vEntry.getKey(), vEntry.getValue()); 99 102 vCount++; 100 103 } 101 104 Assert.assertEquals(pTree.size(), vCount); 105 for (Iterator<Long> vIt = fFactorySeqLong.creationOrderIterator(); vIt.hasNext();) { 106 Long vKey = vIt.next(); 107 fFactorySeqLong.checkValueForKey(vKey, pTree.get(vKey)); 108 } 109 102 110 } 103 111
Note: See TracChangeset
for help on using the changeset viewer.