use of org.apache.flink.types.LongValue in project flink by apache.
the class SingletonEdgeGraph method generate.
@Override
public Graph<LongValue, NullValue, NullValue> generate() {
// Vertices
long vertexCount = 2 * this.vertexPairCount;
DataSet<Vertex<LongValue, NullValue>> vertices = GraphGeneratorUtils.vertexSequence(env, parallelism, vertexCount);
// Edges
LongValueSequenceIterator iterator = new LongValueSequenceIterator(0, vertexCount - 1);
DataSet<Edge<LongValue, NullValue>> edges = env.fromParallelCollection(iterator, LongValue.class).setParallelism(parallelism).name("Edge iterators").map(new LinkVertexToSingletonNeighbor()).setParallelism(parallelism).name("Complete graph edges");
// Graph
return Graph.fromDataSet(vertices, edges, env);
}
use of org.apache.flink.types.LongValue in project flink by apache.
the class StarGraph method generate.
@Override
public Graph<LongValue, NullValue, NullValue> generate() {
// Vertices
DataSet<Vertex<LongValue, NullValue>> vertices = GraphGeneratorUtils.vertexSequence(env, parallelism, vertexCount);
// Edges
LongValueSequenceIterator iterator = new LongValueSequenceIterator(1, this.vertexCount - 1);
DataSet<Edge<LongValue, NullValue>> edges = env.fromParallelCollection(iterator, LongValue.class).setParallelism(parallelism).name("Edge iterators").flatMap(new LinkVertexToCenter()).setParallelism(parallelism).name("Star graph edges");
// Graph
return Graph.fromDataSet(vertices, edges, env);
}
use of org.apache.flink.types.LongValue in project flink by apache.
the class GatherSumApplyITCase method testConnectedComponentsWithObjectReuseEnabled.
@Test
public void testConnectedComponentsWithObjectReuseEnabled() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
env.getConfig().enableObjectReuse();
DataSet<Edge<LongValue, NullValue>> edges = Translate.translateEdgeIds(ConnectedComponentsDefaultData.getDefaultEdgeDataSet(env), new LongToLongValue());
Graph<LongValue, LongValue, NullValue> inputGraph = Graph.fromDataSet(edges, new IdentityMapper<LongValue>(), env);
List<Vertex<LongValue, LongValue>> result = inputGraph.run(new GSAConnectedComponents<LongValue, LongValue, NullValue>(16)).collect();
compareResultAsTuples(result, expectedResultCC);
}
use of org.apache.flink.types.LongValue in project flink by apache.
the class ScatterGatherIteration method createResult.
/**
* Creates the operator that represents this scatter-gather graph computation.
*
* @return The operator that represents this scatter-gather graph computation.
*/
@Override
public DataSet<Vertex<K, VV>> createResult() {
if (this.initialVertices == null) {
throw new IllegalStateException("The input data set has not been set.");
}
// prepare some type information
TypeInformation<K> keyType = ((TupleTypeInfo<?>) initialVertices.getType()).getTypeAt(0);
TypeInformation<Tuple2<K, Message>> messageTypeInfo = new TupleTypeInfo<>(keyType, messageType);
// create a graph
Graph<K, VV, EV> graph = Graph.fromDataSet(initialVertices, edgesWithValue, initialVertices.getExecutionEnvironment());
// check whether the numVertices option is set and, if so, compute the total number of vertices
// and set it within the scatter and gather functions
DataSet<LongValue> numberOfVertices = null;
if (this.configuration != null && this.configuration.isOptNumVertices()) {
try {
numberOfVertices = GraphUtils.count(this.initialVertices);
} catch (Exception e) {
e.printStackTrace();
}
}
if (this.configuration != null) {
scatterFunction.setDirection(this.configuration.getDirection());
} else {
scatterFunction.setDirection(EdgeDirection.OUT);
}
// retrieve the direction in which the updates are made and in which the messages are sent
EdgeDirection messagingDirection = scatterFunction.getDirection();
// add them to the vertex value
if (this.configuration != null && this.configuration.isOptDegrees()) {
return createResultVerticesWithDegrees(graph, messagingDirection, messageTypeInfo, numberOfVertices);
} else {
return createResultSimpleVertex(messagingDirection, messageTypeInfo, numberOfVertices);
}
}
use of org.apache.flink.types.LongValue in project flink by apache.
the class VertexInDegreeTest method testWithRMatGraph.
@Test
public void testWithRMatGraph() throws Exception {
DataSet<Vertex<LongValue, LongValue>> inDegree = directedRMatGraph.run(new VertexInDegree<LongValue, NullValue, NullValue>().setIncludeZeroDegreeVertices(true));
Checksum checksum = new ChecksumHashCode<Vertex<LongValue, LongValue>>().run(inDegree).execute();
assertEquals(902, checksum.getCount());
assertEquals(0x0000000000e1d885L, checksum.getChecksum());
}
Aggregations