/** * Initializes an {@link Edge} from a given {@link GradoopId} triple. The * triple consists of edge id, source vertex id and target vertex id. * * @param idTriple triple containing (in that order) edge id, source vertex * id, target vertex id * @return EPGM edge * @throws Exception */ @Override public Edge map(Tuple3<GradoopId, GradoopId, GradoopId> idTriple) throws Exception { return edgeFactory.initEdge(idTriple.f0, idTriple.f1, idTriple.f2); }
/** * Initializes an {@link Edge} from a given {@link GradoopId} triple. The * triple consists of edge id, source vertex id and target vertex id. * * @param idTriple triple containing (in that order) edge id, source vertex * id, target vertex id * @return EPGM edge * @throws Exception */ @Override public Edge map(Tuple3<GradoopId, GradoopId, GradoopId> idTriple) throws Exception { return edgeFactory.initEdge(idTriple.f0, idTriple.f1, idTriple.f2); }
/** * Initializes an EPGM edge using the specified parameters and adds its label * if the given edge was created for return pattern * * @param out flat map collector * @param graphHead graph head to assign edge to * @param edgeId edge identifier * @param sourceId source vertex identifier * @param targetId target vertex identifier * @param label label associated with edge */ private void initEdgeWithData(Collector<Element> out, GraphHead graphHead, GradoopId edgeId, GradoopId sourceId, GradoopId targetId, String label) { if (!processedIds.contains(edgeId)) { Edge e = edgeFactory.initEdge(edgeId, sourceId, targetId); e.addGraphId(graphHead.getId()); e.setLabel(label); out.collect(e); processedIds.add(edgeId); } } }
/** * Initializes an EPGM edge using the specified parameters and adds its label * if the given edge was created for return pattern * * @param out flat map collector * @param graphHead graph head to assign edge to * @param edgeId edge identifier * @param sourceId source vertex identifier * @param targetId target vertex identifier * @param label label associated with edge */ private void initEdgeWithData(Collector<Element> out, GraphHead graphHead, GradoopId edgeId, GradoopId sourceId, GradoopId targetId, String label) { if (!processedIds.contains(edgeId)) { Edge e = edgeFactory.initEdge(edgeId, sourceId, targetId); e.addGraphId(graphHead.getId()); e.setLabel(label); out.collect(e); processedIds.add(edgeId); } } }
@Override protected E initFrom(E edge) { return edgeFactory.initEdge( edge.getId(), GradoopConstants.DEFAULT_EDGE_LABEL, edge.getSourceId(), edge.getTargetId(), edge.getGraphIds()); } }
@Override protected E initFrom(E edge) { return edgeFactory.initEdge( edge.getId(), GradoopConstants.DEFAULT_EDGE_LABEL, edge.getSourceId(), edge.getTargetId(), edge.getGraphIds()); } }
@Override public Edge map(String csvLine) { String[] tokens = split(csvLine, 5); return edgeFactory.initEdge(GradoopId.fromString(tokens[0]), tokens[3], GradoopId.fromString(tokens[1]), GradoopId.fromString(tokens[2]), parseProperties(MetaDataSource.EDGE_TYPE, tokens[3], tokens[4])); } }
@Override public Edge map(String csvLine) { String[] tokens = split(csvLine, 5); return edgeFactory.initEdge(GradoopId.fromString(tokens[0]), tokens[3], GradoopId.fromString(tokens[1]), GradoopId.fromString(tokens[2]), parseProperties(MetaDataSource.EDGE_TYPE, tokens[3], tokens[4])); } }
@Override public Edge readRow(EPGMEdge origin) { return factory.initEdge( origin.getId(), origin.getLabel(), origin.getSourceId(), origin.getTargetId(), origin.getProperties(), origin.getGraphIds()); } }
@Override public Edge readEdge(Result res) { return edgeFactory.initEdge(readId(res), readLabel(res), readSourceId(res), readTargetId(res), readProperties(res), readGraphIds(res)); }
@Override public Edge map(String csvLine) throws Exception { String[] tokens = split(csvLine, 6); String label = StringEscaper.unescape(tokens[4]); return edgeFactory.initEdge(GradoopId.fromString(tokens[0]), label, GradoopId.fromString(tokens[2]), GradoopId.fromString(tokens[3]), parseProperties(MetaDataSource.EDGE_TYPE, label, tokens[5]), 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 Edge map(String csvLine) throws Exception { String[] tokens = split(csvLine, 6); String label = StringEscaper.unescape(tokens[4]); return edgeFactory.initEdge(GradoopId.fromString(tokens[0]), label, GradoopId.fromString(tokens[2]), GradoopId.fromString(tokens[3]), parseProperties(MetaDataSource.EDGE_TYPE, label, tokens[5]), 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; } }
/** * Creates an edge from JSON string representation. * * @param s json string * @return Gelly edge storing gradoop edge data * @throws Exception */ @Override public Edge map(String s) throws Exception { JSONObject jsonEdge = new JSONObject(s); GradoopId edgeID = getID(jsonEdge); String edgeLabel = getLabel(jsonEdge); GradoopId sourceID = getSourceId(jsonEdge); GradoopId targetID = getTargetId(jsonEdge); Properties properties = Properties.createFromMap( getProperties(jsonEdge)); GradoopIdSet graphs = getGraphs(jsonEdge); return edgeFactory.initEdge(edgeID, edgeLabel, sourceID, targetID, properties, graphs); }
/** * Creates an edge from JSON string representation. * * @param s json string * @return Gelly edge storing gradoop edge data * @throws Exception */ @Override public Edge map(String s) throws Exception { JSONObject jsonEdge = new JSONObject(s); GradoopId edgeID = getID(jsonEdge); String edgeLabel = getLabel(jsonEdge); GradoopId sourceID = getSourceId(jsonEdge); GradoopId targetID = getTargetId(jsonEdge); Properties properties = Properties.createFromMap( getProperties(jsonEdge)); GradoopIdSet graphs = getGraphs(jsonEdge); return edgeFactory.initEdge(edgeID, edgeLabel, sourceID, targetID, properties, graphs); }
GradoopId targetId = s.isOutgoing() ? vertexMapping[(int) s.getTo()] : vertexMapping[(int) s.getFrom()]; Edge e = edgeFactory.initEdge(edgeMapping[i], sourceId, targetId); e.addGraphId(graphHead.getId()); out.collect(e);
GradoopId targetId = s.isOutgoing() ? vertexMapping[(int) s.getTo()] : vertexMapping[(int) s.getFrom()]; Edge e = edgeFactory.initEdge(edgeMapping[i], sourceId, targetId); e.addGraphId(graphHead.getId()); out.collect(e);