Package org.apache.giraph.graph

Examples of org.apache.giraph.graph.Vertex


    // Data to send
    int partitionId = 13;
    Partition<IntWritable, IntWritable, IntWritable> partition =
        conf.createPartition(partitionId, null);
    for (int i = 0; i < 10; ++i) {
      Vertex vertex = conf.createVertex();
      vertex.initialize(new IntWritable(i), new IntWritable(i));
      partition.putVertex(vertex);
    }

    // Send the request
    SendVertexRequest<IntWritable, IntWritable, IntWritable> request =
      new SendVertexRequest<IntWritable, IntWritable, IntWritable>(partition);
    client.sendWritableRequest(workerInfo.getTaskId(), request);
    client.waitAllRequests();

    // Stop the service
    client.stop();
    server.stop();

    // Check the output
    PartitionStore<IntWritable, IntWritable, IntWritable> partitionStore =
        serverData.getPartitionStore();
    assertTrue(partitionStore.hasPartition(partitionId));
    int total = 0;
    Partition<IntWritable, IntWritable, IntWritable> partition2 =
        partitionStore.getOrCreatePartition(partitionId);
    for (Vertex<IntWritable, IntWritable, IntWritable> vertex : partition2) {
      total += vertex.getId().get();
    }
    partitionStore.putPartition(partition2);
    assertEquals(total, 45);
    partitionStore.shutdown();
  }
View Full Code Here


        Maps.newHashMap();
    for (int i = 0; i < 11; ++i) {
      VertexMutations<IntWritable, IntWritable, IntWritable> mutations =
          new VertexMutations<IntWritable, IntWritable, IntWritable>();
      for (int j = 0; j < 3; ++j) {
        Vertex vertex = conf.createVertex();
        vertex.initialize(new IntWritable(i), new IntWritable(j));
        mutations.addVertex(vertex);
      }
      for (int j = 0; j < 2; ++j) {
        mutations.removeVertex();
      }
      for (int j = 0; j < 5; ++j) {
        Edge<IntWritable, IntWritable> edge =
            EdgeFactory.create(new IntWritable(i), new IntWritable(2 * j));
        mutations.addEdge(edge);
      }
      for (int j = 0; j < 7; ++j) {
        mutations.removeEdge(new IntWritable(j));
      }
      vertexIdMutations.put(new IntWritable(i), mutations);
    }

    // Send the request
    SendPartitionMutationsRequest<IntWritable, IntWritable, IntWritable>
        request = new SendPartitionMutationsRequest<IntWritable, IntWritable,
        IntWritable>(partitionId, vertexIdMutations);
    GiraphMetrics.init(conf);
    client.sendWritableRequest(workerInfo.getTaskId(), request);
    client.waitAllRequests();

    // Stop the service
    client.stop();
    server.stop();

    // Check the output
    ConcurrentHashMap<IntWritable, VertexMutations<IntWritable, IntWritable,
    IntWritable>> inVertexIdMutations =
        serverData.getVertexMutations();
    int keySum = 0;
    for (Entry<IntWritable, VertexMutations<IntWritable, IntWritable,
        IntWritable>> entry :
          inVertexIdMutations.entrySet()) {
      synchronized (entry.getValue()) {
        keySum += entry.getKey().get();
        int vertexValueSum = 0;
        for (Vertex<IntWritable, IntWritable, IntWritable>
        vertex : entry.getValue().getAddedVertexList()) {
          vertexValueSum += vertex.getValue().get();
        }
        assertEquals(3, vertexValueSum);
        assertEquals(2, entry.getValue().getRemovedVertexCount());
        int removeEdgeValueSum = 0;
        for (Edge<IntWritable, IntWritable> edge :
View Full Code Here

TOP

Related Classes of org.apache.giraph.graph.Vertex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.