Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.DoubleWritable


    vr.initialize(null, tac);
    assertTrue("Should have been able to read vertex", vr.nextVertex());
    BasicVertex<LongWritable, DoubleWritable, DoubleWritable, BooleanWritable>
        vertex = vr.getCurrentVertex();
    setGraphState(vertex, graphState);
    assertValidVertex(conf, graphState, vertex, new LongWritable(12345), new DoubleWritable(42.42),
       new Edge<LongWritable, DoubleWritable>(new LongWritable(9999999), new DoubleWritable(99.9)));
    assertEquals(vertex.getNumOutEdges(), 1);
  }
View Full Code Here


      } else if (getSuperstep() == 1) {
            // Send messages to vertices that are sure not to exist
            // (creating them)
            LongWritable destVertexId =
                new LongWritable(rangeVertexIdStart(1) + getVertexId().get());
            sendMsg(destVertexId, new DoubleWritable(0.0));
        } else if (getSuperstep() == 2) {
        } else if (getSuperstep() == 3) {
          long vertexCount = workerContext.getVertexCount();
            if (vertexCount * 2 != getNumVertices()) {
                throw new IllegalStateException(
View Full Code Here

    TaskAttemptContext tac = mock(TaskAttemptContext.class);
    when(tac.getConfiguration()).thenReturn(conf);

    BasicVertex vertex = mock(BasicVertex.class);
    when(vertex.getVertexId()).thenReturn(new Text("The Beautiful South"));
    when(vertex.getVertexValue()).thenReturn(new DoubleWritable(32.2d));
    // Create empty iterator == no edges
    when(vertex.iterator()).thenReturn(new ArrayList<Text>().iterator());

    RecordWriter<Text, Text> tw = mock(RecordWriter.class);
    AdjacencyListVertexWriter writer = new AdjacencyListVertexWriter(tw);
View Full Code Here

    TaskAttemptContext tac = mock(TaskAttemptContext.class);
    when(tac.getConfiguration()).thenReturn(conf);

    BasicVertex vertex = mock(BasicVertex.class);
    when(vertex.getVertexId()).thenReturn(new Text("San Francisco"));
    when(vertex.getVertexValue()).thenReturn(new DoubleWritable(0d));
    when(vertex.getNumEdges()).thenReturn(2l);
    ArrayList<Text> cities = new ArrayList<Text>();
    Collections.addAll(cities, new Text("Los Angeles"), new Text("Phoenix"));

    when(vertex.iterator()).thenReturn(cities.iterator());
View Full Code Here

    TaskAttemptContext tac = mock(TaskAttemptContext.class);
    when(tac.getConfiguration()).thenReturn(conf);

    BasicVertex vertex = mock(BasicVertex.class);
    when(vertex.getVertexId()).thenReturn(new Text("San Francisco"));
    when(vertex.getVertexValue()).thenReturn(new DoubleWritable(0d));
    when(vertex.getNumEdges()).thenReturn(2l);
    ArrayList<Text> cities = new ArrayList<Text>();
    Collections.addAll(cities, new Text("Los Angeles"), new Text("Phoenix"));

    when(vertex.iterator()).thenReturn(cities.iterator());
View Full Code Here

    verify(vertex, times(1)).iterator();
    verify(vertex, times(2)).getEdgeValue(Matchers.<WritableComparable>any());
  }

  private void mockEdgeValue(BasicVertex vertex, String s, double d) {
    when(vertex.getEdgeValue(new Text(s))).thenReturn(new DoubleWritable(d));
  }
View Full Code Here

        if (getSuperstep() >= 1) {
            double sum = 0;
            while (msgIterator.hasNext()) {
                sum += msgIterator.next().get();
            }
            DoubleWritable vertexValue =
                new DoubleWritable((0.15f / getNumVertices()) + 0.85f * sum);
            setVertexValue(vertexValue);
            if (getSuperstep() < 30) {
                if (getSuperstep() == 20) {
                    if (getVertexId().get() == 10L) {
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                        }
                        System.exit(1);
                    } else if (getSuperstep() - superstep > 10) {
                        return;
                    }
                }
                long edges = getNumOutEdges();
                sendMsgToAllEdges(
                    new DoubleWritable(getVertexValue().get() / edges));
            } else {
                voteToHalt();
            }
            superstep = getSuperstep();
        }
View Full Code Here

  public void setAggregatedValue(DoubleWritable value) {
      min = value.get();
  }

  public DoubleWritable getAggregatedValue() {
      return new DoubleWritable(min);
  }
View Full Code Here

  public DoubleWritable getAggregatedValue() {
      return new DoubleWritable(min);
  }

  public DoubleWritable createAggregatedValue() {
      return new DoubleWritable();
  }
View Full Code Here

    }

    public void testEdges() {
        Map<IntWritable, DoubleWritable> edgeMap = Maps.newHashMap();
        for (int i = 1000; i > 0; --i) {
            edgeMap.put(new IntWritable(i), new DoubleWritable(i * 2.0));
        }
        vertex.initialize(null, null, edgeMap, null);
        assertEquals(vertex.getNumOutEdges(), 1000);
        int expectedIndex = 1;
        for (IntWritable index : vertex) {
            assertEquals(index.get(), expectedIndex);
            assertEquals(vertex.getEdgeValue(index).get(),
                         expectedIndex * 2.0d);
            ++expectedIndex;
        }
        assertEquals(vertex.removeEdge(new IntWritable(500)),
                     new DoubleWritable(1000));
        assertEquals(vertex.getNumOutEdges(), 999);
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.DoubleWritable

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.