Examples of BooleanWritable


Examples of org.apache.hadoop.io.BooleanWritable

        BSPPeer<Text, Text, NullWritable, NullWritable, MapWritable> peer)
        throws IOException, SyncException, InterruptedException {
      Text key = null;
      Text value = null;
      MapWritable message = new MapWritable();
      message.put(new Text(KeyValueHashPartitionedBSP.TEST_UNEXPECTED_KEYS), new BooleanWritable(false));
      KeyValuePair<Text, Text> tmp = null;

      while ( (tmp = peer.readNext()) != null) {
        key = tmp.getKey();
        value = tmp.getValue();

        int expectedPeerId = Math.abs(key.hashCode() % numTasks);

        if (expectedPeerId == peer.getPeerIndex()) {
          if (expectedKeys.containsKey(key)) {
            // same key twice, incorrect
            message.put(new Text(KeyValueHashPartitionedBSP.TEST_UNEXPECTED_KEYS), new BooleanWritable(true));
            break;
          } else {
            expectedKeys.put(new Text(key), new Text(value));
          }
        } else {
          message.put(new Text(KeyValueHashPartitionedBSP.TEST_UNEXPECTED_KEYS), new BooleanWritable(true));
          break;
        } //if (expectedPeerId == peer.getPeerIndex())
      } //while (peer.readNext(key, value) != false)
      message.put(new Text(KeyValueHashPartitionedBSP.TEST_INPUT_VALUES), expectedKeys);
     
      int master = peer.getNumPeers()/2;
      String masterName = peer.getPeerName(master);
      peer.send(masterName, message);
      peer.sync();

      if(peer.getPeerIndex() == master) {
        MapWritable msg = null;
        MapWritable values = null;
        BooleanWritable blValue = null;
        HashMap<Integer, Integer> input = new HashMap<Integer, Integer>();

        while ( (msg = peer.getCurrentMessage()) != null ) {
          blValue = (BooleanWritable) msg.get(new Text(KeyValueHashPartitionedBSP.TEST_UNEXPECTED_KEYS));
          assertEquals(false, blValue.get());
          values = (MapWritable) msg.get(new Text(KeyValueHashPartitionedBSP.TEST_INPUT_VALUES));
          for (Map.Entry<Writable,Writable> w : values.entrySet()) {
            input.put( Integer.valueOf( w.getKey().toString() ), Integer.valueOf( w.getValue().toString() ));
          }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.