/** * 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); }
/** * Create a new CreateImportVertexCSV function * * @param vertexFactory the factory that is responsible for creating a vertex */ public PropertiesToVertex(EPGMVertexFactory<V> vertexFactory) { this.vertex = vertexFactory.createVertex(); }
@SuppressWarnings("unchecked") @Override public TypeInformation<Vertex> getProducedType() { return TypeExtractor.createTypeInfo(vertexFactory.getType()); } }
/** * 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); }
/** * Creates a new instance of this JSON string to vertex converting function. * * @param vertexFactory The vertex factory used to create new vertices. */ public MinimalJsonToVertex(EPGMVertexFactory<Vertex> vertexFactory) { this.reuse = Objects.requireNonNull(vertexFactory).createVertex(JSON_VERTEX_LABEL); this.reuse.setProperties(Properties.create()); }
@Override public TypeInformation<Vertex> getProducedType() { return TypeExtractor.createTypeInfo(vertexFactory.getType()); } }
@Override protected V initFrom(V element) { return vertexFactory.initVertex( element.getId(), GradoopConstants.DEFAULT_VERTEX_LABEL, element.getGraphIds()); } }
.createVertex(vertex.getValue(), graphIds);
@SuppressWarnings("unchecked") @Override public TypeInformation<Vertex> getProducedType() { return TypeExtractor.createTypeInfo(vertexFactory.getType()); } }
@Override protected V initFrom(V element) { return vertexFactory.initVertex( element.getId(), GradoopConstants.DEFAULT_VERTEX_LABEL, element.getGraphIds()); } }
.createVertex(vertex.getValue(), graphIds);
@Override public TypeInformation<Vertex> getProducedType() { return TypeExtractor.createTypeInfo(vertexFactory.getType()); } }
@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])); } }
/** * Outputs a triple containing of the import vertex identifier, the new EPGM * vertex identifier and the EPGM vertex. * * @param importVertex import vertex * @return triple containing import and EPGM id as well as the EPGM vertex * @throws Exception */ @Override public Tuple3<K, GradoopId, Vertex> map(ImportVertex<K> importVertex) throws Exception { reuseTuple.f0 = importVertex.getId(); Vertex vertex = vertexFactory.createVertex(importVertex.getLabel(), importVertex.getProperties()); reuseTuple.f1 = vertex.getId(); reuseTuple.f2 = updateLineage(vertex, importVertex.getId()); return reuseTuple; }
@Override public TypeInformation<Tuple3<K, GradoopId, Vertex>> getProducedType() { return new TupleTypeInfo<>(getKeyTypeInfo(), TypeExtractor.getForClass(GradoopId.class), TypeExtractor.createTypeInfo(vertexFactory.getType())); } }
@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])); } }
/** * Outputs a triple containing of the import vertex identifier, the new EPGM * vertex identifier and the EPGM vertex. * * @param importVertex import vertex * @return triple containing import and EPGM id as well as the EPGM vertex * @throws Exception */ @Override public Tuple3<K, GradoopId, Vertex> map(ImportVertex<K> importVertex) throws Exception { reuseTuple.f0 = importVertex.getId(); Vertex vertex = vertexFactory.createVertex(importVertex.getLabel(), importVertex.getProperties()); reuseTuple.f1 = vertex.getId(); reuseTuple.f2 = updateLineage(vertex, importVertex.getId()); return reuseTuple; }
/** * {@inheritDoc} */ @Override public TypeInformation<Tuple3<K, GradoopId, Vertex>> getProducedType() { return new TupleTypeInfo<>(getKeyTypeInfo(), TypeExtractor.getForClass(GradoopId.class), TypeExtractor.createTypeInfo(vertexFactory.getType())); } }
/** * 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 protected GraphCollection executeForVertex(LogicalGraph graph) { GradoopFlinkConfig config = graph.getConfig(); EPGMGraphHeadFactory<GraphHead> graphHeadFactory = config.getGraphHeadFactory(); EPGMVertexFactory<Vertex> vertexFactory = config.getVertexFactory(); String variable = getQueryHandler().getVertices().iterator().next().getVariable(); DataSet<Vertex> matchingVertices = graph.getVertices() .filter(new MatchingVertices<>(getQuery())); if (!doAttachData()) { matchingVertices = matchingVertices .map(new Id<>()) .map(new ObjectTo1<>()) .map(new VertexFromId(vertexFactory)); } DataSet<Tuple2<Vertex, GraphHead>> pairs = matchingVertices .map(new AddGraphElementToNewGraph<>(graphHeadFactory, variable)) .returns(new TupleTypeInfo<>( TypeExtractor.getForClass(vertexFactory.getType()), TypeExtractor.getForClass(graphHeadFactory.getType()))); return config.getGraphCollectionFactory().fromDataSets( pairs.map(new Value1Of2<>()), pairs.map(new Value0Of2<>())); }