- Timestamp:
- 02/10/12 20:31:17 (3 months ago)
- Location:
- trunk/Jav_Orient
- Files:
-
- 45 added
- 16 edited
- 2 moved
-
src/eu/scenari/orient/recordstruct/lib/base/StructListLong.java (modified) (2 diffs)
-
src/eu/scenari/orient/recordstruct/lib/base/ValueListAsciiFixed.java (modified) (1 diff)
-
src/eu/scenari/orient/recordstruct/lib/base/ValueListLong.java (modified) (1 diff)
-
src/eu/scenari/orient/recordstruct/lib/base/ValueListLongCached.java (added)
-
src/eu/scenari/orient/recordstruct/lib/base/ValueListRID.java (modified) (1 diff)
-
src/eu/scenari/orient/recordstruct/lib/tree/ValueTree.java (modified) (6 diffs)
-
src/eu/scenari/orient/recordstruct/lib/tree/ValueTreeSlotKV.java (modified) (4 diffs)
-
src/eu/scenari/orient/recordstruct/types/TypesBase.java (modified) (1 diff)
-
src/eu/scenari/orient/recordstruct/value/ValueListImmutableFixed.java (modified) (16 diffs)
-
src/eu/scenari/orient/recordstruct/value/ValueListImmutableFixedCached.java (added)
-
src/eu/scenari/orient/tree/impl/BalancedLayout.java (modified) (1 diff)
-
src/eu/scenari/orient/tree/impl/IBalancingLayout.java (modified) (1 diff)
-
src/eu/scenari/orient/tree/impl/RSTree.java (added)
-
src/eu/scenari/orient/tree/impl/RSTreeRWLock.java (moved) (moved from trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/RSTreeConcurrent.java) (2 diffs)
-
src/eu/scenari/orient/tree/impl/RSTreeRake.java (modified) (1 diff)
-
test-output (added)
-
test-output/Default suite (added)
-
test-output/Default suite/Default test.html (added)
-
test-output/Default suite/Default test.xml (added)
-
test-output/bullet_point.png (added)
-
test-output/collapseall.gif (added)
-
test-output/emailable-report.html (added)
-
test-output/failed.png (added)
-
test-output/index.html (added)
-
test-output/jquery-1.7.1.min.js (added)
-
test-output/navigator-bullet.png (added)
-
test-output/old (added)
-
test-output/old/Default suite (added)
-
test-output/old/Default suite/Default test.properties (added)
-
test-output/old/Default suite/classes.html (added)
-
test-output/old/Default suite/groups.html (added)
-
test-output/old/Default suite/index.html (added)
-
test-output/old/Default suite/main.html (added)
-
test-output/old/Default suite/methods-alphabetical.html (added)
-
test-output/old/Default suite/methods-not-run.html (added)
-
test-output/old/Default suite/methods.html (added)
-
test-output/old/Default suite/reporter-output.html (added)
-
test-output/old/Default suite/testng.xml.html (added)
-
test-output/old/Default suite/toc.html (added)
-
test-output/old/index.html (added)
-
test-output/passed.png (added)
-
test-output/skipped.png (added)
-
test-output/testng-reports.css (added)
-
test-output/testng-reports.js (added)
-
test-output/testng-results.xml (added)
-
test-output/testng.css (added)
-
test/eu/scenari/orient/tree/TreeBasicTestAbstract.java (modified) (4 diffs)
-
test/eu/scenari/orient/tree/TreeBasicUnorderedTest.java (modified) (1 diff)
-
test/eu/scenari/orient/tree/TreeBigTestAbstract.java (modified) (5 diffs)
-
test/eu/scenari/orient/tree/TreeBigUnorderedTest.java (modified) (1 diff)
-
test/eu/scenari/orient/tree/TypesTreeTests.java (modified) (1 diff)
-
test/eu/scenari/orient/tree/mapsupplier (added)
-
test/eu/scenari/orient/tree/mapsupplier/ITreeMapSupplier.java (added)
-
test/eu/scenari/orient/tree/mapsupplier/MVRBTreeSupplier.java (added)
-
test/eu/scenari/orient/tree/mapsupplier/RSTreeSupplier.java (added)
-
test/eu/scenari/orient/tree/perf/MvrbBig.java (added)
-
test/eu/scenari/orient/tree/perf/MvrbSmall.java (added)
-
test/eu/scenari/orient/tree/perf/MvrbSmallIncr.java (added)
-
test/eu/scenari/orient/tree/perf/RsBig.java (added)
-
test/eu/scenari/orient/tree/perf/RsHuge.java (added)
-
test/eu/scenari/orient/tree/perf/RsSmall.java (added)
-
test/eu/scenari/orient/tree/perf/RsSmallIncr.java (added)
-
test/eu/scenari/orient/tree/perf/TreePerfTestAbstract.java (moved) (moved from trunk/Jav_Orient/test/eu/scenari/orient/tree/perf/MVRBTreePerfTest.java) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/lib/base/StructListLong.java
r19672 r19688 44 44 import eu.scenari.orient.recordstruct.IStructList; 45 45 import eu.scenari.orient.recordstruct.IValue.CopyObjective; 46 import eu.scenari.orient.recordstruct.IValueList; 46 47 import eu.scenari.orient.recordstruct.IValueOwner; 47 48 import eu.scenari.orient.recordstruct.impl.StructReader; … … 49 50 import eu.scenari.orient.recordstruct.struct.StructAbstract; 50 51 51 public class StructListLong extends StructAbstract< ValueListLong> implements IStructList<ValueListLong> {52 public class StructListLong extends StructAbstract<IValueList<Long>> implements IStructList<IValueList<Long>> { 52 53 53 public StructListLong(int pCoreStructId) { 54 protected boolean fCacheEntries; 55 56 public StructListLong(int pCoreStructId, boolean pCacheEntries) { 54 57 super(pCoreStructId, IStruct.LENGTH_DYNAMIC, null); 58 fCacheEntries = pCacheEntries; 55 59 } 56 60 57 public ValueListLongtoValue(Object pPojo, IValueOwner pOwner) {58 if (pPojo == null) return new ValueListLong(pOwner);59 if (pPojo instanceof ValueListLong) return (( ValueListLong) pPojo).copy(pOwner, CopyObjective.forDuplicate);60 if (pPojo instanceof List) return new ValueListLong((List) pPojo, pOwner);61 public IValueList<Long> toValue(Object pPojo, IValueOwner pOwner) { 62 if (pPojo == null) return fCacheEntries ? new ValueListLongCached(pOwner) : new ValueListLong(pOwner); 63 if (pPojo instanceof ValueListLong) return ((IValueList<Long>) pPojo).copy(pOwner, CopyObjective.forDuplicate); 64 if (pPojo instanceof List) return fCacheEntries ? new ValueListLongCached((List) pPojo, pOwner) : new ValueListLong((List) pPojo, pOwner); 61 65 throw new ConversionException(this, pPojo); 62 66 } 63 67 64 public ValueListLongnewValue(int pDefaultCapacity, IValueOwner pOwner) {65 return new ValueListLong(pDefaultCapacity, pOwner);68 public IValueList<Long> newValue(int pDefaultCapacity, IValueOwner pOwner) { 69 return fCacheEntries ? new ValueListLongCached(pDefaultCapacity, pOwner) : new ValueListLong(pDefaultCapacity, pOwner); 66 70 } 67 71 68 public ValueListLongreadValue(StructReader pReader, int pLen, IValueOwner pOwner) {69 return new ValueListLong(pReader, pLen, pOwner);72 public IValueList<Long> readValue(StructReader pReader, int pLen, IValueOwner pOwner) { 73 return fCacheEntries ? new ValueListLongCached(pReader, pLen, pOwner) : new ValueListLong(pReader, pLen, pOwner); 70 74 } 71 75 } -
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/lib/base/ValueListAsciiFixed.java
r19672 r19688 82 82 } 83 83 84 protected String unmarshallEntry(int pOffset) { 85 if (fRawEntries[pOffset] == -1) return null; 86 return new String(fRawEntries, pOffset, fStruct.getFixedLength()); 84 protected String readEntry(int pIndex) { 85 int vOffset = index2Offset(pIndex); 86 if (fRawEntries[vOffset] == -1) return null; 87 return new String(fRawEntries, vOffset, fStruct.getFixedLength()); 87 88 } 88 89 89 protected void marshallEntry(String pElt, int pOffset) { 90 protected void writeEntry(String pElt, int pIndex) { 91 int vOffset = index2Offset(pIndex); 90 92 int vLen = fStruct.getFixedLength(); 91 93 if (pElt != null) { 92 94 for (int i = 0; i < vLen; i++) { 93 fRawEntries[ pOffset++] = (byte) pElt.charAt(i);95 fRawEntries[vOffset++] = (byte) pElt.charAt(i); 94 96 } 95 97 } else { 96 98 for (int i = 0; i < vLen; i++) { 97 fRawEntries[ pOffset++] = (byte) -1;99 fRawEntries[vOffset++] = (byte) -1; 98 100 } 99 101 } -
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/lib/base/ValueListLong.java
r19672 r19688 38 38 } 39 39 40 protected Long unmarshallEntry(int pOffset) {41 return OBinaryProtocol.bytes2long(fRawEntries, pOffset);40 protected Long readEntry(int pIndex) { 41 return OBinaryProtocol.bytes2long(fRawEntries, index2Offset(pIndex)); 42 42 } 43 43 44 protected void marshallEntry(Long pElt, int pOffset) {45 OBinaryProtocol.long2bytes(pElt != null ? pElt : 0L, fRawEntries, pOffset);44 protected void writeEntry(Long pElt, int pIndex) { 45 OBinaryProtocol.long2bytes(pElt != null ? pElt : 0L, fRawEntries, index2Offset(pIndex)); 46 46 } 47 47 -
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/lib/base/ValueListRID.java
r19672 r19688 40 40 } 41 41 42 protected ORID unmarshallEntry(int pOffset) { 43 return new ORecordId(OBinaryProtocol.bytes2short(fRawEntries, pOffset), OBinaryProtocol.bytes2long(fRawEntries, pOffset + 2)); 42 protected ORID readEntry(int pIndex) { 43 int vOffset = index2Offset(pIndex); 44 return new ORecordId(OBinaryProtocol.bytes2short(fRawEntries, vOffset), OBinaryProtocol.bytes2long(fRawEntries, vOffset + 2)); 44 45 } 45 46 46 protected void marshallEntry(ORID pElt, int pOffset) { 47 protected void writeEntry(ORID pElt, int pIndex) { 48 int vOffset = index2Offset(pIndex); 47 49 if (pElt != null) { 48 OBinaryProtocol.short2bytes((short) pElt.getClusterId(), fRawEntries, pOffset);49 OBinaryProtocol.long2bytes(pElt.getClusterPosition(), fRawEntries, pOffset + 2);50 OBinaryProtocol.short2bytes((short) pElt.getClusterId(), fRawEntries, vOffset); 51 OBinaryProtocol.long2bytes(pElt.getClusterPosition(), fRawEntries, vOffset + 2); 50 52 } else { 51 OBinaryProtocol.short2bytes((short) ORecordId.CLUSTER_ID_INVALID );52 OBinaryProtocol.long2bytes(ORecordId.CLUSTER_POS_INVALID );53 OBinaryProtocol.short2bytes((short) ORecordId.CLUSTER_ID_INVALID, fRawEntries, vOffset); 54 OBinaryProtocol.long2bytes(ORecordId.CLUSTER_POS_INVALID, fRawEntries, vOffset + 2); 53 55 } 54 56 } -
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/lib/tree/ValueTree.java
r19681 r19688 40 40 41 41 import java.util.ArrayList; 42 import java.util. Map;42 import java.util.SortedMap; 43 43 44 44 import com.orientechnologies.orient.core.id.ORecordId; … … 59 59 import eu.scenari.orient.recordstruct.value.ValueUpdatableAbstract; 60 60 import eu.scenari.orient.tree.impl.RSTree; 61 import eu.scenari.orient.tree.impl.RSTree Concurrent;61 import eu.scenari.orient.tree.impl.RSTreeRWLock; 62 62 import eu.scenari.orient.tree.provider.ITreeNodeProvider; 63 63 import eu.scenari.orient.tree.provider.ITreeProvider; … … 65 65 import eu.scenari.orient.tree.provider.ITreeSlotProvider; 66 66 67 public class ValueTree<K, V> extends ValueUpdatableAbstract< Map<K, V>> implements ITreeProvider<K, V>, IValueSubRecord {67 public class ValueTree<K, V> extends ValueUpdatableAbstract<SortedMap<K, V>> implements ITreeProvider<K, V>, IValueSubRecord { 68 68 69 69 public static final int FIXED_SER_LENGTH = TypesBase.RID.getFullSerializedLentgh() + OBinaryProtocol.SIZE_INT; … … 89 89 fSize = 0; 90 90 if (getTreeStorageConfig().isTreeThreadSafe()) { 91 fPojo = new RSTree Concurrent(this, getTreeStorageConfig().getKeyComparator(), getTreeStorageConfig().getBalancingLayout(), 5000);91 fPojo = new RSTreeRWLock(this, getTreeStorageConfig().getKeyComparator(), getTreeStorageConfig().getBalancingLayout(), 5000); 92 92 } else { 93 93 fPojo = new RSTree(this, getTreeStorageConfig().getKeyComparator(), getTreeStorageConfig().getBalancingLayout()); … … 108 108 } 109 109 110 public Map<K, V> getPojo() {110 public SortedMap<K, V> getPojo() { 111 111 return fPojo; 112 112 } … … 277 277 } 278 278 279 public <RET extends IValue< Map<K, V>>> RET copyFrom(IValue<?> pFromValue, CopyObjective pObjective) {279 public <RET extends IValue<SortedMap<K, V>>> RET copyFrom(IValue<?> pFromValue, CopyObjective pObjective) { 280 280 ValueTree vFrom = (ValueTree) pFromValue; 281 281 fRootEntry = vFrom.fRootEntry.copy(this, pObjective); -
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/lib/tree/ValueTreeSlotKV.java
r19680 r19688 88 88 89 89 public float getFillRate() { 90 return fKeys.size() / fTree.getDefault RakeCapacity();90 return fKeys.size() / fTree.getDefaultSlotCapacity(); 91 91 } 92 92 93 93 public boolean adoptAllEntriesFromLeft(ITreeNodeProvider<K, V> pLeftNodeToKill) { 94 94 ValueTreeSlotKV<K, V> vOther = (ValueTreeSlotKV<K, V>) pLeftNodeToKill; 95 if (fKeys.size() + vOther.getSize() >= fTree.getDefault RakeCapacity()) return false;95 if (fKeys.size() + vOther.getSize() >= fTree.getDefaultSlotCapacity()) return false; 96 96 fKeys.addAll(0, vOther.fKeys); 97 97 fValues.addAll(0, vOther.fValues); … … 101 101 public boolean adoptAllEntriesFromRight(ITreeNodeProvider<K, V> pRightNodeToKill) { 102 102 ValueTreeSlotKV<K, V> vOther = (ValueTreeSlotKV<K, V>) pRightNodeToKill; 103 if (fKeys.size() + vOther.getSize() >= fTree.getDefault RakeCapacity()) return false;103 if (fKeys.size() + vOther.getSize() >= fTree.getDefaultSlotCapacity()) return false; 104 104 fKeys.addAll(vOther.fKeys); 105 105 fValues.addAll(vOther.fValues); … … 109 109 public int adoptEntriesFromLeft(ITreeNodeProvider<K, V> pLeftNode, float pTargetFillRate) { 110 110 ValueTreeSlotKV<K, V> vOther = (ValueTreeSlotKV<K, V>) pLeftNode; 111 int vTargetSize = (int) (fTree.getDefault RakeCapacity() * pTargetFillRate);111 int vTargetSize = (int) (fTree.getDefaultSlotCapacity() * pTargetFillRate); 112 112 int vOtherSize = vOther.getSize(); 113 113 int vRecordsToMove = Math.min(vTargetSize - fKeys.size(), vOtherSize - 1); 114 114 if (vRecordsToMove > 0) { 115 115 List<K> vOtherKeys = vOther.fKeys.subList(vOtherSize - vRecordsToMove, vOtherSize); 116 List<V> vOther SubNodes = vOther.fValues.subList(vOtherSize - vRecordsToMove, vOtherSize);116 List<V> vOtherValues = vOther.fValues.subList(vOtherSize - vRecordsToMove, vOtherSize); 117 117 fKeys.addAll(0, vOtherKeys); 118 fValues.addAll(0, vOther SubNodes);118 fValues.addAll(0, vOtherValues); 119 119 vOtherKeys.clear(); 120 vOther SubNodes.clear();120 vOtherValues.clear(); 121 121 } 122 122 return vRecordsToMove; … … 125 125 public int adoptEntriesFromRight(ITreeNodeProvider<K, V> pRightNode, float pTargetFillRate) { 126 126 ValueTreeSlotKV<K, V> vOther = (ValueTreeSlotKV<K, V>) pRightNode; 127 int vTargetSize = (int) (fTree.getDefault RakeCapacity() * pTargetFillRate);127 int vTargetSize = (int) (fTree.getDefaultSlotCapacity() * pTargetFillRate); 128 128 int vOtherSize = vOther.getSize(); 129 129 int vRecordsToMove = Math.min(vTargetSize - fKeys.size(), vOtherSize - 1); -
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/types/TypesBase.java
r19672 r19688 119 119 //**** List de pojo .... 120 120 121 public static final StructListLong LIST_LONG = new StructListLong(195); 121 public static final StructListLong LIST_LONG = new StructListLong(195, false); 122 123 public static final StructListLong LIST_LONG_CACHED = new StructListLong(196, true); 122 124 123 125 } -
trunk/Jav_Orient/src/eu/scenari/orient/recordstruct/value/ValueListImmutableFixed.java
r19687 r19688 58 58 59 59 /** 60 * 60 * List of fixed serialisation length immutable values. 61 61 */ 62 62 public abstract class ValueListImmutableFixed<E> extends ValueUpdatableAbstract<List<E>> implements IValueList<E> { … … 192 192 193 193 public boolean contains(Object pO) { 194 int vOffset = fOffset;195 194 for (int i = 0; i < fSize; i++) { 196 if (unmarshallEntry(vOffset).equals(pO)) return true; 197 vOffset += getFixedLengthEntry(); 195 if (readEntry(i).equals(pO)) return true; 198 196 } 199 197 return false; … … 209 207 //Cherche à renseigner fNext 210 208 if (fIndex < fSize) { 211 fNext = unmarshallEntry(index2Offset(fIndex));209 fNext = readEntry(fIndex); 212 210 fIndex++; 213 211 } … … 219 217 public Object[] toArray() { 220 218 Object[] vResult = new Object[fSize]; 221 int vOffset = fOffset;222 219 for (int i = 0; i < fSize; i++) { 223 vResult[i] = unmarshallEntry(vOffset); 224 vOffset += getFixedLengthEntry(); 220 vResult[i] = readEntry(i); 225 221 } 226 222 return vResult; … … 229 225 public <T> T[] toArray(T[] pArray) { 230 226 if (pArray.length < fSize) pArray = (pArray.getClass() == Object[].class) ? (T[]) new Object[fSize] : (T[]) Array.newInstance(pArray.getClass().getComponentType(), fSize); 231 int vOffset = fOffset;232 227 for (int i = 0; i < fSize; i++) { 233 pArray[i] = (T) unmarshallEntry(vOffset); 234 vOffset += getFixedLengthEntry(); 228 pArray[i] = (T) readEntry(i); 235 229 } 236 230 return pArray; … … 239 233 public boolean add(E pElement) { 240 234 isolateBufferForUpdates(fSize + 1); 241 marshallEntry(pElement, index2Offset(fSize));242 235 fSize++; 236 writeEntry(pElement, fSize - 1); 243 237 setDirty(); 244 238 return true; … … 248 242 int vOffset = fOffset; 249 243 for (int i = 0; i < fSize; i++) { 250 if ( unmarshallEntry(vOffset).equals(pO)) {244 if (readEntry(i).equals(pO)) { 251 245 if (i < fSize - 1) { 252 246 isolateBufferForUpdates(fSize - 1); … … 266 260 int vCountToAdd = pC.size(); 267 261 if (vCountToAdd == 0) return false; 268 isolateBufferForUpdates(fSize + vCountToAdd); 262 int vCurrentSize = fSize; 263 isolateBufferForUpdates(vCurrentSize + vCountToAdd); 264 fSize += vCountToAdd; 269 265 Iterator<? extends E> vEntry = pC.iterator(); 270 int vOffset = index2Offset(fSize);271 266 while (vEntry.hasNext()) { 272 marshallEntry(vEntry.next(), vOffset); 273 vOffset += getFixedLengthEntry(); 274 } 275 fSize += vCountToAdd; 267 writeEntry(vEntry.next(), vCurrentSize++); 268 } 276 269 setDirty(); 277 270 return true; … … 281 274 int vCountToAdd = pC.size(); 282 275 if (vCountToAdd == 0) return false; 283 isolateBufferForUpdates(fSize + vCountToAdd); 276 int vCurrentSize = fSize; 277 isolateBufferForUpdates(vCurrentSize + vCountToAdd); 278 fSize += vCountToAdd; 284 279 int vOffset = index2Offset(pIndex); 285 if (pIndex < fSize) {286 System.arraycopy(fRawEntries, vOffset, fRawEntries, vOffset + (vCountToAdd * getFixedLengthEntry()), ( fSize - pIndex) * getFixedLengthEntry());280 if (pIndex < vCurrentSize) { 281 System.arraycopy(fRawEntries, vOffset, fRawEntries, vOffset + (vCountToAdd * getFixedLengthEntry()), (vCurrentSize - pIndex) * getFixedLengthEntry()); 287 282 } 288 283 Iterator<? extends E> vIt = pC.iterator(); 289 284 while (vIt.hasNext()) { 290 marshallEntry(vIt.next(), vOffset); 291 vOffset += getFixedLengthEntry(); 292 } 293 fSize += vCountToAdd; 285 writeEntry(vIt.next(), pIndex++); 286 } 294 287 setDirty(); 295 288 return true; … … 304 297 public E get(int pIndex) { 305 298 assert (pIndex >= 0 && pIndex < fSize); 306 return unmarshallEntry(index2Offset(pIndex));299 return readEntry(pIndex); 307 300 } 308 301 … … 310 303 assert (pIndex >= 0 && pIndex <= fSize); 311 304 isolateBufferForUpdates(fSize); 312 int vOffset = index2Offset(pIndex); 313 E vElt = unmarshallEntry(vOffset); 314 marshallEntry(pElement, vOffset); 305 E vElt = readEntry(pIndex); 306 writeEntry(pElement, pIndex); 315 307 return vElt; 316 308 } … … 318 310 public void add(int pIndex, E pElement) { 319 311 assert (pIndex >= 0 && pIndex <= fSize); 312 int vCurrentSize = fSize; 320 313 isolateBufferForUpdates(fSize + 1); 314 fSize++; 321 315 int vOffset = index2Offset(pIndex); 322 if (pIndex < fSize) { 323 System.arraycopy(fRawEntries, vOffset, fRawEntries, vOffset + getFixedLengthEntry(), (fSize - pIndex) * getFixedLengthEntry()); 324 } 325 marshallEntry(pElement, vOffset); 326 fSize++; 316 if (pIndex < vCurrentSize) { 317 System.arraycopy(fRawEntries, vOffset, fRawEntries, vOffset + getFixedLengthEntry(), (vCurrentSize - pIndex) * getFixedLengthEntry()); 318 } 319 writeEntry(pElement, pIndex); 327 320 } 328 321 329 322 public E remove(int pIndex) { 330 323 assert (pIndex >= 0 && pIndex < fSize); 331 E vElt = unmarshallEntry(index2Offset(pIndex));324 E vElt = readEntry(pIndex); 332 325 if (pIndex < fSize - 1) { 333 326 isolateBufferForUpdates(fSize - 1); … … 342 335 343 336 public int indexOf(Object pO) { 344 int vOffset = fOffset;345 337 for (int i = 0; i < fSize; i++) { 346 if (unmarshallEntry(vOffset).equals(pO)) return i; 347 vOffset += getFixedLengthEntry(); 338 if (readEntry(i).equals(pO)) return i; 348 339 } 349 340 return -1; … … 352 343 public int lastIndexOf(Object pO) { 353 344 for (int i = fSize - 1; i >= 0; i--) { 354 if ( unmarshallEntry(index2Offset(i)).equals(pO)) return i;345 if (readEntry(i).equals(pO)) return i; 355 346 } 356 347 return -1; … … 402 393 403 394 public void writeValue(IStructWriter pWriter) { 395 assert (fRawEntries.length >= fSize * getFixedLengthEntry() + fOffset); 404 396 pWriter.addAsValue(this, fRawEntries, fOffset, fSize * getFixedLengthEntry()); 405 397 } … … 430 422 protected abstract int getFixedLengthEntry(); 431 423 432 protected abstract E unmarshallEntry(int pOffset);433 434 protected abstract void marshallEntry(E pElt, int pOffset);424 protected abstract E readEntry(int pIndex); 425 426 protected abstract void writeEntry(E pElt, int pIndex); 435 427 436 428 } -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/BalancedLayout.java
r19681 r19688 14 14 15 15 /** When fill rate is reduced and less than <code>fOptimizeThreshold</code>, try to merge with siblings. */ 16 protected float fOptimizeThreshold = 0.2 5f;16 protected float fOptimizeThreshold = 0.2f; 17 17 18 18 /** 19 19 * Target fillRate on the rightNode when a node is splitted. 20 * If keys are incremental values (ID, timestamp, ...), it would better to set 0.1 .20 * If keys are incremental values (ID, timestamp, ...), it would better to set 0.1 or 0.0. 21 21 */ 22 22 protected float fTargetFillRateForNewRightNode = 0.5f; -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/IBalancingLayout.java
r19680 r19688 3 3 public interface IBalancingLayout { 4 4 5 public final IBalancingLayout DEFAULT_BALANCED_RANDOM_INSERT = new BalancedLayout( );5 public final IBalancingLayout DEFAULT_BALANCED_RANDOM_INSERT = new BalancedLayout(0.5f, 0.2f, 0.5f); 6 6 7 7 public final IBalancingLayout DEFAULT_BALANCED_INCREMENTAL_INSERT = new BalancedLayout(0.0f, 0.2f, 0.0f); -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/RSTreeRWLock.java
r19681 r19688 53 53 54 54 /** 55 * RSTree with concurrent access management .55 * RSTree with concurrent access management in a ReadWriteLock manner. 56 56 */ 57 public class RSTree Concurrent<K, V> extends RSTree<K, V> implements OMemoryWatchDog.Listener {57 public class RSTreeRWLock<K, V> extends RSTree<K, V> implements OMemoryWatchDog.Listener { 58 58 59 59 protected AtomicBoolean fNeedFreeMemory = new AtomicBoolean(false); … … 115 115 } 116 116 117 public RSTree Concurrent(ITreeProvider<K, V> pProvider) {117 public RSTreeRWLock(ITreeProvider<K, V> pProvider) { 118 118 this(pProvider, null, null, 5000); 119 119 } 120 120 121 public RSTree Concurrent(ITreeProvider<K, V> pProvider, Comparator<? super K> pComparator, IBalancingLayout pBalancingLayout, int pLockTimeout) {121 public RSTreeRWLock(ITreeProvider<K, V> pProvider, Comparator<? super K> pComparator, IBalancingLayout pBalancingLayout, int pLockTimeout) { 122 122 super(pProvider, pComparator, pBalancingLayout); 123 123 fLock = new Lock(pLockTimeout); -
trunk/Jav_Orient/src/eu/scenari/orient/tree/impl/RSTreeRake.java
r19687 r19688 361 361 if (getNode(i).accept(pVisitor, pVisitOnlyInMemoryNodes) == Result.stopVisiting) return Result.stopVisiting; 362 362 if (fTree.isThreadSafe()) { 363 ((RSTree Concurrent) fTree).freeMemoryIfNeeded();363 ((RSTreeRWLock) fTree).freeMemoryIfNeeded(); 364 364 } 365 365 } -
trunk/Jav_Orient/test/eu/scenari/orient/tree/TreeBasicTestAbstract.java
r19687 r19688 41 41 import java.util.Iterator; 42 42 import java.util.Map; 43 import java.util.SortedMap; 43 44 44 45 import junit.framework.Assert; … … 69 70 70 71 //Inserts 71 Map<Long, Long> vTree = vRecord.getValue().getPojo();72 SortedMap<Long, Long> vTree = vRecord.getValue().getPojo(); 72 73 for (int i = 1; i <= vSize; i++) { 73 74 Long vKey = pFactory.newKey(); … … 75 76 vRecord.save(); 76 77 checkSize(vTree, i); 78 //checkEntrySetIterator(vTree, pFactory); 77 79 } 78 80 checkSize(vTree, vSize); … … 121 123 } 122 124 123 protected void checkEntrySetIterator( Map<Long, Long> pTree, IKVFactory<Long, Long> pFactory) {125 protected void checkEntrySetIterator(SortedMap<Long, Long> pTree, IKVFactory<Long, Long> pFactory) { 124 126 int vCount = 0; 127 Long vPreviousKey = null; 125 128 for (Map.Entry<Long, Long> vEntry : pTree.entrySet()) { 126 129 pFactory.checkValueForKey(vEntry.getKey(), vEntry.getValue()); 130 if (vPreviousKey != null) Assert.assertTrue(pTree.comparator().compare(vPreviousKey, vEntry.getKey()) > 0); 127 131 vCount++; 128 132 } -
trunk/Jav_Orient/test/eu/scenari/orient/tree/TreeBasicUnorderedTest.java
r19687 r19688 47 47 @Test 48 48 public void testUnorderedInserts() { 49 executeTest(new FactoryUnorderedLong(), TypesTreeTests.TREE_LL _RANDOM);49 executeTest(new FactoryUnorderedLong(), TypesTreeTests.TREE_LL); 50 50 } 51 51 -
trunk/Jav_Orient/test/eu/scenari/orient/tree/TreeBigTestAbstract.java
r19687 r19688 40 40 41 41 import java.util.Iterator; 42 import java.util. Map;42 import java.util.SortedMap; 43 43 44 44 import junit.framework.Assert; … … 49 49 import eu.scenari.orient.recordstruct.lib.tree.StructTree; 50 50 import eu.scenari.orient.recordstruct.lib.tree.ValueTree; 51 import eu.scenari.orient.test.TestDbAbstract;52 51 import eu.scenari.orient.tree.datafactory.IKVFactory; 53 import eu.scenari.orient.tree.impl.RSTree Concurrent;52 import eu.scenari.orient.tree.impl.RSTreeRWLock; 54 53 55 public class TreeBigTestAbstract extends T estDbAbstract {54 public class TreeBigTestAbstract extends TreeBasicTestAbstract { 56 55 57 public static int MAP_ SIZE = 1 * 1000000;56 public static int MAP_BIG_SIZE = 1 * 1000000; 58 57 59 58 @Override … … 62 61 63 62 public void executeTest(IKVFactory<Long, Long> pFactory, StructTree pStructTree) { 64 int vSize = MAP_SIZE;65 63 fDatabase = fDbDriver.acquireDatabase(); 66 64 IRecordStruct<ValueTree<Long, Long>> vRecord = fDatabase.newInstance(); 67 65 vRecord.setValue((ValueTree) pStructTree.toValue(null, vRecord)); 68 66 vRecord.save(); 69 Map<Long, Long> vTree = vRecord.getValue().getPojo();70 Orient.instance().getMemoryWatchDog().addListener((RSTree Concurrent) vTree);67 SortedMap<Long, Long> vTree = vRecord.getValue().getPojo(); 68 Orient.instance().getMemoryWatchDog().addListener((RSTreeRWLock) vTree); 71 69 72 70 //Inserts 73 for (int i = 1; i <= vSize; i++) {71 for (int i = 1; i <= MAP_BIG_SIZE; i++) { 74 72 Long vKey = pFactory.newKey(); 75 73 vTree.put(vKey, pFactory.newValueFor(vKey)); … … 81 79 vRecord.save(); 82 80 System.out.println("[END INSERT]"); 83 checkSize(vTree, vSize);81 checkSize(vTree, MAP_BIG_SIZE); 84 82 System.out.println("[END CHECKSIZE]"); 85 83 checkEntrySetIterator(vTree, pFactory); … … 117 115 } 118 116 119 protected void checkSize(Map<Long, Long> pTree, int pExpectedSize) {120 if (TypesTreeTests.STORE_SIZE) {121 Assert.assertEquals(pExpectedSize, pTree.size());122 }123 }124 125 protected void checkEntrySetIterator(Map<Long, Long> pTree, IKVFactory<Long, Long> pFactory) {126 int vCount = 0;127 for (Map.Entry<Long, Long> vEntry : pTree.entrySet()) {128 pFactory.checkValueForKey(vEntry.getKey(), vEntry.getValue());129 vCount++;130 }131 checkSize(pTree, vCount);132 }133 134 protected void checkAllEntries(Map<Long, Long> pTree, IKVFactory<Long, Long> pFactory) {135 int vCount = 0;136 for (Iterator<Long> vIt = pFactory.creationOrderIterator(); vIt.hasNext();) {137 Long vKey = vIt.next();138 pFactory.checkValueForKey(vKey, pTree.get(vKey));139 vCount++;140 }141 checkSize(pTree, vCount);142 143 }144 145 117 } -
trunk/Jav_Orient/test/eu/scenari/orient/tree/TreeBigUnorderedTest.java
r19687 r19688 9 9 @Test 10 10 public void testUnorderedInserts() { 11 executeTest(new FactoryUnorderedLong(), TypesTreeTests.TREE_LL_ RANDOM_CONCUR);11 executeTest(new FactoryUnorderedLong(), TypesTreeTests.TREE_LL_CONCUR); 12 12 } 13 13 } -
trunk/Jav_Orient/test/eu/scenari/orient/tree/TypesTreeTests.java
r19687 r19688 12 12 13 13 /** */ 14 public static final TreeStorageConfig TREECONFIG_LL _INCR = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(STORE_SIZE)15 .set BalancingLayout(IBalancingLayout.DEFAULT_BALANCED_INCREMENTAL_INSERT).setRakeCapacity(32).setSlotCapacity(32);14 public static final TreeStorageConfig TREECONFIG_LL = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG_CACHED).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(STORE_SIZE).setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_RANDOM_INSERT) 15 .setRakeCapacity(256).setSlotCapacity(256); 16 16 17 17 /** */ 18 public static final TreeStorageConfig TREECONFIG_LL_INCR_CONCUR = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(STORE_SIZE) 18 public static final TreeStorageConfig TREECONFIG_LL_CONCUR = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG_CACHED).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(STORE_SIZE) 19 .setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_RANDOM_INSERT).setRakeCapacity(256).setSlotCapacity(256).setTreeThreadSafe(true); 20 21 /** */ 22 public static final TreeStorageConfig TREECONFIG_LL_INCR = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG_CACHED).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(STORE_SIZE) 23 .setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_INCREMENTAL_INSERT).setRakeCapacity(256).setSlotCapacity(256); 24 25 /** */ 26 public static final TreeStorageConfig TREECONFIG_LL_INCR_CONCUR = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG_CACHED).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(STORE_SIZE) 19 27 .setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_INCREMENTAL_INSERT).setRakeCapacity(256).setSlotCapacity(256).setTreeThreadSafe(true); 20 28 21 /** */ 22 public static final TreeStorageConfig TREECONFIG_LL_RANDOM = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(STORE_SIZE).setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_RANDOM_INSERT) 23 .setRakeCapacity(32).setSlotCapacity(32); 29 public static final StructTree TREE_LL = new StructTree(new ExtendedStructId(1, 1), "LL").setTreeConfig(TREECONFIG_LL); 24 30 25 /** */ 26 public static final TreeStorageConfig TREECONFIG_LL_RANDOM_CONCUR = new TreeStorageConfig().setKeysStruct(TypesBase.LIST_LONG).setValuesStruct(TypesBase.LIST_LONG).setSizeStored(STORE_SIZE) 27 .setBalancingLayout(IBalancingLayout.DEFAULT_BALANCED_RANDOM_INSERT).setRakeCapacity(256).setSlotCapacity(256).setTreeThreadSafe(true); 31 public static final StructTree TREE_LL_CONCUR = new StructTree(new ExtendedStructId(1, 2), "LL_CONCUR").setTreeConfig(TREECONFIG_LL_CONCUR); 28 32 29 public static final StructTree TREE_LL_INCR = new StructTree(new ExtendedStructId(1, 1), "LL_INCR").setTreeConfig(TREECONFIG_LL_INCR);33 public static final StructTree TREE_LL_INCR = new StructTree(new ExtendedStructId(1, 3), "LL_INCR").setTreeConfig(TREECONFIG_LL_INCR); 30 34 31 public static final StructTree TREE_LL_INCR_CONCUR = new StructTree(new ExtendedStructId(1, 2), "LL_INCR_CONCUR").setTreeConfig(TREECONFIG_LL_INCR_CONCUR); 32 33 public static final StructTree TREE_LL_RANDOM = new StructTree(new ExtendedStructId(1, 3), "LL_RANDOM").setTreeConfig(TREECONFIG_LL_RANDOM); 34 35 public static final StructTree TREE_LL_RANDOM_CONCUR = new StructTree(new ExtendedStructId(1, 4), "LL_RANDOM_CONCUR").setTreeConfig(TREECONFIG_LL_RANDOM_CONCUR); 35 public static final StructTree TREE_LL_INCR_CONCUR = new StructTree(new ExtendedStructId(1, 4), "LL_INCR_CONCUR").setTreeConfig(TREECONFIG_LL_INCR_CONCUR); 36 36 37 37 } -
trunk/Jav_Orient/test/eu/scenari/orient/tree/perf/TreePerfTestAbstract.java
r19687 r19688 3 3 import java.util.Iterator; 4 4 import java.util.Map; 5 import java.util.SortedMap; 5 6 6 7 import junit.framework.Assert; 7 8 8 import org.junit.Test; 9 9 import com.orientechnologies.common.profiler.OProfiler; 10 10 import com.orientechnologies.orient.core.id.ORID; 11 import com.orientechnologies.orient.core.serialization.serializer.stream.OStreamSerializerLong;12 import com.orientechnologies.orient.core.type.tree.OMVRBTreeDatabaseLazySave;13 import com.orientechnologies.orient.core.type.tree.provider.OMVRBTreeMapProvider;14 11 15 12 import eu.scenari.orient.test.TestDbAbstract; 16 import eu.scenari.orient.tree.datafactory.FactorySequentialLong; 13 import eu.scenari.orient.tree.datafactory.IKVFactory; 14 import eu.scenari.orient.tree.mapsupplier.ITreeMapSupplier; 17 15 18 public class MVRBTreePerfTest extends TestDbAbstract { 19 public static int MAP_SIZE = 20000; 20 21 protected FactorySequentialLong fFactorySeqLong = new FactorySequentialLong(); 16 public abstract class TreePerfTestAbstract extends TestDbAbstract { 22 17 23 18 @Override … … 25 20 } 26 21 27 @Test 28 public void test1() { 29 int vSize = MAP_SIZE; 22 public void executeTest(String pTestName, int pSizeMap, boolean pTestRefreshDb, int pModuloSave, IKVFactory<Long, Long> pKVFactory, ITreeMapSupplier<Long, Long> pTreeSupplier) { 30 23 fDatabase = fDbDriver.acquireDatabase(); 24 int vModuloPrintProgress = pModuloSave * 100; 31 25 32 OMVRBTreeDatabaseLazySave<Long, Long> vTree = new OMVRBTreeDatabaseLazySave<Long, Long>(fDatabase, null, OStreamSerializerLong.INSTANCE, OStreamSerializerLong.INSTANCE); 33 vTree.save(); 34 vTree.lazySave(); 35 ORID vId = ((OMVRBTreeMapProvider) vTree.getProvider()).getRecord().getIdentity(); 26 SortedMap<Long, Long> vTree = pTreeSupplier.createMap(fDatabase); 27 ORID vRid = pTreeSupplier.getIdMap(vTree); 36 28 37 for (int i = 1; i <= vSize; i++) { 38 Long vKey = fFactorySeqLong.newKey(); 39 vTree.put(vKey, fFactorySeqLong.newValueFor(vKey)); 40 vTree.lazySave(); 41 checkSize(vTree, i); 29 long vTimer = OProfiler.getInstance().startChrono(); 30 for (int i = 1; i <= pSizeMap; i++) { 31 Long vKey = pKVFactory.newKey(); 32 vTree.put(vKey, pKVFactory.newValueFor(vKey)); 33 if (i % pModuloSave == 0) { 34 pTreeSupplier.saveMap(vTree); 35 if (i % vModuloPrintProgress == 0) { 36 System.out.print('+'); 37 } 38 } 42 39 } 43 checkSize(vTree, vSize); 44 checkAllEntries(vTree); 40 OProfiler.getInstance().stopChrono(pTestName + ".1.createEntries", vTimer); 45 41 46 forceNewDatabase(); 47 vTree = new OMVRBTreeDatabaseLazySave<Long, Long>(fDatabase, vId); 48 vTree.load(); 49 checkSize(vTree, vSize); 50 checkAllEntries(vTree); 42 vTimer = OProfiler.getInstance().startChrono(); 43 browseEntrySetEntries(vTree, pKVFactory); 44 OProfiler.getInstance().stopChrono(pTestName + ".2.browseEntrySet", vTimer); 51 45 52 forceNewDatabase(); 53 vTree = new OMVRBTreeDatabaseLazySave<Long, Long>(fDatabase, vId); 54 vTree.load(); 55 for (Iterator<Long> vIt = fFactorySeqLong.unorderedIterator(); vIt.hasNext();) { 56 Long vKey = vIt.next(); 57 fFactorySeqLong.checkValueForKey(vKey, vTree.get(vKey)); 46 vTimer = OProfiler.getInstance().startChrono(); 47 requestAllKeys(vTree, pKVFactory); 48 OProfiler.getInstance().stopChrono(pTestName + ".3.requestAllKeys", vTimer); 49 50 if (pTestRefreshDb) { 51 forceNewDatabase(); 52 vTree = pTreeSupplier.load(fDatabase, vRid); 53 54 vTimer = OProfiler.getInstance().startChrono(); 55 browseEntrySetEntries(vTree, pKVFactory); 56 OProfiler.getInstance().stopChrono(pTestName + ".4.browseEntrySet.fromFreshDb", vTimer); 57 58 forceNewDatabase(); 59 vTree = pTreeSupplier.load(fDatabase, vRid); 60 61 vTimer = OProfiler.getInstance().startChrono(); 62 requestAllKeys(vTree, pKVFactory); 63 OProfiler.getInstance().stopChrono(pTestName + ".5.requestAllKeys.fromFreshDb", vTimer); 58 64 } 59 65 60 //Remove entries 61 forceNewDatabase(); 62 vTree = new OMVRBTreeDatabaseLazySave<Long, Long>(fDatabase, vId); 63 vTree.load(); 64 Long vKey = fFactorySeqLong.getUnorderedKeyToRemove(); 66 vTimer = OProfiler.getInstance().startChrono(); 67 Long vKey = pKVFactory.getUnorderedKeyToRemove(); 68 int i = 0; 65 69 while (vKey != null) { 66 //System.out.println(vKey);70 i++; 67 71 vTree.remove(vKey); 68 vTree.lazySave(); 69 //checkAllEntries(vTree); 70 vKey = fFactorySeqLong.getUnorderedKeyToRemove(); 72 if (i % pModuloSave == 0) { 73 pTreeSupplier.saveMap(vTree); 74 if (i % vModuloPrintProgress == 0) System.out.print('-'); 75 } 76 vKey = pKVFactory.getUnorderedKeyToRemove(); 71 77 } 72 78 Assert.assertTrue(vTree.isEmpty()); 79 OProfiler.getInstance().stopChrono(pTestName + ".6.removeEntries", vTimer); 73 80 } 74 81 75 protected void checkSize(Map<Long, Long> pTree, int pSize) { 76 Assert.assertEquals(pTree.size(), pSize); 82 /** Iterate over Map.entrySet iterator. */ 83 protected void browseEntrySetEntries(SortedMap<Long, Long> pTree, IKVFactory<Long, Long> pFactory) { 84 Long vPreviousKey = null; 85 for (Map.Entry<Long, Long> vEntry : pTree.entrySet()) { 86 pFactory.checkValueForKey(vEntry.getKey(), vEntry.getValue()); 87 if (vPreviousKey != null) Assert.assertTrue(pTree.comparator().compare(vPreviousKey, vEntry.getKey()) > 0); 88 } 77 89 } 78 90 79 protected void checkAllEntries(Map<Long, Long> pTree) {80 int vCount = 0;81 for ( Map.Entry<Long, Long> vEntry : pTree.entrySet()) {82 fFactorySeqLong.checkValueForKey(vEntry.getKey(), vEntry.getValue());83 vCount++;91 /** Each key in the Map is requested one by one in an unordored order. */ 92 protected void requestAllKeys(SortedMap<Long, Long> pTree, IKVFactory<Long, Long> pFactory) { 93 for (Iterator<Long> vIt = pFactory.unorderedIterator(); vIt.hasNext();) { 94 Long vKey = vIt.next(); 95 pFactory.checkValueForKey(vKey, pTree.get(vKey)); 84 96 } 85 checkSize(pTree, vCount);86 for (Iterator<Long> vIt = fFactorySeqLong.creationOrderIterator(); vIt.hasNext();) {87 Long vKey = vIt.next();88 fFactorySeqLong.checkValueForKey(vKey, pTree.get(vKey));89 }90 91 97 } 92 98 }
Note: See TracChangeset
for help on using the changeset viewer.