Skip to content

Commit

Permalink
dbs-leipzig#8 migrated to use updated gradoop api
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Götz committed Jun 27, 2019
1 parent 0076b98 commit 958ccba
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 26 deletions.
14 changes: 7 additions & 7 deletions src/main/java/org/gradoop/demo/server/CytoJSONBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.gradoop.common.model.impl.pojo.Edge;
import org.gradoop.common.model.impl.pojo.GraphHead;
import org.gradoop.common.model.impl.pojo.Vertex;
import org.gradoop.common.model.impl.pojo.EPGMEdge;
import org.gradoop.common.model.impl.pojo.EPGMGraphHead;
import org.gradoop.common.model.impl.pojo.EPGMVertex;
import org.gradoop.common.model.impl.properties.Property;

import java.util.List;
Expand Down Expand Up @@ -86,8 +86,8 @@ public class CytoJSONBuilder {
* @return a cytoscape-conform JSON
* @throws JSONException if the creation of the JSON fails
*/
static String getJSONString(List<GraphHead> graphHeads, List<Vertex> vertices, List<Edge> edges) throws
JSONException {
static String getJSONString(List<EPGMGraphHead> graphHeads, List<EPGMVertex> vertices,
List<EPGMEdge> edges) throws JSONException {

JSONObject returnedJSON = new JSONObject();

Expand All @@ -114,7 +114,7 @@ static String getJSONString(List<GraphHead> graphHeads, List<Vertex> vertices, L
returnedJSON.put(GRAPHS, graphObjects);

JSONArray vertexArray = new JSONArray();
for (Vertex vertex : vertices) {
for (EPGMVertex vertex : vertices) {
JSONObject vertexObject = new JSONObject();
JSONObject vertexData = new JSONObject();

Expand All @@ -133,7 +133,7 @@ static String getJSONString(List<GraphHead> graphHeads, List<Vertex> vertices, L
returnedJSON.put(VERTICES, vertexArray);

JSONArray edgeArray = new JSONArray();
for (Edge edge : edges) {
for (EPGMEdge edge : edges) {
JSONObject edgeObject = new JSONObject();
JSONObject edgeData = new JSONObject();
edgeData.put(EDGE_SOURCE, edge.getSourceId());
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/org/gradoop/demo/server/RequestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.gradoop.common.model.impl.pojo.Edge;
import org.gradoop.common.model.impl.pojo.GraphHead;
import org.gradoop.common.model.impl.pojo.Vertex;
import org.gradoop.common.model.impl.pojo.EPGMEdge;
import org.gradoop.common.model.impl.pojo.EPGMGraphHead;
import org.gradoop.common.model.impl.pojo.EPGMVertex;
import org.gradoop.demo.server.functions.AcceptNoneFilter;
import org.gradoop.demo.server.functions.LabelFilter;
import org.gradoop.demo.server.functions.LabelGroupReducer;
Expand Down Expand Up @@ -430,19 +430,21 @@ public Response getData(GroupingRequest request) throws Exception {
}
}

builder.setRetainVerticesWithoutGroups(request.getRetainVertices());

// by default, we use the group reduce strategy
builder.setStrategy(GroupingStrategy.GROUP_REDUCE);

graph = builder.build().execute(graph);
graph = builder.<EPGMGraphHead, EPGMVertex, EPGMEdge, LogicalGraph, GraphCollection>build().execute(graph);

// specify the output collections
return createResponse(graph);
}

private Response createResponse(GraphCollection graph) {
List<GraphHead> resultHead = new ArrayList<>();
List<Vertex> resultVertices = new ArrayList<>();
List<Edge> resultEdges = new ArrayList<>();
List<EPGMGraphHead> resultHead = new ArrayList<>();
List<EPGMVertex> resultVertices = new ArrayList<>();
List<EPGMEdge> resultEdges = new ArrayList<>();

graph.getGraphHeads().output(new LocalCollectionOutputFormat<>(resultHead));
graph.getVertices().output(new LocalCollectionOutputFormat<>(resultVertices));
Expand All @@ -452,9 +454,9 @@ private Response createResponse(GraphCollection graph) {
}

private Response createResponse(LogicalGraph graph) {
List<GraphHead> resultHead = new ArrayList<>();
List<Vertex> resultVertices = new ArrayList<>();
List<Edge> resultEdges = new ArrayList<>();
List<EPGMGraphHead> resultHead = new ArrayList<>();
List<EPGMVertex> resultVertices = new ArrayList<>();
List<EPGMEdge> resultEdges = new ArrayList<>();

graph.getGraphHead().output(new LocalCollectionOutputFormat<>(resultHead));
graph.getVertices().output(new LocalCollectionOutputFormat<>(resultVertices));
Expand All @@ -463,8 +465,8 @@ private Response createResponse(LogicalGraph graph) {
return getResponse(resultHead, resultVertices, resultEdges);
}

private Response getResponse(List<GraphHead> resultHead, List<Vertex> resultVertices,
List<Edge> resultEdges) {
private Response getResponse(List<EPGMGraphHead> resultHead, List<EPGMVertex> resultVertices,
List<EPGMEdge> resultEdges) {
try {
ENV.execute();
// build the response JSON from the collections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.gradoop.demo.server.functions;

import org.apache.flink.api.common.functions.FilterFunction;
import org.gradoop.common.model.api.entities.EPGMElement;
import org.gradoop.common.model.impl.pojo.EPGMElement;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import org.apache.commons.lang.ArrayUtils;
import org.apache.flink.api.common.functions.FilterFunction;
import org.gradoop.common.model.api.entities.EPGMElement;
import org.gradoop.common.model.impl.pojo.EPGMElement;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.common.collect.Sets;
import org.apache.flink.api.common.functions.MapFunction;
import org.gradoop.common.model.api.entities.EPGMElement;
import org.gradoop.common.model.impl.pojo.EPGMElement;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.util.Collector;
import org.gradoop.common.model.api.entities.EPGMElement;
import org.gradoop.common.model.impl.pojo.EPGMElement;
import org.gradoop.common.model.impl.properties.PropertyValue;


Expand Down
29 changes: 26 additions & 3 deletions src/main/java/org/gradoop/demo/server/pojo/GroupingRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ public class GroupingRequest {
/**
* true, if all edges shall be filtered
*/

private boolean filterAllEdges;

/**
* true: vertices that are not member of any labelGroup are converted as is to supervertices.
*/
private boolean retainVertices;

/**
* set the database name
*
Expand Down Expand Up @@ -134,6 +138,15 @@ public void setFilterAllEdges(boolean filterAllEdges) {
this.filterAllEdges = filterAllEdges;
}

/**
* set if vertex retention should be used.
*
* @param retainVertices vertex retention
*/
public void setRetainVertices(boolean retainVertices) {
this.retainVertices = retainVertices;
}

/**
* get the database name
*
Expand Down Expand Up @@ -208,18 +221,28 @@ public boolean getFilterAllEdges() {
return filterAllEdges;
}

/**
* Returns whether vertices retention is used.
*
* @return vertices retention
*/
public boolean getRetainVertices() {
return retainVertices;
}

/**
* Returns a human readable representation of the request.
*
* @return human readable string
*/

@Override
public String toString() {
return "DB name: " + dbName + "\n" + "Vertex keys: " + Arrays.toString(vertexKeys) + "\n" +
"Edge keys: " + Arrays.toString(edgeKeys) + "\n" + "Vertex aggrFunc: " + vertexAggrFuncs +
"\n" + "Edge aggrFunc: " + edgeAggrFuncs + "\n" + "Vertex filters: " +
Arrays.toString(vertexFilters) + "\n" + "Edge filters: " + Arrays.toString(edgeFilters) +
"\n";
"\n" + "Retain vertices: " + retainVertices + "\n";
}


}

0 comments on commit 958ccba

Please sign in to comment.