Package edu.umd.cloud9.io.array

Examples of edu.umd.cloud9.io.array.ArrayListOfIntsWritable


    node.setNodeId(1);
    node.setPageRank(0.1f);

    assertEquals("{1 0.1000 []}", node.toString());

    node.setAdjacencyList(new ArrayListOfIntsWritable(new int[] {1,2,3,4,5,6}));
    assertEquals("{1 0.1000 [1, 2, 3, 4, 5, 6]}", node.toString());

    node.setAdjacencyList(new ArrayListOfIntsWritable(new int[] {1,2,3,4,5,6,7,8,9,10,11,12}));
    assertEquals("{1 0.1000 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ... (2 more) ]}", node.toString());
  }
View Full Code Here


  public void testSerialize() throws IOException {
    BfsNode node1 = new BfsNode();
    node1.setType(Type.Complete);
    node1.setNodeId(1);
    node1.setDistance(2);
    node1.setAdjacencyList(new ArrayListOfIntsWritable(new int[] {1,2,3,4,5,6}));

    byte[] bytes = node1.serialize();
    BfsNode node2 = BfsNode.create(bytes);

    assertEquals(2, node2.getDistance());
    assertEquals(Type.Complete, node2.getType());
    ArrayListOfIntsWritable adj = node2.getAdjacenyList();
    assertEquals(6, adj.size());
    assertEquals(1, adj.get(0));
    assertEquals(2, adj.get(1));
    assertEquals(3, adj.get(2));
    assertEquals(4, adj.get(3));
    assertEquals(5, adj.get(4));
    assertEquals(6, adj.get(5));
  }
View Full Code Here

    node.setNodeId(1);
    node.setDistance(1);

    assertEquals("{1 1 []}", node.toString());

    node.setAdjacencyList(new ArrayListOfIntsWritable(new int[] {1,2,3,4,5,6}));
    assertEquals("{1 1 [1, 2, 3, 4, 5, 6]}", node.toString());

    node.setAdjacencyList(new ArrayListOfIntsWritable(new int[] {1,2,3,4,5,6,7,8,9,10,11,12}));
    assertEquals("{1 1 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ... (2 more) ]}", node.toString());
  }
View Full Code Here

     
      //auth score for a node X is sum of all hub scores from nodes linking to X
      // so for each outgoing link X1...XN, contribute this node's hub score as part of node X1...XN's auth score
      // ( total auth score will be summed in reducer)
      int typeOut = HITSNode.TYPE_AUTH_MASS;
      ArrayListOfIntsWritable adjList = value.getOutlinks();
      int curr;
      for (int i = 0; i < adjList.size(); i++) {
        curr = adjList.get(i);
        valOut.setType(typeOut);
        valOut.setARank(value.getHRank());
        output.collect(new IntWritable(curr), valOut);
      }
     
      //hub score for a node X is sum of all auth scores from nodes linked from X
      // so for each incoming link X1...XN, contribute this node's auth score as part of node X1...XN's hub score
      // ( total hub score will be summed in reducer)
      typeOut = HITSNode.TYPE_HUB_MASS;
      adjList = value.getInlinks();
      for (int i = 0; i < adjList.size(); i++) {
        curr = adjList.get(i);
        valOut.setType(typeOut);
        valOut.setHRank(value.getARank());
        output.collect(new IntWritable(curr), valOut);
      }
    }
