Package com.intel.hadoop.graphbuilder.preprocess.mapreduce.keyvalue

Examples of com.intel.hadoop.graphbuilder.preprocess.mapreduce.keyvalue.VertexEdgeUnionType


  public void preproessKeyValFactoryTest() {
    try {
      Class valclass = PreprocessJobValueFactory.getValueClassByClassName(
          TypeFactory.getClassName("string"), TypeFactory.getClassName("none"),
          TypeFactory.getClassName("int"));
      VertexEdgeUnionType val = (VertexEdgeUnionType) valclass.newInstance();
      assertEquals(val.createVid().getClass(), StringType.class);
      assertEquals(val.createVdata().getClass(), EmptyType.class);
      assertEquals(val.createEdata().getClass(), IntType.class);
    } catch (NotFoundException e) {
      e.printStackTrace();
    } catch (CannotCompileException e) {
      e.printStackTrace();
    } catch (InstantiationException e) {
View Full Code Here


  @Override
  public void reduce(IntWritable key, Iterator<VertexEdgeUnionType> iter,
      OutputCollector<Text, Text> out, Reporter reporter) throws IOException {

    VertexEdgeUnionType next;
    HashMap<Pair<Object, Object>, Writable> edgeset = new HashMap();
    HashMap<Object, Writable> vertexset = new HashMap();

    while (iter.hasNext()) {
      next = iter.next();
      // Apply reduce on vertex
      if (next.flag() == VertexEdgeUnionType.VERTEXVAL) {
        Object vid = next.vertex().vid();
        if (vertexset.containsKey(vid)) { // duplicate vertex
          if (VertexFunc != null)
            vertexset.put(vid,
                VertexFunc.reduce(next.vertex().vdata(), vertexset.get(vid)));
        } else {
          if (VertexFunc != null)
            vertexset.put(vid,
                VertexFunc.reduce(next.vertex().vdata(), VertexFunc.base()));
          else
            vertexset.put(vid, next.vertex().vdata());
        }
      } else {
        // Apply reduce on edges, remove self and (or merge) duplicate edges.
        // Optionally remove bidirectional edge.
        Pair p = new Pair(next.edge().source(), next.edge().target());

        // self edge
        if (p.getL().equals(p.getR()))
          continue;

        // duplicate edge
        if (edgeset.containsKey(p)) {
          if (EdgeFunc != null)
            edgeset.put(p,
                EdgeFunc.reduce(next.edge().EdgeData(), edgeset.get(p)));
        } else {
          if (EdgeFunc != null)
            edgeset.put(p,
                EdgeFunc.reduce(next.edge().EdgeData(), EdgeFunc.base()));
          else
            edgeset.put(p, next.edge().EdgeData());
        }
      }
    }

    int nverts = 0;
View Full Code Here

TOP

Related Classes of com.intel.hadoop.graphbuilder.preprocess.mapreduce.keyvalue.VertexEdgeUnionType

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.