Skip to content

Gradoop HBase Store

手不要乱摸 edited this page Aug 5, 2018 · 4 revisions

HBase Store for Gradoop

Apache HBase

Apache HBase Apache HBase™ is the Hadoop database, a distributed, scalable, big data store.

With this adapter implementation you can use Apache HBase as DataSource or DataSink for your graph data.

Getting start

Add gradoop-hbase to your dependency

Compile gradoop hbase with

mvn clean install -DskipTests=true

Copy gradoop-store/gradoop-hbase/target/gradoop-hbase-<ver>.jar into your client lib.

Or you can simply use maven pom as below:

<!-- Maven Gradoop HBase -->
<dependency>
    <groupId>org.gradoop</groupId>
    <artifactId>gradoop-hbase</artifactId>
    <version>${gradoop.version}</version>
</dependency>

Creation of an HBase based Graph-store

// create gradoop HBase configuration
GradoopHBaseConfig config = GradoopHBaseConfig.getDefaultConfig();

// create store
HBaseEPGMStore graphStore = new HBaseEPGMStore(config);

let's just add some graph elements

graphStore.writeGraphHead(graphHead);
graphStore.wirteVertex(vertex);
graphStore.writeEdge(edge);

graphStore.flush();

Accessing Data

Example for DataSink & DataSource

Read data from store with flink

// data source
GradoopFlinkConfig flinkConfig = GradoopFlinkConfig.createConfig(getExecutionEnvironment());
DataSource hbaseDataSource = new HBaseDataSource(graphStore, flinkConfig);
GraphCollection result = HBaseDataSource.cypher(
    "MATCH (u1:Person)<-[:hasModerator]-(f:Forum)" +
    "(u2:Person)<-[:hasMember]-(f)" +
    "WHERE u1.name = \"Alice\"");

Write data from store with flink

// data sink
GradoopFlinkConfig flinkConfig = GradoopFlinkConfig.createConfig(getExecutionEnvironment());
DataSink HBaseSink = new HBaseDataSink(graphStore, flinkConfig);
HBaseSink.write(result);

Store Layout

GraphData (table 'graph_heads')

----------*-------------*-------------------------*---------------*-----------------------
  row     |     cf      |           cq            |  timestamp    |   value
----------*-------------*-------------------------*---------------*-----------------------
          |     m       |           l             |               |  {label}
  {id}    *-------------*-------------------------*---------------*-----------------------
          |   p_type    |      {property key}     |               |  {property type byte}
          *-------------*-------------------------*---------------*-----------------------
          |   p_value   |      {property key}     |               |  {property value}
----------*-------------*-------------------------*---------------*-----------------------


VertexData (table 'vertices')

----------*-------------*-------------------------*---------------*-----------------------
  row     |     cf      |           cq            |  timestamp    |   value
----------*-------------*-------------------------*---------------*-----------------------
          |      m      |            l            |               |  {label}
  {id}    *-------------*-------------------------*---------------*-----------------------
          |      m      |            g            |               |  {graph id}
          *-------------*-------------------------*---------------*-----------------------
          |   p_type    |      {property key}     |               |  {property type byte}
          *-------------*-------------------------*---------------*-----------------------
          |   p_value   |      {property key}     |               |  {property value}
----------*-------------*-------------------------*---------------*-----------------------


EdgeData (table 'edges')

----------*-------------*-------------------------*---------------*-----------------------
  row     |     cf      |           cq            |  timestamp    |   value
----------*-------------*-------------------------*---------------*-----------------------
          |      m      |            l            |               |  {label}
          *-------------*-------------------------*---------------*-----------------------
          |      m      |            g            |               |  {graph id}
  {id}    *-------------*-------------------------*---------------*-----------------------
          |      m      |            s            |               |  {source vertex id}
          *-------------*-------------------------*---------------*-----------------------
          |      m      |            t            |               |  {varget vertex id}
          *-------------*-------------------------*---------------*-----------------------
          |   p_type    |      {property key}     |               |  {property type byte}
          *-------------*-------------------------*---------------*-----------------------
          |   p_value   |      {property key}     |               |  {property value}
----------*-------------*-------------------------*---------------*-----------------------

Clone this wiki locally