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


C# SessionNoServer.FlushUpdates方法代码示例

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


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

示例1: SingleReaderSingleUpdater3

 public void SingleReaderSingleUpdater3()
 {
   UInt64 id;
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     Man man = new Man();
     man.Persist(session, man);
     id = man.Id;
     session.Commit();
     session.BeginUpdate();
     man.Age = ++man.Age;
     session.FlushUpdates();
     using (SessionNoServer session2 = new SessionNoServer(systemDir))
     {
       session2.BeginRead();
       Man man2 = (Man)session2.Open(id);
       Assert.Less(man2.Age, man.Age);
       session2.Commit();
     }
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:23,代码来源:ReadersWithUpdater.cs

示例2: TwoUpdaters3

 public void TwoUpdaters3()
 {
   Assert.Throws<OptimisticLockingFailed>(() =>
   {
     UInt64 id;
     try
     {
       using (SessionNoServer session = new SessionNoServer(systemDir))
       {
         session.BeginUpdate();
         Man man = new Man();
         man.Persist(session, man);
         id = man.Id;
         session.Commit();
         session.BeginUpdate();
         man.Age = ++man.Age;
         session.FlushUpdates(); // fStream set for updated databases will cause other write sessions to fail updating these databases
         using (SessionNoServer session2 = new SessionNoServer(systemDir))
         {
           session2.BeginUpdate();
           Man man2 = (Man)session2.Open(id);
           Assert.Less(man2.Age, man.Age);
           man2.Age = ++man.Age;
           session2.Commit(); // OptimisticLockingFailed here
         }
         session.Commit();
       }
     }
     finally
     {
       System.GC.Collect();
     }
   });
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:34,代码来源:MultipleUpdaters.cs

示例3: TwoUpdaters2

 public void TwoUpdaters2()
 {
   Assert.Throws<OpenDatabaseException>(() =>
   {
     UInt64 id;
     try
     {
       using (SessionNoServer session = new SessionNoServer(systemDir))
       {
         session.BeginUpdate();
         Man man = new Man();
         man.Persist(session, man);
         id = man.Id;
         session.Commit();
         session.BeginUpdate();
         man.Age = ++man.Age;
         session.FlushUpdates();
         using (SessionNoServer session2 = new SessionNoServer(systemDir))
         {
           session2.BeginRead();
           Man man2 = (Man)session2.Open(id);
           Assert.Less(man2.Age, man.Age);
           man2.Age = ++man.Age; // We'll get the OpenDatabase exception here since we are not in an update transaction
           session2.Commit();
         }
         session.Commit();
       }
     }
     finally
     {
       System.GC.Collect();
     }
   });
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:34,代码来源:MultipleUpdaters.cs

示例4: importEntireWikipedia


//.........这里部分代码省略.........
              while (textReader.Read())
              {
                System.Xml.XmlNodeType nodeType = textReader.NodeType;
                switch (nodeType)
                {
                  case System.Xml.XmlNodeType.Attribute:
                    break;
                  case System.Xml.XmlNodeType.CDATA:
                    break;
                  case System.Xml.XmlNodeType.Comment:
                    xmlComment = new XmlComment(textReader.Value, xmlDocument);
                    break;
                  case System.Xml.XmlNodeType.Document:
                    break;
                  case System.Xml.XmlNodeType.DocumentFragment:
                    break;
                  case System.Xml.XmlNodeType.DocumentType:
                    break;
                  case System.Xml.XmlNodeType.Element:
                    xmlElement = new XmlElement(textReader.Prefix, textReader.LocalName, textReader.NamespaceURI, xmlDocument);
                    if (textReader.LocalName == "title")
                      titleElement = true;
                    else if (textReader.LocalName == "text")
                      pageText = true;
                    break;
                  case System.Xml.XmlNodeType.EndElement:
                    if (textReader.LocalName == "title" && doc != null)
                      titleElement = false;
                    else if (textReader.LocalName == "text" && doc != null)
                      pageText = false;
                    break;
                  case System.Xml.XmlNodeType.EndEntity:
                    break;
                  case System.Xml.XmlNodeType.Entity:
                    xmlEntity = new XmlEntity(textReader.LocalName, xmlDocument);
                    break;
                  case System.Xml.XmlNodeType.EntityReference:
                    break;
                  case System.Xml.XmlNodeType.None:
                    break;
                  case System.Xml.XmlNodeType.Notation:
                    break;
                  case System.Xml.XmlNodeType.ProcessingInstruction:
                    break;
                  case System.Xml.XmlNodeType.SignificantWhitespace:
                    break;
                  case System.Xml.XmlNodeType.Text:
                    xmlText = new XmlText(textReader.Value, xmlDocument);
                    if (titleElement)
                    {
                      doc = new Document(textReader.Value, indexRoot, session);
                      doc.Persist(documentPlacement, session, true);
                      if (doc.DatabaseNumber != currentDocumentDatabaseNum)
                      {
                        session.FlushUpdates(session.OpenDatabase(currentDocumentDatabaseNum));
                        Console.WriteLine("Database: " + currentDocumentDatabaseNum +" is completed, done importing article " + docCount + " number of lines: " + textReader.LineNumber);
                        currentDocumentDatabaseNum = doc.DatabaseNumber;
                      }
                      //doc.Page.Database.Name = doc.Name;
                    }
                    else if (doc != null && pageText)
                    {
#if DEBUGx
                      Console.WriteLine(doc.Name + " line: " + textReader.LineNumber);
#endif
                      //if (textReader.LineNumber > 1000000)
                      //{
                      //  session.Commit();
                      //  return;
                      //}
                      DocumentText content = new DocumentText(textReader.Value, doc);
                      if (doc.DatabaseNumber != contentPlacement.TryDatabaseNumber)
                        contentPlacement = new Placement(doc.DatabaseNumber, (ushort)contentPlacement.StartPageNumber, 1, contentPlacement.MaxObjectsPerPage, contentPlacement.MaxPagesPerDatabase, false, false, 1, false);
                      content.Persist(contentPlacement, session, false);
                      Debug.Assert(content.DatabaseNumber == doc.DatabaseNumber);
                      doc.Content = content;
                      indexRoot.repository.documentSet.AddFast(doc);
                      if (++docCount % 1000000 == 0)
                      {
                        //session.Commit(false); // skip recovery check, we do it in BeginUpdate which is enough
                        Console.WriteLine("Done importing article " + docCount + " number of lines: " + textReader.LineNumber);
                        //session.BeginUpdate();
                      }
                    }
                    break;
                  case System.Xml.XmlNodeType.Whitespace:
                    xmlWhitespace = new XmlWhitespace(textReader.Value, xmlDocument);
                    break;
                  case System.Xml.XmlNodeType.XmlDeclaration:
                    break;
                };
              }
              Console.WriteLine("Finished importing article " + docCount + " number of lines: " + textReader.LineNumber);
            }
          }
        }
        session.Commit();
      }
      Console.WriteLine(DateTime.Now.ToString() + ", done importing Wikipedia text");
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:101,代码来源:Wikipedia.cs


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