/** * Initializes an {@link Vertex} from a given {@link GradoopId}. * * @param gradoopId Gradoop identifier * @return EPGM vertex * @throws Exception */ @Override public Vertex map(Tuple1<GradoopId> gradoopId) throws Exception { return vertexFactory.initVertex(gradoopId.f0); }
/** * Initializes an {@link Vertex} from a given {@link GradoopId}. * * @param gradoopId Gradoop identifier * @return EPGM vertex * @throws Exception */ @Override public Vertex map(Tuple1<GradoopId> gradoopId) throws Exception { return vertexFactory.initVertex(gradoopId.f0); }
@Override protected V initFrom(V element) { return vertexFactory.initVertex( element.getId(), GradoopConstants.DEFAULT_VERTEX_LABEL, element.getGraphIds()); } }
@Override protected V initFrom(V element) { return vertexFactory.initVertex( element.getId(), GradoopConstants.DEFAULT_VERTEX_LABEL, element.getGraphIds()); } }
@Override public Vertex map(String csvLine) { String[] tokens = split(csvLine, 3); return vertexFactory.initVertex( GradoopId.fromString(tokens[0]), tokens[1], parseProperties(MetaDataSource.VERTEX_TYPE, tokens[1], tokens[2])); } }
@Override public Vertex map(String csvLine) { String[] tokens = split(csvLine, 3); return vertexFactory.initVertex( GradoopId.fromString(tokens[0]), tokens[1], parseProperties(MetaDataSource.VERTEX_TYPE, tokens[1], tokens[2])); } }
/** * Initializes an EPGM vertex using the specified parameters and adds its label * if the given vertex was created for the return pattern. * * @param out flat map collector * @param graphHead graph head to assign vertex to * @param vertexId vertex identifier * @param label label associated with vertex */ private void initVertexWithData(Collector<Element> out, GraphHead graphHead, GradoopId vertexId, String label) { if (!processedIds.contains(vertexId)) { Vertex v = vertexFactory.initVertex(vertexId); v.addGraphId(graphHead.getId()); v.setLabel(label); out.collect(v); processedIds.add(vertexId); } }
/** * Initializes an EPGM vertex using the specified parameters and adds its label * if the given vertex was created for the return pattern. * * @param out flat map collector * @param graphHead graph head to assign vertex to * @param vertexId vertex identifier * @param label label associated with vertex */ private void initVertexWithData(Collector<Element> out, GraphHead graphHead, GradoopId vertexId, String label) { if (!processedIds.contains(vertexId)) { Vertex v = vertexFactory.initVertex(vertexId); v.addGraphId(graphHead.getId()); v.setLabel(label); out.collect(v); processedIds.add(vertexId); } }
@Override public Vertex readVertex(final Result res) { return vertexFactory.initVertex(readId(res), readLabel(res), readProperties(res), readGraphIds(res)); }
@Override public Vertex readRow(EPGMVertex origin) { return factory.initVertex( origin.getId(), origin.getLabel(), origin.getProperties(), origin.getGraphIds() ); }
@Override public Vertex map(String csvLine) throws Exception { String[] tokens = split(csvLine, 4); String label = StringEscaper.unescape(tokens[2]); return vertexFactory.initVertex( GradoopId.fromString(tokens[0]), label, parseProperties(MetaDataSource.VERTEX_TYPE, label, tokens[3]), parseGradoopIds(tokens[1]) ); } }
@Override public Vertex map(String csvLine) throws Exception { String[] tokens = split(csvLine, 4); String label = StringEscaper.unescape(tokens[2]); return vertexFactory.initVertex( GradoopId.fromString(tokens[0]), label, parseProperties(MetaDataSource.VERTEX_TYPE, label, tokens[3]), parseGradoopIds(tokens[1]) ); } }
@Override public GraphTransaction map(GraphTransaction transaction) throws Exception { if (graphHeadTransFunc != null) { transaction.setGraphHead(graphHeadTransFunc.apply( transaction.getGraphHead(), graphHeadFactory.initGraphHead( transaction.getGraphHead().getId(), GradoopConstants.DEFAULT_GRAPH_LABEL))); } if (vertexTransFunc != null) { transaction.setVertices(transaction.getVertices().stream() .map(vertex -> vertexTransFunc.apply( vertex, vertexFactory.initVertex( vertex.getId(), GradoopConstants.DEFAULT_VERTEX_LABEL, vertex.getGraphIds()))) .collect(Collectors.toSet())); } if (edgeTransFunc != null) { transaction.setEdges(transaction.getEdges().stream() .map(edge -> edgeTransFunc.apply( edge, edgeFactory.initEdge( edge.getId(), GradoopConstants.DEFAULT_EDGE_LABEL, edge.getSourceId(), edge.getTargetId(), edge.getGraphIds()))) .collect(Collectors.toSet())); } return transaction; } }
@Override public GraphTransaction map(GraphTransaction transaction) throws Exception { if (graphHeadTransFunc != null) { transaction.setGraphHead(graphHeadTransFunc.apply( transaction.getGraphHead(), graphHeadFactory.initGraphHead( transaction.getGraphHead().getId(), GradoopConstants.DEFAULT_GRAPH_LABEL))); } if (vertexTransFunc != null) { transaction.setVertices(transaction.getVertices().stream() .map(vertex -> vertexTransFunc.apply( vertex, vertexFactory.initVertex( vertex.getId(), GradoopConstants.DEFAULT_VERTEX_LABEL, vertex.getGraphIds()))) .collect(Collectors.toSet())); } if (edgeTransFunc != null) { transaction.setEdges(transaction.getEdges().stream() .map(edge -> edgeTransFunc.apply( edge, edgeFactory.initEdge( edge.getId(), GradoopConstants.DEFAULT_EDGE_LABEL, edge.getSourceId(), edge.getTargetId(), edge.getGraphIds()))) .collect(Collectors.toSet())); } return transaction; } }
/** * Constructs a vertex from a given JSON string representation. * * @param s json string * @return Gelly vertex storing gradoop vertex data * @throws Exception */ @Override public Vertex map(String s) throws Exception { JSONObject jsonVertex = new JSONObject(s); GradoopId vertexID = getID(jsonVertex); String label = getLabel(jsonVertex); Properties properties = Properties.createFromMap( getProperties(jsonVertex)); GradoopIdSet graphs = getGraphs(jsonVertex); return vertexFactory.initVertex(vertexID, label, properties, graphs); } }
/** * Constructs a vertex from a given JSON string representation. * * @param s json string * @return Gelly vertex storing gradoop vertex data * @throws Exception */ @Override public Vertex map(String s) throws Exception { JSONObject jsonVertex = new JSONObject(s); GradoopId vertexID = getID(jsonVertex); String label = getLabel(jsonVertex); Properties properties = Properties.createFromMap( getProperties(jsonVertex)); GradoopIdSet graphs = getGraphs(jsonVertex); return vertexFactory.initVertex(vertexID, label, properties, graphs); } }
Vertex v = vertexFactory.initVertex(vertexMapping[i]); v.addGraphId(graphHead.getId()); out.collect(v);
/** * Creates a {@link Vertex} object from the given {@link VertexGroupItem} * and returns a new {@link org.apache.flink.graph.Vertex}. * * @param groupItem vertex group item * @return vertex including new vertex data * @throws Exception on failure */ @Override public Vertex map(VertexGroupItem groupItem) throws Exception { Vertex supVertex = vertexFactory.initVertex(groupItem.getSuperVertexId()); supVertex.setLabel(groupItem.getGroupLabel()); setGroupProperties(supVertex, groupItem.getGroupingValues(), groupItem.getLabelGroup()); setAggregateProperties( supVertex, groupItem.getAggregateValues(), groupItem.getLabelGroup().getAggregateFunctions()); return supVertex; }
/** * Creates a {@link Vertex} object from the given {@link VertexGroupItem} * and returns a new {@link org.apache.flink.graph.Vertex}. * * @param groupItem vertex group item * @return vertex including new vertex data * @throws Exception on failure */ @Override public Vertex map(VertexGroupItem groupItem) throws Exception { Vertex supVertex = vertexFactory.initVertex(groupItem.getSuperVertexId()); supVertex.setLabel(groupItem.getGroupLabel()); setGroupProperties(supVertex, groupItem.getGroupingValues(), groupItem.getLabelGroup()); setAggregateProperties( supVertex, groupItem.getAggregateValues(), groupItem.getLabelGroup().getAggregateFunctions()); return supVertex; }
/** * Tries to add an unsupported property type {@link Queue} as property value. */ @Test(expected = UnsupportedTypeException.class) public void wrongPropertyTypeTest() throws IOException { HBaseEPGMStore graphStore = createEmptyEPGMStore(); EPGMVertexFactory<Vertex> vertexFactory = new VertexFactory(); // Queue is not supported by final Queue<String> value = Queues.newPriorityQueue(); GradoopId vertexID = GradoopId.get(); final String label = "A"; Properties props = Properties.create(); props.set("k1", value); final GradoopIdSet graphs = new GradoopIdSet(); Vertex vertex = vertexFactory.initVertex(vertexID, label, props, graphs); graphStore.writeVertex(vertex); }