@Override public Tuple3<String, String, String> map(Tuple3<String, String, String> value) throws Exception { int i = 0; do { value.setField("", i); i++; } while (i >= 2); return value; } }
@Override public Tuple3<Integer, Long, String> map(Tuple3<Integer, Long, String> value) throws Exception { Integer incr = Integer.valueOf(value.f0.intValue() + 1); value.setField(incr, 0); return value; } }
@Override public void flatMap(Tuple3<Integer, Long, String> value, Collector<Tuple3<Integer, Long, String>> out) throws Exception { final int numTuples = value.f0 % 4; for (int i = 0; i < numTuples; i++) { value.setField(i, 0); out.collect(value); } } }
@Override public Tuple3<String, String, String> map(Tuple3<String, String, String> value) throws Exception { String tmp = value.f0; for (int i = 0; i < 2; i++) { value.setField("Test", i); } Tuple3<String, String, String> tuple; if (value.f0.equals("x")) { tuple = new Tuple3<String, String, String>(tmp, value.f0, null); } else { tuple = new Tuple3<String, String, String>(tmp, value.f0, ""); } return tuple; } }
@Override public void applyOnEdges(Long vertexID, Iterable<Tuple2<Long, NullValue>> neighbors, Collector<Tuple3<Long, Long, Boolean>> out) throws Exception { Tuple3<Long, Long, Boolean> outT = new Tuple3<>(); outT.setField(vertexID, 0); outT.setField(false, 2); //isCandidate=false Set<Long> neighborIdsSet = new HashSet<Long>(); for (Tuple2<Long, NullValue> t: neighbors) { outT.setField(t.f0, 1); out.collect(outT); neighborIdsSet.add(t.f0); } Object[] neighborIds = neighborIdsSet.toArray(); neighborIdsSet.clear(); outT.setField(true, 2); //isCandidate=true for (int i=0; i<neighborIds.length-1; i++) { for (int j=i; j<neighborIds.length; j++) { // only emit the candidates // with IDs larger than the vertex ID if (((long)neighborIds[i] > vertexID) && ((long)neighborIds[j] > vertexID)) { outT.setField((long)neighborIds[i], 0); outT.setField((long)neighborIds[j], 1); out.collect(outT); } } } } }
public void flatMap(Edge<K, EV> e, Collector<Tuple3<K, K, TreeSet<K>>> out) { TreeSet<K> t; if (neighborhoods.containsKey(e.getSource())) { t = neighborhoods.get(e.getSource()); } else { t = new TreeSet<>(); } t.add(e.getTarget()); neighborhoods.put(e.getSource(), t); outTuple.setField(e.getSource(), 0); outTuple.setField(e.getTarget(), 1); outTuple.setField(t, 2); out.collect(outTuple); } }