当前位置: 首页>>代码示例>>C#>>正文


C# SessionBase.Open方法代码示例

本文整理汇总了C#中SessionBase.Open方法的典型用法代码示例。如果您正苦于以下问题:C# SessionBase.Open方法的具体用法?C# SessionBase.Open怎么用?C# SessionBase.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionBase的用法示例。


在下文中一共展示了SessionBase.Open方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NotifyBeforeCommit

    void NotifyBeforeCommit(SessionBase session)
    {
      var newlyPersisted = session.NewOids;
      Console.Out.WriteLine("Number of newly persisted: " + newlyPersisted.Count);
      foreach (var id in newlyPersisted)
      {
        var pObj = session.Open(id);
      }

      var newlyUnpersisted = session.DeletedOids;
      Console.Out.WriteLine("Number of newly unpersisted: " + newlyUnpersisted.Count);

      var updated = session.UpdatedOids;
      Console.Out.WriteLine("Number of updated: " + updated.Count);
      foreach (var id in updated)
      {
        var pObj = session.Open(id);
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:19,代码来源:FileFolderTest.cs

示例2: calculateNumbers

 void calculateNumbers(SessionBase session)
 {
   ImdbRoot imdbRoot = (ImdbRoot)session.Open(session.DatabaseNumberOf(typeof(ImdbRoot)), 2, 1, false);
   ActingPerson kevin = new Actor("Bacon, Kevin (I)", session);
   if (!imdbRoot.ActingByNameSet.TryGetKey(kevin, ref kevin))
     Console.WriteLine("Couldn't find actor Kevin Bacon!");
   else
   {
     unchasedMovie = kevin.InMovieAs.ToList<Movie>();
     resultArray[bacon]++; // Kevin Bacon himself       
     while (unchasedMovie.Count > 0)
     {
       bacon++;
       processsMovies(session);
       foreach (ActingPerson acting in unchasedPerson)
       {
         foreach (Movie movie in (IEnumerable<Movie>)acting.InMovieAs)
           if (chasedMovie.Contains(movie.ShortId) == false)
             unchasedMovie.Add(movie);
       }
     }
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:23,代码来源:KevinBaconNumbers.cs

示例3: Recover1

 public void Recover1(SessionBase session)
 {
   Database db = null;
   session.BeginUpdate();
   db = session.OpenDatabase(88, true, false);
   if (db != null)
     session.DeleteDatabase(db);
   db = session.OpenDatabase(89, true, false);
   if (db != null)
     session.DeleteDatabase(db);
   session.Commit();
   session.BeginUpdate();
   db = session.NewDatabase(88);
   session.FlushUpdates();
   session.Abort();
   session.BeginUpdate();
   db = session.NewDatabase(88);
   SortedSetAny<float> floatSet;
   Oid floatSetOid;
   string dbPath = System.IO.Path.Combine(systemDir, "89.odb");
   Placement place = new Placement(88);
   for (int i = 0; i < 10; i++)
   {
     floatSet = new SortedSetAny<float>();
     floatSet.Persist(place, session);
     floatSetOid = floatSet.Oid;
   }
   db = session.NewDatabase(89);
   session.Commit();
   File.Delete(dbPath);
   session.BeginUpdate();
   db = session.NewDatabase(89);
   session.Commit();
   FileInfo info = new FileInfo(dbPath);
   info.CopyTo(dbPath + "X");
   session.BeginUpdate();
   SortedSetAny<int> intSet;
   place = new Placement(89);
   for (int i = 0; i < 10; i++)
   {
     intSet = new SortedSetAny<int>();
     intSet.Persist(place, session);
   }
   db = session.OpenDatabase(88);
   var list = db.AllObjects<SortedSetAny<float>>();
   foreach (SortedSetAny<float> set in list)
     set.Unpersist(session);
   db = session.OpenDatabase(89);
   session.Commit();
   intSet = null;
   db = null; // release refs so that cached data isn't stale
   File.Delete(dbPath);
   info = new FileInfo(dbPath + "X");
   info.MoveTo(dbPath);
   session.BeginUpdate();
   intSet = (SortedSetAny<int>)session.Open(89, 1, 1, false);
   Debug.Assert(intSet == null);
   object o = session.Open(88, 1, 1, false);
   floatSet = (SortedSetAny<float>)o;
   Debug.Assert(floatSet != null);
   session.Commit();
   session.BeginUpdate();
   db = session.OpenDatabase(88);
   session.DeleteDatabase(db);
   db = session.OpenDatabase(89);
   session.DeleteDatabase(db);
   session.Commit();
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:68,代码来源:RecoveryTests.cs

示例4: SyncWith

 static public void SyncWith(this SessionBase sessionToUpdate, SessionBase sessionToRead, Func<SessionBase, UInt64, Change, bool> doUpdate)
 {
   UInt64 currentVersion;
   UInt64 pageToReadVersion;
   bool conflictFound = false;
   using (var reader = sessionToRead.BeginRead())
   {
     Changes changes = (Changes)sessionToRead.Open(5, 1, 1, false);
     if (changes != null)
     {
       using (var updater = sessionToUpdate.BeginUpdate())
       {
         var dbs = sessionToUpdate.OpenAllDatabases();
         ReplicaSync matchingReplicaSync = null;
         foreach (ReplicaSync sync in sessionToUpdate.AllObjects<ReplicaSync>())
         {
           if (sync.SyncFromHost == sessionToRead.SystemHostName && sync.SyncFromPath == sessionToRead.SystemDirectory)
           {
             matchingReplicaSync = sync;
             break;
           }
         }
         if (changes.ChangeList.Count > 0)
         {
           foreach (TransactionChanges transactionChanges in changes.ChangeList)
           {
             if (matchingReplicaSync == null || matchingReplicaSync.TransactionNumber < transactionChanges.TransactionNumber)
             {
               foreach (Change change in transactionChanges.ChangeList)
               {
                 Database dbToUpdate = sessionToUpdate.OpenDatabase(change.DatabaseId, false, false);
                 Database dbToRead = sessionToRead.OpenDatabase(change.DatabaseId, false, false);
                 string dbName = dbToRead != null ? dbToRead.Name : null;
                 if (change.Deleted)
                 {
                   if (dbToUpdate == null) // does not exist
                     continue;
                   if (change.PageId == 0) // Database delete
                   {
                     currentVersion = dbToUpdate.Page.PageInfo.VersionNumber;
                     if (currentVersion < change.Version)
                       sessionToUpdate.DeleteDatabase(dbToUpdate);
                     else
                     {
                       conflictFound = true;
                       if (doUpdate(sessionToUpdate, currentVersion, change))
                         sessionToUpdate.DeleteDatabase(dbToUpdate);
                     }
                   }
                   else
                   {
                     Page page = sessionToUpdate.OpenPage(dbToUpdate, change.PageId);
                     if (page == null) // page does not exist
                       continue;
                     currentVersion = page.PageInfo.VersionNumber;
                     if (currentVersion < change.Version)
                       sessionToUpdate.DeletePage(dbToUpdate, page);
                     else
                     {
                       conflictFound = true;
                       if (doUpdate(sessionToUpdate, currentVersion, change))
                         sessionToUpdate.DeleteDatabase(dbToUpdate);
                     }
                   }
                 }
                 else
                 {
                   if (dbToUpdate == null) // does not exist
                     dbToUpdate = sessionToUpdate.NewDatabase(change.DatabaseId, 0, dbName);
                   if (change.PageId > 0)
                   {
                     Page pageToUpdate = sessionToUpdate.OpenPage(dbToUpdate, change.PageId);
                     Page pageToRead = sessionToRead.OpenPage(dbToRead, change.PageId);
                     if (pageToRead == null) // upcoming (not yet processed) changes must have deleted this page
                       continue;
                     currentVersion = pageToUpdate == null ? 0 : pageToUpdate.PageInfo.VersionNumber;
                     pageToReadVersion = pageToRead.PageInfo.VersionNumber;
                     if (currentVersion < pageToReadVersion || dbToUpdate.IsNew)
                       sessionToUpdate.ReplacePage(dbToUpdate, pageToUpdate, pageToRead);
                     else
                     {
                       conflictFound = true;
                       if (doUpdate(sessionToUpdate, currentVersion, change))
                         sessionToUpdate.ReplacePage(dbToUpdate, pageToUpdate, pageToRead);
                     }
                   }
                 }
               }
             }
           }
           UInt64 lastTransactionNumber = changes.ChangeList.Last().TransactionNumber;
           if (matchingReplicaSync != null)
             matchingReplicaSync.TransactionNumber = lastTransactionNumber;
           if (conflictFound)
           {
             sessionToUpdate.Verify();
           }
           sessionToUpdate.Commit();
           if (matchingReplicaSync == null)
           {
//.........这里部分代码省略.........
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:101,代码来源:Sync.cs

示例5: createDocumentInvertedIndex

 static void createDocumentInvertedIndex(SessionBase session, Database db, BTreeSet<Document> documentSet)
 {
   UInt32 dbNum = db.DatabaseNumber;
   Document doc = null;
   Document inputDoc = new Document(db.Id);
   Placement wordPlacement = new Placement(inputDoc.DatabaseNumber, 20000, 1, 25000, 65000, true, false, 1, false);
   Placement wordHitPlacement = new Placement(inputDoc.DatabaseNumber, 40000, 1, 25000, 65500, true, false, 1, false);
   //session.SetTraceDbActivity(db.DatabaseNumber);
   BTreeSetIterator<Document> iterator = documentSet.Iterator();
   iterator.GoTo(inputDoc);
   inputDoc = iterator.Current();
   while (inputDoc != null && inputDoc.Page.Database.DatabaseNumber == dbNum)
   {
     doc = (Document)session.Open(inputDoc.Page.Database, inputDoc.Id); // if matching database is availeble, use it to speed up lookup
     DocumentText docText = doc.Content;
     string text = docText.Text.ToLower();
     MatchCollection tagMatches = Regex.Matches(text, "[a-z][a-z.$]+");
     UInt64 wordCt = 0;
     WordHit wordHit;
     Word word;
     if (++s_docCountIndexed % 50000 == 0)
       Console.WriteLine(DateTime.Now.ToString() + ", done indexing article: " + s_docCountIndexed);
     BTreeSetOidShort<Word> wordSet = doc.WordSet;
     foreach (Match m in tagMatches)
     {
       word = new Word(m.Value);
       if (wordSet.TryGetKey(word, ref word))
       {
         //wordHit = doc.WordHit[word]; // to costly to add tight now - figure out a better way ?
         //wordHit.Add(wordCt);
       }
       else
       {
         word = new Word(m.Value);
         word.Persist(wordPlacement, session);
         wordSet.Add(word);
         wordHit = new WordHit(doc, wordCt++, session);
         //wordHit.Persist(wordHitPlacement, session);
         doc.WordHit.ValuePlacement = wordHitPlacement;
         doc.WordHit.AddFast(word, wordHit);
       }
     }
     inputDoc = iterator.Next();
   }
   session.FlushUpdates(db);
   session.ClearCachedObjects(db); // free up memory for objects we no longer need to have cached
   Console.WriteLine(DateTime.Now.ToString() + ", done indexing article: " + s_docCountIndexed + " Database: " + dbNum + " is completed.");
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:48,代码来源:Wikipedia.cs


注:本文中的SessionBase.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。