Skip to content

Commit

Permalink
Merge pull request apache#51 from aljoscha/master
Browse files Browse the repository at this point in the history
Fix bug in TestReduceOnNeighborMethods caused by object reuse
  • Loading branch information
vasia committed Jan 9, 2015
2 parents 2729ae7 + a10e62f commit 62fa5ee
Showing 1 changed file with 14 additions and 27 deletions.
41 changes: 14 additions & 27 deletions src/test/java/flink/graphs/TestReduceOnNeighborMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,14 @@ public Tuple2<Long, Long> iterateNeighbors(Vertex<Long, Long> vertex,
public Tuple2<Long, Long> iterateNeighbors(
Iterable<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighbors) {
long sum = 0;
Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> first =
new Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>();
Iterator<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighborsIterator =
Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> next = null;
Iterator<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighborsIterator =
neighbors.iterator();
if (neighborsIterator.hasNext()) {
first = neighborsIterator.next();
sum = first.f2.getValue();
}
while(neighborsIterator.hasNext()) {
sum += neighborsIterator.next().f2.getValue();
next = neighborsIterator.next();
sum += next.f2.getValue();
}
return new Tuple2<Long, Long>(first.f0, sum);
return new Tuple2<Long, Long>(next.f0, sum);
}
}, EdgeDirection.OUT);

Expand All @@ -208,19 +204,14 @@ public Tuple2<Long, Long> iterateNeighbors(
public Tuple2<Long, Long> iterateNeighbors(
Iterable<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighbors) {
long sum = 0;
Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> first =
new Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>();
Iterator<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighborsIterator =
Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> next = null;
Iterator<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighborsIterator =
neighbors.iterator();
if (neighborsIterator.hasNext()) {
first = neighborsIterator.next();
sum = first.f2.getValue() * first.f1.getValue();
}
while(neighborsIterator.hasNext()) {
Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> next = neighborsIterator.next();
next = neighborsIterator.next();
sum += next.f2.getValue() * next.f1.getValue();
}
return new Tuple2<Long, Long>(first.f0, sum);
return new Tuple2<Long, Long>(next.f0, sum);
}
}, EdgeDirection.IN);

Expand Down Expand Up @@ -248,18 +239,14 @@ public Tuple2<Long, Long> iterateNeighbors(
public Tuple2<Long, Long> iterateNeighbors(
Iterable<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighbors) {
long sum = 0;
Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> first =
new Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>();
Iterator<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighborsIterator =
Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> next = null;
Iterator<Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>> neighborsIterator =
neighbors.iterator();
if (neighborsIterator.hasNext()) {
first = neighborsIterator.next();
sum = first.f2.getValue();
}
while(neighborsIterator.hasNext()) {
sum += neighborsIterator.next().f2.getValue();
next = neighborsIterator.next();
sum += next.f2.getValue();
}
return new Tuple2<Long, Long>(first.f0, sum);
return new Tuple2<Long, Long>(next.f0, sum);
}
}, EdgeDirection.ALL);

Expand Down

0 comments on commit 62fa5ee

Please sign in to comment.