[ https://issues.apache.org/jira/browse/FLINK-5104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15742664#comment-15742664 ]
ASF GitHub Bot commented on FLINK-5104: --------------------------------------- Github user greghogan commented on a diff in the pull request: https://github.com/apache/flink/pull/2985#discussion_r91996140 --- Diff: flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/validation/InvalidBipartiteVertexIdsValidator.java --- @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.graph.validation; + +import org.apache.flink.api.common.functions.CoGroupFunction; +import org.apache.flink.api.common.functions.MapFunction; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.tuple.Tuple1; +import org.apache.flink.graph.Vertex; +import org.apache.flink.graph.bipartite.BipartiteEdge; +import org.apache.flink.graph.bipartite.BipartiteGraph; +import org.apache.flink.util.Collector; +import static org.apache.flink.api.java.functions.FunctionAnnotation.ForwardedFields; + +/** + * Checks that the edge set input contains valid vertex Ids, i.e. that they + * also exist in top and bottom vertex sets. + */ +public class InvalidBipartiteVertexIdsValidator<KT, KB, VVT, VVB, EV> extends BipartiteGraphValidator<KT, KB, VVT, VVB, EV> { + + @Override + public boolean validate(BipartiteGraph<KT, KB, VVT, VVB, EV> bipartiteGraph) throws Exception { + DataSet<Tuple1<KT>> edgesTopIds = bipartiteGraph.getEdges().map(new GetTopIdsMap<KT, KB, EV>()); + DataSet<Tuple1<KB>> edgesBottomIds = bipartiteGraph.getEdges().map(new GetBottomIdsMap<KT, KB, EV>()); + + DataSet<KT> invalidTopIds = invalidIds(bipartiteGraph.getTopVertices(), edgesTopIds); + DataSet<KB> invalidBottomIds = invalidIds(bipartiteGraph.getBottomVertices(), edgesBottomIds); + + return invalidTopIds.count() == 0 && invalidBottomIds.count() == 0; --- End diff -- `count()` executes the program so shouldn't be called twice. Could use an accumulator in `RichOutputFormat` instead. > Implement BipartiteGraph validator > ---------------------------------- > > Key: FLINK-5104 > URL: https://issues.apache.org/jira/browse/FLINK-5104 > Project: Flink > Issue Type: Sub-task > Components: Gelly > Reporter: Ivan Mushketyk > Assignee: Ivan Mushketyk > > BipartiteGraph should have a validator similar to GraphValidator for Graph > class. -- This message was sent by Atlassian JIRA (v6.3.4#6332)