@Override
    public void map(
        final NullWritable key,
        final FaunusVertex value,
        final Mapper<NullWritable, FaunusVertex, WritableComparable, LongWritable>.Context context)
        throws IOException, InterruptedException {

      if (this.isVertex) {
        if (value.hasPaths()) {
          this.map.incr(ElementPicker.getProperty(value, this.property), value.pathCount());
          context.getCounter(Counters.PROPERTIES_COUNTED).increment(1l);
        }
      } else {
        for (final Edge e : value.getEdges(Direction.OUT)) {
          final FaunusEdge edge = (FaunusEdge) e;
          if (edge.hasPaths()) {
            this.map.incr(ElementPicker.getProperty(edge, this.property), edge.pathCount());
            context.getCounter(Counters.PROPERTIES_COUNTED).increment(1l);
          }
        }
      }

      // protected against memory explosion
      if (this.map.size() > Tokens.MAP_SPILL_OVER) {
        this.dischargeMap(context);
      }

      this.outputs.write(Tokens.GRAPH, NullWritable.get(), value);
    }
Example #2
0
    @Override
    public void map(
        final NullWritable key,
        final FaunusVertex value,
        final Mapper<NullWritable, FaunusVertex, NullWritable, FaunusVertex>.Context context)
        throws IOException, InterruptedException {

      long pathsFiltered = 0l;
      if (this.isVertex) {
        if (value.hasPaths()) {
          final Iterator<List<MicroElement>> itty = value.getPaths().iterator();
          while (itty.hasNext()) {
            final List<MicroElement> path = itty.next();
            this.set.clear();
            this.set.addAll(path);
            if (path.size() != this.set.size()) {
              itty.remove();
              pathsFiltered++;
            }
          }
        }
      } else {
        for (final Edge e : value.getEdges(Direction.BOTH)) {
          final FaunusEdge edge = (FaunusEdge) e;
          if (edge.hasPaths()) {
            final Iterator<List<MicroElement>> itty = edge.getPaths().iterator();
            while (itty.hasNext()) {
              final List<MicroElement> path = itty.next();
              this.set.clear();
              this.set.addAll(path);
              if (path.size() != this.set.size()) {
                itty.remove();
                pathsFiltered++;
              }
            }
          }
        }
      }

      context.getCounter(Counters.PATHS_FILTERED).increment(pathsFiltered);
      context.write(NullWritable.get(), value);
    }