Package org.apache.hadoop.io

Examples of org.apache.hadoop.io.DoubleWritable


  }

  @Test
  public void testUnboxDouble() {
    DoubleBoxerUnboxer d = new DoubleBoxerUnboxer();
    assertEquals(3.14159, d.unbox(new DoubleWritable(3.14159)), 0.000001);
  }
View Full Code Here


        List<IntWritable> counts = new ArrayList<IntWritable>();
        counts.add(new IntWritable(2));
        PairsRelativeOccurrenceReducer reducer = new PairsRelativeOccurrenceReducer();
        Field f = reducer.getClass().getDeclaredField("totalCount");
        f.setAccessible(true);
        DoubleWritable dw = (DoubleWritable)f.get(reducer);
        dw.set(2);
        new ReduceDriver<WordPair, IntWritable, WordPair, DoubleWritable>()
                .withReducer(reducer)
                .withInput(new WordPair("apple", "nut"), counts)
                .withOutput(new WordPair("apple", "nut"), new DoubleWritable(1.0))
                .runTest();
    }
View Full Code Here

                .withReducer(reducer)
                .withInput(new WordPair("apple", "*"), allCounts)
                .runTest();
        Field f = reducer.getClass().getDeclaredField("totalCount");
        f.setAccessible(true);
        DoubleWritable dw = (DoubleWritable)f.get(reducer);
        assertThat(dw.get(), is((double)4));

        f = reducer.getClass().getDeclaredField("currentWord");
        f.setAccessible(true);
        assertThat((f.get(reducer)).toString(), is("apple"));

View Full Code Here

        assertEquals(new LongWritable(Long.MAX_VALUE), typeFromJson);
    }

    @Override
    public void checkDouble(Object typeFromJson) {
        assertEquals(new DoubleWritable(Double.MAX_VALUE), typeFromJson);
    }
View Full Code Here

        writableTypeToJson(new VLongWritable(Long.MAX_VALUE));
    }

    @Test
    public void testDouble() {
        writableTypeToJson(new DoubleWritable(Double.MAX_VALUE));
    }
View Full Code Here

  }

  @Test
  public void testConvertDoubleWritable() {
    AvroDatumConverter<DoubleWritable, Double> converter = mFactory.create(DoubleWritable.class);
    assertEquals(2.0, converter.convert(new DoubleWritable(2.0)).doubleValue(), 0.00001);
  }
View Full Code Here

  public final void cleanup(
      BSPPeer<VertexWritable, VertexArrayWritable, Text, DoubleWritable> peer) {
    try {
      for (Entry<VertexWritable, Double> row : tentativePagerank.entrySet()) {
        peer.write(new Text(row.getKey().getName()),
            new DoubleWritable(row.getValue()));
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    for (FileStatus status : stati) {
      if (!status.isDir() && !status.getPath().getName().endsWith(".crc")) {
        Path path = status.getPath();
        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
        Text key = new Text();
        DoubleWritable value = new DoubleWritable();
        int count = 0;
        while (reader.next(key, value)) {
          LOG.info(key.toString() + " | " + value.get());
          count++;
          if (count > 5)
            break;
        }
        reader.close();
View Full Code Here

    rs.put("youtube.com", 0.029900332230345304);

    SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path(OUTPUT
        + "/part-00000"), conf);
    Text key = new Text();
    DoubleWritable value = new DoubleWritable();
    double sum = 0.0;
    while (reader.next(key, value)) {
      double result = (double) rs.get(key.toString());
      assertEquals(value.get(), result);
      sum += value.get();
    }
    System.out.println("Sum is: " + sum);
    assertEquals(sum, 1.0d);
  }
View Full Code Here

          pi += received.getData();
        }

        pi = pi / numPeers;
        peer
            .write(new Text("Estimated value of PI is"), new DoubleWritable(pi));
      }
    }
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.