Ejemplo n.º 1
0
    public void reduce(
        IntWritable key,
        Iterator<HITSNode> values,
        OutputCollector<IntWritable, HITSNode> output,
        Reporter reporter)
        throws IOException {
      // ArrayListOfIntsWritable adjList = new ArrayListOfIntsWritable();
      adjList.clear();

      // System.out.println(key.toString());
      // System.out.println(adjList.toString());
      while (values.hasNext()) {
        valIn = values.next();
        ArrayListOfIntsWritable adjListIn = valIn.getAdjacencyList();
        adjListIn.trimToSize();
        adjList.addAll(adjListIn.getArray());
        // System.out.println(adjList.toString());
      }

      valOut.setType(HITSNode.TYPE_AUTH_COMPLETE);
      valOut.setHARank((float) 0.0);
      valOut.setAdjacencyList(adjList);
      valOut.setNodeId(key.get());

      output.collect(key, valOut);
    }
Ejemplo n.º 2
0
    public void map(
        LongWritable key,
        Text value,
        OutputCollector<IntWritable, HITSNode> output,
        Reporter reporter)
        throws IOException {

      mOutput = output;

      ArrayListOfIntsWritable links = new ArrayListOfIntsWritable();
      String line = ((Text) value).toString();
      StringTokenizer itr = new StringTokenizer(line);
      if (itr.hasMoreTokens()) {
        int curr = Integer.parseInt(itr.nextToken());
        if (!(stopList.contains(curr))) {
          links.add(curr);
        } else {
          return;
        }
        // add to HMap here
      }
      while (itr.hasMoreTokens()) {
        int curr = Integer.parseInt(itr.nextToken());
        if (!(stopList.contains(curr))) {
          if (adjLists.containsKey(curr)) {
            ArrayListOfIntsWritable list = adjLists.get(curr);
            list.trimToSize();
            links.trimToSize();
            list.addAll(links.getArray());
            adjLists.put(curr, list);
          } else {
            links.trimToSize();
            adjLists.put(curr, links);
          }
        }
      }
    }