tinkerpop(1) 圖資料庫console調研,tinkerpopconsole

來源:互聯網
上載者:User

tinkerpop(1) 圖資料庫console調研,tinkerpopconsole

本文原文串連: http://blog.csdn.net/freewebsys/article/details/46348975 轉載請註明出處!

1,關於圖資料庫

tinkerpop是apache孵化器下面的一個項目。
開源圖資料庫引擎,圖資料庫用的最多的是neo4j,但是有著作權限制,要是使用社區版本就只能是,單機運行。

http://tinkerpop.incubator.apache.org/

文檔參考:
http://tinkerpop.incubator.apache.org/docs/3.0.0.M9-incubating/

2,啟動console
wget https://dist.apache.org/repos/dist/release/incubator/tinkerpop/3.0.0.M9-incubating/apache-gremlin-console-3.0.0.M9-incubating-bin.zipunzip apache-gremlin-console-3.0.0.M9-incubating-bin.zipmv apache-gremlin-console-3.0.0.M9-incubating console

啟動console:(可以單獨啟動)可以嘗試命令,測試資料,但是資料存放區在記憶體中,關閉就丟失了。

cd console# sh bin/gremlin.sh          \,,,/         (o o)-----oOOo-(3)-oOOo-----plugin activated: tinkerpop.serverplugin activated: tinkerpop.utilitiesplugin activated: tinkerpop.sugarplugin activated: tinkerpop.tinkergraph#開啟串連gremlin> g = TinkerGraph.open()==>tinkergraph[vertices:0 edges:0]#建立張三資料gremlin> zhangsan = g.addVertex("name","zhangsan")==>v[0]#建立李四資料gremlin> lisi = g.addVertex("name","lisi")==>v[2]#建立王五資料gremlin> wangwu = g.addVertex("name","wangwu")==>v[4]#設定李四和王五朋友關係,friend是串連的名字,可以隨意取。gremlin> lisi.addEdge("friend",zhangsan)==>e[6][2-friend->0]#設定王五和李四朋友關係gremlin> wangwu.addEdge("friend",lisi)==>e[7][4-friend->2]#查詢全部資料gremlin> g.vertices()==>v[0]==>v[2]==>v[4]#查詢關係gremlin> g.edges()==>e[6][2-friend->0]==>e[7][4-friend->2]gremlin> zhangsan==>v[0]#刪除張三資料gremlin> zhangsan.remove()==>null#刪除後全部資料gremlin> g.vertices()==>v[2]==>v[4]#刪除後關係資料gremlin> g.edges()==>e[7][4-friend->2]

開啟OLTP變數引擎

#開啟變數引擎gtgremlin> gt = g.traversal(standard())==>graphtraversalsource[tinkergraph[vertices:2 edges:1], standard]gremlin> #查看資料gremlin> gt.V()==>v[2]==>v[4]#查詢名字叫lisi的使用者gremlin> gt.V().has("name","lisi")==>v[2]#查詢李四的朋友,因為剛才把張三刪除了。所有沒有資料。gremlin> gt.V().has("name","lisi").out("friend").values("name")#查詢王五的朋友,關係是單向的。gremlin> gt.V().has("name","wangwu").out("friend").values("name")==>lisi

使用官方例子說明:

#初始化資料gremlin> g = TinkerFactory.createModern()==>tinkergraph[vertices:6 edges:6]#初始化遍曆引擎gremlin> gt = g.traversal(standard())==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]#查詢marko knows的人gremlin> gt.V().has('name','marko').out('knows').values('name')==>vadas==>josh#查詢marko created的人gremlin> gt.V().has('name','marko').out('created').values('name')==>lop#查詢marko knows的人,且這些人 created的人gremlin> gt.V().has('name','marko').out('knows').out('created').values('name')==>ripple==>lop#查詢josh created的人gremlin> gt.V().has('name','josh').out('created').values('name')==>ripple==>lop

圖的資料庫給人直觀的插入,查詢,非常方便。
更多查詢參考官網: http://tinkerpop.incubator.apache.org/docs/3.0.0.M9-incubating/

3,總結

本文原文串連: http://blog.csdn.net/freewebsys/article/details/46348975 轉載請註明出處!

圖資料庫非常方便,console是一個單機的記憶體版本,可以進行測試,查詢。
生產環境部署需要使用server版本。繼續研究。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.