public void InsertRepeatedNodesTest(string host, int port)
        {
            var gremlinDB = new GremlinDB(host, port, false);

            gremlinDB.Drop();

            var skills = new List <Skill>
            {
                new Skill()
                {
                    Name = ".net", Category = "platforms"
                },
                new Skill()
                {
                    Name = "c#", Category = "languages"
                },
                new Skill()
                {
                    Name = "c#", Category = "languages"
                }
            };

            gremlinDB.InsertNodes(skills);

            Assert.Equal(2, gremlinDB.CountNodes());
        }
        public void InsertNodesTest(string host, int port)
        {
            var gremlinDB = new GremlinDB(host, port, false);

            gremlinDB.Drop();

            var skills = new List <Skill>
            {
                new Skill()
                {
                    Name = ".net", Category = "platforms"
                },
                new Skill()
                {
                    Name = "c#", Category = "languages"
                },
                new Skill()
                {
                    Name = "java", Category = "languages"
                },
                new Skill()
                {
                    Name = "maven", Category = "development tools"
                },
                new Skill()
                {
                    Name = "junit", Category = "development tools"
                },
                new Skill()
                {
                    Name = "jenkins", Category = "development tools"
                },
                new Skill()
                {
                    Name = "eclipse", Category = "development tools"
                }
            };

            gremlinDB.InsertNodes(skills);

            Assert.Equal(7, gremlinDB.CountNodes());

            gremlinDB.Drop();

            Assert.Equal(0, gremlinDB.CountNodes());
        }
        public void NoNodesTest(string host, int port)
        {
            var gremlinDB = new GremlinDB(host, port, false);

            gremlinDB.Drop();

            Assert.Equal(0, gremlinDB.CountNodes());
        }
Пример #4
0
        public async Task RunAsync(string endpoint = "localhost", int port = 8182)
        {
            try
            {
                var skills = new List <Skill>();

                // This uses the default Neptune and Gremlin port, 8182
                var gremlinDB = new GremlinDB(endpoint, port);

                // Drop entire DB
                //gremlinDB.Drop();

                // get job posts
                var jobPosts = JobPostRepo.Get();
                //var jobPosts = JobPostRepo.GetJobPosts();

                // load csv data for skills
                skills = LoadDataToMemory();
                // skills into DB
                Stopwatch stopWatch  = new Stopwatch();
                Stopwatch stopWatch1 = new Stopwatch();
                stopWatch.Start();
                stopWatch1.Start();
                gremlinDB.InsertNodes(skills);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND inserting NODES\n");

                // edges into DB
                IJobPostProcessor jobPostProcessor = new JobPostProcessor();
                Console.WriteLine("Start processing JOB POSTS");
                stopWatch.Restart();
                var jobPostsSkills = jobPostProcessor.ProcessJobPosts(skills, jobPosts);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND iprocessing JOB POSTS\n");

                Console.WriteLine("Start inserting EDGES");
                stopWatch.Restart();
                gremlinDB.InsertEdges(jobPostsSkills);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND inserting EDGES\n");

                // get related skills
                const string skillNameForSearch = "c#";
                const int    limit = 10;

                Console.WriteLine("Start RELATED skills");
                var relatedSkills = gremlinDB.GetRelatedSkills(skillNameForSearch, limit);
                Console.WriteLine(stopWatch1.Elapsed);

                Console.WriteLine($"Top {limit} skills related to {skillNameForSearch}:\n");
                foreach (var skill in relatedSkills)
                {
                    Console.WriteLine($"Name: {skill.Name}, Category: {skill.Category}, Weight: {skill.Weight}");
                }

                Console.WriteLine("\n\nTotal number of skills: {0}", gremlinDB.CountNodes());

                await Helpers.Metrics.CommitDataAsync();

                Console.WriteLine("Finished");
            }
            catch (Exception e)
            {
                Console.WriteLine("{0}", e);
            }
        }