コード例 #1
0
        public static void MThreadProc6()
        {
            OServer   server   = Server.Connect();
            ODatabase database = new ODatabase("localhost", 2424, "TreeOfScience", ODatabaseType.Graph, "admin", "admin");

            string url, json;
            Vertex v;

            MagVertex m = new MagVertex {
            };

            url = @"F:\graph\mag_papers_";
            for (int i = 122; i < 123 /*167*/; i++)
            {
                using (StreamReader sr = File.OpenText(url + i + ".txt"))
                {
                    while ((json = sr.ReadLine()) != null)
                    {
                        v = JsonConvert.DeserializeObject <Vertex>(json);
                        if (v.authors != null)
                        {
                            for (int currentAuthor = 0; currentAuthor < v.authors.Length; currentAuthor++)
                            {
                                v.authors[currentAuthor].@class = "Author";
                                v.authors[currentAuthor].@type  = "d";
                            }
                        }
                        m.mag_id     = v.id;
                        m.title      = v.title;
                        m.authors    = v.authors;
                        m.year       = v.year;
                        m.venue      = v.venue;
                        m.keywords   = v.keywords;
                        m.fos        = v.fos;
                        m.n_citation = v.n_citation;
                        m.references = v.references;
                        m.page_stat  = v.page_stat;
                        m.page_end   = v.page_end;
                        m.doc_type   = v.doc_type;
                        m.lang       = v.lang;
                        m.publisher  = v.publisher;
                        m.volume     = v.volume;
                        m.issue      = v.issue;
                        m.issn       = v.issn;
                        m.isbn       = v.isbn;
                        m.doi        = v.doi;
                        m.pdf        = v.pdf;
                        m.url        = v.url;
                        m.Abstract   = v.Abstract;
                        json         = JsonConvert.SerializeObject(m).Replace("Abstract", "abstract").Replace("type", "@type").Replace("class", "@class").Replace("doc_@type", "doc_type");
                        database.Command("INSERT INTO Document CONTENT " + json);
                    }
                }
                Console.WriteLine("m" + i);
            }
        }
コード例 #2
0
        public static void MagTransThr6()
        {
            OServer   server   = Server.Connect();
            ODatabase database = new ODatabase("localhost", 2424, "TreeOfScience", ODatabaseType.Graph, "admin", "admin");

            string url, json;
            Vertex v;

            MagVertex m = new MagVertex {
            };

            url = @"F:\graph\mag_papers_";
            for (int i = 112; i < 167 /*167*/; i++)
            {
                string        batch;
                StringBuilder builder = new StringBuilder("BEGIN;\n", 250000000);
                using (StreamReader sr = File.OpenText(url + i + ".txt"))
                {
                    for (int rcount = 1; (json = sr.ReadLine()) != null; rcount++)
                    {
                        v = JsonConvert.DeserializeObject <Vertex>(json);
                        if (v.authors != null)
                        {
                            for (int currentAuthor = 0; currentAuthor < v.authors.Length; currentAuthor++)
                            {
                                v.authors[currentAuthor].@class = "Author";
                                v.authors[currentAuthor].@type  = "d";
                            }
                        }
                        m.mag_id     = v.id;
                        m.title      = v.title;
                        m.authors    = v.authors;
                        m.year       = v.year;
                        m.venue      = v.venue;
                        m.keywords   = v.keywords;
                        m.fos        = v.fos;
                        m.n_citation = v.n_citation;
                        m.references = v.references;
                        m.page_stat  = v.page_stat;
                        m.page_end   = v.page_end;
                        m.doc_type   = v.doc_type;
                        m.lang       = v.lang;
                        m.publisher  = v.publisher;
                        m.volume     = v.volume;
                        m.issue      = v.issue;
                        m.issn       = v.issn;
                        m.isbn       = v.isbn;
                        m.doi        = v.doi;
                        m.pdf        = v.pdf;
                        m.url        = v.url;
                        m.Abstract   = v.Abstract;
                        json         = JsonConvert.SerializeObject(m).Replace("Abstract", "abstract").Replace("type", "@type").Replace("class", "@class").Replace("doc_@type", "doc_type");
                        builder.Append("INSERT INTO Document CONTENT ");
                        builder.Append(json);
                        builder.Append(";\n");
                        if (rcount % 1000 == 0)
                        {
                            builder.Append("COMMIT;");
                            batch = builder.ToString();
                            Console.WriteLine(String.Concat(DateTime.Now, " m", i, " ", rcount / 1000));
                            database.SqlBatch(batch).Run();
                            builder.Clear();
                            builder.Append("BEGIN;\n");
                        }
                    }
                }
                builder.Append("COMMIT;");
                batch = builder.ToString();
                database.SqlBatch(batch).Run();
                Console.WriteLine(String.Concat(DateTime.Now, " m", i, " OK"));
            }
        }