本文整理汇总了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();
}
}
示例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();
}
});
}
示例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();
}
});
}
示例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");
}