private static RelationList findRelationList(Cons<Pair<String, RelationList>> allLists, Object lastList, String attrName) { while (allLists != lastList) { Pair<String, RelationList> list = allLists.first(); // it is not safe to use == instead of equals(Object) to // compare Strings here because this method may be // called with non-interned strings (when reading the changelogs from DB) if (list.first.equals(attrName)) { return list.second; } allLists = allLists.rest(); } return null; }
public E get(int index) { if (index > (size - 1)) { throw new NoSuchElementException(); } else { Cons<E> iter = elems; while (index-- > 0) { iter = iter.rest(); } return iter.first(); } }
private static VBox[] borrowFromPool() { Cons<VBox[]> available = pool.get(); if (available.isEmpty()) { VBox[] newArray = new VBox[1000]; return newArray; } else { pool.set(available.rest()); return available.first(); } }
private SimpleReadSet makeSimpleReadSet() { HashSet<String> vboxIds = new HashSet<String>(); if (!this.bodiesRead.isEmpty()) { // the first may not be full jvstm.VBox[] array = this.bodiesRead.first(); for (int i = next + 1; i < array.length; i++) { String vboxId = ((VBox) array[i]).getId(); vboxIds.add(vboxId); } // the rest are full for (jvstm.VBox[] ar : bodiesRead.rest()) { for (int i = 0; i < ar.length; i++) { String vboxId = ((VBox) array[i]).getId(); vboxIds.add(vboxId); } } } return new SimpleReadSet(vboxIds.toArray(new String[vboxIds.size()])); }
while (myArrays != parentArrays) { returnToPool(myArrays.first()); myArrays = myArrays.rest();
@Override protected void deleteDomainObject() { super.deleteDomainObject(); // Mark the VState as deleted obj$state.markAsDeleted(); // Ensure that all RelationLists exist... create$allLists(); Cons<Pair<String, RelationList>> lists = relationLists; while (lists != (Object) Cons.empty()) { // ... and mark them as deleted lists.first().second.markAsDeleted(); lists = lists.rest(); } } }
protected boolean isSnapshotValidationWorthIt(ActiveTransactionsRecord lastRecord) { if (this.bodiesRead.isEmpty()) { return false; } int numberOfReadsToCheck = this.bodiesRead.first().length - (next + 1); // if there are more arrays the rest are full, for sure for (VBox[] array : bodiesRead.rest()) { numberOfReadsToCheck += array.length; } int numberOfWritesToCheck = 0; for (ActiveTransactionsRecord rec = this.activeTxRecord.getNext(); rec != null; rec = rec.getNext()) { numberOfWritesToCheck += rec.getWriteSet().size(); } return ((float) numberOfWritesToCheck) / numberOfReadsToCheck > WR_THRESHOLD; }
protected void validateGlobalReads(Cons<ReadBlock> reads, int startIdx) { VBox[] array = reads.first().entries; // the first may not be full for (int i = startIdx + 1; i < array.length; i++) { InplaceWrite iter = array[i].inplace; do { int maxVersion = retrieveAncestorVersion(iter.orec.owner); if (maxVersion >= 0) { manualAbort(); TransactionSignaller.SIGNALLER.signalCommitFail(iter.orec.owner); } iter = iter.next; } while (iter != null); } // the rest are full for (ReadBlock block : reads.rest()) { array = block.entries; for (int i = 0; i < array.length; i++) { InplaceWrite iter = array[i].inplace; do { int maxVersion = retrieveAncestorVersion(iter.orec.owner); if (maxVersion >= 0) { manualAbort(); TransactionSignaller.SIGNALLER.signalCommitFail(iter.orec.owner); } iter = iter.next; } while (iter != null); } } }
private E removeExisting(Cons<E> frontElems) { E result = frontElems.first(); frontElems = frontElems.rest(); if (frontElems.isEmpty()) { frontElems = rear.get().reverse(); if (!frontElems.isEmpty()) { // only clear the rear if it had anything rear.put((Cons<E>) Cons.empty()); } } front.put(frontElems); size.dec(); return result; }