Package com.tdunning.plume

Examples of com.tdunning.plume.Pair


      reducer.process(Pair.create(arg0.obj, vals), new EmitFn() {
      @Override
        public void emit(Object v) {
          try {
            if(v instanceof Pair) {
              Pair p = (Pair)v;
              mos.write(arg0.sourceId+"", p.getKey(), p.getValue());
            } else {
              mos.write(arg0.sourceId+"", NullWritable.get(), (WritableComparable)v);
            }
          } catch (Exception e) {
            e.printStackTrace(); // TODO How to report this
View Full Code Here


        GroupByKey gBK = (GroupByKey) op;
        parent = execute(gBK.getOrigin());
        Map<Object, List> groupMap = Maps.newHashMap();
        // Perform in-memory group by operation
        for (Object obj : parent) {
          Pair p = (Pair)obj;
          List list = groupMap.get(p.getKey());
          if(list == null) {
            list = new ArrayList();
          }
          list.add(p.getValue());
          groupMap.put(p.getKey(), list);
        }
        for (Map.Entry<Object, List> entry: groupMap.entrySet()) {
          result.add((T)new Pair(entry.getKey(), entry.getValue()));
        }
      }
      return result;
    }
  }
View Full Code Here

          en.getValue().process(toProcess, new EmitFn() {
            @Override
            public void emit(Object v) {
              try {
                if(v instanceof Pair) {
                  Pair p = (Pair)v;
                  context.write(
                    new PlumeObject((WritableComparable)p.getKey(), channel),
                    new PlumeObject((WritableComparable)p.getValue(), channel)
                  );
                } else {
                  context.write(
                    new PlumeObject((WritableComparable)v, channel),
                    new PlumeObject((WritableComparable)v, channel)
View Full Code Here

          emitter.emit(Pair.create(t, new Text("foo")));
        }}, tableOf(strings(), strings()))
         .groupByKey()
         .map(new DoFn() {
        public void process(Object v, EmitFn emitter) {
          Pair p = (Pair)v;
          // do some more foo processing        
          emitter.emit(Pair.create(p.getKey(), new Text("bar")));
        }
      }, tableOf(strings(), strings()))
        // second group by key
         .groupByKey()
         .map(new DoFn() {
        public void process(Object v, EmitFn emitter) {
          Pair p = (Pair)v;
          // do some more foo processing        
          emitter.emit(Pair.create(p.getKey(), new Text("bar 2")));
        }
      }, tableOf(strings(), strings()));
     
      addOutput(output);
    }
View Full Code Here

TOP

Related Classes of com.tdunning.plume.Pair

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.