本文整理汇总了C#中Vertex.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Vertex.SetProperty方法的具体用法?C# Vertex.SetProperty怎么用?C# Vertex.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertex
的用法示例。
在下文中一共展示了Vertex.SetProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ingestData
public void ingestData()
{
if (Directory.Exists(Path.Combine(SessionBase.BaseDatabasePath, s_systemDir)))
Directory.Delete(Path.Combine(SessionBase.BaseDatabasePath, s_systemDir), true); // remove systemDir from prior runs and all its databases.
Directory.CreateDirectory(Path.Combine(SessionBase.BaseDatabasePath, s_systemDir));
File.Copy(s_licenseDbFile, Path.Combine(SessionBase.BaseDatabasePath, s_systemDir, "4.odb"));
using (SessionNoServer session = new SessionNoServer(s_systemDir, 5000, false, true))
{
session.BeginUpdate();
session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.LZ4;
Graph g = new Graph(session);
// SCHEMA
VertexType userType = g.NewVertexType("User");
EdgeType friendEdgeType = g.NewEdgeType("Friend", true, userType, userType);
PropertyType countryProperty = userType.NewProperty("country", DataType.String, PropertyKind.NotIndexed);
PropertyType incomeProperty = userType.NewProperty("income", DataType.Long, PropertyKind.NotIndexed);
PropertyType friendshipStartProperty = friendEdgeType.NewProperty("start", DataType.DateTime, PropertyKind.NotIndexed);
// DATA
int lineNumber = 0;
long fiendsCt = 0;
int stop = (int)Math.Pow(2, 26); // make sure to create enough of these
for (int i = 1; i < stop; i++)
g.NewVertex(userType);
session.Commit();
session.BeginUpdate();
foreach (string line in File.ReadLines(s_inputData))
{
if (++lineNumber % 10000 == 0)
Console.WriteLine("Parsing user " + lineNumber + ", friends total: " + fiendsCt + " at " + DateTime.Now);
string[] fields = line.Split(' ');
Vertex aUser = null;
foreach (string s in fields)
{
if (s.Length > 0)
{
if (aUser == null)
aUser = new Vertex(g, userType, int.Parse(s));
else
{
++fiendsCt;
Vertex aFriend = new Vertex(g, userType, int.Parse(s));
if (fiendsCt % 2 == 0)
aFriend.SetProperty(countryProperty, "Sweden"); // just some random stuff
else
aFriend.SetProperty(incomeProperty, fiendsCt); // just some random stuff
Edge edge = friendEdgeType.NewEdge(aUser, aFriend);
if (fiendsCt % 2 == 0)
edge.SetProperty(friendshipStartProperty, DateTime.Now);
}
}
}
if (DataCache.MaximumMemoryUse <= 27000000000)
{
if (lineNumber >= 20000) // remove this condition if you have time to wait a long while...
break;
}
}
Console.WriteLine("Done importing " + lineNumber + " users with " + fiendsCt + " friends");
session.Commit();
}
}