View Full Code Here

        OutputCollector<IntWritable, HITSNode> output, Reporter reporter)
        throws IOException {

      mOutput = output;
      int typeOut = 0;
      ArrayListOfIntsWritable adjList;
      output.collect(key, value);

      int curr;
      typeOut = 0;
      //emit avals to inlinks as hvals
      adjList = value.getOutlinks();
      for (int i = 0; i < adjList.size(); i++) {
        curr = adjList.get(i);
        if (rankmapA.containsKey(curr)) {
          rankmapA.put(curr, sumLogProbs(rankmapA.get(curr),
              value.getHRank()));
        } else {
          rankmapA.put(curr, value.getHRank());
        }
      }
      //emit hvals to outlinks as avals
      adjList = value.getInlinks();
      for (int i = 0; i < adjList.size(); i++) {
        curr = adjList.get(i);
        if (rankmapH.containsKey(curr)) {
          rankmapH.put(curr, sumLogProbs(rankmapH.get(curr),
              value.getARank()));
        } else {
          rankmapH.put(curr, value.getARank());
View Full Code Here

    }

    public void reduce(IntWritable key, Iterator<HITSNode> values,
        OutputCollector<IntWritable, HITSNode> output, Reporter reporter)
        throws IOException {
      ArrayListOfIntsWritable adjList = new ArrayListOfIntsWritable();

      float hrank = Float.NEGATIVE_INFINITY;
      float arank = Float.NEGATIVE_INFINITY;

      valOut.setInlinks(adjList);
      valOut.setOutlinks(adjList);

      while (values.hasNext()) {
        valIn = values.next();

        // get type
        int type = valIn.getType();
        adjList.clear();

        if (type == HITSNode.TYPE_NODE_COMPLETE || type == HITSNode.TYPE_NODE_STRUCTURE) {
          //adjList = valIn.getAdjacencyList();
          valOut.setOutlinks(new ArrayListOfIntsWritable(
                valIn.getOutlinks()));
            // System.out.println(key.toString() + " " + "H" + " " +
            // hpayloadOut.toString());
          valOut.setInlinks(new ArrayListOfIntsWritable(
                valIn.getInlinks()));
            // System.out.println(key.toString() + " " + "A" + " " +
            // hpayloadOut.toString());
          }
        // else add rank to current rank
View Full Code Here

      while (values.hasNext()) {
        BfsNode n = values.next();

        if (n.getType() == BfsNode.Type.Structure) {
          // This is the structure; update accordingly.
          ArrayListOfIntsWritable list = n.getAdjacenyList();
          structureReceived++;

          int arr[] = new int[list.size()];
          for (int i = 0; i < list.size(); i++) {
            arr[i] = list.get(i);
          }

          node.setAdjacencyList(new ArrayListOfIntsWritable(arr));
        } else {
          // This is a message that contains distance.
          if (n.getDistance() < dist) {
            dist = n.getDistance();
          }
View Full Code Here

    if (type.equals(Type.Complete)) {
      distance = in.readInt();
    }

    adjacenyList = new ArrayListOfIntsWritable();
    adjacenyList.readFields(in);
  }
View Full Code Here

      nid.set(cur);
      node.setNodeId(cur);
      node.setDistance(cur == src ? 0 : Integer.MAX_VALUE);

      if (arr.length == 1) {
        node.setAdjacencyList(new ArrayListOfIntsWritable());
      } else {
        int[] neighbors = new int[arr.length - 1];
        for (int i = 1; i < arr.length; i++) {
          neighbors[i - 1] = Integer.parseInt(arr[i]);
        }
        node.setAdjacencyList(new ArrayListOfIntsWritable(neighbors));
      }

      context.getCounter(Graph.Nodes).increment(1);
      context.getCounter(Graph.Edges).increment(arr.length - 1);
View Full Code Here

  private static class MergeReducer extends MapReduceBase implements
      Reducer<IntWritable, HITSNode, IntWritable, HITSNode> {
    public void reduce(IntWritable key, Iterator<HITSNode> values,
        OutputCollector<IntWritable, HITSNode> output, Reporter reporter)
        throws IOException {
      ArrayListOfIntsWritable adjList = new ArrayListOfIntsWritable();

      //construct new HITSNode
      HITSNode nodeOut = new HITSNode();
     
      nodeOut.setType(HITSNode.TYPE_NODE_COMPLETE);
      nodeOut.setARank(0);
      nodeOut.setInlinks(new ArrayListOfIntsWritable());
      nodeOut.setHRank(0);
      nodeOut.setOutlinks(new ArrayListOfIntsWritable());
      nodeOut.setNodeId(key.get());
     
      while (values.hasNext()) {
        HITSNode nodeIn = values.next();
        if (nodeIn.getType() == HITSNode.TYPE_HUB_COMPLETE)
        {
          nodeOut.setHRank(nodeIn.getHRank());
          nodeOut.setOutlinks(new ArrayListOfIntsWritable(nodeIn.getOutlinks()));
        }
        if (nodeIn.getType() == HITSNode.TYPE_AUTH_COMPLETE)
        {
          nodeOut.setARank(nodeIn.getARank());
          nodeOut.setInlinks(new ArrayListOfIntsWritable(nodeIn.getInlinks()));
        }
      }
      output.collect(key, nodeOut);
    }
View Full Code Here

TOP

Related Classes of edu.umd.cloud9.io.array.ArrayListOfIntsWritable

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.