Skip to content

Commit

Permalink
[ #295] Move HBase related code into separate maven module
Browse files Browse the repository at this point in the history
* HBase dependency still necessary in gradoop-common and gradoop-flink (usage of Bytes class)
* fixes  #295
  • Loading branch information
smee authored and s1ck committed Jun 12, 2017
1 parent d444a89 commit 9afacb2
Show file tree
Hide file tree
Showing 105 changed files with 1,186 additions and 482 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@
import org.gradoop.common.model.impl.pojo.GraphHeadFactory;
import org.gradoop.common.model.impl.pojo.Vertex;
import org.gradoop.common.model.impl.pojo.VertexFactory;
import org.gradoop.common.storage.api.EdgeHandler;
import org.gradoop.common.storage.api.GraphHeadHandler;
import org.gradoop.common.storage.api.VertexHandler;
import org.gradoop.common.storage.impl.hbase.HBaseEdgeHandler;
import org.gradoop.common.storage.impl.hbase.HBaseGraphHeadHandler;
import org.gradoop.common.storage.impl.hbase.HBaseVertexHandler;

import static com.google.common.base.Preconditions.checkNotNull;

/**
* Basic Gradoop Configuration.
Expand All @@ -48,18 +40,11 @@
public class GradoopConfig
<G extends EPGMGraphHead, V extends EPGMVertex, E extends EPGMEdge> {

/**
* Graph head handler.
*/
private final GraphHeadHandler<G> graphHeadHandler;
/**
* EPGMVertex handler.
*/
private final VertexHandler<V, E> vertexHandler;
/**
* EPGMEdge handler.
*/
private final EdgeHandler<E, V> edgeHandler;
private final GraphHeadFactory graphHeadFactory;

private final VertexFactory vertexFactory;

private final EdgeFactory edgeFactory;

/**
* Creates a new Configuration.
Expand All @@ -68,14 +53,11 @@ public class GradoopConfig
* @param vertexHandler vertex handler
* @param edgeHandler edge handler
*/
protected GradoopConfig(GraphHeadHandler<G> graphHeadHandler,
VertexHandler<V, E> vertexHandler, EdgeHandler<E, V> edgeHandler) {
this.graphHeadHandler =
checkNotNull(graphHeadHandler, "GraphHeadHandler was null");
this.vertexHandler =
checkNotNull(vertexHandler, "VertexHandler was null");
this.edgeHandler =
checkNotNull(edgeHandler, "EdgeHandler was null");
@SuppressWarnings("unchecked")
protected GradoopConfig() {
this.graphHeadFactory = new GraphHeadFactory();
this.vertexFactory = new VertexFactory();
this.edgeFactory = new EdgeFactory();
}

/**
Expand All @@ -85,57 +67,18 @@ protected GradoopConfig(GraphHeadHandler<G> graphHeadHandler,
* @return Default Gradoop configuration.
*/
public static GradoopConfig<GraphHead, Vertex, Edge> getDefaultConfig() {
VertexHandler<Vertex, Edge> vertexHandler = new HBaseVertexHandler<>(
new VertexFactory());
EdgeHandler<Edge, Vertex> edgeHandler = new HBaseEdgeHandler<>(
new EdgeFactory());
GraphHeadHandler<GraphHead> graphHeadHandler = new HBaseGraphHeadHandler<>(
new GraphHeadFactory());
return new GradoopConfig<>(graphHeadHandler, vertexHandler, edgeHandler);
}

/**
* Creates a Gradoop configuration based on the given arguments.
*
* @param graphHeadHandler EPGM graph head handler
* @param vertexHandler EPGM vertex handler
* @param edgeHandler EPGM edge handler
* @param <G> EPGM graph head type
* @param <V> EPGM vertex type
* @param <E> EPGM edge type
*
* @return Gradoop HBase configuration
*/
public static
<G extends EPGMGraphHead, V extends EPGMVertex, E extends EPGMEdge>
GradoopConfig createConfig(
GraphHeadHandler<G> graphHeadHandler,
VertexHandler<V, E> vertexHandler,
EdgeHandler<E, V> edgeHandler) {
return new GradoopConfig<>(graphHeadHandler, vertexHandler, edgeHandler);
}

public GraphHeadHandler<G> getGraphHeadHandler() {
return graphHeadHandler;
}

public VertexHandler<V, E> getVertexHandler() {
return vertexHandler;
}

public EdgeHandler<E, V> getEdgeHandler() {
return edgeHandler;
return new GradoopConfig<>();
}

public EPGMGraphHeadFactory<G> getGraphHeadFactory() {
return graphHeadHandler.getGraphHeadFactory();
public GraphHeadFactory getGraphHeadFactory() {
return graphHeadFactory;
}

public EPGMVertexFactory<V> getVertexFactory() {
return vertexHandler.getVertexFactory();
public VertexFactory getVertexFactory() {
return vertexFactory;
}

public EPGMEdgeFactory<E> getEdgeFactory() {
return edgeHandler.getEdgeFactory();
public EdgeFactory getEdgeFactory() {
return edgeFactory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public interface EPGMVertexFactory<V extends EPGMVertex>
* @param properties vertex properties
* @return vertex data
*/
EPGMVertex createVertex(String label, Properties properties);
V createVertex(String label, Properties properties);

/**
* Initializes a vertex based on the given parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ private void initEdges() {
* @return EPGM graph head
*/
private G initGraphHead(Graph g) {
G graphHead = config.getGraphHeadFactory().createGraphHead(
G graphHead = (G) config.getGraphHeadFactory().createGraphHead(
g.getLabel(), Properties.createFromMap(g.getProperties()));
graphHeadIds.put(g.getId(), graphHead.getId());
graphHeads.put(graphHead.getId(), graphHead);
Expand All @@ -500,7 +500,7 @@ private G initGraphHead(Graph g) {
private V initVertex(Vertex v) {
V vertex;
if (!vertexIds.containsKey(v.getId())) {
vertex = config.getVertexFactory().createVertex(
vertex = (V) config.getVertexFactory().createVertex(
v.getLabel(),
Properties.createFromMap(v.getProperties()),
createGradoopIdSet(v));
Expand All @@ -522,7 +522,7 @@ private V initVertex(Vertex v) {
private E initEdge(Edge e) {
E edge;
if (!edgeIds.containsKey(e.getId())) {
edge = config.getEdgeFactory().createEdge(
edge = (E) config.getEdgeFactory().createEdge(
e.getLabel(),
vertexIds.get(e.getSourceVertexId()),
vertexIds.get(e.getTargetVertexId()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@
* Constants used in Gradoop.
*/
public final class GConstants {
/**
* Default HBase table name for graph heads.
*/
public static final String DEFAULT_TABLE_GRAPHS = "graph_heads";
/**
* Default HBase table name for vertices.
*/
public static final String DEFAULT_TABLE_VERTICES = "vertices";
/**
* Default HBase table name for edges.
*/
public static final String DEFAULT_TABLE_EDGES = "edges";

/**
* Default label for unlabeled vertices.
*/
Expand All @@ -52,51 +39,6 @@ public final class GConstants {
*/
public static final String NULL_STRING = "NULL";

/**
* Column family name for label.
*/
public static final String CF_META = "m";
/**
* Column identifier for label.
*/
public static final String COL_LABEL = "l";
/**
* Column identifier for graphs.
*/
public static final String COL_GRAPHS = "g";
/**
* Column family name for properties.
*/
public static final String CF_PROPERTIES = "p";
/**
* Column family name for vertices.
*/
public static final String CF_VERTICES = "v";
/**
* Column family for edges.
*/
public static final String CF_EDGES = "e";
/**
* Column family name for outgoing edges.
*/
public static final String CF_OUT_EDGES = "oe";
/**
* Column family name for incoming edges.
*/
public static final String CF_IN_EDGES = "ie";
/**
* Column identifier for source vertex identifier.
*/
public static final String COL_SOURCE = "s";
/**
* Column identifier for target vertex identifier.s
*/
public static final String COL_TARGET = "t";

/**
* Default cache size for scans in HBase.
*/
public static final int HBASE_DEFAULT_SCAN_CACHE_SIZE = 500;
/**
* Default label of an EPGM database graph.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import org.gradoop.common.model.api.entities.EPGMEdgeFactory;
import org.gradoop.common.model.api.entities.EPGMGraphHeadFactory;
import org.gradoop.common.model.api.entities.EPGMVertexFactory;
import org.gradoop.common.model.impl.id.GradoopId;
import org.gradoop.common.model.impl.id.GradoopIdList;
import org.gradoop.common.model.impl.pojo.Edge;
import org.gradoop.common.model.impl.pojo.EdgeFactory;
import org.gradoop.common.model.impl.pojo.GraphHead;
import org.gradoop.common.model.impl.pojo.GraphHeadFactory;
import org.gradoop.common.model.impl.pojo.Vertex;
import org.gradoop.common.model.impl.pojo.VertexFactory;
import org.gradoop.common.model.impl.properties.Properties;
import org.gradoop.flink.algorithms.fsm.transactional.common.TFSMConstants;
import org.gradoop.flink.algorithms.fsm.transactional.tle.pojos.FSMEdge;
Expand All @@ -48,15 +49,15 @@ public abstract class SubgraphDecoder implements Serializable {
/**
* graph Head Factory
*/
protected final GraphHeadFactory graphHeadFactory;
protected final EPGMGraphHeadFactory<GraphHead> graphHeadFactory;
/**
* vertex Factory
*/
protected final VertexFactory vertexFactory;
protected final EPGMVertexFactory<Vertex> vertexFactory;
/**
* edge Factory
*/
protected final EdgeFactory edgeFactory;
protected final EPGMEdgeFactory<Edge> edgeFactory;

/**
* Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import org.apache.flink.api.common.functions.AbstractRichFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.configuration.Configuration;
import org.gradoop.common.model.api.entities.EPGMEdgeFactory;
import org.gradoop.common.model.api.entities.EPGMGraphHeadFactory;
import org.gradoop.common.model.api.entities.EPGMVertexFactory;
import org.gradoop.common.model.impl.id.GradoopId;
import org.gradoop.common.model.impl.id.GradoopIdList;
import org.gradoop.common.model.impl.pojo.Edge;
import org.gradoop.common.model.impl.pojo.EdgeFactory;
import org.gradoop.common.model.impl.pojo.GraphHeadFactory;
import org.gradoop.common.model.impl.pojo.GraphHead;
import org.gradoop.common.model.impl.pojo.Vertex;
import org.gradoop.common.model.impl.pojo.VertexFactory;
import org.gradoop.common.model.impl.properties.Properties;
import org.gradoop.flink.datagen.transactions.foodbroker.config.FoodBrokerConfig;
import org.gradoop.flink.datagen.transactions.foodbroker.config.Constants;
Expand All @@ -48,15 +49,15 @@ public abstract class AbstractProcess extends AbstractRichFunction {
/**
* EPGM graph head factory.
*/
protected GraphHeadFactory graphHeadFactory;
protected EPGMGraphHeadFactory<GraphHead> graphHeadFactory;
/**
* EPGM vertex factory.
*/
protected VertexFactory vertexFactory;
protected EPGMVertexFactory<Vertex> vertexFactory;
/**
* EPGM edge factory.
*/
protected EdgeFactory edgeFactory;
protected EPGMEdgeFactory<Edge> edgeFactory;
/**
* Foodbroker configuration.
*/
Expand Down Expand Up @@ -143,8 +144,9 @@ public abstract class AbstractProcess extends AbstractRichFunction {
* @param edgeFactory EPGM edge Factory
* @param config FoodBroker configuration
*/
public AbstractProcess(GraphHeadFactory graphHeadFactory, VertexFactory vertexFactory,
EdgeFactory edgeFactory, FoodBrokerConfig config) {
public AbstractProcess(EPGMGraphHeadFactory<GraphHead> graphHeadFactory,
EPGMVertexFactory<Vertex> vertexFactory,
EPGMEdgeFactory<Edge> edgeFactory, FoodBrokerConfig config) {
this.graphHeadFactory = graphHeadFactory;
this.vertexFactory = vertexFactory;
this.edgeFactory = edgeFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import com.google.common.collect.Maps;
import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.configuration.Configuration;
import org.gradoop.common.model.api.entities.EPGMEdgeFactory;
import org.gradoop.common.model.api.entities.EPGMGraphHeadFactory;
import org.gradoop.common.model.api.entities.EPGMVertexFactory;
import org.gradoop.common.model.impl.id.GradoopId;
import org.gradoop.common.model.impl.id.GradoopIdList;
import org.gradoop.common.model.impl.pojo.Edge;
import org.gradoop.common.model.impl.pojo.EdgeFactory;
import org.gradoop.common.model.impl.pojo.GraphHead;
import org.gradoop.common.model.impl.pojo.GraphHeadFactory;
import org.gradoop.common.model.impl.pojo.Vertex;
import org.gradoop.common.model.impl.pojo.VertexFactory;
import org.gradoop.common.model.impl.properties.Properties;
import org.gradoop.flink.datagen.transactions.foodbroker.config.FoodBrokerConfig;
import org.gradoop.flink.datagen.transactions.foodbroker.config.Constants;
Expand Down Expand Up @@ -56,8 +56,8 @@ public class Brokerage
* @param edgeFactory EPGM edge factory
* @param config Foodbroker configuration
*/
public Brokerage(GraphHeadFactory graphHeadFactory,
VertexFactory vertexFactory, EdgeFactory edgeFactory,
public Brokerage(EPGMGraphHeadFactory<GraphHead> graphHeadFactory,
EPGMVertexFactory<Vertex> vertexFactory, EPGMEdgeFactory<Edge> edgeFactory,
FoodBrokerConfig config) {
super(graphHeadFactory, vertexFactory, edgeFactory, config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.util.Collector;
import org.gradoop.common.model.api.entities.EPGMEdgeFactory;
import org.gradoop.common.model.api.entities.EPGMGraphHeadFactory;
import org.gradoop.common.model.api.entities.EPGMVertexFactory;
import org.gradoop.common.model.impl.id.GradoopId;
import org.gradoop.common.model.impl.id.GradoopIdList;
import org.gradoop.common.model.impl.pojo.Edge;
import org.gradoop.common.model.impl.pojo.EdgeFactory;
import org.gradoop.common.model.impl.pojo.GraphHead;
import org.gradoop.common.model.impl.pojo.GraphHeadFactory;
import org.gradoop.common.model.impl.pojo.Vertex;
import org.gradoop.common.model.impl.pojo.VertexFactory;
import org.gradoop.common.model.impl.properties.Properties;
import org.gradoop.flink.datagen.transactions.foodbroker.config.Constants;
import org.gradoop.flink.datagen.transactions.foodbroker.config.FoodBrokerConfig;
Expand Down Expand Up @@ -78,16 +78,16 @@ public class ComplaintHandling
/**
* Valued constructor.
*
* @param graphHeadFactory EPGM graph head factory
* @param vertexFactory EPGM vertex factory
* @param edgeFactory EPGM edge factory
* @param epgmGraphHeadFactory EPGM graph head factory
* @param epgmVertexFactory EPGM vertex factory
* @param epgmEdgeFactory EPGM edge factory
* @param config FoodBroker configuration
* @param globalSeed global seed
*/
public ComplaintHandling(GraphHeadFactory graphHeadFactory,
VertexFactory vertexFactory, EdgeFactory edgeFactory,
public ComplaintHandling(EPGMGraphHeadFactory<GraphHead> epgmGraphHeadFactory,
EPGMVertexFactory<Vertex> epgmVertexFactory, EPGMEdgeFactory<Edge> epgmEdgeFactory,
FoodBrokerConfig config, long globalSeed) {
super(graphHeadFactory, vertexFactory, edgeFactory, config);
super(epgmGraphHeadFactory, epgmVertexFactory, epgmEdgeFactory, config);
this.globalSeed = globalSeed;
}

Expand Down
Loading

0 comments on commit 9afacb2

Please sign in to comment.