データ形式

DSE Graphは、さまざまな形式を処理します。各形式には利点があり、どちらを使用するかは好みの問題です。

DSE Graphは、DSE Graph Loaderを使用して、コンマ区切り(CSV)、JSON、テキスト・データを取り込むことができます。DSE Graph Loaderは、必要に応じて取り込み時にデータを変換できるツールですが、変換が複雑な場合、データの取り込みが遅くなります。

Gryoはコンパクトなバイナリー形式で、DSE Graphにデータを入力するための最速かつ最も省スペースな形式です。この方法は、データがDSE Graphまたは別のグラフ・データベースから生成されている場合に使用できます。

GraphSONは、データとスキーマの両方を人間が読み取れる形式で渡すJSONスタイルのファイル形式です。構造が明らかであるため、作業がしやすい反面、ファイル・サイズが大きくなります。GraphMLは、データとスキーマの両方を同様に渡すXMLベースのファイル形式です。グラフ関連のツールとライブラリによって広くサポートされており、DSE Graphの安定した交換形式です。GraphSONとGraphMLは一般的な形式であり、別のグラフ・データベースからDSE Graphにデータをインポートするのに便利です。

CSV

CSVファイルは、DSE Graphに入力できる一般的なファイル形式です。CSVグラフ・データのサンプル:
personId|name|nickname|gender|CALORIES|macroGoal
1|Julia Child|null|F||
2|Simone Beck|null|F||

JSON

JSONファイルは、DSE Graphに入力できる一般的なファイル形式です。JSONグラフ・データのサンプル:
{ "personId":1, "country": {"value":"USA", "startYear":1930, "endYear":1949 } }

Gryo

グラフのデータをGryoファイルに書き込むには、単純なgraph.io()コマンドを使用します。
graph.io(gryo()).writeGraph("/tmp/recipe.gryo")

GraphSON

グラフのデータをGraphSONファイルに書き込むには、単純なgraph.io()コマンドを使用します。
graph.io(graphson()).writeGraph("/tmp/recipe.gson")

GraphSONファイルの出力のサンプル:

