コード例 #1
0
  EntryViewImpl(
      Transaction aTxn, MangledEntry[] aTemplates, boolean holdLocks, boolean doUpdate, long aLimit)
      throws TransactionException, IOException {

    shouldUpdate = doUpdate;

    theTxn = TxnDispatcher.get().resolve(aTxn);

    /*
     Basic process is to assemble a set of fully matching Entry UID's which we
     then step through ascertaining whether these UID's are still valid and possibly
     asserting locks transactionally.

     Full matching is done in each view and the matching tuples are then
     logged/merged in the UIDSet

     These tuple ids are then scanned through using EntryReposImpl::find to load
     the entry, verify it's valid etc after which we may or may not maintain a
     transaction lock (these steps are done in EntryRx).
    */
    theUIDs = new UIDSet(aLimit);

    theBuffer = new EntryRx(theTxn, holdLocks);
    theDynamicView = new NewView(this, aTemplates, theUIDs);

    if (shouldUpdate) EventQueue.get().insert(theDynamicView.getSearchTask());

    /*
     For each template do a full tree search and assemble all matches
    */
    for (int i = 0; i < aTemplates.length; i++) {
      if (theUIDs.isFull()) break;

      DiskView myFixedView = new DiskView(aTemplates[i], theUIDs);

      EntryRepository myRepos = EntryRepositoryFactory.get().find(aTemplates[i].getType());

      if (myRepos != null) {
        myRepos.find(aTemplates[i], myFixedView);

        // Try subtypes
        Set<String> mySubtypes = myRepos.getSubtypes();

        for (String t : mySubtypes) {
          myRepos = EntryRepositoryFactory.get().find(t);

          if (myRepos != null) {
            myRepos.find(aTemplates[i], myFixedView);
          }
        }
      }
    }
  }
コード例 #2
0
  public EntryChit next() throws TransactionException, IOException {
    synchronized (this) {
      if (theStatus == DECEASED) {
        if (theException != null) throw theException;
        else throw new TransactionException("No longer active");
      }
    }

    SpaceEntryUID myUID;

    while ((myUID = theUIDs.pop()) != null) {
      EntryRepository myRepos = EntryRepositoryFactory.get().get(myUID.getType());

      myRepos.find(theBuffer, myUID.getOID(), null);

      MangledEntry myEntry = theBuffer.getEntry();

      if (myEntry != null) return new EntryChit(myEntry, myUID);
    }

    return null;
  }