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


C# SessionNoServer.DefaultDatabaseLocation方法代码示例

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


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

示例1: Button_Click

 private void Button_Click(object sender, RoutedEventArgs e)
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
     const UInt32 numberOfPersons = 10000;
     const ushort nodeMaxSize = 5000;
     const ushort comparisonByteArraySize = sizeof(UInt64); // enough room to hold entire idNumber of a Person
     const bool comparisonArrayIsCompleteKey = true;
     const bool addIdCompareIfEqual = false;
     Person person;
     session.BeginUpdate();
     session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.None;
     //mySession.SetTraceAllDbActivity();
     BTreeSet<string> stringSet = new BTreeSet<string>(null, session);
     BTreeSetOidShort<string> stringSetShort = new BTreeSetOidShort<string>(null, session);
     BTreeMap<string, string> stringMap = new BTreeMap<string, string>(null, session);
     BTreeMapOidShort<string, string> stringMapShort = new BTreeMapOidShort<string, string>(null, session);
     CompareByField<Person> compareByField = new CompareByField<Person>("idNumber", session, addIdCompareIfEqual);
     BTreeSet<Person> bTree = new BTreeSet<Person>(compareByField, session, nodeMaxSize, comparisonByteArraySize, comparisonArrayIsCompleteKey);
     session.Persist(bTree); // Persist the root of the BTree so that we have something persisted that can be flushed to disk if memory available becomes low
     for (int i = 0; i < numberOfPersons; i++)
     {
       person = new Person();
       // session.Persist(person);
       bTree.AddFast(person);
     }
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.UseExternalStorageApi = true;
     session.BeginRead();
     BTreeSet<Person> bTree = session.AllObjects<BTreeSet<Person>>().First();
     foreach (Person person in (IEnumerable<Person>)bTree)
     {
       if (person.IdNumber > 196988888791402)
       {
         Console.WriteLine(person);
         break;
       }
     }
     session.Commit();
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:45,代码来源:MainPage.xaml.cs

示例2: 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();
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:68,代码来源:FacebookGraph.cs