{"id":{"@type":"g:Map","@value":["~label","recipe","recipeId",{"@type":"g:Int32","@value":2003}]},"label":"recipe","inE":{"created":[{"id":{"@type":"g:Map","@value":["~label","created","
~out_vertex",{"@type":"g:Map","@value":["~label","person","personId",{"@type":"g:Int32","@value":1}]},"~in_vertex",{"@type":"g:Map","@value":["~label","recipe","recipeId",{"@type":"g:Int
32","@value":2003}]},"~local_id",{"@type":"g:UUID","@value":"f38f9dd1-2978-11e8-8043-6bfe97ac83b9"}]},"outV":{"@type":"g:Map","@value":["~label","person","personId",{"@type":"g:Int32","@
value":1}]},"properties":{"createDate":{}}}]},"outE":{"includedIn":[{"id":{"@type":"g:Map","@value":["~label","includedIn","~out_vertex",{"@type":"g:Map","@value":["~label","recipe","rec
ipeId",{"@type":"g:Int32","@value":2003}]},"~in_vertex",{"@type":"g:Map","@value":["~label","book","bookId",{"@type":"g:Int32","@value":1001}]},"~local_id",{"@type":"g:UUID","@value":"f3
90fd61-2978-11e8-8043-6bfe97ac83b9"}]},"inV":{"@type":"g:Map","@value":["~label","book","bookId",{"@type":"g:Int32","@value":1001}]}},{"id":{"@type":"g:Map","@value":["~label","includedI
n","~out_vertex",{"@type":"g:Map","@value":["~label","recipe","recipeId",{"@type":"g:Int32","@value":2003}]},"~in_vertex",{"@type":"g:Map","@value":["~label","ingredient","ingredId",{"@t
ype":"g:Int32","@value":3008}]},"~local_id",{"@type":"g:UUID","@value":"f3903a15-2978-11e8-8043-6bfe97ac83b9"}]},"inV":{"@type":"g:Map","@value":["~label","ingredient","ingredId",{"@type
":"g:Int32","@value":3008}]},"properties":{"amount":"2-3 Tbsp"}},{"id":{"@type":"g:Map","@value":["~label","includedIn","~out_vertex",{"@type":"g:Map","@value":["~label","recipe","recipe
Id",{"@type":"g:Int32","@value":2003}]},"~in_vertex",{"@type":"g:Map","@value":["~label","ingredient","ingredId",{"@type":"g:Int32","@value":3010}]},"~local_id",{"@type":"g:UUID","@value
":"f3903a16-2978-11e8-8043-6bfe97ac83b9"}]},"inV":{"@type":"g:Map","@value":["~label","ingredient","ingredId",{"@type":"g:Int32","@value":3010}]},"properties":{"amount":"1 1/2 lbs blanch
ed, trimmed"}},

GraphML

グラフのデータをGraphMLファイルに書き込むには、単純なgraph.io()コマンドを使用します。
graph.io(graphml()).writeGraph("/tmp/recipe.gml")

GraphSONファイルの出力のサンプル:

<?xml version='1.0' encoding='UTF-8'?><graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.grap
hdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.1/graphml.xsd"><key id="instructions" for="node" attr.name="instructions" attr.type="string"/><key id="notes" for="node" attr.n
ame="notes" attr.type="string"/><key id="mealId" for="node" attr.name="mealId" attr.type="int"/><key id="gender" for="node" attr.name="gender" attr.type="string"/><key id="ingredId" for=
"node" attr.name="ingredId" attr.type="int"/><key id="type" for="node" attr.name="type" attr.type="string"/><key id="recipeId" for="node" attr.name="recipeId" attr.type="int"/><key id="b
ookId" for="node" attr.name="bookId" attr.type="int"/><key id="labelV" for="node" attr.name="labelV" attr.type="string"/><key id="publishYear" for="node" attr.name="publishYear" attr.typ
e="int"/><key id="ISBN" for="node" attr.name="ISBN" attr.type="string"/><key id="name" for="node" attr.name="name" attr.type="string"/><key id="personId" for="node" attr.name="personId"
attr.type="int"/><key id="labelE" for="edge" attr.name="labelE" attr.type="string"/><key id="amount" for="edge" attr.name="amount" attr.type="string"/><key id="createDate" for="edge" att
r.name="createDate" attr.type="string"/><graph id="G" edgedefault="directed"><node id="{~label=recipe, recipeId=2003}"><data key="labelV">recipe</data><data key="instructions">Take a sal
ad bowl or platter and line it with lettuce leaves, shortly before serving. Drizzle some olive oil on the leaves and dust them with salt.</data><data key="notes"></data><data key="name">
Salade Nicoise</data><data key="recipeId">2003</data></node><node id="{~label=recipe, recipeId=2005}"><data key="labelV">recipe</data><data key="instructions">Preheat the oven to 375 deg
rees F. Cook bacon in a large skillet over medium heat until very crisp and fat has rendered, 8-10 minutes.</data><data key="notes"> </data><data key="name">Spicy Meatloaf</data><data ke
y="recipeId">2005</data></node><node id="{~label=recipe, recipeId=2006}"><data key="labelV">recipe</data><data key="instructions">Saute the shallots, celery, herbs, and seasonings in 3 t
ablespoons of the butter for 3 minutes. Add the watercress and let it wilt.</data><data key="notes"> </data><data key="name">Oysters Rockefeller</data><data key="recipeId">2006</data></n
ode><node id="{~label=recipe, recipeId=2007}"><data key="labelV">recipe</data><data key="instructions">In a heavy-bottomed pot, melt the butter. When it starts to foam, add the onions an
d thyme and cook over medium-low heat until tender, about 10 minutes.</data><data key="notes">Quick and easy.</data><data key="name">Carrot Soup</data><data key="recipeId">2007</data></n
ode><node id="{~label=recipe, recipeId=2001}"><data key="labelV">recipe</data><data key="instructions">Braise the beef. Saute the onions and carrots. Add wine and cook in a dutch oven at
 425 degrees for 1 hour.</data><data key="notes">Takes a long time to make.</data><data key="name">Beef Bourguignon</data><data key="recipeId">2001</data></node><node id="{~label=recipe,
 recipeId=2002}"><data key="labelV">recipe</data><data key="instructions">Peel and cut the egglant. Make sure you cut eggplant into lengthwise slices that are about 1-inch wmyIde, 3-inch
es long, and 3/8-inch thick</data><data key="notes">I've made this 13 times.</data>