HGraphDB TinkerPop 图数据库的 HBase 实现 项目简介
HGraphDB 是一个使用 HBase 作为图数据库的客户端层, 是 Apache TinkerPop 3 接口的实现。安装<dependency>
<groupId>io.hgraphdb</groupId>
<artifactId>hgraphdb</artifactId>
<version>1.0.1</version>
</dependency>使用要初始化 HGraphDB,需创建一个 HBaseGraphConfiguration 实例,然后使用静态工厂方法创建一个 HBaseGraph 实例。Configuration cfg = new HBaseGraphConfiguration()
.setInstanceType(InstanceType.DISTRIBUTED)
.setGraphNamespace("mygraph")
.setCreateTables(true)
.setRegionCount(numRegionServers)
.set("hbase.zookeeper.quorum", "127.0.0.1")
.set("zookeeper.znode.parent", "/hbase-unsecure");
HBaseGraph graph = (HBaseGraph) GraphFactory.open(cfg);如上所见,HBase 特定的配置参数可以直接传递。这些将在获取 HBase 连接时用到。结果图可以像其他任何 TinkerPop 图实例一样使用。Vertex v1 = graph.addVertex(T.id, 1, T.label, "person", "name", "John");
Vertex v2 = graph.addVertex(T.id, 2, T.label, "person", "name", "Sally");
v1.addEdge("knows", v2, T.id, "edge1", "since", LocalDate.now());
<groupId>io.hgraphdb</groupId>
<artifactId>hgraphdb</artifactId>
<version>1.0.1</version>
</dependency>使用要初始化 HGraphDB,需创建一个 HBaseGraphConfiguration 实例,然后使用静态工厂方法创建一个 HBaseGraph 实例。Configuration cfg = new HBaseGraphConfiguration()
.setInstanceType(InstanceType.DISTRIBUTED)
.setGraphNamespace("mygraph")
.setCreateTables(true)
.setRegionCount(numRegionServers)
.set("hbase.zookeeper.quorum", "127.0.0.1")
.set("zookeeper.znode.parent", "/hbase-unsecure");
HBaseGraph graph = (HBaseGraph) GraphFactory.open(cfg);如上所见,HBase 特定的配置参数可以直接传递。这些将在获取 HBase 连接时用到。结果图可以像其他任何 TinkerPop 图实例一样使用。Vertex v1 = graph.addVertex(T.id, 1, T.label, "person", "name", "John");
Vertex v2 = graph.addVertex(T.id, 2, T.label, "person", "name", "Sally");
v1.addEdge("knows", v2, T.id, "edge1", "since", LocalDate.now());