示例3: Main

    static void Main(string[] args)
    {
      bool import = args.Length > 0 && args[0].ToLower() == "-import";
      bool dirExist = Directory.Exists(s_systemDir);
      if (import || !dirExist)
      {
        if (dirExist)
          Directory.Delete(s_systemDir, true); // remove systemDir from prior runs and all its databases.
        Directory.CreateDirectory(s_systemDir);
        File.Copy(s_licenseDbFile, Path.Combine(s_systemDir, "4.odb"));

        using (SessionNoServer session = new SessionNoServer(s_systemDir))
        {
          DataCache.MaximumMemoryUse = 10000000000; // 10 GB, set this to what fits your case
          session.BeginUpdate();
          session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.LZ4;
          Graph g = new Graph(session);
          session.Persist(g);

          // SCHEMA
          VertexType userType = g.NewVertexType("User");
          PropertyType genderType = userType.NewProperty("Gender", DataType.Integer, PropertyKind.Indexed);

          VertexType ratingType = g.NewVertexType("Rating");
          PropertyType ratingValuePropertyType = ratingType.NewProperty("RatingValue", DataType.Integer, PropertyKind.Indexed);

          EdgeType ratingEdgeType = g.NewEdgeType("UserToRating", true, userType, ratingType);

          EdgeType ratingOfType = g.NewEdgeType("RatingOf", false, userType, userType);
          PropertyType ratingEdgePropertyType = ratingOfType.NewProperty("Rating", DataType.Integer, PropertyKind.Indexed);

          // DATA
          using (FileStream stream = File.OpenRead(System.IO.Path.Combine(s_inputDataDir, "gender.dat")))
          {
            using (StreamReader file = new System.IO.StreamReader(stream))
            {
              string line;
              int lineNumber = 0;
              while ((line = file.ReadLine()) != null)
              {
                lineNumber++;
                string[] fields = line.Split(',');
                Vertex aUser = userType.NewVertex();
                aUser.SetProperty(genderType, (int)fields[1][0] == 'M' ? Gender.Male : fields[1][0] == 'F' ? Gender.Female : Gender.Unknown);
              }
              Console.WriteLine("Done importing " + lineNumber + " users");
            }
          }

          using (FileStream stream = File.OpenRead(System.IO.Path.Combine(s_inputDataDir, "ratings.dat")))
          {
            using (StreamReader file = new System.IO.StreamReader(stream))
            {
              string line;
              int lineNumber = 0;
              Vertex rater = null;
              int raterId;
              int priorRaterId = -1;

              while ((line = file.ReadLine()) != null)
              {
                lineNumber++;
                if (lineNumber % 1000000 == 0)
                  Console.WriteLine("Parsing rating # " + lineNumber);
                string[] fields = line.Split(',');
                raterId = int.Parse(fields[0]);
                if (raterId != priorRaterId)
                  rater = userType.GetVertex(raterId);
                priorRaterId = raterId;
                int ratedId = int.Parse(fields[1]);
                int rating = int.Parse(fields[2]);
                Vertex ratingVertex = (from v in ratingType.GetVertices() where ((int)v.GetProperty(ratingValuePropertyType)) == rating select v).FirstOrDefault();
                if (ratingVertex == null)
                {
                  ratingVertex = ratingType.NewVertex();
                  ratingVertex.SetProperty(ratingValuePropertyType, rating);
                }
                Vertex rated = userType.GetVertex(ratedId);
                Edge aRatingOf = ratingOfType.NewEdge(rater, rated);
                aRatingOf.SetProperty(ratingEdgePropertyType, rating);
                Edge userRating = ratingEdgeType.NewEdge(rated, ratingVertex);
                if (lineNumber >= 10000000) // remove this condition if you have time to wait a while and you have at least 16GB of RAM memory
                  break;
              }
              Console.WriteLine("Done importing " + lineNumber + " ratings");
            }
          }
          session.Commit();
        }
      }
      // Query
      using (SessionNoServer session = new SessionNoServer(s_systemDir))
      {
        session.BeginRead();
        Graph g = Graph.Open(session);
        VertexType userType = g.FindVertexType("User");
        PropertyType genderType = userType.FindProperty("Gender");

        VertexType ratingType = g.FindVertexType("Rating");
        PropertyType ratingValuePropertyType = ratingType.FindProperty("RatingValue");
//.........这里部分代码省略.........
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:101,代码来源:DatingRecommendations.cs

示例4: AddVertices

    public void AddVertices()
    {
      using (var session = new SessionNoServer(@"d:\graphtest2"))
      {
        session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.LZ4;
        DataCache.MaximumMemoryUse = 4000000000;
        var sw = new Stopwatch();
        sw.Start();
        //int i = 0;
        //var dbl = new DatabaseLocation(Dns.GetHostEntry("wordanalysis.cloudapp.net").HostName, @"Z:\DBStore\", 0,
        //    3, session);
        //DatabaseLocation bl = session.NewLocation(dbl);
        //session.Commit(false);   
        //        Assert.That(bl!=null);

        // var db = session.OpenDatabase(15, true);
        session.BeginUpdate();
        var graph = new Graph(session);

        //define schema                       Trace.Wri


        VertexType concept = graph.NewVertexType("Concept");
        PropertyType conceptName = concept.NewProperty("ConceptName", DataType.String, PropertyKind.Unique);
        PropertyType conceptSize = concept.NewProperty("ConceptSize", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType conceptFrequency = concept.NewProperty("ConceptFrequency", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType similarity = concept.NewProperty("Similarity", DataType.Double, PropertyKind.NotIndexed);
        PropertyType vagueness = concept.NewProperty("Vagueness", DataType.Double, PropertyKind.NotIndexed);

        VertexType instance = graph.NewVertexType("Instance", concept);
        PropertyType instanceSize = instance.NewProperty("InstanceSize", DataType.Integer,
            PropertyKind.NotIndexed);
        PropertyType instanceName = instance.NewProperty("InstanceName", DataType.String,
            PropertyKind.Unique);
        PropertyType instanceFrequency = instance.NewProperty("InstanceFrequency",
            DataType.Integer,
            PropertyKind.NotIndexed);

        //VertexType attributes = graph.NewVertexType("Attribute");

        ////EdgeType hasAttirbute = attributes.edgattributes.NewHeadToTailEdge(nameScorePair,);
        //EdgeType cooccursWith = graph.NewEdgeType("CooccursWith", true, instance, instance);
        //PropertyType coocurrenceFrequency = namedScore.NewProperty("IntScore", DataType.Integer,
        //    PropertyKind.NotIndexed);

        //VertexType synonym = graph.NewVertexType("Synonym", namedScore);

        //PropertyType synonymScore = synonym.NewProperty("Score", DataType.Integer, PropertyKind.NotIndexed);
        //EdgeType hasSynonym = graph.NewEdgeType("HasSynonym", true, synonym, instance);


        EdgeType isA = graph.NewEdgeType("IsA", true, concept, instance);
        PropertyType frequency = isA.NewProperty("frequency", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType popularity = isA.NewProperty("popularity", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType ZipfSlope = isA.NewProperty("zipf_slope", DataType.Double, PropertyKind.NotIndexed);
        PropertyType ZipfPearson = isA.NewProperty("zipf_pearson", DataType.Double, PropertyKind.NotIndexed);
        EdgeType cooccurence = graph.NewEdgeType("Coocurrence", true, concept, concept);
        //LRVertex vx1 = graph.NewVertex(instance);
        //vx1.SetProperty("Name", "bla");

        //LRVertex vx2 = graph.NewVertex(instance);
        //vx2.SetProperty("bla", "name");
        //LREdge edge = graph.NewEdge(cooccurence, vx1, vx2);

        Vertex v2 = graph.NewVertex(concept);


        v2.SetProperty(conceptName, "factor");
        Vertex v3 = graph.NewVertex(instance);

        v3.SetProperty(instanceName, "age");


        session.Commit();
      }
      using (var session = new SessionNoServer(@"d:\graphtest2"))
      {
        //session.DefaultDatabaseLocation().CompressPages = true;
        DataCache.MaximumMemoryUse = 4000000000;
        var sw = new Stopwatch();
        sw.Start();
        //int i = 0;

        session.BeginRead();
        var graph = Graph.Open(session);

        //define schema                       Trace.Wri


        var vertexTypes = graph.FindVertexTypes();
        //vertexTypes.Select(x => x.TypeName).PrintDump();
        var edgeTypes = graph.FindEdgeTypes();

        VertexType concept = vertexTypes.FirstOrDefault(x => x.TypeName == "Concept") ?? graph.NewVertexType("Concept");

        PropertyType conceptName = concept.FindProperty("ConceptName");
        Assert.IsNotNull(conceptName, "ConceptName");
        PropertyType conceptSize = concept.FindProperty("ConceptSize");
        Assert.IsNotNull(conceptSize, "ConceptSize");
        PropertyType conceptFrequency = concept.FindProperty("ConceptFrequency");
//.........这里部分代码省略.........
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:101,代码来源:VelocityGraphTest.cs

示例5: TestVelecoityBuildLocal

    // [Test]
    public void TestVelecoityBuildLocal()
    {
      using (var session = new SessionNoServer(@"d:\graphtest"))
      {
        session.BeginUpdate();
        session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.LZ4;
        DataCache.MaximumMemoryUse = 2000000000;
        //var dbl = new DatabaseLocation(Dns.GetHostEntry("wordanalysis.cloudapp.net").HostName, @"Z:\DBStore\", 0,
        //    3, session);
        //DatabaseLocation bl = session.NewLocation(dbl);
        //session.Commit(false);   
        //        Assert.That(bl!=null);

        var graph = new Graph(session);
        session.Persist(graph);
        //define schema
        // session.BeginUpdate();
        VertexType namedScore = graph.NewVertexType("NamedScore");
        PropertyType name = namedScore.NewProperty("Name", DataType.String, PropertyKind.Indexed);
        PropertyType int_score = namedScore.NewProperty("IntScore", DataType.Integer,
            PropertyKind.NotIndexed);
        PropertyType double_score = namedScore.NewProperty("DoubleScore", DataType.Double,
            PropertyKind.NotIndexed);

        VertexType concept = graph.NewVertexType("Concept");
        PropertyType conceptName = concept.NewProperty("Name", DataType.String, PropertyKind.Unique);
        PropertyType conceptSize = concept.NewProperty("ConceptSize", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType conceptFrequency = concept.NewProperty("ConceptFrequency", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType similarity = concept.NewProperty("Similarity", DataType.Double, PropertyKind.NotIndexed);
        PropertyType vagueness = concept.NewProperty("Vagueness", DataType.Double, PropertyKind.NotIndexed);

        VertexType instance = graph.NewVertexType("Instance", concept);
        PropertyType instanceSize = instance.NewProperty("InstanceSize", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType instanceFrequency = instance.NewProperty("InstanceFrequency", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType instanceName = instance.NewProperty("Name", DataType.String, PropertyKind.Unique);

        VertexType attributes = graph.NewVertexType("Attribute", namedScore);

        //EdgeType hasAttirbute = attributes.edgattributes.NewHeadToTailEdge(nameScorePair,);
        EdgeType cooccursWith = graph.NewEdgeType("CooccursWith", true, instance, instance);
        PropertyType coocurrenceFrequency = namedScore.NewProperty("IntScore", DataType.Integer, PropertyKind.NotIndexed);

        VertexType synonym = graph.NewVertexType("Synonym", namedScore);

        PropertyType synonymScore = synonym.NewProperty("Score", DataType.Integer, PropertyKind.NotIndexed);
        EdgeType hasSynonym = graph.NewEdgeType("HasSynonym", true, synonym, instance);


        EdgeType isA = graph.NewEdgeType("IsA", true, concept, instance);
        PropertyType frequency = isA.NewProperty("frequency", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType popularity = isA.NewProperty("popularity", DataType.Integer, PropertyKind.NotIndexed);
        PropertyType ZipfSlope = isA.NewProperty("zipf_slope", DataType.Double, PropertyKind.NotIndexed);
        PropertyType ZipfPearson = isA.NewProperty("zipf_pearson", DataType.Double, PropertyKind.NotIndexed);
        EdgeType cooccurence = graph.NewEdgeType("Coocurrence", true, concept, concept);
        //Vertex vx1 = graph.NewVertex(instance);
        //vx1.SetProperty("Name", "bla");

        //Vertex vx2 = graph.NewVertex(instance);
        //vx2.SetProperty("bla", "name");
        //Edge edge = graph.NewEdge(cooccurence, vx1, vx2);

        using (var llz = new StreamReader(@"d:\isa_core.txt"))
        {
          string lastConcept = string.Empty;
          while (!llz.EndOfStream)
          {
            string ln = llz.ReadLine();
            if (string.IsNullOrEmpty(ln)) continue;
            string[] items = ln.Split(new[] { '\t' });

            if (items.Length < 4) continue;

            int id = -1;
            if (!int.TryParse(items[2], out id)) continue;
            var conceptVertex = graph.FindVertex(conceptName, items[0], false);
            if (conceptVertex == null)
            {
              conceptVertex = graph.NewVertex(concept);
              conceptVertex.SetProperty(conceptName, items[0]);
              conceptVertex.SetProperty(conceptFrequency, int.Parse(items[4]));
              conceptVertex.SetProperty(conceptSize, int.Parse(items[5]));
              double d = double.NaN;
              double.TryParse(items[6], out d);
              conceptVertex.SetProperty(vagueness, d);
              d = double.NaN;
              double.TryParse(items[7], out d);
              conceptVertex.SetProperty(ZipfSlope, d);
              d = double.NaN;
              double.TryParse(items[8], out d);
              conceptVertex.SetProperty(ZipfPearson, d);
            }
            var instanceVertex = graph.FindVertex(instanceName, items[1], false);

            if (instanceVertex == null)
            {
              instanceVertex = graph.NewVertex(instance);
              instanceVertex.SetProperty(instanceFrequency, int.Parse(items[9]));
              instanceVertex.SetProperty(instanceSize, int.Parse(items[10]));
            }
//.........这里部分代码省略.........
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:101,代码来源:VelocityGraphTest.cs

示例6: Create1Vertices


//.........这里部分代码省略.........
        {
        }
        Vertex findMats = userNamePropertyType.GetPropertyVertex("Mats", true);
        var list = userNamePropertyType.GetPropertyVertices("Mats", true).ToList();
        //Edge findWhen = bestFriendPropertyType.GetPropertyEdge(now);
        //var list2 = bestFriendPropertyType.GetPropertyEdges(now);
        Console.WriteLine(findMats);
       // session.Commit();
       // session.BeginRead();
        PropertyType adressProperty = g.FindVertexProperty(powerUserType, "Address");
        Vertex find1 = adressProperty.GetPropertyVertex(1, true);
        session.Abort();
        /*session.BeginUpdate();
        g.Unpersist(session);
        session.Commit();
        dirExist = Directory.Exists(systemDir);
        try
        {
          if (Directory.Exists(systemDir))
            Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases.
          Directory.CreateDirectory(systemDir);
          File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb"));
        }
        catch
        {
          File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb"));
        }*/

      }

      using (SessionNoServer session = new SessionNoServer(systemDir, 5000, false, true))
      {
        session.BeginUpdate();
        session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.None;
        Graph g = new Graph(session, vertexIdSetPerVertexType);
        session.Persist(g);
        Graph g2 = new Graph(session);
        session.Persist(g2);
        Graph g3 = new Graph(session);
        session.Persist(g3);
        UInt32 dbNum = session.DatabaseNumberOf(typeof(Graph));
        Graph g4 = (Graph)session.Open(dbNum, 2, 1, true); // g4 == g
        Graph g5 = (Graph)session.Open(dbNum, 2, 2, true); // g5 == g2
        Graph g6 = (Graph)session.Open(dbNum, 2, 3, true); // g6 == g3
        for (int i = 4; i < 8; i++)
        {
          Graph gt = new Graph(session);
          session.Persist(gt);
        }
        Graph g7 = new Graph(session);
        Placement place = new Placement(dbNum, 15);
        session.Persist(place, g7);
        // SCHEMA
        VertexType userType = g.NewVertexType("User");
        VertexType locationType = g.NewVertexType("Location");
        VertexType aVertexType = g.NewVertexType("A");
        VertexType bVertexType = g.NewVertexType("B");
        VertexType cVertexType = g.NewVertexType("C");
        EdgeType uEdge = g.NewEdgeType("unrestricted", true);
        Vertex aVertex = g.NewVertex(aVertexType);
        Vertex bVertex = g.NewVertex(bVertexType);
        Vertex cVertex = g.NewVertex(cVertexType);
        Edge abEdge = (Edge)aVertex.AddEdge("unrestricted", bVertex);
        Edge bcEdge = (Edge)aVertex.AddEdge("unrestricted", cVertex);
        Dictionary<Vertex, HashSet<Edge>> traverse = aVertex.Traverse(uEdge, Direction.Out);
        abEdge.Remove();
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:67,代码来源:VelocityGraphTest.cs


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