public BulkInsertEdge ( string dataFileName, string tableSchema, string sourceTableName, string sourceNodeIdName, string sinkTableName, string sinkNodeIdName, string edgeColumnName, IList |
||
dataFileName | string | The name of data file. |
tableSchema | string | The Schema name of node table. Default by "dbo". |
sourceTableName | string | The source node table name of node table. |
sourceNodeIdName | string | The node id name of source node table. |
sinkTableName | string | The Sink node table name of node table. |
sinkNodeIdName | string | The node id name of Sink node table. |
edgeColumnName | string | The edge column name in source node table. |
dataEdgeAttributeName | IList |
User-supplied edge attribute name in data file in order. /// By default(null), data file should exactly contain all the Edge Attribute in creating order. /// Empty stands for that data file doesn't provide edge attribute. |
fieldTerminator | string | The field terminator of data file. Default by "\t". |
rowTerminator | string | The row terminator of data file. Default by "\r\n". |
updateMethod | bool | Choose update method or rebuild table method to implement bulk insert edge. /// True, the data file contains Header |
Header | bool | |
리턴 | void |
public static void run() { GraphViewConnection con = new GraphViewConnection(TutorialConfiguration.getConnectionString()); con.Open(); con.ClearData(); try { generateFiles(); Console.WriteLine("Creating tables..."); #region Create a schema for reader and book con.CreateNodeTable(@"CREATE TABLE [Book] ( [ColumnRole:""NodeId""] name VARCHAR(40) )"); con.CreateNodeTable(@"CREATE TABLE [Reader] ( [ColumnRole:""NodeId""] name VARCHAR(30), [ColumnRole:""Property""] gender VARCHAR(10), [ColumnRole:""Edge"",Reference:""Book""] Reads VARBINARY(max) )"); #endregion Console.WriteLine("BulkLoading..."); #region Bulk Load Nodes con.BulkInsertNode(ReaderFileName, "Reader", "dbo", null, ",", "\n"); con.BulkInsertNode(BookFileName, "Book", "dbo", null, ",", "\n"); con.BulkInsertEdge(readRelationFileName, "dbo", "Reader", "name", "Book", "name", "Reads", null, ",", "\n"); #endregion Console.WriteLine("Querying..."); #region Query var res = con.ExecuteReader(@"SELECT x.name as name1, y.name as name2 FROM Reader x, Book y MATCH x-[Reads]->y "); try { while (res.Read()) { System.Console.WriteLine(res["name1"].ToString() + " Reads " + res["name2"].ToString()); } } finally { if (res != null) res.Close(); } #endregion } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } finally // close the connection and drop table { con.ClearGraphDatabase(); con.Close(); deleteFiles(); } }