@Override public void join(Edge edge, Vertex vertex, Collector<Edge> collector) throws Exception { if (vertex == null) { collector.collect(edge); } else if (edge != null) { REUSABLE_EDGE.setId(GradoopId.get()); REUSABLE_EDGE.setSourceId(isSourceNow ? vId : edge.getSourceId()); REUSABLE_EDGE.setTargetId(isSourceNow ? edge.getTargetId() : vId); REUSABLE_EDGE.setProperties(edge.getProperties()); REUSABLE_EDGE.setLabel(edge.getLabel()); REUSABLE_EDGE.setGraphIds(edge.getGraphIds()); collector.collect(REUSABLE_EDGE); } } }
@Override public void flatMap(Edge edge, Collector<EdgeString> collector) throws Exception { GradoopId sourceId = edge.getSourceId(); GradoopId targetId = edge.getTargetId(); String edgeLabel = "[" + edge.getId() + "]"; for (GradoopId graphId : edge.getGraphIds()) { collector.collect(new EdgeString(graphId, sourceId, targetId, edgeLabel)); } } }
@Override public Edge initEdge(final GradoopId id, final String label, final GradoopId sourceVertexId, final GradoopId targetVertexId, final Properties properties, GradoopIdSet graphIds) { checkNotNull(id, "Identifier was null"); checkNotNull(label, "Label was null"); checkNotNull(sourceVertexId, "Source vertex id was null"); checkNotNull(targetVertexId, "Target vertex id was null"); return new Edge(id, label, sourceVertexId, targetVertexId, properties, graphIds); }
/** * Drop edge properties. * * @param current current edge * @param transformed copy of current except label and properties * @return current edge without properties */ private static Edge dropEdgeProperties(Edge current, Edge transformed) { transformed.setLabel(current.getLabel()); return transformed; }
@Override public Edge apply(Edge current, Edge transformed) { if (current.getLabel().equals(forEdgeLabel)) { GradoopId source = current.getSourceId(); GradoopId target = current.getTargetId(); current.setSourceId(target); current.setTargetId(source); current.setLabel(newLabel); } return current; } }
@Nonnull SortedKeyValueIterator<Key, Value> source ) throws IOException { Edge row = new Edge(); if (!source.hasTop()) { return null; row.setId(GradoopId.fromString(source.getTopKey().getRow().toString())); row.setGraphIds(new GradoopIdSet()); while (source.hasTop()) { Key key = source.getTopKey(); Value value = source.getTopValue(); if (!Objects.equals(row.getId().toString(), key.getRow().toString())) { break; row.setLabel(value.toString()); break; case AccumuloTables.KEY.SOURCE: row.setSourceId(GradoopId.fromString(value.toString())); break; case AccumuloTables.KEY.TARGET: row.setTargetId(GradoopId.fromString(value.toString())); break; case AccumuloTables.KEY.PROPERTY: row.setProperty( key.getColumnQualifier().toString(), PropertyValue.fromRawBytes(value.get()) break;
@Override public TripleWithCandidates<GradoopId> map(E e) throws Exception { reuseTuple.setEdgeId(e.getId()); reuseTuple.setSourceId(e.getSourceId()); reuseTuple.setTargetId(e.getTargetId()); reuseTuple.setCandidates( getCandidates(edgeCount, ElementMatcher.getMatches(e, queryEdges, DEFAULT_EDGE_LABEL))); return reuseTuple; } }
@Override public org.apache.flink.graph.Edge<GradoopId, PropertyValue> map(Edge epgmEdge) { reuseEdge.setSource(epgmEdge.getSourceId()); reuseEdge.setTarget(epgmEdge.getTargetId()); reuseEdge.setValue(epgmEdge.getPropertyValue(propertyKey)); return reuseEdge; } }
@Override public Tuple3<E, GradoopId, GradoopId> map(E edge) { reuseTuple.setFields(edge, edge.getSourceId(), edge.getTargetId()); return reuseTuple; } }
@Override public void flatMap(Edge edge, Collector<EdgeString> collector) throws Exception { GradoopId sourceId = edge.getSourceId(); GradoopId targetId = edge.getTargetId(); String edgeLabel = "[" + label(edge) + "]"; for (GradoopId graphId : edge.getGraphIds()) { collector.collect(new EdgeString(graphId, sourceId, targetId, edgeLabel)); } } }
@Override public void flatMap(GraphTransaction graphTransaction, Collector<String> collector) throws Exception { for (Edge edge : graphTransaction.getEdges()) { collector.collect(edge.getLabel()); } } }
@Override public IdWithLabel map(E edge) throws Exception { reuseTuple.setId(edge.getSourceId()); reuseTuple.setLabel(edge.getLabel()); return reuseTuple; } }
@Override public IdWithLabel map(E edge) throws Exception { reuseTuple.setId(edge.getTargetId()); reuseTuple.setLabel(edge.getLabel()); return reuseTuple; } }
.filter(e -> e.getLabel().matches(PATTERN_EDGE.pattern()) || (e.hasProperty(PROP_SINCE) && e.getPropertyValue(PROP_SINCE).getInt() < 2015)) .collect(Collectors.toList());
/** * Returns the edge id * @return edge id */ public GradoopId getEdgeId() { return f1.getId(); }
.stream() .filter(e -> e.hasProperty(PROP_STATUS)) .filter(e -> e.getPropertyValue(PROP_STATUS).getString().matches(PATTERN_EDGE_PROP.pattern())) .collect(Collectors.toList());
if (e.getLabel().equals("knows")) { if (e.getPropertyValue("since").getInt() == 2016) { return true;
@Override public Edge join(Edge edge, Vertex vertex) throws Exception { PropertyValue newEdgeValue = vertex.getPropertyValue(propertyKey); if (edge.hasProperty(propertyKey)) { if (edge.getPropertyValue(propertyKey).compareTo(newEdgeValue) < 0) { return edge; } } edge.setProperty(propertyKey, newEdgeValue); return edge; } }
@Override public void join(Edge first, Tuple2<Vertex, GradoopId> second, Collector<Edge> out) throws Exception { if (second != null && !(second.f1.equals(GradoopId.NULL_VALUE))) { if (isItSourceDoingNow) { first.setSourceId(second.f1); } else { first.setTargetId(second.f1); } } out.collect(first); }
/** * 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); } } }